Skip to content

Commit

Permalink
fix: 抓取知网网页条目,将旧条目附件移到新抓取条目中
Browse files Browse the repository at this point in the history
l0o0 committed Nov 17, 2021
1 parent 7dc46e0 commit dc99ace
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions chrome/content/scripts/jasminum.js
Original file line number Diff line number Diff line change
@@ -146,14 +146,16 @@ Zotero.Jasminum = new function () {
citations: [null]
};
newItems = await this.Utils.fixItem(newItems, targetData);
// Move notes to newItems
if (item.getNotes()) {
for (let noteID of item.getNotes()) {
var noteItem = Zotero.Items.get(noteID);
noteItem.parentID = newItems[0].id;
await noteItem.saveTx();
// Move notes and attachments to newItems
let childIDs = item.getNotes().concat(item.getAttachments());
if (childIDs.length > 0) {
for (let childID of childIDs) {
var childItem = Zotero.Items.get(childID);
childItem.parentID = newItems[0].id;
await childItem.saveTx();
}
}

// Move item to Trash
item.deleted = true;
await item.saveTx();
@@ -281,7 +283,7 @@ Zotero.Jasminum = new function () {
var creator = creators[i];
if ( // English Name
(creator.lastName.search(/[A-Za-z]/) >= 0 ||
creator.firstName.search(/[A-Za-z]/) >= 0) &&
creator.firstName.search(/[A-Za-z]/) >= 0) &&
creator.firstName === "" // 名为空
) {
var EnglishName = creator.lastName;
@@ -313,7 +315,7 @@ Zotero.Jasminum = new function () {
creator.lastName.search(/[A-Za-z]/) !== -1 ||
creator.lastName.search(/[A-Za-z]/) !== -1
) {
creator.lastName = creator.firstName + " " + creator.lastName;
creator.lastName = creator.firstName + " " + creator.lastName;
} else { // For Chinese Name
creator.lastName = creator.lastName + creator.firstName;
}

0 comments on commit dc99ace

Please sign in to comment.