{
"translatorID": "4a3820a3-a7bd-44a1-8711-acf7b57d2c37",
"translatorType": 4,
"label": "Web of Science Nextgen",
"creator": "Abe Jellinek",
"target": "^https://(www\\.webofscience\\.com|webofscience\\.clarivate\\.cn)/",
"minVersion": "3.0",
"maxVersion": null,
"priority": 100,
"inRepository": true,
"browserSupport": "gcsibv",
"lastUpdated": "2024-04-03 06:10:00"
}
/*
***** BEGIN LICENSE BLOCK *****
Copyright © 2021 Abe Jellinek
This file is part of Zotero.
Zotero is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Zotero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Zotero. If not, see .
***** END LICENSE BLOCK *****
*/
function detectWeb(doc, url) {
if (url.includes('/full-record/') && getItemID(url)) {
let docType = text(doc, '#FullRTa-doctype-0').trim().toLowerCase();
if (docType == 'proceedings paper') {
return "conferencePaper";
}
else if (docType == "book") {
return "book";
}
else if (docType == "data set") {
return "document"; //change to dataset
}
else if (text(doc, '#FullRTa-patentNumber-0')) {
return "patent";
}
else {
return "journalArticle";
}
}
else if (getSearchResults(doc, true)) {
return "multiple";
}
Z.monitorDOMChanges(doc.querySelector('app-wos'));
return false;
}
function getSearchResults(doc, checkOnly) {
var items = {};
var found = false;
var rows = doc.querySelectorAll('app-article-metadata a[href*="/WOS:"], app-summary-title a[href*="/WOS:"]');
for (let row of rows) {
let href = row.href;
let title = ZU.trimInternal(row.textContent);
if (!href || !title) continue;
if (checkOnly) return true;
found = true;
items[href] = title;
}
return found ? items : false;
}
function doWeb(doc, url) {
if (detectWeb(doc, url) == "multiple") {
Zotero.selectItems(getSearchResults(doc, false), function (items) {
if (items) ZU.processDocuments(Object.keys(items), scrape);
});
}
else {
scrape(doc, url);
}
}
function scrape(doc, url) {
function processTaggedData(text) {
let importer = Zotero.loadTranslator("import");
// Web of Science Tagged
importer.setTranslator("594ebe3c-90a0-4830-83bc-9502825a6810");
importer.setString(text);
importer.setHandler('itemDone', function (obj, item) {
if (item.title.toUpperCase() == item.title) {
item.title = ZU.capitalizeTitle(item.title, true);
}
for (let creator of item.creators) {
if (creator.firstName.toUpperCase() == creator.firstName) {
creator.firstName = ZU.capitalizeTitle(creator.firstName, true);
}
if (creator.lastName.toUpperCase() == creator.lastName) {
creator.lastName = ZU.capitalizeTitle(creator.lastName, true);
}
}
if (item.url) {
item.complete();
return;
}
let gatewayURL = attr(doc, 'a#FRLinkTa-link-1', 'href');
resolveGateway(gatewayURL, (url) => {
item.url = url;
item.complete();
});
});
importer.translate();
}
let id = getItemID(url);
getSessionID(doc, (sessionID) => {
let postData = {
action: 'saveToFieldTagged',
colName: 'WOS',
displayCitedRefs: 'true',
displayTimesCited: 'true',
displayUsageInfo: 'true',
fileOpt: 'othersoftware',
filters: 'fullRecord',
product: 'UA',
view: 'fullrec',
ids: [id]
};
ZU.doPost(
'/api/wosnx/indic/export/saveToFile',
JSON.stringify(postData),
processTaggedData,
{ 'X-1P-WOS-SID': sessionID }
);
});
}
function getItemID(url) {
let idInURL = url.match(/((?:WOS|RSCI|KJD|DIIDW|MEDLINE|DRCI|BCI|SCIELO|ZOOREC|CCC):[^/?&(]+)/);
// Z.debug(idInURL)
return idInURL && idInURL[1];
}
function getSessionID(doc, callback) {
const sidRegex = /(?:sid=|"SID":")([a-zA-Z0-9]+)/i;
// session ID is embedded in the static page inside an inline