网页翻译助手 was reported 2021-07-19 as an unauthorized copy of 网页翻译助手.

网页翻译助手 uses the MIT License license. Visit tldrlegal.com for help understanding what this license means.

Script License Created Updated
Reported 网页翻译助手 MIT 2021-01-16 06:48:20 UTC 2021-01-16 06:48:19 UTC
Original 网页翻译助手 MIT 2019-09-05 09:45:59 UTC 2021-03-09 08:17:27 UTC
  • // ==UserScript==
  • // @name 网页翻译助手
  • -// @version 1.2.9
  • +// @version 1.2.8
  • // @namespace https://github.com/zyufstudio/TM/tree/master/webTranslate
  • -// @description 支持划词翻译,输入文本翻译,谷歌整页翻译。可以自行选择谷歌翻译,有道字典翻译和百度翻译。
  • +// @description 支持划词翻译,输入文本翻译,谷歌整页翻译.
  • // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAENklEQVRoQ+2ZTVITQRTH/28qyNIJFxCqnGwNJzCcwHACcelkIZxAPAG4IFkaTyCegHgC4jZjVfACzLBEUvOs7jCx57unZ6JSRZZJ9+v3e+/1++gQHviHHrj+eAT41x4s9YA99F5qK3nb+h4c7QTa6xtYmAuwNfLeg3Fc5QxmBGy1doO3O1dV9tVZmwmwdeYdg/DeTDB/vnY7B2Z7q+/KBhh6XF3UcgeDr3y3s2O6v+q+FIB9NutaRJdVBanrQ+bdYNCZ1pGhuzcNMPJ6FuNCV0DWuhA4ClzntI4M3b1rARBhRERjXSWK1oUhfy3y5loAmlBclcHAue86+1lyHwTAfXb4cD1wUmm9EgAzfhLoPLT4fGUNRpeAPgH6Bc/ARcw89Qed3eRWLQAGbhg4LrqY9sjrUYgxEZ7FDmH6GAPWUZ7JJvBh0ijXrpPStxRAKs/c00mLAiKewcyLmn0yt63Nha/yGgGEoP3Afb4KGSEYT+5eWxbZQniUJUT9INAFEeT3RXGr4wSxpj30JqoXKgMw8M13nV50oH02OyDQSUxJWX55zKB+8vu8uP1rAKr17dF8m8LFZUr5Em1Cau2ozZ09/NEn8Dum1puypq+2B1SXbQ1nY4Be61rvTxjxOPy1cRS12e2z2SURdcHITIuq/FoA4vL6rrOK56QwBn/n241eXv/fHs6mBHpRFViEHVsb+8I79QAYgT9w2pECSWFlFlxZuiqBSAz3YVcLQJxbFEJyeGEcwMJyAmO+UVPtltKSJzOZyiTuhAX+woyv/sDpNxZCMkUqKVReYl5MCXiaZdSQ+U0w6MgGLt2S59eD9tC7IKCn7s/zukkanfiusxdLo0SnaYi4gnkTXXLYiQqfLJa3re3kfaodQkkvSOuKQra5OLB4WbBCC5PgrTNZQZ7MbXqymKdqAnAjwZXsU5aRGgGQsQ7e02olpPJ3FzJNJj4ixonwSkIz71qgvpi7RYPoD5ztrLBsBCASHDIfBoPOx7yksmwl8ClLeXnHgW/ENAXxO2GUyENF42ejAEsl+Eq204DSTnOXiHqipS7LmOFtq02bi/OovykbPRsHKFNQ4/dTkXoj68ui9WtjL78Y1mzmNBQyWiKqOETPT3hWBPE/egBRwRLZjDbvJqLdyIP4LwFCwl6UdssgzAAaeNgqjKtEFxqDAGKF0whAHK72MUZBXrApOSRFxXGZnfhKfVc1B6j1uFuGrD8nGwNIL6wBIq/nyUOuBbDqbUbeaiYus230uxWil/U8X9RWZ7cSszmBVm2GVjeqq2TZuqwRtAqAeECwiD6p5/xVgGhQSTd1PAVRyd9QvK1a/r6Xio24kdzS/8jKLF30e3voBXkDUFW5WRObkLFWAOOXjASdvPzU6mY9w6wVYFmk/nSfla0O3IAxYat1mPeGtFaAqgqbrH8EMLFak3sePdCkNU1k/QadtchPhjx3/AAAAABJRU5ErkJggg==
  • // @author Johnny Li
  • // @license MIT
  • // @connect cdn.bootcss.com
  • // @connect translate.google.cn
  • // @connect fanyi.youdao.com
  • -// @connect dict.youdao.com
  • // @connect fanyi.baidu.com
  • // @connect shared.ydstatic.com
  • // @require https://cdn.jsdelivr.net/npm/jquery@2.2.3/dist/jquery.min.js
  • });
  • }
  • - /**
  • - * 获取有道翻译音标
  • - * @param {String} transText
  • - * @param {Function} callback
  • - */
  • - function getYDSymbol(transText, callback) {
  • - var url = StringFormat("http://dict.youdao.com/fsearch?client=fanyideskweb&keyfrom=fanyi.web&q={0}&doctype=xml&xmlVersion=3.2&dogVersion=1.0&appVer=3.1.17.4208", encodeURIComponent(transText));
  • - GM_xmlhttpRequest({
  • - method: "GET",
  • - url: url,
  • - timeout: 5000,
  • - onload: function (ydRes) {
  • - var xmlnode=ydRes.responseXML;
  • - var symbol = {
  • - uk:"",
  • - us: ""
  • - };
  • - var root = xmlnode.getElementsByTagName("yodaodict")[0];
  • - if ("" + root.getElementsByTagName("uk-phonetic-symbol")[0] != "undefined" && "" + root.getElementsByTagName("uk-phonetic-symbol")[0].childNodes[0] != "undefined") {
  • - symbol.uk = root.getElementsByTagName("uk-phonetic-symbol")[0].childNodes[0].nodeValue;
  • - }
  • - if ("" + root.getElementsByTagName("us-phonetic-symbol")[0] != "undefined" && "" + root.getElementsByTagName("us-phonetic-symbol")[0].childNodes[0] != "undefined") {
  • - symbol.us = root.getElementsByTagName("us-phonetic-symbol")[0].childNodes[0].nodeValue;
  • - }
  • - callback(symbol);
  • - },
  • - onerror: function (e) {
  • - console.error(e);
  • - }
  • - });
  • - }
  • -
  • //有道翻译
  • var youdaoTrans = {
  • code: "yd",
  • h_headers = {},
  • h_data = "";
  • - var youdaoTransApi = "http://fanyi.youdao.com/translate_o?client=fanyideskweb&keyfrom=fanyi.web&smartresult=dict&version=2.1&doctype=json";
  • + var youdaoTransApi = "http://fanyi.youdao.com/translate_o?client=fanyideskweb&keyfrom=fanyi.web&version=2.1&doctype=json";
  • var tempsalt = "" + (new Date).getTime() + parseInt(10 * Math.random(), 10);
  • var newSign = this.sign != "" ? this.sign : "]BjuETDhU)zqSxf-=B#7m";
  • var tempsign = $.md5("fanyideskweb" + Trans.transText + tempsalt + newSign);
  • Trans.transResult.orig = origs;
  • Trans.transResult.origLang = src.split("2")[0];
  • - var smartResult = data.smartResult;
  • - if (smartResult && smartResult.entries.length > 0) {
  • - getYDSymbol(Trans.transText, function (symbol) {
  • - Trans.transResult.symbols.en = symbol.uk;
  • - Trans.transResult.symbols.am = symbol.us;
  • - h_onloadfn();
  • - });
  • - }else {
  • - h_onloadfn();
  • - }
  • }
  • + h_onloadfn();
  • }, 300);
  • },
  • onerror: function (e) {
  • setTimeout(function () {
  • var result= JSON.parse(r.responseText);
  • var trans_result=result.trans_result;
  • - var dict_result=result.dict_result || null;
  • var transDatas = trans_result.data;
  • var trans = [],origs = [],src = "";
  • Trans.transResult.trans = trans;
  • Trans.transResult.orig = origs;
  • Trans.transResult.origLang = src;
  • -
  • - if(dict_result){
  • - var symbols=dict_result.simple_means.symbols;
  • - Trans.transResult.symbols.en=symbols[0].ph_en || "";
  • - Trans.transResult.symbols.am=symbols[0].ph_am || "";
  • - }
  • h_onloadfn();
  • }, 300);
  • },
  • //原文
  • orig:[],
  • //原文语言
  • - origLang:"",
  • - //音标
  • - symbols:{
  • - //英标
  • - en:"",
  • - //美标
  • - am:"",
  • - }
  • + origLang:""
  • },
  • Execute:function(h_onloadfn){
  • - resetTransResult(this);
  • + this.transResult.trans=[];
  • + this.transResult.orig=[];
  • + this.transResult.origLang="";
  • this.transEngineObj.Execute(h_onloadfn);
  • },
  • GetLangList:function(){
  • return langList;
  • },
  • Update:function(){
  • - resetTransResult(this);
  • + this.transResult.trans=[];
  • + this.transResult.orig=[];
  • + this.transResult.origLang="";
  • this.transEngineObj=this.transEngineList[this.transEngine];
  • this.transTargetLang=this.transEngineObj.defaultTargetLang;
  • this.transOrigLang=this.transEngineObj.defaultOrigLang;
  • }
  • };
  • - function resetTransResult(that){
  • - that.transResult.trans=[];
  • - that.transResult.orig=[];
  • - that.transResult.origLang="";
  • - that.transResult.symbols.en="";
  • - that.transResult.symbols.am="";
  • - }
  • -
  • //面板
  • var Panel={
  • popBoxEl:{},
  • }
  • var wordTransPanelHtml = StringFormat(
  • '<div>翻译引擎:<select>{2}</select> 翻译语言:<input type="text" value="{4}" readonly style="width:80px"/> &#x21E8; <select>{3}</select></div>' +
  • - '<div style="word-wrap:break-word">{1}</div>', randomCode, html.transHtml, transEngineOptionsHtml, html.langListHtml, html.origLangName);
  • + '<div style="word-wrap:break-word">{1}</div>'
  • + ,randomCode,html.transHtml,transEngineOptionsHtml,html.langListHtml,html.origLangName);
  • Panel.popBoxEl = popBoxEl;
  • Panel.randomCode = randomCode;
  • - Panel.Create("", "auto bottom", false, wordTransPanelHtml, function ($panel) {
  • - +
  • + Panel.Create("","auto bottom",false,wordTransPanelHtml,function($panel){+
  • //目标语言
  • $panel.find(StringFormat("#panelBody{0} div:eq(0) select:eq(1)", randomCode)).change(function (e) {
  • var origLang = Trans.transResult.origLang;
  • var transContHtml = "";
  • - if (Trans.transResult.trans.length > 0 && Trans.transResult.orig.length > 0) {
  • - //译文
  • + if(Trans.transResult.trans.length>0 && Trans.transResult.orig.length>0)
  • + {
  • var transHtml = [];
  • transHtml.push('<div style="padding-top: 5px;"><ul style="list-style: none;margin: 0;padding: 0;">');
  • for (var i = 0; i < Trans.transResult.trans.length; i++) {
  • transHtml.push(StringFormat('<li style="list-style: none;"><span>{0}</span></li>', transtxt));
  • }
  • transHtml.push("</ul></div>");
  • - //原文
  • var origHtml = [];
  • - //原文内容
  • origHtml.push('<div style="padding-bottom: 5px;"><ul style="list-style: none;margin: 0;padding: 0;">');
  • for (var j = 0; j < Trans.transResult.orig.length; j++) {
  • var origtxt = Trans.transResult.orig[j];
  • origHtml.push(StringFormat('<li style="list-style: none;"><span>{0}</span></li>', origtxt));
  • }
  • - origHtml.push("</ul>");
  • - //原文音标
  • - if (Trans.transResult.symbols.en!="" || Trans.transResult.symbols.am!="") {
  • - origHtml.push('<div>');
  • - if(Trans.transResult.symbols.en!="")
  • - origHtml.push(StringFormat('<span style="padding-right: 10px;">英 [{0}]</span>',Trans.transResult.symbols.en));
  • - if(Trans.transResult.symbols.am!="")
  • - origHtml.push(StringFormat('<span>美 [{0}]</span>',Trans.transResult.symbols.am));
  • - origHtml.push('</div>');
  • - }
  • - origHtml.push("</div>");
  • -
  • -
  • + origHtml.push("</ul></div>");
  • transContHtml = origHtml.join("") + "<hr/>" + transHtml.join("");
  • Trans.transOrigLang = origLang;
  • - } else {
  • + }
  • + else {
  • var txt = "该翻译引擎不支持 " + langList[Trans.transOrigLang] + " 翻译成 " + langList[Trans.transTargetLang];
  • transContHtml = StringFormat("<div><span>{0}</span></div>", txt);
  • }
  • TextTransPanel.Create($body,randomCode);
  • });
  • GM_registerMenuCommand("Google整页翻译",function(){
  • - if(guid=="")
  • - guid=Guid();
  • - var cbscript=StringFormat('!function(){!function(){function e(){window.setTimeout(function(){window[t].showBanner(!0)},10)}function n(){return new google.translate.TranslateElement({autoDisplay:!1,floatPosition:0,multilanguagePage:!0,includedLanguages:"zh-CN,zh-TW,en",pageLanguage:"auto"})}var t=(document.documentElement.lang,"TE_{0}"),o="TECB_{0}";if(window[t])e();else if(!window.google||!google.translate||!google.translate.TranslateElement){window[o]||(window[o]=function(){window[t]=n(),e()});var a=document.createElement("script");a.src="https://translate.google.cn/translate_a/element.js?cb="+encodeURIComponent(o)+"&client=tee",document.getElementsByTagName("head")[0].appendChild(a)}}()}();',guid);
  • - $head.append(StringFormat('<script>{0}</script>',cbscript));
  • + 谷歌整页翻译(guid,$head);
  • + });
  • + GM_registerMenuCommand("开关此站自动整页翻译",function(){
  • + if(GM_getValue(location.host,"0") == "0"){
  • + 谷歌整页翻译(guid,$head);
  • + GM_setValue(location.host,"1");
  • + }else{
  • + GM_setValue(location.host,"0");
  • + location.reload(0);
  • + };
  • });
  • GM_registerMenuCommand("设置",function(){
  • $("div#wordTrans"+randomCode).hide();
  • RegMenu();
  • };
  • };
  • + function 谷歌整页翻译(guid,$head){
  • + if($head == null || $head == ""){
  • + $head = $("html head");
  • + };
  • + if(guid=="") {
  • + guid=Guid();
  • + var cbscript=StringFormat('!function(){!function(){function e(){window.setTimeout(function(){window[t].showBanner(!0)},10)}function n(){return new google.translate.TranslateElement({autoDisplay:!1,floatPosition:0,multilanguagePage:!0,includedLanguages:"zh-CN,zh-TW,en",pageLanguage:"auto"})}var t=(document.documentElement.lang,"TE_{0}"),o="TECB_{0}";if(window[t])e();else if(!window.google||!google.translate||!google.translate.TranslateElement){window[o]||(window[o]=function(){window[t]=n(),e()});var a=document.createElement("script");a.src="https://translate.google.cn/translate_a/element.js?cb="+encodeURIComponent(o)+"&client=tee",document.getElementsByTagName("head")[0].appendChild(a)}}()}();',guid);
  • + $head.append(StringFormat('<script>{0}</script>',cbscript));
  • + var 定时器变量 = setInterval(function(){
  • + if($("iframe[id*='.container']").length == 0){
  • + if($("iframe[id*='.container']").contents().find("a[aria-haspopup='true']").length == 0){
  • + return;
  • + };
  • + }
  • + clearInterval(定时器变量);
  • + var 定时器变量 = setInterval(function(){
  • + clearInterval(定时器变量);
  • + $("body").css("top","0px");
  • + $("iframe[id*='.container']").hide();
  • + $("div[id='goog-gt-tt']").remove();
  • + }, 200);
  • + }, 100);
  • + };
  • + };
  • var webTrans=new WebTranslate();
  • webTrans.init();
  • + if(GM_getValue(location.host,"0") != "0"){
  • + 谷歌整页翻译("",null);
  • + };
  • }());

小影哟 (the reported user) has made:

This report has been upheld by a moderator.

The concept of open source doesn't mean you can modify and publish code without proper attribution. The description should link to the original or the script should specify the URL, author, and license by using @original-script, @original-author, and @original-license. After you fix and update this deleted script, ask a moderator to undelete it.