{
"translatorID": "274284a8-fc91-4f54-be77-bfcb7f9c3d6f",
"label": "PC Gamer",
"creator": "czar",
"target": "^https?://(www\\.)?pcgamer\\.com",
"minVersion": "3.0",
"maxVersion": "",
"priority": 100,
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2018-07-07 03:30:20"
}
/*
***** 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) {
var isBlogPost = ZU.xpath(doc,'//*[@id="main"]/article');
if (isBlogPost.length) {
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
translator.setDocument(doc);
translator.setHandler('itemDone', function (obj, item) { // correct bad metadata in here
item.itemType = "blogPost";
item.publicationTitle = "PC Gamer";
item.language = "en-US";
item.creators = []; // reset bad author metadata
var authorMetadata = doc.querySelectorAll('a[rel="author"]');
for (let author of authorMetadata) {
item.creators.push(ZU.cleanAuthor(author.text, "author"));
}
item.complete();
});
translator.getTranslatorObject(function(trans) {
trans.addCustomFields({ // pull from meta tags in here
'pub_date': 'date'
});
trans.doWeb(doc, url);
});
}
function getSearchResults(doc, checkOnly) {
var items = {};
var found = false;
var rows = doc.querySelectorAll('div#content > div.mainCarousel span.article-name, div.listingResults h3');
var links = doc.querySelectorAll('div#content > div.mainCarousel div.feature-block-item-wrapper > a:first-of-type, div.listingResults div.listingResult > a:first-of-type');
for (let i=0; i