{ "translatorID": "b6d0a7a-d076-48ae-b2f0-b6de28b194e", "label": "ScienceDirect", "creator": "Michael Berkowitz and Aurimas Vinckevicius", "target": "^https?://[^/]*science-?direct\\.com[^/]*/science(?:/article/|\\?.*\\b_ob=ArticleListURL|/(?:journal|bookseries|book|handbooks|referenceworks)/\\d)", "minVersion": "3.0", "maxVersion": "", "priority": 100, "inRepository": true, "translatorType": 4, "browserSupport": "gcsib", "lastUpdated": "2014-06-02 02:22:48" } function detectWeb(doc, url) { if ((url.indexOf("_ob=DownloadURL") !== -1) || doc.title == "ScienceDirect Login" || doc.title == "ScienceDirect - Dummy" || (url.indexOf("/science/advertisement/") !== -1)) { return false; } if((url.indexOf("pdf") !== -1 && url.indexOf("_ob=ArticleURL") === -1 && url.indexOf("/article/") === -1) || url.search(/\/(?:journal|bookseries|book|handbooks|referenceworks)\//) !== -1 || url.indexOf("_ob=ArticleListURL") !== -1) { if (getArticleList(doc).length > 0) { return "multiple"; } else { return false; } } else if(url.indexOf("pdf") === -1) { // Book sections have the ISBN in the URL if (url.indexOf("/B978") !== -1) { return "bookSection"; } else if(getISBN(doc)) { if(getArticleList(doc).length) { return "multiple"; } else { return "book"; } } else { return "journalArticle"; } } } function getExportLink(doc) { var link = ZU.xpath(doc, '//div[@class="icon_exportarticlesci_dir"]/a/@href'); return link.length ? link[0].textContent : false; } function getExportFormAction(doc) { var form = ZU.xpath(doc, '//div[@id="export_popup"]/form')[0]; return form ? form.action : false; } function getPDFLink(doc) { return ZU.xpathText(doc, '//div[@id="articleNav"]//div[contains(@class, "icon_pdf")]\ /a[not(@title="Purchase PDF")]/@href[1]'); } function getISBN(doc) { var isbn = ZU.xpathText(doc, '//td[@class="tablePubHead-Info"]\ //span[@class="txtSmall"]'); if(!isbn) return; isbn = isbn.match(/ISBN:\s*([-\d]+)/); if(!isbn) return; return isbn[1].replace(/[-\s]/g, ''); } function getFormValues(text, inputs) { var re = new RegExp("]+name=(['\"]?)(" + inputs.join('|') + ")\\1[^>]*>", 'g'); var input, val, params = {}; while(input = re.exec(text)) { val = input[0].match(/value=(['"]?)(.*?)\1[\s>]/); if(!val) continue; params[encodeURIComponent(input[2])] = encodeURIComponent(val[2]); } return params; } function getAbstract(doc) { var p = ZU.xpath(doc, '//div[contains(@class, "abstract") and not(contains(@class, "abstractHighlights"))]/p'); var paragraphs = []; for(var i=0; i]+name=(['"])exportCite\1[\s\S]+?<\/form>/); if(form) { form = form[0]; } else { form = text.match(/]*>/g); if(!form) { Z.debug('No forms found on page.'); } else { Z.debug(form.join('\n*********\n')); } throw new Error('exportCite form could not be found.'); } var postParams = getFormValues(form, [ //'_ArticleListID', //do we still need this? '_acct', '_docType', '_eidkey', '_method', '_ob', '_uoikey', '_userid', 'count', 'Export', 'JAVASCRIPT_ON', 'md5' ]); postParams["format"] = "cite-abs"; postParams["citation-type"] = "RIS"; var post = ''; for(var key in postParams) { post += key + '=' + postParams[key] + "&"; } ZU.doPost('/science', post, function(text) { processRIS(doc, text) }); }); } function processRIS(doc, text) { //T2 doesn't appear to hold the short title anymore. //Sometimes has series title, so I'm mapping this to T3, // although we currently don't recognize that in RIS text = text.replace(/^T2\s/mg, 'T3 '); //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) { text = text.replace(/TY\s+-[\S\s]+?ER/g, function(m) { if(m.search(/^PY\s+-\s+\d{4}\b/m) === -1 && m.search(/^Y2\s+-\s+\d{4}\b/m) !== -1 ) { return m.replace(/^PY\s+-.*\r?\n/mg, '') .replace(/^Y2\s+-/mg, 'PY -'); } return m; }); } //Certain authors sometimes have "role" prefixes text = text.replace( /^((?:A[U\d]|ED)\s+-\s+)Editor-in-Chief:\s+/mg, '$1'); var translator = Zotero.loadTranslator("import"); translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); translator.setString(text); translator.setHandler("itemDone", function(obj, item) { //issue sometimes is set to 0 for single issue volumes (?) if(item.issue == 0) delete item.issue; //add spaces after initials for(var i=0, n=item.creators.length; i