September 22, 2011

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:

Amzn Title

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.


  1. I’m having problems getting it to work with Quix, will update when I get it to work. 


Geek Code


Previous post
Would Gulliver have had a Blog? It’s early. Too early for my taste, but that may be the adrenaline talking. Around us darkness is loosing ground quickly to daylight, and the
Next post
We Drove Drunk (I am sorry) Dear Roberto the 3rd, If you ever get the opportunity to exist I have to apologize. Today I conspired against your existence. Your dad turned