Created
February 11, 2013 13:53
-
-
Save gh640/4754529 to your computer and use it in GitHub Desktop.
Amazon JPの商品ページからAmazon USの商品ページを開くブックマークレット。
対象商品は、洋書/輸入版CD/DVD限定などASIN番号あるいはISBN番号が日本とアメリカのAmazonとで共通のもののみ。
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
javascript:(function(){ | |
/* Amazon JP の書籍詳細ページから Amazon US の書籍詳細ページに飛ぶブックマークレット */ | |
/* htmlドキュメント内からISBNもしくはASINを探す */ | |
var bs = document.body.getElementsByTagName('b'); | |
for(var i=0;i<bs.length;i++){ | |
/* 洋書の場合はISBNを探す */ | |
if( bs[i].innerText == 'ISBN-10:'){ | |
codeuniq = bs[i].parentNode.innerText.slice(8); | |
var code_is_isbn = true; | |
break; | |
} | |
/* CDやDVDの輸入版の場合はASINを探す */ | |
if( bs[i].innerText == 'ASIN:'){ | |
codeuniq = bs[i].parentNode.innerText.slice(6); | |
var code_is_isbn = false; | |
break; | |
} | |
} | |
/* ISBNが見つからなければアラートのみで終了 見つかればAmazon USで検索 */ | |
if(typeof codeuniq === 'undefined'){ | |
alert('ISBN/ASIN not found'); | |
}else{ | |
/* 洋書の場合はadvanced searchの検索結果ページを開く */ | |
/* CDやDVDの場合は商品ページを開く */ | |
if(code_is_isbn){ | |
var amazon = 'http://www.amazon.com/gp/search/?search-alias=stripbooks&field-isbn='; | |
}else{ | |
var amazon = 'http://www.amazon.com/dp/'; | |
} | |
var w = window.open(amazon + escape(codeuniq)); | |
w.focus(); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment