July 3, 2020

Bookmarklet: Open Amazon book in Goodreads

Introduction I like before buying a book on Amazon to check the reviews on Goodreads. You can use a bookmarklet to do this in one click.

Goodreads offers one but it doesn't work. https://www.goodreads.com/user/edit?tab=widgets
Here is a working solution.
 

Good solution in Github

See https://gist.github.com/lightningdb/cfee260c3b7af7e65fce

javascript: var asin_elements, asin;asin_elements = document.getElementsByName('ASIN'); if (asin_elements.length == 0) { asin_elements = document.getElementsByName('ASIN.0'); };if (asin_elements.length == 0) { alert('Sorry, this doesn\'t appear to be an Amazon book page.'); }else { asin = asin_elements[0].value; if (asin.match(/\D/) === null) { var x = window.open('http://www.goodreads.com/review/isbn/'+ asin, 'add_review'); } else { var x = window.open('https://www.goodreads.com/search?q='+ asin); } x.focus();}

My solution

My solution used some regexp trick:

javascript: var array = document.URL.match(/amazon\..*?\/.*?\/([^\/\?]*)/); if (array == null) { alert('Sorry, this doesn\'t appear to be an Amazon book page.'); } else { var x = window.open('https://www.goodreads.com/search?q='+ array[1] + '&search_type=books'); x.focus(); }

Installation

Add a bookmark and paste the code in the URL



No comments:

Post a Comment