検索ブックマークレット
だいぶ便利そうなものをChatGPTに作ってもらった
code:Javascropt
javascript:(function(){
var selectedText = window.getSelection().toString();
if(!selectedText) {
alert('テキストを選択してください。');
return;
}
var site = prompt('検索サイトを選択してください (a: アマゾン, c: カーリル, g: Google, m: メルカリ, n: 国会図書館, y: YouTube):').toLowerCase();
var url;
switch(site) {
case 'a':
url = 'https://www.amazon.co.jp/s?k=' + encodeURIComponent(selectedText);
break;
case 'c':
url = 'https://calil.jp/search?q=' + encodeURIComponent(selectedText);
break;
case 'g':
url = 'https://www.google.com/search?q=' + encodeURIComponent(selectedText);
break;
case 'm':
url = 'https://www.mercari.com/jp/search/?keyword=' + encodeURIComponent(selectedText);
break;
case 'n':
url = 'https://ndlonline.ndl.go.jp/#!/search?keyword=' + encodeURIComponent(selectedText)+ '&materialtype=Tosho&searchCode=DETAIL';
break;
case 'y':
url = 'https://www.youtube.com/results?search_query=' + encodeURIComponent(selectedText);
break;
default:
alert('正しいサイトコードを入力してください。');
return;
}
window.open(url, '_blank');
})();