<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; JS: Переводчик страниц для браузера Maxthon]]></title>
	<link rel="self" href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=9341&amp;type=atom" />
	<updated>2015-04-16T19:12:12Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.script-coding.com/viewtopic.php?id=9341</id>
		<entry>
			<title type="html"><![CDATA[Re: JS: Переводчик страниц для браузера Maxthon]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=93442#p93442" />
			<content type="html"><![CDATA[<p>Вот мое <a href="http://расширение%20http://extension.maxthon.com/detail/index.php?view_id=2848">расширение http://extension.maxthon.com … ew_id=2848</a> для перевода страниц по нажатию</p>]]></content>
			<author>
				<name><![CDATA[tyz.92]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=33006</uri>
			</author>
			<updated>2015-04-16T19:12:12Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=93442#p93442</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: JS: Переводчик страниц для браузера Maxthon]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=80646#p80646" />
			<content type="html"><![CDATA[<p>Вот&nbsp; это <a href="http://rghost.ru/52954358/">расширение</a> полностью.</p>]]></content>
			<author>
				<name><![CDATA[Ядрён]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=30092</uri>
			</author>
			<updated>2014-03-10T09:05:05Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=80646#p80646</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[JS: Переводчик страниц для браузера Maxthon]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=80635#p80635" />
			<content type="html"><![CDATA[<p>Доброго времени суток. Есть расширение переводчика страниц для браузера Maxthon.Оно работает не правильно переводит все страницы подряд и русские и зарубежные. А можно как нибудь сделать проверку на русские и зарубежные сайты ,что бы на русских сайтах (Banner) не запускался.В расширении 3 файла , я не знаю в каком нужно сделать изменения, по этому выкладываю все 3 файла.</p><p>&nbsp; &nbsp;mstranslator.js<br /></p><div class="codebox"><pre><code>//Google ????
&#039;use strict&#039;;

((function() {
  var runtime = (window.external.mxGetRuntime) ? window.external.mxGetRuntime() : null;
  //????
  var userLang = (runtime) ? runtime.locale.getSystemLocale() : navigator.language;

  //?????
  var injection = function (userLang) {
    var pageLang = &#039;auto&#039;; //????
    var autoTrans = true; //????

    var GUID = &#039;{EB4828F0-271D-4e4a-B846-53D4285F4DDA}&#039;; //from def.json
    var uid = GUID.slice(1, -1).replace(/-/g, &#039;&#039;);
    var teId = &#039;TE_&#039; + uid;
    var cbId = &#039;TECB_&#039; + uid;

    function doScript(win) {

      function show() {
        win.setTimeout(function() {
          win[teId].showBanner(autoTrans);
        }, 10);
      }

      function newElem() {
        var elem = new win.google.translate.TranslateElement({
          autoDisplay: false,
          floatPosition: 0,
          multilanguagePage: true,
          pageLanguage: pageLang
        });
        return elem;
      }

      if (win[teId]) {
        show();
      } else {
        if (!win.google || !win.google.translate ||
            !win.google.translate.TranslateElement) {
          if (!win[cbId]) {
            win[cbId] = function() {
              win[teId] = newElem();
              show();
            };
          }

          var doc = win.document;
          var script = doc.createElement(&#039;script&#039;);
          script.type = &#039;text/javascript&#039;;
          script.charset = &#039;utf-8&#039;;
          script.src = &#039;//translate.google.com/translate_a/element.js?cb=&#039; +
                  encodeURIComponent(cbId) + &#039;&amp;hl=&#039; + userLang;
          var heads = doc.getElementsByTagName(&#039;head&#039;);
          if (heads.length === 0) {
            var head = doc.documentElement.insertBefore(doc.createElement(&#039;head&#039;), doc.documentElement.firstChild);
          } else {
            var head = heads[0];
          }
          head.appendChild(script);
        }
      }
    }

    //?? Frames
    function frmSplit(win) {
      var e;
      try {
        if (win.location.href == &#039;about:blank&#039;) {
          return;
        }
      } catch (e) {
        return;
      }
      doScript(win);
      var frms = win.frames;
      var frmLen = frms.length;
      for (var j = 0; j &lt; frmLen; j++) {
        try {
          frmSplit(frms[j]);
        } catch (e) {}
      }
    }
    frmSplit(self);
  };

  //???????
  function injector() {
    var doc = window.document;
    if (!doc.body) { //XML
      return;
    }
    var script = doc.createElement(&#039;script&#039;);
    script.type = &#039;text/javascript&#039;;
    var text = &#039;((&#039; + injection + &#039;)(&quot;&#039; + userLang + &#039;&quot;));&#039;;
    if (script.addEventListener) {
      script.appendChild(doc.createTextNode(text));
    } else { //IE &lt;= 8
      script.text = text;
    }
    var heads = doc.getElementsByTagName(&#039;head&#039;);
    if (heads.length === 0) {
      var head = doc.documentElement.insertBefore(doc.createElement(&#039;head&#039;), doc.documentElement.firstChild);
    } else {
      var head = heads[0];
    }
    head.appendChild(script);
    setTimeout(function(){head.removeChild(script);}, 100);
  }
  injector();
})());</code></pre></div><p>&nbsp; </p><br /><p>def.json<br /></p><div class="codebox"><pre><code>[
  {
    &quot;type&quot;: &quot;extension&quot;,
    &quot;frameworkVersion&quot;:&quot;1.0.6&quot;,
    &quot;version&quot;:&quot;5.4&quot;,
    &quot;guid&quot;: &quot;{14b63894-fc55-4645-ae7e-c8e31b458ab4}&quot;,
    &quot;name&quot;: &quot;????&quot;,
    &quot;icon&quot;: &quot;icon&quot;,
    &quot;title&quot;: {
        &quot;en&quot;: &quot;MicrosoftTranslator&quot;,
        &quot;zh-cn&quot;: &quot;????&quot;,
    },
    &#039;author&#039;:{
        &#039;name&#039;:&#039;By Tony&#039;,
        &#039;email&#039;:&#039;tony25142000@yahoo.com.cn&#039;
    },
    &#039;description&#039;:{
        &#039;zh-cn&#039;:&#039;????&#039;,
        &#039;en&#039;:&#039;MicrosoftTranslator&#039;
    },    
    &#039;config&#039; : &#039;config.html&#039;,
    &#039;permissions&#039; : {
            &#039;httpRequest&#039;: [ 
            &#039;www.bing.com&#039;,
            &#039;api.microsofttranslator.com&#039;            
            ]
        },   
    &quot;actions&quot;: [
    {
        &quot;type&quot;:&quot;panel&quot;,
        &quot;icon&quot;: &quot;icon&quot;,
        &quot;entryPoints&quot;:[&quot;toolbar&quot;,&quot;sidebar&quot;],
        &quot;main&quot;:&quot;menu.html&quot;,
        &quot;name&quot;:&quot;MicrosoftTranslator&quot;,
        &quot;title&quot;: &quot;????&quot;,
        &quot;allowPin&quot;:true,
        &quot;resizable&quot;:true,
        &quot;width&quot;:{
        &quot;default&quot;:280,
        &quot;min&quot;:120,
        &quot;max&quot;:340
        },
        &quot;height&quot;: {
        &quot;default&quot;: 120,
        &quot;min&quot;: 100,
        &quot;max&quot;: 200
        }
    },
    {
        &quot;type&quot;: &quot;script&quot;,
        &quot;entryPoints&quot;: [
          &quot;doc_end&quot;
        ],
        &quot;js&quot;: [
          &quot;checkautoload.js&quot;
        ],
        &quot;include&quot;: [
          &quot;*&quot;
        ],
        &quot;includeFrames&quot;: false
      }
    ]
  }
]</code></pre></div><br /><p>checkautoload.js<br /></p><div class="codebox"><pre><code>if(window.location.protocol==&quot;http:&quot;||window.location.protocol==&quot;https:&quot;){var rt=window.external.mxGetRuntime();var browser=rt.create(&quot;mx.browser&quot;);if(rt.storage.getConfig(&quot;tolan&quot;)==&quot;&quot;){rt.storage.setConfig(&quot;tolan&quot;,&quot;zh-chs&quot;)}if(rt.storage.getConfig(&quot;delayclose&quot;)==&quot;&quot;){rt.storage.setConfig(&quot;delayclose&quot;,&quot;15000&quot;)}if(rt.storage.getConfig(&quot;wordtranslatorhotkey&quot;)==&quot;&quot;){rt.storage.setConfig(&quot;wordtranslatorhotkey&quot;,87)}if(rt.storage.getConfig(&quot;mstranslatorhotkey&quot;)==&quot;&quot;){rt.storage.setConfig(&quot;mstranslatorhotkey&quot;,84)}if(rt.storage.getConfig(&quot;mstwautodetect&quot;)==&quot;&quot;){rt.storage.setConfig(&quot;mstwautodetect&quot;,&quot;autodetect&quot;);}var wordtranslator=rt.storage.getConfig(&quot;wordtranslator&quot;);var mstranslator=rt.storage.getConfig(&quot;mstranslator&quot;);if(mstranslator==&quot;autoload&quot;){browser.injectScriptFile(&quot;mstranslator.js&quot;)}else{rt.storage.setConfig(&quot;mstranslator&quot;,&quot;noautoload&quot;)}if(wordtranslator==&quot;autoload&quot;){browser.injectScriptFile(&quot;wordtranslator.js&quot;)}else{rt.storage.setConfig(&quot;wordtranslator&quot;,&quot;noautoload&quot;)}var autoloadwordtranslatorhotkey=rt.storage.getConfig(&quot;wordtranslatorhotkey&quot;);var autoloadmstranslatorhotkey=rt.storage.getConfig(&quot;mstranslatorhotkey&quot;);var keycodetokey={&quot;65&quot;:&quot;a&quot;,&quot;66&quot;:&quot;b&quot;,&quot;67&quot;:&quot;c&quot;,&quot;68&quot;:&quot;d&quot;,&quot;69&quot;:&quot;e&quot;,&quot;70&quot;:&quot;f&quot;,&quot;71&quot;:&quot;g&quot;,&quot;72&quot;:&quot;h&quot;,&quot;73&quot;:&quot;i&quot;,&quot;74&quot;:&quot;j&quot;,&quot;75&quot;:&quot;k&quot;,&quot;76&quot;:&quot;l&quot;,&quot;77&quot;:&quot;m&quot;,&quot;78&quot;:&quot;n&quot;,&quot;79&quot;:&quot;o&quot;,&quot;80&quot;:&quot;p&quot;,&quot;81&quot;:&quot;q&quot;,&quot;82&quot;:&quot;r&quot;,&quot;83&quot;:&quot;s&quot;,&quot;84&quot;:&quot;t&quot;,&quot;85&quot;:&quot;u&quot;,&quot;86&quot;:&quot;v&quot;,&quot;87&quot;:&quot;w&quot;,&quot;88&quot;:&quot;x&quot;,&quot;89&quot;:&quot;y&quot;,&quot;90&quot;:&quot;z&quot;,&quot;48&quot;:&quot;0&quot;,&quot;49&quot;:&quot;1&quot;,&quot;50&quot;:&quot;2&quot;,&quot;51&quot;:&quot;3&quot;,&quot;52&quot;:&quot;4&quot;,&quot;53&quot;:&quot;5&quot;,&quot;54&quot;:&quot;6&quot;,&quot;55&quot;:&quot;7&quot;,&quot;56&quot;:&quot;8&quot;,&quot;57&quot;:&quot;9&quot;};if(typeof(keycodetokey[autoloadwordtranslatorhotkey])!=&quot;undefined&quot;&amp;&amp;typeof(keycodetokey[autoloadmstranslatorhotkey])!=&quot;undefined&quot;){document.addEventListener(&#039;keydown&#039;,function(e){if(!e.shiftKey&amp;&amp;e.ctrlKey&amp;&amp;e.altKey){if(e.keyCode==autoloadwordtranslatorhotkey){browser.injectScriptFile(&quot;wordtranslator.js&quot;);return}if(e.keyCode==autoloadmstranslatorhotkey){browser.injectScriptFile(&quot;mstranslator.js&quot;);return}}},false)}
if(rt.storage.getConfig(&quot;mstwautodetect&quot;)==&quot;autodetect&quot;)
{
var MTWdiv=document.createElement(&quot;div&quot;);

}

}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Ядрён]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=30092</uri>
			</author>
			<updated>2014-03-09T20:20:54Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=80635#p80635</id>
		</entry>
</feed>
