-
Notifications
You must be signed in to change notification settings - Fork 0
/
CiteULike.js
58 lines (54 loc) · 1.65 KB
/
CiteULike.js
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
{
"translatorID":"8917b41c-8527-4ee7-b2dd-bcbc3fa5eabd",
"translatorType":4,
"label":"CiteULike",
"creator":"Sean Takats",
"target":"https?://(?:www\\.)?citeulike.org(?:.*/tag/[^/]*$|/search/|/journal/|/group/[0-9]+/library$|/\\?page=[0-9]+$|/.*article/[0-9]+$|/$)",
"minVersion":"1.0.0b4.r5",
"maxVersion":"",
"priority":100,
"inRepository":true,
"lastUpdated":"2008-02-01 19:30:00"
}
function detectWeb(doc, url){
var articleRe = /\/article\/[0-9]+$/;
var m = url.match(articleRe);
var newUris = new Array();
if (m){
return "journalArticle";
} else {
return "multiple";
}
}
function doWeb(doc, url){
var articleRe = /\/article\/[0-9]+$/;
var m = url.match(articleRe);
var newUris = new Array();
if (m){
newUris.push(url.replace(/citeulike\.org\//, "citeulike.org/endnote/"));
} else {
var namespace = doc.documentElement.namespaceURI;
var nsResolver = namespace ? function(prefix) {
if (prefix == 'x') return namespace; else return null;
} : null;
var elmt;
var elmts = doc.evaluate('//a[@class="title"]', doc, nsResolver, XPathResult.ANY_TYPE, null);
var items = new Object();
while(elmt = elmts.iterateNext()) {
items[elmt.href] = Zotero.Utilities.trimInternal(elmt.textContent);
}
items = Zotero.selectItems(items);
if(!items) return true;
for(var uri in items) {
newUris.push(uri.replace(/citeulike\.org\//, "citeulike.org/endnote/"));
}
}
Zotero.Utilities.HTTP.doGet(newUris, function(text) {
var translator = Zotero.loadTranslator("import");
translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7");
translator.setString(text);
translator.translate();
Zotero.done();
});
Zotero.wait();
}