Skip to content

Commit

Permalink
Goodreads: Update for site change
Browse files Browse the repository at this point in the history
  • Loading branch information
AbeJellinek committed Dec 11, 2024
1 parent f2ddb99 commit 8607c37
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions Goodreads.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2021-07-07 18:32:10"
"lastUpdated": "2024-12-11 18:50:04"
}

/*
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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');
Expand All @@ -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 = [
{
Expand Down

0 comments on commit 8607c37

Please sign in to comment.