{ "translatorID": "e570f517-83f2-4735-97d2-44499aee0b21", "label": "Eurogamer/USgamer", "creator": "czar", "target": "^https?://(www\\.)?(eurogamer|usgamer)\\.(net|cz|de|es|it|nl|pl|pt)", "minVersion": "3.0", "maxVersion": "", "priority": 100, "inRepository": true, "translatorType": 4, "browserSupport": "gcsibv", "lastUpdated": "2018-07-14 19:42:21" } /* ***** BEGIN LICENSE BLOCK ***** Copyright © 2018 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 ***** */ function detectWeb(doc, url) { if (/articles/.test(url)) { return "blogPost"; } else if (getSearchResults(doc, true)) { return "multiple"; } } function scrape(doc, url) { var translator = Zotero.loadTranslator('web'); translator.setTranslator('951c027d-74ac-47d4-a107-9c3069ab7b48'); // embedded metadata (EM) translator.setDocument(doc); translator.setHandler('itemDone', function (obj, item) { // corrections to EM item.itemType = "blogPost"; if (item.publicationTitle) { item.publicationTitle = item.publicationTitle.replace('.net',''); } if (item.abstractNote) { item.abstractNote = item.abstractNote.replace(/…/,"..."); } var json_ld = doc.querySelector('script[type="application/ld+json"]'); // JSON-LD not yet built into EM if (json_ld) { var json = JSON.parse(json_ld.textContent); item.date = json.datePublished; if (json.author && json.author.name) { item.creators.push(ZU.cleanAuthor(json.author.name, "author")); } } if (item.creators.length === 0) { // usgamer.net doesn't have JSON-LD and Eurogamer.de's didn't include authors var authorMetadata = doc.querySelectorAll('.author .name a, .details .author a'); for (let author of authorMetadata) { item.creators.push(ZU.cleanAuthor(author.text, "author")); } } if (!item.date) { // usgamer.net doesn't have JSON-LD var dateMetadata = doc.querySelector('span.published'); if (dateMetadata) { item.date = ZU.strToISO(dateMetadata.getAttribute('content')); } } var tags = doc.querySelectorAll('.tags a'); if (tags && url.includes('usgamer.net')) { // Eurogamer tags weren't worth it but USgamer's are good for (let tagObj of tags) { var tag = tagObj.textContent; if (tag == tag.toLowerCase()) { tag = tag.replace(/\w/, c => c.toUpperCase()); } item.tags.push(tag); } } item.complete(); }); translator.getTranslatorObject(function(trans) { trans.doWeb(doc, url); }); } function getSearchResults(doc, checkOnly) { var items = {}; var found = false; var rows = doc.querySelectorAll('a.gs-title, .details .title a'); for (let i=0; i