Skip to content

Instantly share code, notes, and snippets.

@simonv3
Last active September 30, 2016 17:13
Show Gist options
  • Save simonv3/11257371 to your computer and use it in GitHub Desktop.
Save simonv3/11257371 to your computer and use it in GitHub Desktop.
Goodreads Bookmarklet. Based on the bookmarklet provided by goodreads, but actually working.
<a href="javascript: var array = document.URL.match(/amazon\.(.*?)\/.*?\/((\d|[A-Z]){10})/); if (array == null) {alert('Sorry, this doesn\'t appear to be an Amazon book page.'); } else {var x = window.open('https://www.goodreads.com/review/isbn/'+ array[2] + '?tld=' + array[1] + '&from=bm', 'add_review'); x.focus(); }"class="mediumText">Add to Goodreads</a>
@simonv3
Copy link
Author

simonv3 commented Apr 24, 2014

This will probably be expanded on in the future so that a new window isn't actually opened.

@lightningdb
Copy link

I just came across this, after writing an updated bookmarklet myself earlier today.

My one may be of interest as it takes a different approach, which so far has been more robust than using regex.
https://gist.github.com/lightningdb/cfee260c3b7af7e65fce

@simonv3
Copy link
Author

simonv3 commented Sep 5, 2014

@lightningdb Just saw this! Yeah, I pretty much just tweaked the one on the goodreads site. There's probably a couple of things that can be changed about it. I'm not sure about relying on the contents of the Amazon site, whereas I don't actually see ISBNs changing regularly, and being removed from the regex. Rather, I'd focus seeing whether there's an ASIN in the URL as well.

What focusing on the ISBN (and thus the URL) does allow is if there's something that looks like an ISBN in any url, not just Amazon, it makes it much more flexible to use.

Neither of our things work for URLs that aren't sold directly by Amazon looks like: example or search results, which many sites link to as a default.

Edit: Though I guess goodreads is owned by Amazon now, so the whole ISBN vs ASIN discussion in light of a goodreads bookmark might be moot.

@simonv3
Copy link
Author

simonv3 commented Sep 5, 2014

Update: Just added the ability to recognize ASIN numbers in the URL.

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