簡易翻訳(Google)

    
      
  • /*
     * @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);
    })();
    
    
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2016/02/05 18:58:21 - 2016-02-05
  2. 2016/02/05 18:49:42 - 2016-02-05