{ "translatorID": "ca0e7488-ef20-4485-8499-9c47e60dcfa7", "label": "RSC Publishing", "creator": "Sebastian Karcher", "target": "^https?://(:?www\\.|google\\.)?pubs\\.rsc\\.org/", "minVersion": "2.1.9", "maxVersion": "", "priority": 100, "inRepository": true, "translatorType": 4, "browserSupport": "gcsb", "lastUpdated": "2017-06-20 13:43:21" } /* ***** BEGIN LICENSE BLOCK ***** RSC Publishing Translator Copyright © 2011 Aurimas Vinckevicius 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 getResults(doc) { /**Both search result and book ToC pages use javascript to load content, so * this actually doesn't work as intended. Search results will work, but * will also trigger on empty result set. detectWeb for book ToC does not * work, but doWeb does, */ return ZU.xpath(doc, '//div[@id="all" or @id="chapterList"]\ //div[contains(@class,"title_text")]\ //a[not(contains(@href,"/database/"))]'); } function detectWeb(doc, url) { if (url.search(/\/results[?\/]/i) != -1 || url.indexOf('/ebook/') != -1 && getResults(doc).length) { return 'multiple'; } //apparently URLs sometimes have upper case as in /Content/ArticleLanding/ if (url.search(/\/content\/articlelanding\//i) != -1 && ZU.xpathText(doc, '//meta[@name="citation_title"]/@content')) { return 'journalArticle'; } if (url.search(/\/content\/chapter\//i) != -1) { return 'bookSection'; } } function scrape(doc, url, type) { var translator = Zotero.loadTranslator('web'); translator.setTranslator('951c027d-74ac-47d4-a107-9c3069ab7b48'); translator.setDocument(doc); translator.setHandler('itemDone', function(obj, item) { // item.itemType = type; //keywords is frequently an empty string if (item.tags.length == 1 && !item.tags[0]) { item.tags = []; } if (item.date) { item.date = ZU.strToISO(item.date); } item.complete(); }); translator.getTranslatorObject(function(trans) { trans.itemType = type; trans.doWeb(doc, url); }); } function doWeb(doc, url) { var type = detectWeb(doc, url); if (type == 'multiple') { var results = getResults(doc); var items = new Object(); for (var i=0, n=results.length; i