From 8607c377bf57bc618469984ee85954e2f98f2a5c Mon Sep 17 00:00:00 2001 From: Abe Jellinek Date: Wed, 11 Dec 2024 13:50:13 -0500 Subject: [PATCH] Goodreads: Update for site change https://forums.zotero.org/discussion/120426/goodreads-translator-no-longer-detects-books --- Goodreads.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Goodreads.js b/Goodreads.js index 2c7466b3839..f663faf2667 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 = [ {