Skip to content

Commit db3f788

Browse files
committed
changed finding mechanism
1 parent f1d81ac commit db3f788

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

src/fetchpublisher.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export async function fetchPublisher(bookTitle: string): Promise<string | null>{
6666

6767
if(getPref("fetchPublisher")){
6868
const link = await fetchSelfLink(bookTitle)
69-
const request = await Zotero.HTTP.request('GET', link)
69+
const request = await Zotero.HTTP.request('GET', link!)
7070
ztoolkit.log(request)
7171
if (request.status !== 200) {
7272
return 'Failed to fetch data from the link';

src/hooks.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import { it } from "node:test";
1515
import * as ParseChapter from "./parsechapter"
1616
import { openAsBlob } from "node:fs";
1717
import * as Typography from "./typgraphy"
18-
import { first } from "cheerio/lib/api/traversing";
1918

2019
async function onStartup() {
2120
await Promise.all([
@@ -92,11 +91,14 @@ function onAdd(id: number){
9291
ztoolkit.log("item added - id = " + id)
9392

9493
const attachment = Zotero.Items.get(id)
95-
const title = attachment.getDisplayTitle()
94+
const attachmentLink = attachment.getField("url") as string
9695

97-
ztoolkit.log(title)
9896

99-
if(title == "RI OPAC"){
97+
98+
99+
ztoolkit.log(attachmentLink)
100+
101+
if(attachmentLink.includes("/opac.regesta-imperii")){
100102
const chapterID = id - 1 // the chapter's id is one less than the attachment's id
101103
const item = Zotero.Items.get(chapterID)
102104

@@ -105,7 +107,7 @@ function onAdd(id: number){
105107

106108
if(item.itemType == "bookSection"){
107109
ztoolkit.log("chapter: " + item.getDisplayTitle())
108-
processChapter(item, attachment.getField("url") as string)
110+
processChapter(item, attachmentLink)
109111
} else {
110112
ztoolkit.log("not a chapter")
111113
if(item.itemType == "book"){

0 commit comments

Comments
 (0)