Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Add to Goodreads from Amazon.com book page bookmarklet
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();}
@lightningdb

This comment has been minimized.

Copy link
Owner Author

@lightningdb lightningdb commented Aug 6, 2014

This is more robust than the original bookmarklet I found on the Goodreads site (which I've been using with mixed success for years.)

It doesn't use a URL passing regex, but rather hidden ASIN elements on the page, and is thus much more robust.

This also works with Amazon UK and German Amazon.

@lightningdb

This comment has been minimized.

Copy link
Owner Author

@lightningdb lightningdb commented Aug 7, 2014

To add this to your browser:

  • click on the "Raw" button above.
  • copy the text
  • add a bookmark to your browser, and for the location, paste the text that you copied in the previous step
  • name the bookmark

Now it is installed, click the bookmark anytime you want to add an Amazon book to your Goodreads queue (note: it doesn't actually do the adding, it takes you the page where you can click "Want To Read".)

@lightningdb

This comment has been minimized.

Copy link
Owner Author

@lightningdb lightningdb commented Feb 27, 2016

I've updated this today to workaround a limitation in Goodreads. Recently (AFAICT), the bookmarklet stopped working for products that had an ASIN (an Amazon identifier) instead of an ISBN, because of the way Goodreads URL structure worked. So, the old bookmarklet would work for products with an ISBN, but not for products with an ASIN (Amazon Standard Identification Number), which in my limited research seems to be Kindle books.

The fix I've implemented follows the following logic:

  • if the ASIN field in the page (in the HTML it is called ASIN whether it is an ASIN or ISBN) is all digits, it is an ISBN and should go direct to the book page
  • otherwise if there are letters in the value, it must be an ASIN, and as far as I can tell, the best that we can do on Goodreads is to direct the user to the search page (with the search field filled with the ASIN) as Randy suggested.

Install the bookmark as instructed in previous comments.

@JBaby9783

This comment has been minimized.

Copy link

@JBaby9783 JBaby9783 commented Jul 24, 2019

Thank you very much!!!!

@csababorzasi

This comment has been minimized.

Copy link

@csababorzasi csababorzasi commented May 1, 2020

Thank you very much, I much appreciate it for making this public!

Yet, would you be able to make a similar one for LibraryThing as well (https://www.librarything.com/)? I want to add my kindle library title to LibraryThing, tried changing the search address but it doesn't work this way.

@lightningdb

This comment has been minimized.

Copy link
Owner Author

@lightningdb lightningdb commented May 3, 2020

@csababorzasi Thanks. I don't currently have time to create one for LibraryThing, as I don't use it so would have to get familiar with it, but I imagine it would have a similar method for finding books, so it should be relatively easy to modify the script. Let me know how you go.

@csababorzasi

This comment has been minimized.

Copy link

@csababorzasi csababorzasi commented May 3, 2020

Hi @lightningdb, finally I was able to do it and it works fine, see code below. I just changed the links, that's it. First I used the links reverse that's why I didn't get it. Thanks again for making the code available, it's a great help!

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('https://www.librarything.com/addbooks' + asin, 'add_review');
} else {
var x = window.open('https://www.librarything.com/addbooks?search=' + asin);
}
x.focus();
}

@lightningdb

This comment has been minimized.

Copy link
Owner Author

@lightningdb lightningdb commented May 3, 2020

Terrific! Glad you were able to make something work :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment