Amazon – View Book on Shelfari: A Greasemonkey Script
This morning, while browsing Amazon.com, I was annoyed (not for the first time) that Amazon didn’t have a link to add a book to your Shelfari.com shelf. Amazon has owned Shelfari.com for almost 3 years now, and every shelfari book page has links to but the book on Amazon.com, so this isn’t an unreasonable request.
My first thought was to search userscripts.org to see if there was already a script to do this and sure enough, there was. This is the way these things go. Luckily for me, it was broken and had been abandoned 4 years ago, so I got to do some coding!
Before I go any further, if you don’t know what greasemonkey is, crawl out from under that rock and scroll to the bottom of this page (and before you Chrome users start a Firefox flame-war, Chrome installs greasemonkey scripts natively!). And if you don’t know what Shelfari.com is, check out my short post about it.
The broken script, by “mathias”, puts the shelfari.com logo above the product image, and clicking on it links you to a shelfari search page for that book. I actually only had one small fix needed to make it work again. He was pulling the ISBN off the image url, which Amazon stopped doing a while ago. I updated it to use the ASIN embedded in every product page (as a hidden field).
After making the script work again, I noticed it was adding the link to every product detail page, whether it be a book, kindle, or cutlery set! That isn’t very useful within the scope of this script, so I added checks to make sure it only displayed the logo/link on book, ebook, and audiobook pages.
Now, for those of you who don’t know what greasemonkey is you should definitely get familiar with it, as it is one of the coolest ways to customize websites to your liking. Greasemonkey scripts are small pieces of code that let you tweak websites exactly to your liking, sometimes adding tons of functionality. Its a Firefox add-on, and once installed you can install any greasemonkey script just by clicking on it, without reloading your browser. If you prefer Google’s Chrome browser, it installs greasemonkey scripts natively with no add-ons necessary!
I only did a small bit of work on this script, improving on another author’s work (as all good programmers should), but I think it’s immensely useful to shelfari users so I wanted to make it’s presence known. The next time some blog/article links you to an amazon page for a book and you want to add it to your “want to read” shelf, it’s only a click away!amazon, Books, ebook, greasemonkey, script, shelfari, userscripts