Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ScienceDirect: Don't add isDTMRedir URL param #3368

Merged
merged 1 commit into from
Oct 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ScienceDirect.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2024-06-13 19:43:00"
"lastUpdated": "2024-10-03 14:17:12"
}

function detectWeb(doc, url) {

Check warning on line 15 in ScienceDirect.js

View workflow job for this annotation

GitHub Actions / Lint, Check, Test

Missing license block
if (!doc.body.textContent.trim()) return false;

if ((url.includes("_ob=DownloadURL"))
Expand All @@ -25,7 +25,7 @@
if ((url.includes("pdf")
&& !url.includes("_ob=ArticleURL")
&& !url.includes("/article/"))
|| url.search(/\/(?:journal|bookseries|book|handbook)\//) !== -1) {

Check warning on line 28 in ScienceDirect.js

View workflow job for this annotation

GitHub Actions / Lint, Check, Test

Unnecessary '.search()', use 'RegExp#test()' instead
if (getArticleList(doc).length > 0) {
return "multiple";
}
Expand All @@ -34,7 +34,7 @@
}
}

if (url.search(/\/search[?/]/) != -1) {

Check warning on line 37 in ScienceDirect.js

View workflow job for this annotation

GitHub Actions / Lint, Check, Test

Unnecessary '.search()', use 'RegExp#test()' instead
if (getArticleList(doc).length > 0) {
return "multiple";
}
Expand Down Expand Up @@ -133,8 +133,8 @@
let pii = urlMetadata.pii;
let md5 = urlMetadata.queryParams.md5;
let pid = urlMetadata.queryParams.pid;
if (path && pdfExtension && pii && md5 && pid){

Check warning on line 136 in ScienceDirect.js

View workflow job for this annotation

GitHub Actions / Lint, Check, Test

Missing space before opening brace
pdfURL = `/${path}/${pii}${pdfExtension}?md5=${md5}&pid=${pid}&isDTMRedir=Y`;
pdfURL = `/${path}/${pii}${pdfExtension}?md5=${md5}&pid=${pid}`;
Zotero.debug("Created PDF URL from JSON data: " + pdfURL);
return pdfURL;
}
Expand All @@ -153,7 +153,7 @@
// enough to get us through even without those parameters.
pdfURL = attr(doc, 'link[rel="canonical"]', 'href');
if (pdfURL) {
pdfURL = pdfURL + '/pdfft?isDTMRedir=true&download=true';
pdfURL = pdfURL + '/pdfft?download=true';

Check failure on line 156 in ScienceDirect.js

View workflow job for this annotation

GitHub Actions / Lint, Check, Test

Assignment (=) can be replaced with operator assignment (+=)
Zotero.debug("Trying to construct PDF URL from canonical link: " + pdfURL);
return pdfURL;
}
Expand Down Expand Up @@ -254,7 +254,7 @@
};

var replaced = false;
if (snapshot && title.search(/Article plus Supplemental Information/i) != -1) {

Check warning on line 257 in ScienceDirect.js

View workflow job for this annotation

GitHub Actions / Lint, Check, Test

Unnecessary '.search()', use 'RegExp#test()' instead
// replace full text PDF
for (var j = 0, m = item.attachments.length; j < m; j++) {
if (item.attachments[j].title == "ScienceDirect Full Text PDF") {
Expand Down Expand Up @@ -283,10 +283,10 @@

// Sometimes PY has some nonsensical value. Y2 contains the correct
// date in that case.
if (text.search(/^Y2\s+-\s+\d{4}\b/m) !== -1) {

Check warning on line 286 in ScienceDirect.js

View workflow job for this annotation

GitHub Actions / Lint, Check, Test

Unnecessary '.search()', use 'RegExp#test()' instead
text = text.replace(/TY\s+-[\S\s]+?ER/g, function (m) {
if (m.search(/^PY\s+-\s+\d{4}\b/m) === -1

Check warning on line 288 in ScienceDirect.js

View workflow job for this annotation

GitHub Actions / Lint, Check, Test

Unnecessary '.search()', use 'RegExp#test()' instead
&& m.search(/^Y2\s+-\s+\d{4}\b/m) !== -1

Check warning on line 289 in ScienceDirect.js

View workflow job for this annotation

GitHub Actions / Lint, Check, Test

Unnecessary '.search()', use 'RegExp#test()' instead
) {
return m.replace(/^PY\s+-.*\r?\n/mg, '')
.replace(/^Y2\s+-/mg, 'PY -');
Expand Down
Loading