Skip to content

Commit

Permalink
feat: can trash arXiv PDF without annotation
Browse files Browse the repository at this point in the history
See #24
  • Loading branch information
AllanChain committed Nov 30, 2024
1 parent b3bdea7 commit 7deedaf
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions addon/chrome/content/preferences.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
preference="extensions.zotero.__addonRef__.downloadJournalPDF"
data-l10n-id="pref-downloadJournalPDF"
/>
<checkbox
id="zotero-prefpane-__addonRef__-merge.trashUnannotatedPDF"
preference="extensions.zotero.__addonRef__.merge.trashUnannotatedPDF"
data-l10n-id="pref-merge-trashUnannotatedPDF"
/>
<html:p data-l10n-id="pref-merge-arXiv-warn"></html:p>
<checkbox
id="zotero-prefpane-__addonRef__-merge.arXivExtra"
Expand Down
2 changes: 2 additions & 0 deletions addon/locale/en-US/preferences.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ pref-merge-arXivExtra =
.label = Keep arXiv information in the Extra field when merging
pref-merge-arXivURL =
.label = Use arXiv URL in the URL field when merging
pref-merge-trashUnannotatedPDF =
.label = Trash arXiv PDF without annotation when merging
pref-merge-arXiv-warn = The following two settings could add arXiv information in the exported citation:
pref-source = arXiv Update sources
pref-source-doi =
Expand Down
2 changes: 2 additions & 0 deletions addon/locale/zh-CN/preferences.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ pref-merge-arXivExtra =
.label = 合并条目时,保留 Extra 字段中的 arXiv 信息
pref-merge-arXivURL =
.label = 合并条目时,在 URL 字段中保留 arXiv 的 URL
pref-merge-trashUnannotatedPDF =
.label = 合并条目时,删除无注释的 arXiv PDF
pref-merge-arXiv-warn = 以下两条设置可能导致导出的引用信息包含 arXiv 信息:
pref-source = arXiv 更新源
pref-source-doi =
Expand Down
1 change: 1 addition & 0 deletions addon/prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ pref("__prefsPrefix__.updateSource.arXiv", true);
pref("__prefsPrefix__.mergePreferJournalPDF", true);
pref("__prefsPrefix__.merge.arXivExtra", false);
pref("__prefsPrefix__.merge.arXivURL", false);
pref("__prefsPrefix__.merge.trashUnannotatedPDF", false);
8 changes: 8 additions & 0 deletions src/modules/arxiv-merge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@ export class arXivMerge {
title: preprintJSON.archiveID ?? "Preprint URL",
});
}
if (getPref("merge.trashUnannotatedPDF")) {
for (const attachmentID of preprintItem.getAttachments()) {
const attachment = await Zotero.Items.getAsync(attachmentID);
if (!attachment.isPDFAttachment()) continue;
if (attachment.getAnnotations().length) continue;
await Zotero.Items.trashTx(attachmentID);
}
}
// Set prefered PDF
if (getPref("mergePreferJournalPDF")) {
let oldestPDFDate = new Date();
Expand Down

0 comments on commit 7deedaf

Please sign in to comment.