diff --git a/Goodreads.js b/Goodreads.js index 2c7466b383..f663faf266 100644 --- a/Goodreads.js +++ b/Goodreads.js @@ -9,7 +9,7 @@ "inRepository": true, "translatorType": 4, "browserSupport": "gcsibv", - "lastUpdated": "2021-07-07 18:32:10" + "lastUpdated": "2024-12-11 18:50:04" } /* @@ -37,7 +37,7 @@ function detectWeb(doc, url) { - if (url.includes('/book/show/') && doc.querySelector('meta[property="books:isbn"]')) { + if (url.includes('/book/show/') && getISBN(doc)) { return "book"; } else if (getSearchResults(doc, true)) { @@ -73,7 +73,7 @@ function doWeb(doc, url) { } function scrape(doc, _url) { - let ISBN = ZU.cleanISBN(attr(doc, 'meta[property="books:isbn"]', 'content')); + let ISBN = getISBN(doc); // adapted from Amazon translator let search = Zotero.loadTranslator('search'); @@ -93,6 +93,13 @@ function scrape(doc, _url) { search.getTranslators(); } +function getISBN(doc) { + let json = text(doc, 'script[type="application/ld+json"]'); + if (!json) return null; + json = JSON.parse(json); + return json.isbn; +} + /** BEGIN TEST CASES **/ var testCases = [ {