a new custom translator isn't called when visiting a target web page

I've been trying to write a new translator for conference abstracts (Society for Neuroscience 2017).

I wrote a .js file as below and placed it in Zotero's translator folder. There may be some errors, but I think it's close to be functional. However, at the moment, when I visit the example web page, the Zotero connector icon doesn't change to conferecePaper icon and stays generic. I suspect it's related to an error in "target" regular expression, but cannot work it out.

Could someone give me a hint or solution?

At the moment, translatorID is a fake randome number.

Best,
Kouichi


Example pages
http://www.abstractsonline.com/pp8/#!/4376/presentation/23054
http://www.abstractsonline.com/pp8/#!/4376/participants/saalman/1

Source Code

{
"translatorID": "3d0231ce-fd4b-478c-b1d3-840389e5b68d",
"label": "SfN Abstract",
"creator": "Kouichi C. Nakamura",
"target": "^https?://www\\.abstractsonline\\.com/pp8/#!/\d+/(presentation|presentations|sessions|participants)/",
"minVersion": "3.0",
"maxVersion": "",
"priority": 200,
"inRepository": false,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2017-09-15 20:46:00"
}

function detectWeb(doc, url) { return FW.detectWeb(doc, url); }
function doWeb(doc, url) { return FW.doWeb(doc, url); }

FW.Scraper({
itemType : 'conferencePaper',
detect : FW.Url().match(/\/presentation\/\d+/),
title : FW.Xpath('//h1[@class="color-primary"]').text().replace(/\d+\s\.\s\w+\d+\s\-\s/,""),
pages : FW.Xpath('//h1[@class="color-primary"]').text().match(/\d+\s\.\s\w+\d+/),
attachments : {
url: FW.Url(),
title: "Society for Neuroscience Abstract",
type: "text/html"
},
creators : FW.Xpath('//div[@class="span7"]/dl/dd[1]')
.text().replace(/(\d,(?=\d)|\d|\*)/g,"").cleanAuthor("author"),
// Zotero.utilities.cleanAuthor(string,"author")
// https://www.zotero.org/support/dev/translators_reference_guide#string_manipulation
// "*M. J. REDINBAUGH1, J. M. PHILLIPS1, N. A. KAMBI1, S. MOHANTA1, A. RAZ2,3, Y. B. SAALMANN1"
date : FW.Xpath('//span[@class="session-date"]').text().match(/\w+\s\d+,\s\d+/),
abstractNote : FW.Xpath('//div[@class="span7"]/dl/dd[3]').text(),
publicationTitle : "Society for Neuroscience Abstract",
url : FW.Url(),
conferenceName : "Society for Neuroscience",
language : "eng"
});


FW.MultiScraper({
itemType : 'multiple',
detect : FW.Url().match(/(presentations|sessions|participants)\/[^\\]+\/\d+/),
choices : {
titles : FW.Xpath('//h4[@class="name"]/span[@class="bodyTitle"]/a').text().replace(/^\d+\.\d+\.\s/,""),
urls : FW.Url().replace(/presentations.+$|sessions.+$|participants.+$/,"") +
"/presentations/" +
FW.Xpath('//h4[@class="name"]').key("data-id").text()
//
// 751.03. Stimulation of central lateral thalamus restores conscious processing under propofol and isoflurane anesthesia
//
}


Sign In or Register to comment.