Skip to content

Instantly share code, notes, and snippets.

@gh640
Last active December 12, 2015 09:49
Show Gist options
  • Save gh640/4754516 to your computer and use it in GitHub Desktop.
Save gh640/4754516 to your computer and use it in GitHub Desktop.
選択した文字列をAmazon.co.jpで検索するブックマークレット。
javascript:(function(){
var q, location;
/* 選択された文字列を取得 */
/* 選択されてなければダイアログから文字列を取得 */
q = ""+(window.getSelection?window.getSelection():document.getSelection());
if(!q) q = prompt("Amazon search... ","");
/* urlエスケープした上でAmazonにリクエスト */
if(q!=null){
location = "http://www.amazon.co.jp/s/?field-keywords="+escape(q).replace(/ /g,"+");
}else{
location = "http://www.amazon.co.jp/";
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment