Created
June 19, 2016 20:15
-
-
Save anonymous/fd81d0abe0d9bec83a328e50036bfbc4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"translatorID": "50010cf7-541a-460d-ac3b-c0fda066dba9", | |
"label": "Heise Archiv", | |
"creator": "Taras Keiditsch", | |
"target": "^https?://shop\\.heise\\.de/katalog/", | |
"minVersion": "3.0", | |
"maxVersion": "", | |
"priority": 100, | |
"inRepository": true, | |
"translatorType": 4, | |
"browserSupport": "g", | |
"lastUpdated": "2016-06-19 20:04:02" | |
} | |
/** | |
Copyright (c) 2016, Taras Keiditsch | |
This program 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. | |
This program 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 this program. If not, see | |
<http://www.gnu.org/licenses/>. | |
*/ | |
// based on CiNii.js translator by Michael Berkowitz and Mitsuo Yoshida | |
// Created using the Zotero Scaffold Firefox Addon | |
function detectWeb(doc, url) { | |
// if there is a bibtex-info element, the site is scrapeable | |
if (ZU.xpath(doc, '//textarea[@class="bibtex-info"]').length > 0) { | |
return "journalArticle"; | |
} | |
} | |
function doWeb(doc, url) { | |
// if you are logged in as subscriber, you can download the PDF. Get the link here. | |
var pdfUrl = ZU.xpathText(doc, '//div[@class="article-archive-free-download-container"]/a/@href'); | |
//Zotero.debug(pdfUrl); | |
// load the bibtex translator and pass the bibtex field contents | |
var trans = Zotero.loadTranslator("import"); | |
trans.setTranslator("9cb70025-a888-4a29-a210-93ec52da40d4"); | |
trans.setString(ZU.xpathText(doc, '//textarea[@class="bibtex-info"]')); | |
// Insert the missing information after the translator call | |
trans.setHandler("itemDone", function(obj, item) { | |
item.abstractNote = ZU.xpathText(doc, '//div[@class="product_view_short_desc clearfix"]/p'); | |
item.url = url; | |
item.attachments.push({url: pdfUrl, title: 'Full Text PDF', mimeType: 'application/pdf'}); | |
var docTags = ZU.xpath(doc, '//ul[@class="product-tags"]/li/a'); | |
for (var i in docTags) { | |
//Zotero.debug(docTags[i].innerHTML); | |
item.tags.push(docTags[i].innerHTML); | |
} | |
item.complete(); | |
}); | |
trans.translate(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment