Skip to content

Commit

Permalink
let's try again
Browse files Browse the repository at this point in the history
  • Loading branch information
holyspiritomb committed Nov 30, 2023
1 parent 779abb0 commit 86612da
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
15 changes: 7 additions & 8 deletions goodreads-libby-adguard.user.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ==UserScript==
// @name Goodreads Libby Results (forked)
// @namespace https://github.com/holyspiritomb
// @version 1.1.2
// @version 1.2.0
// @description Searches for the book you are looking at on Goodreads across all your libby libraries. Forked from Dylancyclone's script.
// @author holyspiritomb
// @updateURL https://raw.githubusercontent.com/holyspiritomb/goodreads-libby-userscript/main/goodreads-libby-adguard.user.js
Expand Down Expand Up @@ -66,17 +66,16 @@
};

const addGoodreadsResults = async () => {
let isRedesign = (document.querySelector("div#__next"));
let bookTitle = isRedesign ? document.querySelector("[data-testid='bookTitle']").innerText : document.querySelector("meta[property='og:title']").content;
let bookAuthor = isRedesign ? document.querySelector("[aria-label^='By: ']").innerText : document.querySelector(".authorName").innerText;
if (bookAuthor == null) {
bookAuthor = document.querySelector("span.ContributorLink__name").innerText;
}
let bookTitle = document.querySelector("[data-testid='bookTitle']").innerText;
let bookAuthor;
let findBookAuthorEl = () => document.querySelector("[aria-label^='By: ']") || document.querySelector("span.ContributorLink__name");
let searchTitle = bookTitle.replace(/\(.*\)/, "").replace(/^\s+|\s+$/g, '').replace(/[&|,]/g, ' ').replace(/: .*/, '').replace(/[ ]+/, ' ');
let searchString;
if (bookAuthor == null) {
let bookAuthorEl = findBookAuthorEl();
if (bookAuthorEl == null) {
searchString = encodeURIComponent(searchTitle);
} else {
bookAuthor = bookAuthorEl.innerText;
searchString = encodeURIComponent(searchTitle) + "&creator=" + encodeURIComponent(bookAuthor);
}
//console.log(searchString);
Expand Down
11 changes: 4 additions & 7 deletions goodreads-libby.user.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ==UserScript==
// @name Goodreads Libby Results (forked)
// @namespace https://github.com/holyspiritomb
// @version 1.1.3
// @version 1.2.0
// @description Searches for the book you are looking at on Goodreads across all your libby libraries. Forked from Dylancyclone's script.
// @author holyspiritomb
// @updateURL https://raw.githubusercontent.com/holyspiritomb/goodreads-libby-userscript/main/goodreads-libby.user.js
Expand Down Expand Up @@ -65,15 +65,12 @@
};

const addGoodreadsResults = async () => {
let isRedesign = (document.querySelector("div#__next"));
let bookTitle = isRedesign ? document.querySelector("[data-testid='bookTitle']").innerText : document.querySelector("meta[property='og:title']").content;
let bookTitle = document.querySelector("[data-testid='bookTitle']").innerText;
let bookAuthor;
let bookAuthorEl = document.querySelector("[aria-label^='By: ']");
if (bookAuthorEl == null) {
bookAuthorEl = document.querySelector("span.ContributorLink__name");
}
let findBookAuthorEl = () => document.querySelector("[aria-label^='By: ']") || document.querySelector("span.ContributorLink__name");
let searchTitle = bookTitle.replace(/\(.*\)/, "").replace(/^\s+|\s+$/g, '').replace(/[&|,]/g, ' ').replace(/: .*/, '').replace(/[ ]+/, ' ');
let searchString;
let bookAuthorEl = findBookAuthorEl();
if (bookAuthorEl == null) {
searchString = encodeURIComponent(searchTitle);
} else {
Expand Down
1 change: 0 additions & 1 deletion pre-push.sh → pre-commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
cat goodreads-libby.user.js | sed "s/@grant GM_addStyle/@grant GM_addStyle\n\/\/ @grant unsafeWindow/;s/main\/goodreads-libby.user.js/main\/goodreads-libby-adguard.user.js/" > goodreads-libby-adguard.user.js

git add goodreads-libby-adguard.user.js
# git commit goodreads-libby-adguard.user.js -m "adguard version automatic commit"

0 comments on commit 86612da

Please sign in to comment.