Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save yaSebastian/4b787df8c199859037e21148ec4657e7 to your computer and use it in GitHub Desktop.

Select an option

Save yaSebastian/4b787df8c199859037e21148ec4657e7 to your computer and use it in GitHub Desktop.
Amazon short URL bookmarklet
(function(d) {
var asin = d.getElementById('ASIN');
var url;
if (asin) {
url = 'http://' + d.domain.split('.').slice(-2).join('.') + '/dp/' + asin.value;
window.location.href = url;
} else {
alert("Can't find an Amazon product ID.");
}
}(document));
// Bookmarklet:
// javascript:(function(d){var asin=d.getElementById('ASIN');var url;if(asin){url='http://'+d.domain.split('.').slice(-2).join('.')+'/dp/'+asin.value;window.location.href=url;}else{alert("Can't find an Amazon product ID.");}}(document));
// Alternative bookmarklet generator:
// http://ted.mielczarek.org/code/mozilla/bookmarklet.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment