{ "translatorID": "0dda3f89-15de-4479-987f-cc13f1ba7999", "label": "Ancestry.com US Federal Census", "creator": "Abe Jellinek", "target": "^https?://(www\\.)?ancestry\\.com/", "minVersion": "3.0", "maxVersion": "", "priority": 100, "inRepository": true, "translatorType": 4, "browserSupport": "gcibv", "lastUpdated": "2021-07-22 19:20:28" } /* ***** BEGIN LICENSE BLOCK ***** Copyright © 2021 Abe Jellinek This file is part of Zotero. Zotero 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. Zotero 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 Zotero. If not, see . ***** END LICENSE BLOCK ***** */ function detectWeb(doc, url) { if (text(doc, '.pageTitle .pageIntro a').includes('United States Federal Census')) { return "bookSection"; } return false; } function doWeb(doc, url) { scrape(doc, url); } function scrape(doc, url) { let item = new Zotero.Item('bookSection'); item.title = text(doc, '.pageTitle span'); let [date, place, roll, page] = doc.querySelectorAll('.sourceText em'); // not ideal item.bookTitle = text(doc, '.pageTitle .pageIntro a').trim() + ` [${place.textContent}]`; item.publisher = 'National Archives and Records Administration'; // technically the Census is published 72 years after it's taken, but citing // that way doesn't seem to be the convention. item.date = date.textContent; item.pages = `${page.textContent} (roll ${roll.textContent})`; item.archive = 'Ancestry.com'; item.url = url.replace(/[?#].*/, ''); let recordTable = doc.querySelector('#recordServiceData'); if (recordTable) { recordTable = recordTable.cloneNode(true); let familyMembers = recordTable.querySelector('.tableContainerRow'); if (familyMembers) familyMembers.remove(); item.notes.push({ note: ZU.trimInternal(recordTable.outerHTML) }); } let imageSrc = attr(doc, '.photo.clickable img', 'src'); let dbId = imageSrc.match(/\/namespaces\/([^/]+)/)[1]; let imageId = imageSrc.match(/([^/]+)\.jpg/)[1]; ZU.doGet( `/imageviewer/api/media/token?dbId=${dbId}&imageId=${imageId}`, function (respText) { try { let json = JSON.parse(respText); item.attachments.push({ title: 'Census Record', mimeType: 'image/jpeg', url: json.imageDownloadUrl }); item.complete(); } catch (_) { item.complete(); // whatever, this is fragile } } ); } /** BEGIN TEST CASES **/ var testCases = [ { "type": "web", "url": "https://www.ancestry.com/discoveryui-content/view/131479739:2442?tid=&pid=&queryId=2a5ea51171527460c8a3755eb4b3fc1e&_phsrc=BYN5&_phstart=successSource", "items": [ { "itemType": "bookSection", "title": "Albert Einstein", "creators": [], "date": "1940", "archive": "Ancestry.com", "bookTitle": "1940 United States Federal Census [Princeton, Mercer, New Jersey]", "libraryCatalog": "Ancestry.com US Federal Census", "pages": "10B (roll m-t0627-02357)", "publisher": "National Archives and Records Administration", "url": "https://www.ancestry.com/discoveryui-content/view/131479739:2442", "attachments": [ { "title": "Census Record", "mimeType": "image/jpeg" } ], "tags": [], "notes": [ { "note": "
Name: Albert Einstein
Respondent: Yes
Age: 61
Estimated Birth Year: [abt 1879] []
Gender: Male
Race: White
Birthplace: Germany
Marital Status: Widowed
Relation to Head of House: Head
Home in 1940: Princeton, Mercer, New Jersey
Map of Home in 1940:
Street: Mercer - Street
House Number: 112
Farm: No
Inferred Residence in 1935: Princeton, Mercer, New Jersey
Residence in 1935: Princeton
Resident on farm in 1935: No
Citizenship: Having first papers
Sheet Number: 10B
Number of Household in Order of Visitation: 267
Occupation: Pychies Professor
Industry: Private School
House Owned or Rented: Owned
Value of Home or Monthly Rental if Rented: 22000
Attended School or College: No
Highest Grade Completed: College, 5th or subsequent year
Hours Worked Week Prior to Census: 44
Class of Worker: Wage or salary worker in private work
Weeks Worked in 1939: 52
Income: 5000
Income Other Sources: Yes
Neighbors:
" } ], "seeAlso": [] } ] }, { "type": "web", "url": "https://www.ancestry.com/discoveryui-content/view/18443183:7884?tid=&pid=&queryId=283135001368664572d798e1a9012c06&_phsrc=oJW436&_phstart=successSource", "items": [ { "itemType": "bookSection", "title": "Pauline Rosenboom", "creators": [], "date": "1910", "archive": "Ancestry.com", "bookTitle": "1910 United States Federal Census [Bronx Assembly District 34, New York, New York]", "libraryCatalog": "Ancestry.com US Federal Census", "pages": "4A (roll T624_1001)", "publisher": "National Archives and Records Administration", "url": "https://www.ancestry.com/discoveryui-content/view/18443183:7884", "attachments": [ { "title": "Census Record", "mimeType": "image/jpeg" } ], "tags": [], "notes": [ { "note": "
Name: Pauline Rosenboom [Pauline Rosenbaum]
Age in 1910: 51
Birth Date: 1859 [1859]
Birthplace: Austria
Home in 1910: Bronx Assembly District 34, New York, New York, USA
Street: est Clenton Ave
Race: White
Gender: Female
Immigration Year: 1887
Relation to Head of House: Mother-in-law
Marital Status: Widowed
Father's Birthplace: Austria
Mother's Birthplace: Austria
Native Tongue: English
Attended School: No
Able to read: Yes
Able to Write: Yes
Number of Children Born: 7
Number of Children Living: 5
Neighbors:
" } ], "seeAlso": [] } ] } ] /** END TEST CASES **/