Skip to content

Commit

Permalink
fix: 修复从阅读页面下载的学位论文不能自动添加目录,更新书签添加成功的通知
Browse files Browse the repository at this point in the history
  • Loading branch information
l0o0 committed Dec 5, 2021
1 parent b8b915f commit dea47d4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
6 changes: 4 additions & 2 deletions chrome/content/scripts/jasminum.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,10 @@ Zotero.Jasminum = new function () {



this.addBookmarkItem = async function () {
var item = ZoteroPane.getSelectedItems()[0];
this.addBookmarkItem = async function (item) {
if (item === undefined) {
item = ZoteroPane.getSelectedItems()[0];
}
if (!(await this.Scrape.checkPath())) {
this.Utils.showPopup(
"PDFtk Server is not installed",
Expand Down
15 changes: 12 additions & 3 deletions chrome/content/scripts/scrape.js
Original file line number Diff line number Diff line change
Expand Up @@ -520,14 +520,20 @@ Zotero.Jasminum.Scrape = new function () {
var itemUrl = "";
var itemReaderUrl = "";
var itemChapterUrl = "";
if (
if ( // CNKI reader URL exists
parentItem.getField("url") &&
parentItem.getField("url").includes("Kreader/CatalogView")
) {
itemReaderUrl = parentItem.getField("url");
} else if (
// 匹配知网 URL
parentItem.getField("url") &&
parentItem.getField("url").match(/^https?:\/\/kns\.cnki\.net/) &&// Except nxgp.cnki.net
this.Scrape.getIDFromUrl(parentItem.getField("url")) // A valid ID
) {
Zotero.debug("** Jasminum item url exists");
itemUrl = parentItem.getField("url");
itemReaderUrl = this.Scrape.getReaderUrl(itemUrl);
} else {
Zotero.debug("Jasminum search for item url");
var fileData = {
Expand All @@ -543,10 +549,10 @@ Zotero.Jasminum.Scrape = new function () {
// Frist row in search table is selected.
itemUrl = targetRows[0].querySelector("a.fz14").getAttribute("href");
itemUrl = "https://kns.cnki.net/KCMS" + itemUrl.slice(4);
itemReaderUrl = this.Scrape.getReaderUrl(itemUrl);
// 获取文献链接URL -> 获取章节目录URL
}
Zotero.debug("** Jasminum item url: " + itemUrl);
itemReaderUrl = this.Scrape.getReaderUrl(itemUrl);
Zotero.debug("** Jasminum item reader url: " + itemReaderUrl);
itemChapterUrl = await this.Scrape.getChapterUrl(itemReaderUrl);
Zotero.debug("** Jasminum item chapter url: " + itemChapterUrl);
Expand Down Expand Up @@ -617,7 +623,10 @@ Zotero.Jasminum.Scrape = new function () {
await OS.File.copy(cachePDF.path, item.getFilePath());
cacheFile.remove(false);
cachePDF.remove(false);
Zotero.debug("** Jasminum add bookmark complete!");
this.Utils.showPopup(
"学位论文书签",
`${item.getFilename()} 书签添加成功`
);
} catch (e) {
Zotero.logError(e);
try {
Expand Down

0 comments on commit dea47d4

Please sign in to comment.