{ "translatorID": "0dda3f89-15de-4479-987f-cc13f1ba7999", "label": "Ancestry.com US Federal Census", "creator": "Elena Razlogova", "target": "^https?://search\\.ancestry\\.com/.*(usfedcen|1890orgcen|1910uscenindex)", "minVersion": "1.0.0b4.r1", "maxVersion": "", "priority": 100, "inRepository": true, "translatorType": 4, "browserSupport": "g", "lastUpdated": "2015-06-02 10:57:09" } function detectWeb(doc, url) { var namespace = doc.documentElement.namespaceURI; var nsResolver = namespace ? function(prefix) { if (prefix == 'x') return namespace; else return null; } : null; var result = doc.evaluate('//div[@class="g_container"]/div[@class="g_panelWrap"]/div[@class="g_panelCore"]/div[@class="s_container"]/div[@class="p_rsltList"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); var rows = doc.evaluate('//div[@class="g_container"]/div[@class="g_panelWrap"]/div[@class="g_panelCore"]/div[@class="s_container"]/div[@class="p_rsltList"]/table/tbody/tr[@class="tblrow record"]', doc, nsResolver, XPathResult.ANY_TYPE, null); var row; while (row = rows.iterateNext()) { links = doc.evaluate('.//a', row, nsResolver, XPathResult.ANY_TYPE, null); var linkNo=0; while (link=links.iterateNext()) { linkNo=linkNo+1; } break; } if (result && linkNo == 2) { return "multiple"; } else { var indivRe = /indiv=1/; var m = indivRe.exec(doc.location.href); var indiv = 0; if (m) { indiv = 1; } checkURL = doc.location.href.replace("pf=", ""); if (doc.location.href == checkURL && indiv == 1) { return "bookSection"; } } } // this US Federal Census scraper is a hack - so far there is no proper item type in Zotero for this kind of data (added to trac as a low priority ticket) // this scraper creates proper citation for the census as a whole (should be cited as book) // but also adds name, city, and state for a particular individual to the citation to make scanning for names & places easier in the middle pane // (that's why the resulting item type is a book section) // it also adds all searchable text as a snapshot and a scan of the census record as an image function scrape(doc) { var namespace = doc.documentElement.namespaceURI; var nsResolver = namespace ? function(prefix) { if (prefix == 'x') return namespace; else return null; } : null; // get initial census data; a proper census record item type should have separate fields for all of these except perhaps dbid var info = doc.evaluate('//div[@class="facets"][@id="connect"]/div[@class="g_box"]/p/a', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); if (info) { info = info.toString(); var data = new Array(); var parts = info.split(/[?&]/); for (var i=0; i