Fix zotero.org translator saving on individual item pages
This commit is contained in:
parent
4beb908dfa
commit
9707464e05
|
@ -8,7 +8,7 @@
|
||||||
"maxVersion":"",
|
"maxVersion":"",
|
||||||
"priority":100,
|
"priority":100,
|
||||||
"inRepository":true,
|
"inRepository":true,
|
||||||
"lastUpdated":"2009-09-22 07:05:00"
|
"lastUpdated":"2009-09-29 23:15:00"
|
||||||
}
|
}
|
||||||
|
|
||||||
function detectWeb(doc, url) {
|
function detectWeb(doc, url) {
|
||||||
|
@ -32,9 +32,6 @@ function detectWeb(doc, url) {
|
||||||
|
|
||||||
// Individual item
|
// Individual item
|
||||||
else if (url.match(/\/items\/[0-9]+(\?.*)?$/)) {
|
else if (url.match(/\/items\/[0-9]+(\?.*)?$/)) {
|
||||||
// FIXME: temporarily broken
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// TODO: embed in page, because this is absurd
|
// TODO: embed in page, because this is absurd
|
||||||
var typeMap = {
|
var typeMap = {
|
||||||
"Note": "note",
|
"Note": "note",
|
||||||
|
@ -74,7 +71,7 @@ function detectWeb(doc, url) {
|
||||||
"Encyclopedia Article":"encyclopediaArticle",
|
"Encyclopedia Article":"encyclopediaArticle",
|
||||||
"Dictionary Entry": "dictionaryEntry"
|
"Dictionary Entry": "dictionaryEntry"
|
||||||
};
|
};
|
||||||
var td = doc.evaluate('//div[@id="content"]/div[@class="major-col"]/table//tr[th[text()="Item Type"]]/td', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext();
|
var td = doc.evaluate('//div[@id="content"]/div[@class="major-col"]/table//tr[th[text()="Item Type"]]/td', doc, null, XPathResult.ANY_TYPE, null).iterateNext();
|
||||||
return td ? typeMap[td.textContent] : "book";
|
return td ? typeMap[td.textContent] : "book";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -173,6 +170,17 @@ function doWeb(doc, url) {
|
||||||
}, function () { Zotero.done(); });
|
}, function () { Zotero.done(); });
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if (url.indexOf("/groups/") == -1) {
|
||||||
|
var userID = doc.getElementById('libraryUserID').getAttribute('title');
|
||||||
|
var apiPrefix = "https://api.zotero.org/users/" + userID + "/";
|
||||||
|
var itemRe = /^https?:\/\/[^\/]*zotero\.org\/[^\/]+\/items\/([0-9]+)/;
|
||||||
|
}
|
||||||
|
// Group library
|
||||||
|
else {
|
||||||
|
var groupID = doc.getElementById('libraryGroupID').getAttribute('title');
|
||||||
|
var apiPrefix = "https://api.zotero.org/groups/" + groupID + "/";
|
||||||
|
var itemRe = /^https?:\/\/[^\/]*zotero\.org\/groups\/[^\/]+\/items\/([0-9]+)/;
|
||||||
|
}
|
||||||
var itemID = url.match(itemRe)[1];
|
var itemID = url.match(itemRe)[1];
|
||||||
var apiURL = apiPrefix + "items/" + itemID + "?content=full";
|
var apiURL = apiPrefix + "items/" + itemID + "?content=full";
|
||||||
Zotero.Utilities.doGet(apiURL, function (text) {
|
Zotero.Utilities.doGet(apiURL, function (text) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user