Created
August 7, 2023 14:31
-
-
Save RosemaryOrchard/6a20703010eeb645b268dcb110ec42cb to your computer and use it in GitHub Desktop.
Bookmarklet to add Search In Goodreads links to Audible Wish Lists
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript: (() => { | |
Array.from(document.querySelectorAll('.productListItem')).forEach((book, bookIndex) => { | |
const title = book.querySelector('ul li .bc-size-headline3').innerText; | |
const author = book.querySelector('ul .authorLabel a').innerText; | |
const searchQuery = `${title.split(':')[0]} ${author}`; | |
const url = `https://www.goodreads.com/search?q=${searchQuery.split(" ").map(text => encodeURIComponent(text)).join("+")}`; | |
const buttonArea = book.querySelector('.adblBuyBox'); | |
const goodreadsButtonDiv = document.createElement('div'); | |
goodreadsButtonDiv.classList.add('bc-row'); | |
goodreadsButtonDiv.classList.add('bc-text-center'); | |
goodreadsButtonDiv.classList.add('bc-spacing-top-mini'); | |
goodreadsButtonDiv.id = `search-in-goodreads-${bookIndex}`; | |
const goodreadsButtonSpan = document.createElement('span'); | |
goodreadsButtonSpan.classList.add('bc-button'); | |
goodreadsButtonSpan.classList.add('bc-button-secondary'); | |
const goodreadsButton = document.createElement('a'); | |
goodreadsButton.classList.add('bc-button-text'); | |
goodreadsButton.href=url; | |
goodreadsButton.setAttribute('target', '_blank'); | |
goodreadsButton.innerText = 'Search in Goodreads'; | |
goodreadsButtonSpan.append(goodreadsButton); | |
goodreadsButtonDiv.append(goodreadsButtonSpan); | |
buttonArea.append(goodreadsButtonDiv); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment