September 22, 2011

Amazon Short URL Bookmarklet

A few weeks ago I found this great bookmarklet by Otavio Cordeiro.

It basically gives you the 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 text at the beginning of every page was driving me insane, so I added a .replace to remove it1.

So without further ado:

var id = '';
var asin = document.getElementById('ASIN');
var asin0 = document.getElementsByName('ASIN.0');
var title = document.title.replace(" ","");

if (asin)
id = asin.value;
else if (asin0)
id = asin0[0].value;
else {
alert('Can\'t find an Amazon product ID');

'Shortened Amazon Page:',
title +'\n'+ '' + 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 30