forked from zotero/zotero-bits
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIGN.js
More file actions
68 lines (56 loc) · 2.24 KB
/
IGN.js
File metadata and controls
68 lines (56 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
{
"translatorID":"d210c5a1-73e1-41ad-a3c9-331d5a3ead48",
"label":"IGN",
"creator":"odie5533",
"target":"^http://[^/]*\\.ign\\.com/",
"minVersion":"1.0",
"maxVersion":"",
"priority":100,
"inRepository":"1",
"translatorType":4,
"lastUpdated":"2010-08-12 16:16:53"
}
/*
IGN Translator - Parses IGN articles and creates Zotero-based metadata
Copyright (C) 2010 odie5533
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
function detectWeb(doc, url) {
if (url.match(/articles/)) {
return "webpage";
}
}
function scrape(doc, url) {
var newItem = new Zotero.Item("webpage");
newItem.publicationTitle = "IGN";
newItem.url = doc.location.href;
newItem.title = doc.title.replace(/ - [^-]+ at IGN/, "");
// pages
var pages = doc.evaluate('//div[@class="ui-page-list clear"]/ul/li[last()-1]', doc, null, XPathResult.ANY_TYPE, null);
if (p = pages.iterateNext())
newItem.pages = p.textContent;
// date
var dates = doc.evaluate('//h2[@class="publish-date"]/text()', doc, null, XPathResult.ANY_TYPE, null);
newItem.date = dates.iterateNext().textContent.replace(/^\s+|\s+$/g,'');
//authors
var byline = doc.evaluate('//div[@class="hdr-sub byline"]/a/text()', doc, null, XPathResult.ANY_TYPE, null);
var authors = byline.iterateNext().textContent.split(" and ");
for each(var a in authors) {
newItem.creators.push(Zotero.Utilities.cleanAuthor(a, "author"));
}
// attach html
newItem.attachments.push({title:"IGN Article Snapshot", mimeType:"text/html", url:doc.location.href, snapshot:true});
newItem.complete();
}
function doWeb(doc, url) {
scrape(doc, url);
}