Permalink
Browse files

Quick fix for Google Books Multiples (#1491)

This might be due for a re-write -- lots of legacy code here, but that
requires checking lots of cases as translator accommodates lots of
different views&errors
  • Loading branch information...
adam3smith committed Dec 3, 2017
1 parent 092c7bc commit 1baa02669ee8b7f4969a95f02ae23d66b36c0c79
Showing with 6 additions and 7 deletions.
  1. +6 −7 Google Books.js
View
@@ -9,7 +9,7 @@
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsbv",
"lastUpdated": "2017-01-01 16:11:33"
"lastUpdated": "2017-12-03 04:20:33"
}
/*
@@ -68,7 +68,6 @@ function doWeb(doc, url) {
ZU.doGet("//books.google.com/books/feeds/volumes/"+m[2], parseXML);
} else {
var items = getItemArrayGB(doc, doc, 'google\\.' + suffix + '/books\\?id=([^&]+)', '^(?:All matching pages|About this Book|Table of Contents|Index)');
//Zotero.debug(items);
// Drop " - Page" thing
for(var i in items) {
items[i] = items[i].replace(/- Page [0-9]+\s*$/, "");
@@ -254,10 +253,10 @@ function getItemArrayGB (doc, inHere, urlRe, rejectRe) {
}
}
else {
var links = inHere[j].getElementsByTagName("img");//search for <img>-elements, scrape title from alt-attribute, href-link from parent <a>-element
var links = inHere[j].querySelectorAll("h3.r a");
for(var i=0; i<links.length; i++) {
if(!urlRe || urlRegexp.test(links[i].parentNode.href)) {
var text = links[i].alt;
if(!urlRe || urlRegexp.test(links[i].href)) {
var text = links[i].parentNode.textContent;
//Z.debug(text)
if(text) {
text = Zotero.Utilities.trimInternal(text);
@@ -267,7 +266,7 @@ function getItemArrayGB (doc, inHere, urlRe, rejectRe) {
availableItems[links[i].href] += " "+text;
}
} else {
availableItems[links[i].parentNode.href] = text;
availableItems[links[i].href] = text;
}
}
}
@@ -497,4 +496,4 @@ var testCases = [
]
}
]
/** END TEST CASES **/
/** END TEST CASES **/

0 comments on commit 1baa026

Please sign in to comment.