LoginSignup
10
8

More than 5 years have passed since last update.

スクリプトだけ翻訳しないブックマークレット

Last updated at Posted at 2014-07-11

概要

Webページ上でGoogle翻訳を利用する前に使用する。

ページ上のcodeタグとpreタグで囲われたソースコードすべてにnotranslateクラスを付与する。
stackoverflowなどで利用出来る。

実行前

code
<code>echo 'Hello World'</code>

実行結果

code
<code class="notranslate">echo 'Hello World'</code>

スクリプト

Bookmarklet
javascript:void(function(){!function(d,f,s){s=d.createElement("script");s.src="//j.mp/1bPoAXq";s.onload=function(){f(jQuery.noConflict(1))};d.body.appendChild(s)}(document,function($){t=$('code,pre').addClass('notranslate');console.log('translatesucess!!');})})()

具体的な処理

code
jQuery(document).ready(function (jQuery) {

   var code = $('code,pre').addClass('notranslate');

 });

今後

  • 複数指定した選択範囲だけ翻訳しないようにする。
  • chrome Extensionにする。

参考

以下の記事を参考にさせて頂きました。

10
8
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
8