/* ***** BEGIN LICENSE BLOCK ***** Copyright © 2021 YOUR_NAME <- TODO 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) { // TODO: adjust the logic here if (url.includes('/article/')) { return "newspaperArticle"; } else if (getSearchResults(doc, true)) { return "multiple"; } return false; } function getSearchResults(doc, checkOnly) { var items = {}; var found = false; // TODO: adjust the CSS selector var rows = doc.querySelectorAll('h2 > a.title[href*="/article/"]'); for (let row of rows) { // TODO: check and maybe adjust let href = row.href; // TODO: check and maybe adjust 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); } }