Newest update of Zotero connector for Chrome broke my translator
Hi!
I noticed that the Zotero connector (extension) for Chrome updated today to 5.0.3. I've made a simple personal webtranslator for a Swedish Drug Summary of Product Characteristics database (www.fass.se). The translator has worked fine for a year or two but suddenly stopped working with the latest chrome update today (the translator worked fine this tuesday and IT STILL WORKS when using the FIREFOX extension).
I'm using Zotero standalone 4.0.29.17 on a Windows 7 machine.
This is the output from "debug output logging":
(2)(+0000003): Translate: Detect using FASS failed:
string => TypeError: Function.prototype.apply was called on undefined, which is a undefined and not a function
stack => TypeError: Function.prototype.apply was called on undefined, which is a undefined and not a function
at Zotero.Translate.Web._detectTranslatorLoaded (file:///C:/Users/johsv21/AppData/Local/Google/Chrome/User%20Data/Default/Extensions/ekhagklcjbdpajgpjgmbionohlpdbjgc/5.0.3_0/zotero/translation/translate.js:1723:47)
at Zotero.Translate.Web. (file:///C:/Users/johsv21/AppData/Local/Google/Chrome/User%20Data/Default/Extensions/ekhagklcjbdpajgpjgmbionohlpdbjgc/5.0.3_0/zotero/translation/translate.js:1707:16)
at
url => http://www.fass.se/LIF/product?17&userType=0&nplId=20060217000051&docType=6
downloadAssociatedFiles => true
automaticSnapshots => true
I'm not a developer, and know javascripting just very superficial. Thus I'm having some difficulties understanding this output. Does anyone have an idea of what could be wrong?
-----------------------------
This is the code for the translator:
{
"translatorID": "2b0a6048-39c4-4f48-9e61-7a4482f87793",
"label": "FASS",
"creator": "Johan",
"target": "^https?://([^/]*\\.)?fass\\.se.*docType=6",
"minVersion": "3.0",
"maxVersion": "",
"priority": 100,
"inRepository": false,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2016-07-21 13:14:44"
}
function detectWeb(doc, url) {
if(url.indexOf('docType=6')){
return 'journalArticle';
}
}
function doWeb(doc, url) {
var item = new Zotero.Item("journalArticle");
var handelsnamn = ZU.xpathText(doc,'//*[@id="product-card"]/header/div/h1/text()');
var generika = ZU.xpathText(doc, './/*[@id="product-card"]/div[4]/ul/li/a/span');
var uppdaterat = ZU.xpathText(doc, '//*[@id="readspeaker-article-content"]/div[1]/h2[10]/following::text()[1]|//*[@id="readspeaker-article-content"]/div[1]/h2[10]/following::text()[following::br]|//*[@id="readspeaker-article-content"]/div[1]/h2[10]/following::text()[following::br]');
var pdfurl = ZU.xpathText(doc, '//*[@id="list-of-contents"]/article/header/div[2]/div[1]/ul/li[2]/a/@href');
var handelsnamntext = Zotero.Utilities.trimInternal(handelsnamn);
var generikatext = Zotero.Utilities.trimInternal(generika);
//var pdfurltext = Zotero.Utilities.trimInternal(pdfurl);
item.title = handelsnamntext + " (" + generikatext.toLowerCase() + ")";
item.date = Zotero.Utilities.trimInternal(uppdaterat);
item.url = "http://www.fass.se";
item.publicationTitle = "SPC, Läkemedelsverket";
var linkurl = doc.location.href;
item.attachments = [{
url: linkurl,
title: "FASS - " + handelsnamntext + " (" + generikatext.toLowerCase() + ")",
mimeType: "text/html",
snapshot: false
}];
item.complete();
}
I noticed that the Zotero connector (extension) for Chrome updated today to 5.0.3. I've made a simple personal webtranslator for a Swedish Drug Summary of Product Characteristics database (www.fass.se). The translator has worked fine for a year or two but suddenly stopped working with the latest chrome update today (the translator worked fine this tuesday and IT STILL WORKS when using the FIREFOX extension).
I'm using Zotero standalone 4.0.29.17 on a Windows 7 machine.
This is the output from "debug output logging":
(2)(+0000003): Translate: Detect using FASS failed:
string => TypeError: Function.prototype.apply was called on undefined, which is a undefined and not a function
stack => TypeError: Function.prototype.apply was called on undefined, which is a undefined and not a function
at Zotero.Translate.Web._detectTranslatorLoaded (file:///C:/Users/johsv21/AppData/Local/Google/Chrome/User%20Data/Default/Extensions/ekhagklcjbdpajgpjgmbionohlpdbjgc/5.0.3_0/zotero/translation/translate.js:1723:47)
at Zotero.Translate.Web. (file:///C:/Users/johsv21/AppData/Local/Google/Chrome/User%20Data/Default/Extensions/ekhagklcjbdpajgpjgmbionohlpdbjgc/5.0.3_0/zotero/translation/translate.js:1707:16)
at
url => http://www.fass.se/LIF/product?17&userType=0&nplId=20060217000051&docType=6
downloadAssociatedFiles => true
automaticSnapshots => true
I'm not a developer, and know javascripting just very superficial. Thus I'm having some difficulties understanding this output. Does anyone have an idea of what could be wrong?
-----------------------------
This is the code for the translator:
{
"translatorID": "2b0a6048-39c4-4f48-9e61-7a4482f87793",
"label": "FASS",
"creator": "Johan",
"target": "^https?://([^/]*\\.)?fass\\.se.*docType=6",
"minVersion": "3.0",
"maxVersion": "",
"priority": 100,
"inRepository": false,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2016-07-21 13:14:44"
}
function detectWeb(doc, url) {
if(url.indexOf('docType=6')){
return 'journalArticle';
}
}
function doWeb(doc, url) {
var item = new Zotero.Item("journalArticle");
var handelsnamn = ZU.xpathText(doc,'//*[@id="product-card"]/header/div/h1/text()');
var generika = ZU.xpathText(doc, './/*[@id="product-card"]/div[4]/ul/li/a/span');
var uppdaterat = ZU.xpathText(doc, '//*[@id="readspeaker-article-content"]/div[1]/h2[10]/following::text()[1]|//*[@id="readspeaker-article-content"]/div[1]/h2[10]/following::text()[following::br]|//*[@id="readspeaker-article-content"]/div[1]/h2[10]/following::text()[following::br]');
var pdfurl = ZU.xpathText(doc, '//*[@id="list-of-contents"]/article/header/div[2]/div[1]/ul/li[2]/a/@href');
var handelsnamntext = Zotero.Utilities.trimInternal(handelsnamn);
var generikatext = Zotero.Utilities.trimInternal(generika);
//var pdfurltext = Zotero.Utilities.trimInternal(pdfurl);
item.title = handelsnamntext + " (" + generikatext.toLowerCase() + ")";
item.date = Zotero.Utilities.trimInternal(uppdaterat);
item.url = "http://www.fass.se";
item.publicationTitle = "SPC, Läkemedelsverket";
var linkurl = doc.location.href;
item.attachments = [{
url: linkurl,
title: "FASS - " + handelsnamntext + " (" + generikatext.toLowerCase() + ")",
mimeType: "text/html",
snapshot: false
}];
item.complete();
}
You may also want to just try moving to the Zotero 5.0 beta version, which is what the 5.0 connectors are optimized for.
Is there an easy way to revert back to an earlier chrome connector version?
Is the zotero 5.0 version considered stable enough for everyday use?
I don't think there's an easy way to revert to older Chrome connectors (given the nature of the Play store), but not 100% sure. (Zotero components that install from zotero.org are all available in all older versions).