Skip to content

Instantly share code, notes, and snippets.

@bouzuya

bouzuya/amazon-gp.js

Created Jul 22, 2012
Embed
What would you like to do?
javascript:
(function(){
var id = 'bouzuya-22';
var pattern = /^http:\/\/www\.amazon\.co\.jp(?:.*)\/(?:(?:gp\/product)|(?:dp))\/([0-9A-Za-z]{10}).*$/;
var result = location.href.match(pattern);
if (result == null) {
return;
}
var text = document.createTextNode('A!');
var href = 'http://amazon.jp/o/ASIN/' + result[1] + '/' + id;
var anchor = document.createElement('a');
anchor.appendChild(text);
anchor.setAttribute('href', href);
document.getElementById('btAsinTitle').appendChild(anchor);
return false;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment