Forked from rondevera/amazon-short-url-bookmarklet.js
Last active
September 30, 2019 11:54
-
-
Save wuhup/d1f08c78efc4189bdab85e59bc2eeb5b to your computer and use it in GitHub Desktop.
Amazon short URL bookmarklet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
updated to remove subdomains, like - smile.amazon.com - to make it shorter
(doesn't work on co.uk though)