翻訳ブックマークレット Rev.2

前々から気にはなっていたのだが、Google等の翻訳ブックマークレット
同じウィンドウで翻訳結果を表示しようとする。
原文のページがどっかへいってしまうのは地味に不便だ。
まぁ、locationで移動しないでwindow.openで移動してやればいいだけなのだが。


Operaにはブックマークしてあったのだが、Opera Linkをいじっているうちに消えてしまった。
再度作成したが、とても面倒だったのでここにメモしておく。
一応前回のメモも併せて参照のこと。

excite
javascript:(
  function(){
    var%20b=((window.getSelection&&window.getSelection())||
             (document.getSelection&&document.getSelection())||
             (document.selection&&document.selection.createRange&&document.selection.createRange().text));
    if (b!='') {
      window.open('http://www.excite.co.jp/world/english/?before='+encodeURIComponent(b)+'&wb_lp=ENJA&ie=UTF-8', null);
    }
    else {
      window.open('http://www.excite.co.jp/world/english/web/?wb_url='+encodeURIComponent(location.href)+'&wb_lp=ENJA&wb_dis=3',null);
    }
  }
)();
Yahoo!

選択文字列をテキスト翻訳させたいのだがテキスト翻訳のトップページが表示されるだけだ。
javascriptというかWeb系は本当に適当な知識しかないので後日なんとかする予定。*1

javascript:(
  function(){
    var%20b=((window.getSelection&&window.getSelection())||
             (document.getSelection&&document.getSelection())||
             (document.selection&&document.selection.createRange&&document.selection.createRange().text));
    if (b!='') {
      window.open('http://honyaku.yahoo.co.jp/transtext/?eid=CR-EJ&text='+encodeURIComponent(b), null);
    }
    else {
      window.open('http://honyaku.yahoofs.jp/url_result?eid=CR-EJ&both=T&url='+encodeURIComponent(location.href),null);
    }
  }
)();
Google
javascript:
  var%20t=(
    (window.getSelection&&window.getSelection())||
    (document.getSelection&&document.getSelection())||
    (document.selection&&document.selection.createRange&&document.selection.createRange().text)
  );
  var%20e=(document.charset||document.characterSet);
  if(t!=''){
    void(window.open('http://translate.google.co.jp/translate_t?text='+t+'&hl=ja&langpair=auto|ja&tbb=1&ie='+e,null));
  }
  else{
    void(window.open('http://translate.google.co.jp/translate?u='+escape(location.href)+'&hl=ja&langpair=auto|ja&tbb=1&ie='+e,null));
  };

*1:だれか助けてくれるとうれしいけども