{ "translatorID": "82b534ea-abf0-4527-9d5d-48cd98a89ba5", "label": "Sacramento Bee", "creator": "czar", "target": "^https?://(www\\.)?sacbee\\.com", "minVersion": "3.0", "maxVersion": "", "priority": 100, "inRepository": true, "translatorType": 4, "browserSupport": "gcsibv", "lastUpdated": "2017-07-09 05:05:18" } /* ***** BEGIN LICENSE BLOCK ***** Copyright © 2017 czar http://en.wikipedia.org/wiki/User_talk:Czar 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 ***** */ // attr()/text() function attr(doc,selector,attr,index){if(index>0){var elem=doc.querySelectorAll(selector).item(index);return elem?elem.getAttribute(attr):null}var elem=doc.querySelector(selector);return elem?elem.getAttribute(attr):null}function text(doc,selector,index){if(index>0){var elem=doc.querySelectorAll(selector).item(index);return elem?elem.textContent:null}var elem=doc.querySelector(selector);return elem?elem.textContent:null} function detectWeb(doc, url) { if (/article\d+/.test(url)) { return "newspaperArticle"; } else if (/(\/((news|sports|entertainment)\/)|(search\/\?q=))|sacbee\.com\/?$/.test(url) && getSearchResults(doc, true) ) { return "multiple"; } } function scrape(doc, url) { var item = new Zotero.Item("newspaperArticle"); item.publicationTitle = "The Sacramento Bee"; item.language = "en-US"; item.ISSN = "0890-5738"; item.url = url; item.title = attr(doc,'[property="og:title"]','content'); item.date = text(doc,'.published-date'); if (item.date) { // don't perform on empty string item.date = ZU.strToISO(item.date); } item.abstractNote = text(doc,'#content-body- p'); var keywords = attr(doc,'meta[name="keywords"]','content'); if (keywords) { // so as not to perform a split when keyword string is null item.tags = keywords.split(", "); } item.attachments.push({ title: "The Sacramento Bee Snapshot", mimeType: "text/html", document: doc }); // Authors var authorMetadata = doc.querySelectorAll('.ng_byline_name'); if (authorMetadata.length) { // querySelectorAll always retuns a NodeList, so test against length instead // when authors are split between multiple selectors, combine them var authorString = ''; for (i=0; i < authorMetadata.length; i++) { authorString = authorString.concat(' '+authorMetadata[i].textContent); } authorString = authorString.replace('By ','').split(" and "); do { item.creators.push(ZU.cleanAuthor(authorString[0], "author")); authorString.shift(); } while (authorString.length); } item.complete(); } function getSearchResults(doc, checkOnly) { var items = {}; var found = false; var rows = doc.querySelectorAll('#site-search-results .title a, .media-body .title a, #story-list .title a, .col-sm-7 .title a'); for (var i=0; i