Amazon Short URL Bookmarklet
A few weeks ago I found this great bookmarklet by Otavio Cordeiro.
It basically gives you the amzn.com/X123 short url Amazon uses on their site. Since I keep my book and geek wishlist as a text file in Notational Velocity, this was very useful.
However I wanted it to also include the title so adding stuff to the list was just a matter of copy&paste. After a few days of use, I noticed the Amazon.com: text at the beginning of every page was driving me insane, so I added a .replace
to remove it1.
So without further ado:
(function(){
var id = '';
var asin = document.getElementById('ASIN');
var asin0 = document.getElementsByName('ASIN.0');
var title = document.title.replace("Amazon.com: ","");
if (asin)
id = asin.value;
else if (asin0)
id = asin0[0].value;
else {
alert('Can\'t find an Amazon product ID');
return;
}
prompt(
'Shortened Amazon Page:',
title +'\n'+ 'http://amzn.com/' + id);
})()
Which I guess you also want in bookmarklet ready packaging, so just grab it below and drop it on your Bookmark Bar:
Try it out visiting this Amazon page and clicking on it. Trust me, come November, you will want to have this link.
Thanks to Chris Zarate for the great Bookmarkleter tool, makes is sooo much easier to play around with bookmarklets.