commit 48b8361c8aff381ad96f3732c8ea3ba5e0a20093
parent 11f10624e9736cc0e894271593bbbfeaaea71c8f
Author: Matt Burton <mcburton@gmail.com>
Date: Thu, 16 Jul 2009 15:12:20 +0000
Fixes #1523, Adding support for amazon guides and lists
Diffstat:
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/translators/Amazon.com.js b/translators/Amazon.com.js
@@ -16,7 +16,8 @@ function detectWeb(doc, url) {
var suffixRe = new RegExp("https?://(?:www\.)?amazon\.([^/]+)/");
var suffixMatch = suffixRe.exec(url);
var suffix = suffixMatch[1];
- var searchRe = new RegExp('^https?://(?:www\.)?amazon\.' + suffix + '/(gp/search/|exec/obidos/search-handle-url/|s/)');
+ var searchRe = new RegExp('^https?://(?:www\.)?amazon\.' + suffix + '/(gp/search/|exec/obidos/search-handle-url/|s/|[^/]+/lm/|gp/richpub/)');
+ Zotero.debug(searchRe.test(doc.location.href));
if(searchRe.test(doc.location.href)) {
return "multiple";
} else {
@@ -63,7 +64,7 @@ function doWeb(doc, url) {
var suffixMatch = suffixRe.exec(url);
var suffix = suffixMatch[1];
- var searchRe = new RegExp('^https?://(?:www\.)?amazon\.' + suffix + '/(gp/search/|exec/obidos/search-handle-url/|s/)');
+ var searchRe = new RegExp('^https?://(?:www\.)?amazon\.' + suffix + '/(gp/search/|exec/obidos/search-handle-url/|s/|[^/]+/lm/|gp/richpub/)');
var m = searchRe.exec(doc.location.href);
var uris = new Array();
if (suffix == "co.jp"){
@@ -71,11 +72,19 @@ function doWeb(doc, url) {
}
if (suffix == ".com") suffix = "com";
if(m) {
- var xpath = '//div[@class="productTitle"]/a | //a[span[@class="srTitle"]]';
+ var availableItems = new Array();
+
+
+ if(doc.location.href.match(/gp\/richpub\//)){ // Show selector for Guides
+ var xpath = '//a[(contains(@href, "ref=cm_syf_dtl_pl") or contains(@href, "ref=cm_syf_dtl_top")) and preceding-sibling::b]';
+ } else if (doc.location.href.match(/\/lm\//)) { // Show selector for Lists
+ var xpath = '//span[@id="lm_asinlink95"]//a'
+ } else { // Show selector for Search results
+ var xpath = '//div[@class="productTitle"]/a | //a[span[@class="srTitle"]]';
+ }
var elmts = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null);
var elmt = elmts.iterateNext();
var asins = new Array();
- var availableItems = new Array();
var i = 0;
var asinRe = new RegExp('/(dp|product)/([^/]+)/');
do {
@@ -90,6 +99,7 @@ function doWeb(doc, url) {
} while (elmt = elmts.iterateNext());
var items = Zotero.selectItems(availableItems);
+
if(!items) {
return true;
}