{ "translatorID":"27ee5b2c-2a5a-4afc-a0aa-d386642d4eed", "translatorType":4, "label":"PubMed Central", "creator":"Michael Berkowitz and Rintze Zelle", "target":"https?://[^/]*.nih.gov/", "minVersion":"1.0.0b4.r5", "maxVersion":"", "priority":100, "inRepository":true, "lastUpdated":"2010-06-14 11:55:00" } function detectWeb(doc, url) { var namespace = doc.documentElement.namespaceURI; var nsResolver = namespace ? function(prefix) { if (prefix == 'x') return namespace; else return null; } : null; try {var pmid = url.match(/ncbi\.nlm\.nih\.gov\/pmc\/articles\/PMC([\d]+)/)[1];} catch (e) {} if (pmid) { return "journalArticle"; } var uids = doc.evaluate('//div[@class="toc-pmcid"]', doc, nsResolver, XPathResult.ANY_TYPE, null); if(uids.iterateNext()) { if (uids.iterateNext()){ return "multiple"; } return "journalArticle"; } } function lookupPMCIDs(ids, doc) { Zotero.wait(); var newUri = "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pmc&retmode=xml&id=" + ids.join(","); Zotero.debug(newUri); Zotero.Utilities.HTTP.doGet(newUri, function (text) { text = text.replace(/]*>/, "").replace(/<\?xml[^>]*\?>/, ""); // Remove xml parse instruction and doctype text = text.replace(/(<[^!>][^>]*>)/g, function replacer(str, p1, p2, offset, s) { return str.replace(/-/gm, ""); }); //Strip hyphens from element names, attribute names and attribute values text = text.replace(/(<[^!>][^>]*>)/g, function replacer(str, p1, p2, offset, s) { return str.replace(/:/gm, ""); }); //Strip colons from element names, attribute names and attribute values text = Zotero.Utilities.trim(text); XML.prettyPrinting = false; XML.ignoreWhitespace = false; var xml = new XML(text); for (var i = 0; i < xml.article.length(); i++) { var newItem = new Zotero.Item("journalArticle"); var journal = xml.article[i].front.journalmeta; if (journal.journalid.(@journalidtype == "nlmta").length()) { newItem.journalAbbreviation = Zotero.Utilities.superCleanString(journal.journalid.(@journalidtype == "nlmta").text().toString()); } newItem.publicationTitle = Zotero.Utilities.superCleanString(journal.journaltitle.text().toString()); var issn = journal.issn.(@pubtype == "epub").text().toString(); var issn = journal.issn.(@pubtype == "ppub").text().toString(); if (issn) { newItem.ISSN = issn; } var article = xml.article[i].front.articlemeta; if (article.abstract.p.length()) { newItem.abstractNote = Zotero.Utilities.unescapeHTML(article.abstract.p.toXMLString()); } if (article.articleid.(@pubidtype == "doi").length()) { newItem.DOI = article.articleid.(@pubidtype == "doi").text().toString(); } var PMID = article.articleid.(@pubidtype == "pmid").text().toString(); if (PMID) { newItem.extra = "PMID: " + PMID + "\n"; } newItem.extra = newItem.extra + "PMCID: " + ids[i]; newItem.title = Zotero.Utilities.unescapeHTML(article.titlegroup.articletitle.toXMLString().split(" 1) { ids = Zotero.selectItems(ids); } if (!ids) { return true; } var pmcids = new Array(); for (var i in ids) { pmcids.push(i); } lookupPMCIDs(pmcids, doc); } }