js.bml[5] = 'Selection to Service'
/// ページの選択文字列を取得するイディオム /// top.getSelection ? getSelection() +'' : document.selection.createRange().text // IE
Opera と Safari が手元に無いので確認出来ないが,たぶんこんな感じ。
これを使ってテンプレートを作る。
// 文字列取得 → プロンプト → サイトを開く javascript:['サービス名','http://a.b.c/$?hoge=fuga',function(p){if(p=prompt(this[0],top.getSelection?getSelection()+'':document.selection.createRange().text))top.open(this[1].replace(/\$/g,encodeURIComponent(p)))}][2]()
例:
javascript:['英辞郎','http://eow.alc.co.jp/$/UTF-8/',function(p){if(p=prompt(this[0],top.getSelection?getSelection()+'':document.selection.createRange().text))top.open(this[1].replace(/\$/g,encodeURIComponent(p)))}][2]()
javascript:['Google Site Search','http://www.google.com/search?as_sitesearch='+document.domain+'&q=$',function(p){if(p=prompt(this[0],top.getSelection?getSelection()+'':document.selection.createRange().text))top.open(this[1].replace(/\$/g,encodeURIComponent(p)))}][2]()
*1:08-12-02 ごそっと修正