簡易翻訳(Google)
by
maRk
2016-02-05 [2016/02/05 18:58:21]
Translate bookmarklet
-
/*
* @title 簡易翻訳(Google)
* @description Translate bookmarklet
* @include http://*
* @license MIT License
* @require
* @javascript_url
*/
(function(){
var text = window.getSelection().toString() || prompt('keyword ?');
if (text == null || text == '') return;
var matches = /^(?=[a-zA-Z]{2,})(?!^[亜-黑ぁ-んァ-ヶ]{2,})/;
var translate = matches.test(text.replace(/[\d\s"'<>()(){}\[\].\\/\\^\-\+=\|\*@$#\!;\:]/g, '')) ? 'en/ja/' : 'ja/en/';
return location.href = 'https://translate.google.co.jp/?hl=ja#' + translate + encodeURIComponent(text);
})();
/*;;;
;;;;;
javascript:(function(){var c=window.getSelection().toString()||prompt("keyword ?");if(c==null||c==""){return}var a=/^(?=[a-zA-Z]{2,})(?!^[亜-黑ぁ-んァ-ヶ]{2,})/;var b=a.test(c.replace(/[\d\s"'<>()(){}\[\].\\/\\^\-\+=\|\*@$#\!;\:]/g,""))?"en/ja/":"ja/en/";return location.href="https://translate.google.co.jp/?hl=ja#"+b+encodeURIComponent(c)})();
;;;;;
;;;*/
-
- Permalink
- このページへの個別リンクです。
- RAW
- 書かれたコードへの直接のリンクです。
- Packed
- 文字列が圧縮された書かれたコードへのリンクです。
- Userscript
- Greasemonkey 等で利用する場合の .user.js へのリンクです。
- Loader
- @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
- Metadata
- コード中にコメントで @xxx と書かれたメタデータの JSON です。