From 63f87c66dffd378de68e84e821e2fc1a180b7aaf Mon Sep 17 00:00:00 2001 From: Brenden Ferland Date: Tue, 20 May 2025 15:51:03 -0400 Subject: [PATCH 1/2] Allow installation on Zotero 7.1 --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 07da0dd..f293e83 100644 --- a/manifest.json +++ b/manifest.json @@ -9,7 +9,7 @@ "id": "frlars21@github.com", "update_url": "https://www.zotero.org/download/plugins/make-it-red/updates.json", "strict_min_version": "6.999", - "strict_max_version": "7.0.*" + "strict_max_version": "7.1.*" } } } From 352f47fac5094ddc5c368695ed2c06d048e765da Mon Sep 17 00:00:00 2001 From: Brenden Ferland Date: Tue, 20 May 2025 16:14:08 -0400 Subject: [PATCH 2/2] Improve Crossref handling --- bin/build | 2 +- locale/en-US/citation-counts.ftl | 2 +- zoterocitationcounts.js | 14 ++++++++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/bin/build b/bin/build index 615cb4c..ac15923 100755 --- a/bin/build +++ b/bin/build @@ -11,4 +11,4 @@ zip -r zoterocitationcountsmanager-${version}.xpi locale/* manifest.json bootstr # - increase version number in all files (not just here) # - run this script to create a new .xpi file # - commit and push to Github -# - make a release on Github, and manually upload the new .xpi file \ No newline at end of file +# - make a release on Github, and manually upload the new .xpi file diff --git a/locale/en-US/citation-counts.ftl b/locale/en-US/citation-counts.ftl index f084549..a7af18a 100644 --- a/locale/en-US/citation-counts.ftl +++ b/locale/en-US/citation-counts.ftl @@ -33,4 +33,4 @@ citationcounts-preferences-pane-autoretrieve-api-none = .label = No ## Misc -citationcounts-internal-error = Internal error \ No newline at end of file +citationcounts-internal-error = Internal error diff --git a/zoterocitationcounts.js b/zoterocitationcounts.js index d81604f..fbbef7e 100644 --- a/zoterocitationcounts.js +++ b/zoterocitationcounts.js @@ -527,11 +527,17 @@ ZoteroCitationCounts = { //////////////////////////////////////////// _crossrefUrl: function (id, type) { - return `https://api.crossref.org/works/${id}/transform/application/vnd.citationstyles.csl+json`; + return `https://api.crossref.org/works/${id}`; }, - _crossrefCallback: function (response) { - return response["is-referenced-by-count"]; + _crossrefCallback: async function (response) { + const count = response?.message?.["is-referenced-by-count"]; + + // small delay to avoid hitting Crossref rate limits when + // processing many items at once + await new Promise((r) => setTimeout(r, 500)); + + return count; }, _inspireUrl: function (id, type) { @@ -549,7 +555,7 @@ ZoteroCitationCounts = { // The callback can be async if we want. _semanticScholarCallback: async function (response) { - count = response["citationCount"]; + const count = response["citationCount"]; // throttle Semantic Scholar so we don't reach limit. await new Promise((r) => setTimeout(r, 3000));