Skip to content

Instantly share code, notes, and snippets.

@wuhup
Forked from rondevera/amazon-short-url-bookmarklet.js
Last active September 30, 2019 11:54
Show Gist options
  • Save wuhup/d1f08c78efc4189bdab85e59bc2eeb5b to your computer and use it in GitHub Desktop.
Save wuhup/d1f08c78efc4189bdab85e59bc2eeb5b to your computer and use it in GitHub Desktop.
Amazon short URL bookmarklet
(function(d){
var asin = d.getElementById('ASIN'), url;
if (asin) {
url = 'http://' + d.domain.split('.').slice(-2).join('.') + '/dp/' + asin.value;
if (prompt('Short Amazon URL (hit OK to load):', url)) {
window.location.href = url;
}
} else {
alert("Can't find an Amazon product ID.");
}
}(document));
// Bookmarklet:
// javascript:(function(d){var asin=d.getElementById('ASIN'),url;if(asin){url='http://'+d.domain.split('.').slice(-2).join('.')+'/dp/'+asin.value;if(prompt('Short Amazon URL (hit OK to load):',url)){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
@wuhup
Copy link
Author

wuhup commented Feb 28, 2017

updated to remove subdomains, like - smile.amazon.com - to make it shorter
(doesn't work on co.uk though)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment