Google select text translator

Translate any selected text into the language you wants with google translator

// ==UserScript==
// @id              googletranslatorbytoprapid
// @name            Google select text translator
// @name:zh-CN      谷歌点击划词翻译
// @version         4.03
// @namespace       https://greasyfork.org/en/scripts/36842
// @author          Toprapid
// @copyright       2017+,toprapid
// @description     Translate any selected text into the language you wants with google translator
// @description:zh-cn      谷歌点击划词翻译综合插件
// @match           http://*/*
// @match           https://*/*
// @grant           GM_registerMenuCommand
// @grant           GM_addStyle
// @grant           GM_xmlhttpRequest
// @grant           GM_getValue
// @grant           GM_setValue
// ==/UserScript==

//版本
var gtVer="4.03";

var sourceTranslateLanguageNameInStorage = "sourceTranslateLanguage";
var targetTranslateLanguageNameInStorage = "targetTranslateLanguage";
var translatorSettingLanguageInStorage="translatorSettingLanguage";
var defaultSourceLanguage = "-1";
var defaultTranslateLanguage = "0";
var currentSourceLanguage = parseInt(GM_getValue(sourceTranslateLanguageNameInStorage, defaultSourceLanguage));
var currentTranslateLanguage= parseInt(GM_getValue(targetTranslateLanguageNameInStorage, defaultTranslateLanguage));
var translatorSettingLanguage = GM_getValue(translatorSettingLanguageInStorage, "0") === "0" ? 0 : 1;
//国家与语言代码字符串
//国家
var uLanguageNames = [["中文", "中文", "中文", "英语", "英语", "英语", "英语", "英语", "英语", "英语", "英语", "芬兰语", "英语", "丹麦语", "英语", "希伯来语", "英语", "英语", "英语", "英语", "英语", "英语", "英语", "英语", "英语", "英语", "韩文", "日语", "荷兰语", "荷兰语", "葡萄牙语", "葡萄牙语", "法语", "法语", "法语", "法语", "法语", "西班牙语", "西班牙语", "西班牙语", "西班牙语", "西班牙语", "西班牙语", "西班牙语", "德语", "德语", "德语", "俄语","乌克兰语", "意大利语", "希腊语", "挪威语", "匈牙利语", "土耳其语", "捷克语", "斯洛文尼亚语", "波兰语", "瑞典语", "西班牙语"], ["Chinese", "Chinese", "Chinese", "English", "English", "English", "English", "English", "English", "English", "English", "Finnish", "English", "Danish", "English", "Hebrew", "English", "English", "English", "English", "English", "English", "English", "English", "English", "English", "Korean", "Japanese", "Dutch", "Dutch", "Portuguese", "Portuguese", "French", "French", "French", "French", "French", "Spanish", "Spanish", "Spanish", "Spanish", "Spanish", "Spanish", "Spanish", "German", "German", "German", "Russian","Ukrainian", "Italian", "Greek", "Norwegian", "Hungarian", "Turkish", "Czech", "Slovenian", "Polish", "Sweden Language", "Spanish"]];
//国家所对应的地区
var uRegionNames = [["简体", "繁体台湾", "繁体香港", "香港", "美国", "英国", "全球", "加拿大", "澳大利亚", "爱尔兰", "芬兰", "芬兰", "丹麦", "丹麦", "以色列", "以色列", "南非", "印度", "挪威", "新加坡", "新西兰", "印度尼西亚", "菲律宾", "泰国", "马来西亚", "阿拉伯", "韩国", "日本", "荷兰", "比利时", "葡萄牙", "巴西", "法国", "卢森堡", "瑞士", "比利时", "加拿大", "拉丁美洲", "西班牙", "阿根廷", "美国", "墨西哥", "哥伦比亚", "波多黎各", "德国", "奥地利", "瑞士", "俄罗斯", "乌克兰","意大利", "希腊", "挪威", "匈牙利", "土耳其", "捷克共和国", "斯洛文尼亚语", "波兰", "瑞典", "智利"],["Simplified", "Traditional Taiwan", "Traditional Hong Kong", "Hong Kong", "America", "United Kingdom", "Global", "Canada", "Australia", "Irish", "Finland", "Finland", "Denmark", "Denmark", "Israel", "Israel", "South Africa", "Indian", "Norway", "Singapore", "New Zealand", "Indonesia", "the Philippines", "Thai", "Malaysia", "Arab", "Korea", "Japan", "Dutch", "Belgium", "Portugal", "Brazil", "French", "Luxembourg", "Switzerland", "Belgium", "Canada", "Latin America", "Spain", "Argentina", "America", "Mexico", "Columbia", "Puerto Rico", "Germany", "Austria", "Switzerland", "Russia", "Ukraine","Italy", "Greece", "Norway", "Hungary", "Turkey", "Czech Republic", "Slovenian", "Poland", "Sweden", "Chile"]];
//最终代码
var uLanguageCode = ["zh-cn", "zh-tw", "zh-hk", "en-hk", "en-us", "en-gb", "en-ww", "en-ca", "en-au", "en-ie", "en-fi", "fi-fi", "en-dk", "da-dk", "en-il", "he-il", "en-za", "en-in", "en-no", "en-sg", "en-nz", "en-id", "en-ph", "en-th", "en-my", "en-xa", "ko-kr", "ja-jp", "nl-nl", "nl-be", "pt-pt", "pt-br", "fr-fr", "fr-lu", "fr-ch", "fr-be", "fr-ca", "es-la", "es-es", "es-ar", "es-us", "es-mx", "es-co", "es-pr", "de-de", "de-at", "de-ch", "ru-ru", "uk-uk","it-it", "el-gr", "no-no", "hu-hu", "tr-tr", "cs-cz", "sl-sl", "pl-pl", "sv-se", "es-cl"];
//腾讯代码
var tLanguageCode=["自动识别","中文", "中文", "中文", "英语", "英语", "英语", "英语", "英语", "英语", "英语", "英语", "xxx", "英语", "xxx", "英语", "xxx", "英语", "英语", "英语", "英语", "英语", "英语", "英语", "英语", "英语", "英语", "韩语", "日语", "xxx", "xxx", "葡萄牙语", "葡萄牙语", "法语", "法语", "法语", "法语", "法语", "西班牙语", "西班牙语", "西班牙语", "西班牙语", "西班牙语", "西班牙语", "西班牙语", "德语", "德语", "德语", "俄语","xxx", "意大利语", "xxx", "xxx", "xxx", "土耳其语", "xxx", "xxx", "xxx", "xxx", "西班牙语","泰语","越南语","印尼语","马来西亚语","阿拉伯语","印地语"];
//google翻译api变量
var UA = navigator.userAgent;
var googleDomain = ["translate.google.cn", "translate.google.com"];
var dictURL = "https://" + googleDomain[translatorSettingLanguage] + "/translate_a/single?client=t";
var ttsURL = "http://" + googleDomain[translatorSettingLanguage] + "/translate_tts?client=t";
var alURL="https://"+googleDomain[translatorSettingLanguage] +"/?op=translate";
var audioContext= new AudioContext();
var tokenNameInStorage=["google_value_tk_zh_cn","google_value_tk_en_us"];
var isEnabled = true;
var isTranslatorDisabledTemporarily=true;
var oldText = "";
var searchedTextCache=[];
var searchedTextIndex=-1;
var speakerIconBase64Data="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3QEQDhUFQkzk7wAAAIpJREFUOMtj/P//PwNFgAQD3jMwMDRg6MVjwHw0/n4GBob/DAwM5xkYGAQIGTAfqhgdFEDF1+MzAKYZl9P6oXIO2AxA1owsAXc2lH7PwMCwHtmA/zgwPLygYYBi0f///xmYSIgwByT2QxiDiYFCQIoBB5DY8rgSEtmBSLVopEpCokpSJjozMVKanQFy4nkNOfntnwAAAABJRU5ErkJggg==";
var settingIconBase64Data="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAAEEfUpiAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAACQVJREFUeNpi/P//PwMyYAERra2tRxgZmaz///9XwABSsf/Awf8gevOWrf/BKpYsXpR34cLF/1cuX2QECCBGdDOYWVlZbzOzsE76+fNXw4zp09sZT50+83/liuUKPDw8DyIjoxiY//37266hqf2Wg5OLYf26tYwAAQQ3o6en53ZJSYnqp0+f/8+aNXMrUCgLiB/BFezavef/zx/fGU6dOqXgHxD44O/fvwxbNm9iZAJJ5uTkbH/29DmDkJAwAyMj44N7d+8x3Lxxi+H9+/cqGM5csXLV/61bNgsAmR9BfIAAwlCADlhgDKDd/w8dOgTSJWBsbPz/7NmzjEBHMzBBA++qINB+Ti4ufnkFxf+8fHwMioqKYKPBClRUVbXevn3L8OL58/RLFy8cuHHjJsOFCxe6wG4oLi7+7+LqxsDCwsLg4uzECBLcsnXbf14eHobNmzcJgB25YcOm/8LCwgwPH95nUFZWZmBj42A4efI4Q1ZWFiPcF9Omz/z/588fBiZGRoa3b18zPH78WGPOnDk34b44fuzIRCCVAPIFECcD8U2QOEAA4Q2Hvr6+XUDKFaQOm3xRUREinGCgs7NzS2JikvejR48YYmPjGH79+sXw5s2b/3JycgyPHj1k2LFjB4phTDDGtm3b/j958vR/aFi49/Yd2xmYgaHy6vVrho+fPjEwMTMz7Nmzh+HP338gQ/9HRcf8//Hjx2p4TFVWVh4A0ULCogz37t0DRoIyw6qVK9Lb29tnw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vcmpi15yur06p3QkA2zfs2KGtBX9AK39PN9h7ja913zqeDOdpCPUDa+Wl5c/JpFTGiC1eIPBgJMnTzoArGxsbLz6sKE0KEQNQLf6Fy9WapK0pXKO0086nGkg+L18t8/ns921mFsvNZ3+AoCVzElmpInqBSJeJzU1k8kUlggZZmH/8dNSv2f9/5Vf/iwWwDyySDIlGOC+P6NMkbnwADqyRSTipw8R8QyJuPxAwP8AYYpg82V9fX1IREjAtymCCfg2RcjYVDN3sEb134qgPzRIS0sDReAtDv8/2MikTvlXEoGWlhYm4tatW6irq0NZWdlBErCFCXiUIogY7e3th2pra58PzYSPUkRra+t8m8323MyhFI9QxHsAzJiBfwNuBKZbF34OrAAAAABJRU5ErkJggg==";
var forbiddenIconBase64Data="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAF0UlEQVR4XoVVDUyVVRg+33f///USP8JCxdIGSpj/mWJqWjpnUbpJpILM0BIsneV0ahvYRMJpaaLpcqyS5pqlIv7NvIimYBsWhAoXRGEBl/v/+917v9P7nl1IGcyzvTvf2Xm/93nP+z7POZxIKRls8BwXB9M87bTNc3ip7FVDfNzIoD9AfXZHc8jvq/bUllbD/mX430aGGByYdLANxdjVa0dnHtqTn/uGKiVhmGKkUUWkPEc4jiOBkJj20OpNq2//MHff1796ecNr2aLj+pkhQSCDJ7OO1Uz5tGJ1wYpJG99M1tp9QeIOhIgvGCaUsn0ilXBEI5cQvVJGlFKebP3htqvq5PnzrpvFuRDLNfAECNAX3Bi7eM/f5aU5sc8PV/HtVi8Jif+DS+AEMglP0F8CQLhWAEC8QUnutNtDOQWH22xXv0iBfWHQEkGty4/uWRUzTCXjzRYPc1BDpjE6BZHxPLF6BRIGwBEQEIfVI2C5SKfDT1IT9NK9RdmJBQWuA7CV91QvcZImvJ357pp3Zo+L1Up63IH+4CP0SlLbZiUpr673z19edO6trL0XJy8rfrRm/2Uv7hs1cugLITZvkCweHyefumhOFlRiHhkwdAkZpdZ7P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pYnV0ZU5hbWU9Im9wYWNpdHkiIHZhbHVlcz0iMTswIiBrZXlUaW1lcz0iMDsxIiBkdXI9IjFzIiBiZWdpbj0iLTAuMDgzMzMzMzMzMzMzMzMzMzNzIiByZXBlYXRDb3VudD0iaW5kZWZpbml0ZSI+PC9hbmltYXRlPgogIDwvcmVjdD4KPC9nPjxnIHRyYW5zZm9ybT0icm90YXRlKDMzMCA1MCA1MCkiPgogIDxyZWN0IHg9IjQ3IiB5PSIyNCIgcng9IjkuNCIgcnk9IjQuOCIgd2lkdGg9IjYiIGhlaWdodD0iMTIiIGZpbGw9IiMxMGM5NTIiPgogICAgPGFuaW1hdGUgYXR0cmlidXRlTmFtZT0ib3BhY2l0eSIgdmFsdWVzPSIxOzAiIGtleVRpbWVzPSIwOzEiIGR1cj0iMXMiIGJlZ2luPSIwcyIgcmVwZWF0Q291bnQ9ImluZGVmaW5pdGUiPjwvYW5pbWF0ZT4KICA8L3JlY3Q+CjwvZz48L3N2Zz4=";
var ANS_TYPE_GOOGLE_RESULT=0,ANS_TYPE_ZDIC_HTML=2,ANS_TYPE_YOUDAO_WORD=3,ANS_TYPE_YOUDAO_SENTENCE=4,ANS_TYPE_ACCURATE=5;
var CACHE_TYPE_GOOGLE_RESULT=0,CACHE_TYPE_ZDIC_HTML=1,CACHE_TYPE_YOUDAO_WORD=2,CACHE_TYPE_YOUDAO_SENTENCE=3,CACHE_TYPE_ACCURATE=4;
var translatedDataMap=new Map();
var translatedSoundMap=new Map();
var lingoesServerConfigNameInStorage="lingoesServerConfig";
var defaultLingoesServerConfigValue="0|0|127.0.0.1|11111";
var lingoes_isEnabled=!1,lingoes_showingWay=0,lingoes_serverIp="127.0.0.1",lingoes_serverPort="11111";
var youdaoConfigNameInStorage="youdaoConfig";
var defaultYoudaoConfigValue="0|0|0";
var youdao_isEnabled=!1,youdao_isOnlyForSingleWord=!0;
var hotKeyNameInStorage="hotKeyName";
var hotKeyNameForQSInStorage = "QSHotKeyName";
var defaultHotKeyValue= "1|1|1|81"; //Ctrl+Alt+Q enabled
var defaultHotKeyValueForQS="1|1|1|68"; //Ctrl+Alt+D enabled
var hotKey_Ctrl=!0,hotKey_Alt=!0,hotKey_Code=81, hotkey_isActive = !0, isHotkeyEventRegistered=!1;
var hotKey_Ctrl_forQS = !0, hotKey_Alt_forQS = !0, hotKey_Code_forQS = 68, hotkey_isActive_forQS = !0, isHotkeyEventRegistered_forQS = !1;
var hotkeyType_forPlugin=0;
var hotkeyType_forQS=1;
var isPinned=!1;
var isToolBarMoving=!1;
var tBarOffsetX=0;
var tBarOffsetY=0;
var isEnableSimpleMode=!1;
var isEnableSimpleModeDefaultConfig="0";
var isEnableSimpleModeConfigString="isEnableSimpleModeConfigString";
var isEnableRealtimeTranslationMode=!0;
var isEnableRealtimeTranslationModeDefaultConfig="1";
var isEnableRealtimeTranslationModeConfigString="isEnableRealtimeTranslationModeConfigString";
var isRemoveWebsiteSelectingRestriction=!0;
var isRemoveWebsiteSelectingRestrictionDefaultConfig="1";
var isRemoveWebsiteSelectingRestrictionConfigString="isRemoveWebsiteSelectingRestrictionConfigString";
var isWebsiteRestrictionRemoved=!1;
var isEnableAccurateMode=!1;
var isEnableAccurateModeDefaultConfig="0";
var isEnableAccurateModeConfigString="isEnableAccurateModeConfigString";
var isTMode=!1;
var isTModeDefaultConfig="0";
var isTModeConfigString="isTMode";
var translatedDataConfigString="translatedDataConfigString";
var translationTaskTimout=0;
var translationTaskInterval=100;
var maxTimesToDestroy=200;
let accurateData={dy:maxTimesToDestroy,mx:0,my:0,md5:"",wh:null};
var isExistsTranslationTask={
    get:function(){
        return GM_getValue("isExistsTranslationTaskConfigString","0")!=="0";
    },
    set:function(vl){
        GM_setValue("isExistsTranslationTaskConfigString",vl ? "1":"0");
    }
};

//current target language for playing sound
var curTarLanForSpeaker = uLanguageCode[currentTranslateLanguage];

let maxNResult=80;
let tencentTStr="";
function fetchNResult(){
    let n=document.getElementsByClassName("tlid-translation");
    if(n){
        if(n.length>0){
            let s=n[0].innerHTML;
            if(s.length>0){
                GM_setValue(translatedDataConfigString,s);
            }
            isExistsTranslationTask.set(false);
            window.close();
            return;
        }
    }
    if(maxNResult-->0)setTimeout(fetchNResult,200);
}
function fetchTResult(){
    let n=document.getElementsByClassName("textinput");
    if(n){
        if(n.length>0){
			n[0].value=tencentTStr; 
			triggerEvent(n[0],"propertychange");
			fetchZResult();
            return;
        }
    }
    if(maxNResult-->0)setTimeout(fetchTResult,200);
}
function fetchZResult(){
	let z=document.getElementsByClassName("textpanel-target-textblock");
	if(z){
		if(z.length>0){
			if(z[0].innerHTML!=="undefined" && z[0].innerHTML!==null){
				let s=z[0].innerHTML.trim();
				if(s.length>0){
                    GM_setValue(translatedDataConfigString,`<style type="text/css">#gt_prefs_contentDiv span.hidden{display:none;};</style>${s}`);
                    isExistsTranslationTask.set(false);
                    window.close();
					return;
				}
			}
		}
	}
	if(maxNResult-->0)setTimeout(fetchZResult,100);
}
getModesConfigValue();
if(isEnableAccurateMode){
    if(isExistsTranslationTask.get()){
        if(/translate\.google\.[com|cn]+\/\?op=translate\&sl=/gi.test(location.href)){
            if(translatorSettingLanguage===1){
                document.onreadystatechange=function(e){
                    if(document.readyState==="complete"){
                        fetchNResult();
                    }
                }
            }
            else{
                fetchNResult();
            }
            return;
        }
        if(/^https:\/\/fanyi\.qq\.com\/$/gi.test(location.href)){
            document.onreadystatechange=function(e){
                if(document.readyState==="complete"){
                    let dta=GM_getValue(translatedDataConfigString,null);
                    if(dta!=null && dta!="undefined" && dta!==""){
                        let s=dta.split("|");
                        if(s.length===3){
                            let zn=document.getElementsByTagName("ul");
                            let sps=null;
                            let i=0;
                            tencentTStr=decodeURI(s[2]);
                            for(;i<zn.length;i++){
                                if(zn[i].hasAttribute("node-type")){
                                    if(zn[i].getAttribute("node-type")==="target_language_list"){
                                        sps=zn[i].getElementsByTagName("span");
                                        break;
                                    }
                                }
                            }
                            if(sps){
                                for(let n=0;n<sps.length;n++){
                                    if(sps[n].innerText===s[0]){
                                        triggerEvent(sps[n],"click");
                                        break;
                                    }
                                }
                            }
                            sps=null;
                            for(;i<zn.length;i++){
                                if(zn[i].hasAttribute("node-type")){
                                    if(zn[i].getAttribute("node-type")==="target_language_list"){
                                        sps=zn[i].getElementsByTagName("span");
                                        break;
                                    }
                                }
                            }
                            if(sps){
                                for(let n=0;n<sps.length;n++){
                                    if(sps[n].innerText===s[1]){
                                        triggerEvent(sps[n],"click");
                                        break;
                                    }
                                }
                            }
                            fetchTResult();
                        }
                    }
                }
            }
            return;
        }
    }
}
getHotKeyValue(hotkeyType_forPlugin);
getHotKeyValue(hotkeyType_forQS);
getLingoesConfigValue();
getYoudaoConfigValue();

window.document.body.addEventListener("mouseup", googleTranslate, false);

var on = function (node, e, f) {
    node.addEventListener(e, f, false);
};
var $ = function (s) {
    return document.getElementById('gt_prefs_' + s);
};


var setup=function() {
    var d = document;
    if ($('setup')) return;
    var div = d.createElement('div');
    div.id = 'gt_prefs_setup';
    d.body.appendChild(div);
    var styleNode = GM_addStyle(`
            #gt_prefs_setup {opacity:0.9; box-shadow:-2px 0px 9px 5px #898D91;position:fixed;z-index:2147483647;top:30px;right:60px;padding:20px 30px;background:radial-gradient(circle, rgba(31,103,127,1) 0%, rgba(83,160,124,1) 94%, rgba(132,175,155,1) 96%, rgba(31,96,161,1) 98%, rgba(56,115,173,1) 98%, rgba(5,183,246,1) 100%);width:600px;border:1px solid black; border-radius:10px;}
            #gt_prefs_setup * { color:#deff08;text-align:left;line-height:normal;font-size:12px; }
            #gt_prefs_setup a { color:black;text-decoration:underline; }
            #gt_prefs_setup div { text-align:center;font-weight:bold;font-size:14px; }
            #gt_prefs_setup ul { margin:15px 0 15px 0;padding:0;list-style:none;border:0; }
            #gt_prefs_setup input,select {border:1px solid blue;border-radius:5px;width:auto;padding:2px;background:#53a07c;text-align:center;}
            #gt_prefs_setup li { margin:0;padding:6px 0;vertical-align:middle;border:0 }
            #gt_prefs_setup button { background:transparent;width:150px;margin:0 10px;text-align:center;border:1px blue solid;border-radius:5px;box-shadow:2px 2px 2px 1px #2C3E50;}
            #gt_prefs_setup textarea { width:98%; height:60px; margin:3px 0; text-align:center;border-radius:5px;}
            #gt_prefs_setup b { font-weight: bold; font-family: "微软雅黑", sans-serif; }
            #gt_prefs_setup button:disabled { color: graytext; }
    `);
    var sb_Title=["谷歌点击划词翻译设置","Google select text translator Setting"],
        sb_CurStatus = [["(启用中)", "(禁用中)"], ["(Enabled)", "(Disabled)"]],
        sb_HotkeyForQuickSearch = ["快速查询热键:", "Hotkey for Quick Search:"],
        sb_HotkeyActivatorForQuickSearch = ["启用热键", "Enable Hotkey"],
        sb_Usage = ["插件开关热键:", "Hotkey for Plugin switch:"],
        sb_HotKeyActivator=["启用热键","Enable Hotkey"],
        sb_CurVersion=["当前版本:","Current Version "],
        sb_CurAuthor=[",作者:",", Author: "],
        sb_CurUILanguage=[",Current UI Language:",", 当前界面语言:"],
        sb_UILanguage=[["Chinese Simplified","English"],["英文","中文"]],
        sb_SourceLanguage = ["指定源语言:", "Select the source language:"],
        sb_SourceLanguageSetToAuto = ["自动检测", "Auto Detect"],
        sb_TargetLanguage=["设置目标翻译语言:","Select the target language to translate:"],
        sb_Confirmation=[["确定","取消"],["Save","Cancel"]],
        sb_UseLingoesAPILocalServer=["启用本地灵格斯API服务(需要本机安装灵格斯词典软件,并在其设置中启用API服务器)。","Enable Lingoes Local API Server (Need Lingoes software installed, and enable it's API server)."],
        sb_LingoesAPIServerIP=["灵格斯API服务器 -- IP地址:","Lingoes Local API Server -- IP:"],
        sb_LingoesAPIServerPort=["端口号:","Port:"],
        sb_LingoesShowingWay=[["显示取词窗口","主界面取词","主界面翻译文字","查询方式:"],["Showing query result","Main UI query","Main UI translator","Query way:"]],
        sb_LingoesErrorWarning=[["输入的IPv4地址不规范!本地地址一般为:127.0.0.1","端口号必须为0-65535间的数字!"],["The Ipv4 address is wrong! For localhost server, use 127.0.0.1 please!","Port number must be a digital between 0 to 65535"]],
        sb_UseYoudaoSever=["启用有道翻译代替谷歌翻译引擎(注:仅限中英互译):","Use Youdao translator (PS: only used between Chinese and English):"],
        sb_YoudaoTranslationWay=[["全面启用","仅限单词"],["Totaly enabled","Only for words"]],
        sb_ErrorWarning=["输入的热键必须为字母或数字!","The hot key must be alphabet or digital!"],
        sb_SimpleMode=["简洁模式(仅翻译成目标语言)","Simple Mode (Show translated content only)"],
        sb_RealTimeTranslationMode=["启用对选定内容的实时翻译模式(否则需点击翻译图标进行翻译)","Enable real-time selection translating mode (Otherwise click an icon to translate)"],
        sb_RemoveSelectingRestriction=["移除网站对文本选定的限制(如果导致部分网站功能异常,请禁用该选项)","Remove website selection restriction (Disable this if website runs unusually)"],
        sb_AccurateMode=["对长句使用精确翻译模式(需借助临时弹出翻译引擎窗口获取翻译数据,速度较慢),选择引擎:","Use accurate mode for sentences (Need to popup the translation window to get translated data. It's slowly), Choose translator:"],
        sb_AccurateEngineSelection=[["谷歌翻译引擎","腾讯翻译引擎"],["Google Engine","Tencent Engine"]];
    var divHtml = `
        <div>${sb_Title[translatorSettingLanguage]}${sb_CurStatus[translatorSettingLanguage][(isEnabled ? 0:1)]}</div>
            <ul>
                <li>${sb_CurVersion[translatorSettingLanguage]} <b>${gtVer}</b>${sb_CurAuthor[translatorSettingLanguage]}<b>Toprapid</b>${sb_CurUILanguage[translatorSettingLanguage]}
                    <select id="gt_prefs_se_curUILanguage">
                        <option value="0" selected="selected">${sb_UILanguage[translatorSettingLanguage][0]}</option>
                        <option value="1">${sb_UILanguage[translatorSettingLanguage][1]}</option>
                    </select>
                </li>
                <li>${sb_Usage[translatorSettingLanguage]}
                    <input type="checkbox" id="gt_prefs_cb_ctrl" value="Ctrl" />Ctrl<b>+</b>
                    <input type="checkbox" id="gt_prefs_cb_alt" value="Alt" />Alt<b>+</b>
                    <input type="text" maxlength="1" style="text-transform:uppercase;" onclick="javascript:this.select();" id="gt_prefs_txt_key" value="${String.fromCharCode(hotKey_Code)}" />
                    <input type="checkbox" id="gt_prefs_cb_stat" value="isActive" />${sb_HotKeyActivator[translatorSettingLanguage]}
                </li>
                <li>${sb_HotkeyForQuickSearch[translatorSettingLanguage]}
                    <input type="checkbox" id="gt_prefs_cb_ctrl_forQS" value="Ctrl" />Ctrl<b>+</b>
                    <input type="checkbox" id="gt_prefs_cb_alt_forQS" value="Alt" />Alt<b>+</b>
                    <input type="text" maxlength="1" style="text-transform:uppercase;" onclick="javascript:this.select();" id="gt_prefs_txt_key_forQS" value="${String.fromCharCode(hotKey_Code_forQS)}" />
                    <input type="checkbox" id="gt_prefs_cb_stat_forQS" value="isActive" />${sb_HotkeyActivatorForQuickSearch[translatorSettingLanguage]}
                </li>
                <li><input type="checkbox" id="gt_prefs_cb_stat_enable_simple_mode" value="isEnableSimpleMode" />${sb_SimpleMode[translatorSettingLanguage]}</li>
                <li>
                    <input type="checkbox" id="gt_prefs_cb_stat_enable_accurate_mode" value="isEnableAccurateMode" />${sb_AccurateMode[translatorSettingLanguage]}
                    <select id="gt_prefs_se_accurate_engine">
                        <option value="0" ${!isTMode ? 'selected="selected"' : ''}>${sb_AccurateEngineSelection[translatorSettingLanguage][0]}</option>
                        <option value="1" ${isTMode ? 'selected="selected"' : ''}>${sb_AccurateEngineSelection[translatorSettingLanguage][1]}</option>
                    </select>
                </li>
                <li><input type="checkbox" id="gt_prefs_cb_stat_enable_realtime_translation_mode" value="isEnableRealtimeTranslationMode" />${sb_RealTimeTranslationMode[translatorSettingLanguage]}</li>
                <li><input type="checkbox" id="gt_prefs_cb_stat_remove_website_restriction" value="isRemoveWebsiteSelectingRestriction" />${sb_RemoveSelectingRestriction[translatorSettingLanguage]}</li>
                <li><input type="checkbox" id="gt_prefs_cb_stat_using_lingoes" onclick="javascript:document.getElementById('gt_prefs_li_lingoes_config').style.display=(this.checked ? 'block':'none');" value="isActive" />${sb_UseLingoesAPILocalServer[translatorSettingLanguage]}</li>
                <li id="gt_prefs_li_lingoes_config">${sb_LingoesAPIServerIP[translatorSettingLanguage]}
                       <input type="text" maxlength="15" onclick="javascript:this.select();" id="gt_prefs_txt_lingoes_ip" value="${lingoes_serverIp}" />
                       ${sb_LingoesAPIServerPort[translatorSettingLanguage]}
                       <input type="text" maxlength="15" onclick="javascript:this.select();" id="gt_prefs_txt_lingoes_port" value="${lingoes_serverPort}" />
                       <br/>
                       ${sb_LingoesShowingWay[translatorSettingLanguage][3]}
                       <select id="gt_prefs_se_lingoes_showingWay">
                       `;
    for (let i=0;i<3;i++){
            divHtml+=`<option value="${i}" ${lingoes_showingWay===i ? 'selected="selected"':''}>${sb_LingoesShowingWay[translatorSettingLanguage][i]}</option>`
    }
        divHtml+=`</select></li>
                <li>
                    <input type="checkbox" id="gt_prefs_cb_stat_using_youdao" value="isActive" />${sb_UseYoudaoSever[translatorSettingLanguage]}
                    <select id="gt_prefs_se_youdao_trans_way">
                        <option value="0" ${!youdao_isOnlyForSingleWord ? 'selected="selected"' : ''}>${sb_YoudaoTranslationWay[translatorSettingLanguage][0]}</option>
                        <option value="1" ${youdao_isOnlyForSingleWord ? 'selected="selected"' : ''}>${sb_YoudaoTranslationWay[translatorSettingLanguage][1]}</option>
                    </select>
                </li>
                <li>${sb_SourceLanguage[translatorSettingLanguage]}
                    <select id="gt_prefs_se_curSourceLanguage">
                        <option value="0" ${currentSourceLanguage < 0 ? 'selected="selected"' : ''}>${sb_SourceLanguageSetToAuto[translatorSettingLanguage]}</option>`;
    for (let i = 0; i < uLanguageCode.length; i++) {
        if (currentSourceLanguage === i) divHtml += `<option value="${i}" selected="selected">${uLanguageNames[translatorSettingLanguage][i]}-${uRegionNames[translatorSettingLanguage][i]}(${uLanguageCode[i]})</option>`;
        else divHtml += `<option value="${i}">${uLanguageNames[translatorSettingLanguage][i]}-${uRegionNames[translatorSettingLanguage][i]}(${uLanguageCode[i]})</option>`;
    }
    divHtml+=`</select>
                </li>
                <li>${sb_TargetLanguage[translatorSettingLanguage]}
                    <select id="gt_prefs_se_curTargetLanguage">`;
    for (let i=0;i<uLanguageCode.length;i++){
        if (currentTranslateLanguage===i) divHtml += `<option value="${i}" selected="selected">${uLanguageNames[translatorSettingLanguage][i]}-${uRegionNames[translatorSettingLanguage][i]}(${uLanguageCode[i]})</option>`;
        else divHtml+=`<option value="${i}">${uLanguageNames[translatorSettingLanguage][i]}-${uRegionNames[translatorSettingLanguage][i]}(${uLanguageCode[i]})</option>`;
    }
    divHtml += `</select>
                </li>
            </ul>
        <div><button id="gt_prefs_ok">${sb_Confirmation[translatorSettingLanguage][0]}</button><button id="gt_prefs_cancel">${sb_Confirmation[translatorSettingLanguage][1]}</button></div>`;
    div.innerHTML= divHtml;
    div = null;

    var close = function () {
        if (styleNode) {
            styleNode.parentNode.removeChild(styleNode);
        }
        var div = $('setup');
        div.parentNode.removeChild(div);
    };

    on($('ok'), 'click', function () {
        //save lingoes server config
        if(!/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/.test($("txt_lingoes_ip").value.trim())){
            alert(sb_LingoesErrorWarning[translatorSettingLanguage][0]);
            return;
        }
        if (!/^[0-9]{1,5}$/.test($("txt_lingoes_port").value.trim())){
            alert(sb_LingoesErrorWarning[translatorSettingLanguage][1]);
            return;
        }
        var portNum=parseInt($("txt_lingoes_port").value.trim());
        if (portNum<0&&portNum>65535){
            alert(sb_LingoesErrorWarning[translatorSettingLanguage][1]);
            return;
        }
        saveLingoesSettings($("cb_stat_using_lingoes").checked, $("se_lingoes_showingWay").selectedIndex, $("txt_lingoes_ip").value.trim(), $("txt_lingoes_port").value.trim());
        saveYoudaoSettings($("cb_stat_using_youdao").checked, $("se_youdao_trans_way").selectedIndex, null);
        saveModeSettings(isTModeConfigString,(isTMode=($("se_accurate_engine").selectedIndex!==0)));
        saveModeSettings(isEnableSimpleModeConfigString,(isEnableSimpleMode=$("cb_stat_enable_simple_mode").checked));
        saveModeSettings(isEnableAccurateModeConfigString,(isEnableAccurateMode=$("cb_stat_enable_accurate_mode").checked));
        saveModeSettings(isEnableRealtimeTranslationModeConfigString,(isEnableRealtimeTranslationMode=$("cb_stat_enable_realtime_translation_mode").checked));
        saveModeSettings(isRemoveWebsiteSelectingRestrictionConfigString,(isRemoveWebsiteSelectingRestriction=$("cb_stat_remove_website_restriction").checked));
        if($("translatorDiv")){
            if(isEnableSimpleMode){
                $("iconSimplified").style.display="block";
                $("iconDetailed").style.display="none";
            }
            else{
                $("iconSimplified").style.display="none";
                $("iconDetailed").style.display="block";
            }
            if(isEnableAccurateMode){
                $("iconAccurate").style.display="block";
                $("iconNonAccurate").style.display="none";
            }
            else{
                $("iconAccurate").style.display="none";
                $("iconNonAccurate").style.display="block";
            }
            if(isEnableRealtimeTranslationMode){
                $("iconRealtime").style.display="block";
                $("iconNotRealtime").style.display="none";
                $("iconForbidden").style.display="block";
            }
            else{
                $("iconRealtime").style.display="none";
                $("iconNotRealtime").style.display="block";
                $("iconForbidden").style.display="none";
            }
        }
        if(isRemoveWebsiteSelectingRestriction && !isWebsiteRestrictionRemoved){
            removeWebsiteSelectingRestriction();
        }
        if (translatorSettingLanguage===0){
            youdao_isEnabled= $("cb_stat_using_youdao").checked;
            GM_setValue(youdaoConfigNameInStorage,(youdao_isEnabled ? "1":"0")+"|1|0");
        }
        if ($("se_curUILanguage").selectedIndex > 0){
            translatorSettingLanguage= translatorSettingLanguage===0 ? 1:0;
            GM_setValue(translatorSettingLanguageInStorage, translatorSettingLanguage.toString());
            dictURL = "https://" + googleDomain[translatorSettingLanguage] + "/translate_a/single?client=t";
            alURL="https://"+googleDomain[translatorSettingLanguage] +"/?op=translate";
        }
        if ($("se_curSourceLanguage").selectedIndex !== currentSourceLanguage) {
            currentSourceLanguage = $("se_curSourceLanguage").selectedIndex - 1;
            GM_setValue(sourceTranslateLanguageNameInStorage, currentSourceLanguage.toString());
        }
        if ($("se_curTargetLanguage").selectedIndex!==currentTranslateLanguage){
            currentTranslateLanguage= $("se_curTargetLanguage").selectedIndex;
            GM_setValue(targetTranslateLanguageNameInStorage,currentTranslateLanguage.toString());
        }
        var kyc= $("txt_key").value.toUpperCase().charCodeAt(0);
        if (kyc!==hotKey_Code || $("cb_ctrl").checked!==hotKey_Ctrl || $("cb_alt").checked!==hotKey_Alt || $("cb_stat").checked!==hotkey_isActive){
            if (kyc<=128){
                makeAndSaveHotKeyValue($("cb_stat").checked, $("cb_ctrl").checked, $("cb_alt").checked, kyc, hotkeyType_forPlugin);
            }
            else{
                alert(sb_ErrorWarning[translatorSettingLanguage]);
            }
        }
        kyc = $("txt_key_forQS").value.toUpperCase().charCodeAt(0);
        if (kyc !== hotKey_Code_forQS || $("cb_ctrl_forQS").checked !== hotKey_Ctrl_forQS || $("cb_alt_forQS").checked !== hotKey_Alt_forQS || $("cb_stat_forQS").checked !== hotkey_isActive_forQS) {
            if (kyc <= 128) {
                makeAndSaveHotKeyValue($("cb_stat_forQS").checked, $("cb_ctrl_forQS").checked, $("cb_alt_forQS").checked, kyc, hotkeyType_forQS);
            }
            else {
                alert(sb_ErrorWarning[translatorSettingLanguage]);
            }
        }
        close();
    });
    if (lingoes_isEnabled) $("cb_stat_using_lingoes").checked = true;
    else $("li_lingoes_config").style.display = "none";
    $("se_youdao_trans_way").selectedIndex = youdao_isOnlyForSingleWord ? 1 : 0;
    $("se_accurate_engine").selectedIndex= isTMode ? 1:0;
    $("cb_stat_using_youdao").checked = youdao_isEnabled;
    if (hotkey_isActive) $("cb_stat").checked = true;
    if (hotKey_Ctrl)$("cb_ctrl").checked = true;
    if (hotKey_Alt) $("cb_alt").checked = true;
    if (hotkey_isActive_forQS) $("cb_stat_forQS").checked = true;
    if (hotKey_Ctrl_forQS) $("cb_ctrl_forQS").checked = true;
    if (hotKey_Alt_forQS) $("cb_alt_forQS").checked = true;
    if(isEnableSimpleMode) $("cb_stat_enable_simple_mode").checked=true;
    if(isEnableAccurateMode) $("cb_stat_enable_accurate_mode").checked=true;
    if(isEnableRealtimeTranslationMode) $("cb_stat_enable_realtime_translation_mode").checked=true;
    if(isRemoveWebsiteSelectingRestriction)$("cb_stat_remove_website_restriction").checked=true;
    on($('cancel'), 'click', close);
};

function saveLingoesSettings(isEnabled,showingWay,ip,port){
    lingoes_isEnabled=isEnabled;
    var lingoesConfigStr = (lingoes_isEnabled ? "1|" : "0|") + (lingoes_showingWay = showingWay).toString() + "|" + (lingoes_serverIp = ip) + "|" + (lingoes_serverPort = port);
    GM_setValue(lingoesServerConfigNameInStorage, lingoesConfigStr);
}

function saveYoudaoSettings(isEnabled,showingWay,Reserved) {
    youdao_isEnabled=isEnabled;
    youdao_isOnlyForSingleWord = showingWay === 1;
    GM_setValue(youdaoConfigNameInStorage, (youdao_isEnabled ? "1|" : "0|") + (youdao_isOnlyForSingleWord ? "1|" : "0|") + (Reserved == null ? "0" : Reserved));
}

function saveModeSettings(configStr,isEnable){
    GM_setValue(configStr, (isEnable==true ? "1":"0"));
}

function makeAndSaveHotKeyValue(hkStat,hkCtrl,hkAlt,keyCode,hotkeyType) {
    var kv;
    switch(hotkeyType){
        case hotkeyType_forPlugin:
            kv = ((hotkey_isActive = hkStat) ? "1|" : "0|") + ((hotKey_Ctrl = hkCtrl) ? "1|" : "0|") + ((hotKey_Alt = hkAlt) ? "1|" : "0|") + (hotKey_Code = keyCode).toString();
            GM_setValue(hotKeyNameInStorage, kv);
            break;
        case hotkeyType_forQS:
            kv = ((hotkey_isActive_forQS = hkStat) ? "1|" : "0|") + ((hotKey_Ctrl_forQS = hkCtrl) ? "1|" : "0|") + ((hotKey_Alt_forQS = hkAlt) ? "1|" : "0|") + (hotKey_Code_forQS = keyCode).toString();
            GM_setValue(hotKeyNameForQSInStorage,kv);
            break;
        default:
            console.log("Error occured while make and save hot key value.");
            return;
    }
    registerHotKeyEvent(hotkeyType);
}

function getHotKeyValue(hotkeyType) {
    var keyCodes="";
    switch (hotkeyType){
        case hotkeyType_forPlugin:
            keyCodes = GM_getValue(hotKeyNameInStorage, defaultHotKeyValue).split("|");
            if (keyCodes.length !== 4) keyCodes = defaultHotKeyValue.split("|");
            hotKey_Ctrl = keyCodes[1] === "1";
            hotKey_Alt = keyCodes[2] === "1";
            hotKey_Code = parseInt(keyCodes[3]);
            hotkey_isActive = keyCodes[0] === "1";
            break;
        case hotkeyType_forQS:
            keyCodes = GM_getValue(hotKeyNameForQSInStorage, defaultHotKeyValueForQS).split("|");
            if (keyCodes.length !== 4) keyCodes = defaultHotKeyValueForQS.split("|");
            hotKey_Ctrl_forQS = keyCodes[1] === "1";
            hotKey_Alt_forQS = keyCodes[2] === "1";
            hotKey_Code_forQS= parseInt(keyCodes[3]);
            hotkey_isActive_forQS = keyCodes[0] === "1";
            break;
        default:
            return;
    }
    registerHotKeyEvent(hotkeyType);
}

function getLingoesConfigValue(){
    var rst = GM_getValue(lingoesServerConfigNameInStorage, defaultLingoesServerConfigValue).split("|");
    lingoes_isEnabled = rst[0] === "1";
    lingoes_showingWay = parseInt(rst[1]);
    lingoes_serverIp = rst[2];
    lingoes_serverPort = rst[3];
}

function getModesConfigValue(){
    let rst=GM_getValue(isEnableSimpleModeConfigString,isEnableSimpleModeDefaultConfig);
    isEnableSimpleMode= rst==="0" ? false:true;
    rst=GM_getValue(isEnableRealtimeTranslationModeConfigString,isEnableRealtimeTranslationModeDefaultConfig);
    isEnableRealtimeTranslationMode= rst==="0" ? false:true;
    rst=GM_getValue(isRemoveWebsiteSelectingRestrictionConfigString,isRemoveWebsiteSelectingRestrictionDefaultConfig);
    isRemoveWebsiteSelectingRestriction= rst==="0" ? false:true;
    rst=GM_getValue(isEnableAccurateModeConfigString,isEnableAccurateModeDefaultConfig);
    isEnableAccurateMode= rst==="0" ? false:true;
    rst=GM_getValue(isTModeConfigString,isTModeDefaultConfig);
    isTMode= rst==="0" ? false:true;
}

function getYoudaoConfigValue() {
    var rst = GM_getValue(youdaoConfigNameInStorage, defaultYoudaoConfigValue);
    youdao_isEnabled = rst[0] === "1";
    youdao_isOnlyForSingleWord = rst[1] === "1";
}

function registerHotKeyEvent(hotkeyType){
    switch(hotkeyType){
        case hotkeyType_forPlugin:
            if (hotkey_isActive) {
                if (!isHotkeyEventRegistered) {
                    window.document.body.addEventListener("keyup", toggleGoogleTranslate, false);
                    isHotkeyEventRegistered = !0;
                }
            }
            else {
                if (isHotkeyEventRegistered) {
                    window.document.body.removeEventListener("keyup", toggleGoogleTranslate, false);
                    isHotkeyEventRegistered = !1;
                }
            }
            break;
        case hotkeyType_forQS:
            if (hotkey_isActive_forQS) {
                if (!isHotkeyEventRegistered_forQS) {
                    window.document.body.addEventListener("keyup", toggleQuickSearch, false);
                    isHotkeyEventRegistered_forQS = !0;
                }
            }
            else {
                if (isHotkeyEventRegistered_forQS) {
                    window.document.body.removeEventListener("keyup", toggleQuickSearch, false);
                    isHotkeyEventRegistered_forQS = !1;
                }
            }
            break;
        default:
            return;
    }
}

GM_registerMenuCommand("Google select text translator Setting(谷歌划词设置)", setup);

function createToolTip(){
    let tp=$("toolTip");
    if(!tp){
        tp=document.createElement("span");
        tp.id="gt_prefs_toolTip";
        document.body.appendChild(tp);
        GM_addStyle(`
        #gt_prefs_toolTip{position: absolute;background: #eafdff;border-radius: .4em;display:none;color:blue;font-weight:bold;font-size:14px;}
        #gt_prefs_toolTip:after {content: '';position:absolute;bottom: 0;left: 50%;width:auto;height:auto;border: 20px solid transparent;border-top-color: #eafdff;border-bottom: 0;border-left: 0;margin-left: -10px;margin-bottom: -20px;}
        `)
    }
    return tp;
}

var loadingIconUI={
    get(){
        let li=$("loading_icon");
        if(!li){
            li=document.createElement("img");
            li.id="gt_prefs_loading_icon";
            li.setAttribute("src",loadingIconBase64Data);
            li.width=64;
            li.height=64;
            li.style.zIndex=9999;
            li.style.display="none";
            li.style.position="fixed";
            document.body.appendChild(li);
        }
        return li;
    },
    show(pos){
        let li=this.get();
        if(pos){
            li.style.left=pos.mx+"px";
            li.style.top=pos.my+"px";
        }
        li.style.display="block";
    },
    hide(){
        this.get().style.display="none";
    }
}

function createTranslatorIcon(){
    let ci=$("translator_icon");
    if(!ci){
        ci=document.createElement("img");
        ci.id="gt_prefs_translator_icon";
        ci.setAttribute("src",translatorIconBase64Data);
        ci.width=32;
        ci.height=32;
        ci.style.zIndex=9999;
        ci.style.display="none";
        ci.style.position="fixed";
        ci.onmouseover=function(e){
            ci.style.display="none";
            toolTip.show(this,e);
            setTimeout(function(){
                toolTip.hide();
            },2000);
            isTranslatorDisabledTemporarily=!1;
            googleTranslate(e);
        }
        document.body.appendChild(ci);
    }
    return ci;
}

var realtimeTranslatorUI={
    n:0,
    delayTime:5000,
    get:function(){
        let rti=$("realtime_translator_icon");
        if(!rti){
            rti=document.createElement("img");
            rti.id="gt_prefs_realtime_translator_icon";
            rti.setAttribute("src",translatorIconBase64Data);
            rti.width=32;
            rti.height=32;
            rti.style.zIndex=9999;
            rti.style.display="none";
            rti.style.position="fixed";
            rti.onclick=function(e){
                var selectedText = window.getSelection().toString().trim();
                if (selectedText) {
                    oldText=selectedText;
                    searchedTextProcessor.addText(oldText);
                    GetTranslation(oldText, e.clientX, e.clientY);
                }
                realtimeTranslatorUI.hide();
            }
            document.body.appendChild(rti);
        }
        return rti;
    },
    show:function(){
        let rti=$("realtime_translator_icon");
        if(rti){
            rti.style.display="block";
        }
    },
    hide:function(){
        let rti=$("realtime_translator_icon");
        if(rti){
            rti.style.display="none";
            this.destroy();
        }
    },
    delay:function(){
        let rti=$("realtime_translator_icon");
        this.n=setTimeout(function(){
            realtimeTranslatorUI.hide();
        },this.delayTime);
    },
    destroy:function(){
        if(this.n){
            clearTimeout(this.n);
            this.n=0;
        }
    }
};


var toolTip={
    s:{"gt_prefs_iconForbidden":["暂停","Disable"],"gt_prefs_iconPrevious":["上一个","Previous"],"gt_prefs_iconSetting":["设置","Setting"],"gt_prefs_iconSearch":["搜索","Search"],"gt_prefs_iconClose":["关闭","Close"],"gt_prefs_iconNext":["下一个","Next"],"gt_prefs_iconCopy":["拷贝","Copy"],"gt_prefs_iconPin":["固定","Pin to screen"],"gt_prefs_translator_icon":["点击翻译","Click to translate"],"gt_prefs_iconDetailed":["详解模式","Detailed Mode"],"gt_prefs_iconSimplified":["简洁模式","Simplified Mode"],"gt_prefs_iconRealtime":["实时翻译模式","Real-time Translation Mode"],"gt_prefs_iconNotRealtime":["点击图标翻译模式","Click-icon Translation Mode"],"gt_prefs_tBar":["按住拖动窗口","Press down and drag"],"gt_prefs_iconAccurate":["精确翻译模式","Accurate Translation Mode"],"gt_prefs_iconNonAccurate":["普通模式","Normal Mode"]},
    show(el,e){
        let tp=createToolTip();
        tp.innerHTML=toolTip.s[el.id][translatorSettingLanguage];
        let oL=0;
        if($("translatorDiv"))if($("tBar")){oL=$("translatorDiv").offsetLeft+$("tBar").offsetLeft;}
        let oS= translatorSettingLanguage===0 ? (tp.innerHTML.length*tp.innerHTML.length-Math.ceil(tp.innerHTML.length/5)*10+5):(tp.innerHTML.length*2-10+Math.ceil(tp.innerHTML.length/10)*10);
        tp.style.left=(el.offsetLeft+oL-oS)+"px";
        tp.style.top=(el.offsetTop+el.parentNode.offsetTop+el.parentNode.parentNode.offsetTop-40)+"px";
        tp.style.display="block";
    },
    hide(){
        $("toolTip").style.display="none";
    }
};

function toggleGoogleTranslate(e) {
    if(e.keyCode === 27){
        if(isToolBarMoving){
            window.removeEventListener("mousemove", divMove, true);
            isToolBarMoving=!1;
            return;
        }
    }
    if (e.keyCode === hotKey_Code && (hotKey_Alt ? e.altKey : e.altKey === false) && (hotKey_Ctrl ? e.ctrlKey : e.ctrlKey === false)) {
        if (isEnabled) {
            window.document.body.removeEventListener("mouseup", googleTranslate, false);
            alert(translatorSettingLanguage ? "Google select text translator is disabled!":"谷歌点击划词翻译,已禁用!");
            isEnabled = isTranslatorDisabledTemporarily = false;
			translatorDivUI.hide();
        } else {
            window.document.body.addEventListener("mouseup", googleTranslate, false);
            alert(translatorSettingLanguage ? "Google select text translator is enabled!" : "谷歌点击划词翻译,已启用!");
            isEnabled = isTranslatorDisabledTemporarily = true;
        }
    }
}

var quickSearchDiv=null;
var searchBox=null;
var oldSIdx=-1,oldDIdx=-1;
function showQuickSearch(){
  //Showing quick searching pannel
  if (!quickSearchDiv){
    GM_addStyle(`
        #gt_prefs_quickSearch { position:fixed;z-index:998;top:30%;left:30%;width:40%;padding:0.3%;background:radial-gradient(ellipse at center, #EDF4FC 0%,#e3edf9 60%,#c9d7e5 80%, #c3cedb 90%, #bac6d3 95%, #adb5bc 100%);border:1px solid black;box-shadow:-2px 0px 9px 5px #898D91;opacity:0.9; border-radius:5px;}
        #gt_prefs_quickSearch * { color:black;text-align:left;line-height:normal;font-size:12px; }
        #gt_prefs_quickSearch a { color:black;text-decoration:underline; }
        #gt_prefs_quickSearch div { text-align:center;font-weight:bold;font-size:14px; }
        #gt_prefs_quickSearch ul { margin:15px 0 15px 0;padding:0;list-style:none;background:#eee;border:0; }
        #gt_prefs_quickSearch input {width:99%;border:1px solid gray;padding:2px;background:white;text-align:center;}
        #gt_prefs_quickSearch select {width:auto;border:1px solid gray;padding:2px;background:white;text-align:center;color:Green;}
        #gt_prefs_quickSearch li { margin:0;padding:6px 0;vertical-align:middle;background:#eee;border:0 }
        #gt_prefs_quickSearch button { width:150px;margin:0 10px;text-align:center;background:transparent;border-radius:5px;box-shadow:2px 2px 2px 1px gray;}
        #gt_prefs_quickSearch textarea { width:98%; height:98%; margin:3px 0; }
        #gt_prefs_quickSearch p,b { font-weight: bold;color:Green; margin:2px 0px; font-family: "微软雅黑", sans-serif;text-align:center; }
        #gt_prefs_quickSearch button:disabled { color: graytext; }
    `);
    quickSearchDiv = document.createElement('div');
    quickSearchDiv.id = 'gt_prefs_quickSearch';
    document.body.appendChild(quickSearchDiv);
    searchBox=null;
    searchBox=document.createElement("input");
    searchBox.id ="gt_prefs_searchBox";
    searchBox.value = "";
    searchBox.align="center";
    searchBox.onkeyup=function (e) {
        //ENTER
        if (e.keyCode===13){
            queryIt();
        }
        //ESC
        if (e.keyCode===27){
            if (searchBox.value==="") quickSearchDiv.style.display = "none";
            else searchBox.value="";
        }
    }
    var queryIt=function () {
        var queryStr = searchBox.value.trim();
        if (queryStr === "") {
            quickSearchDiv.style.display = "none";
            return;
        }
        var nSIdx= $("srcLanguageSelector").selectedIndex;
        var nDIdx= $("dstLanguageSelector").selectedIndex;
        if (oldText===queryStr){
            if (nSIdx===oldSIdx&&nDIdx===oldDIdx) {
                var translatorDiv = $("translatorDiv");
                if (translatorDiv) {
                    if (translatorDiv.style.display === "none") translatorDiv.style.display = "block";
                }
                return;
            }
        }
        translateIt((oldSIdx=nSIdx) <= 0 ? "auto" : uLanguageCode[nSIdx - 1], uLanguageCode[(oldDIdx=nDIdx)], oldText = queryStr, quickSearchDiv.offsetLeft, quickSearchDiv.offsetTop + quickSearchDiv.offsetHeight);
    }
    var hintText=document.createElement("p");
    hintText.id = "gt_prefs_hintText";
    hintText.innerText=translatorSettingLanguage===0 ? "输入要查询的单词或句子(按回车进行查询,按ESC退出查询):":"Enter the word or sentence you want to query ( Press enter to query, ESC to exit or clear.) :";
    var srcLanguageSelector=document.createElement("select");
    srcLanguageSelector.id = "gt_prefs_srcLanguageSelector";
    var divHtml=`<option value="0" ${currentSourceLanguage < 0 ? 'selected="selected"' : ''}>${translatorSettingLanguage===0 ? "自动检测":"Auto Detect"}</option>;`;
    for (let i = 0; i < uLanguageCode.length; i++) {
        if (currentSourceLanguage === i) divHtml += `<option value="${i}" selected="selected">${uLanguageNames[translatorSettingLanguage][i]}-${uRegionNames[translatorSettingLanguage][i]}(${uLanguageCode[i]})</option>`;
        else divHtml += `<option value="${i}">${uLanguageNames[translatorSettingLanguage][i]}-${uRegionNames[translatorSettingLanguage][i]}(${uLanguageCode[i]})</option>`;
    }
    srcLanguageSelector.innerHTML=divHtml;
    var dstLanguageSelector=document.createElement("select");
    dstLanguageSelector.id="gt_prefs_dstLanguageSelector";
    divHtml = "";
    for (let i = 0; i < uLanguageCode.length; i++) {
        if (currentTranslateLanguage === i) divHtml += `<option value="${i}" selected="selected">${uLanguageNames[translatorSettingLanguage][i]}-${uRegionNames[translatorSettingLanguage][i]}(${uLanguageCode[i]})</option>`;
        else divHtml += `<option value="${i}">${uLanguageNames[translatorSettingLanguage][i]}-${uRegionNames[translatorSettingLanguage][i]}(${uLanguageCode[i]})</option>`;
    }
    dstLanguageSelector.innerHTML=divHtml;
    var languageChooseParagraph= document.createElement("p");
    languageChooseParagraph.appendChild(document.createTextNode(translatorSettingLanguage === 0 ? "源语言:" : "Source:"));
    languageChooseParagraph.appendChild(srcLanguageSelector);
    languageChooseParagraph.appendChild(document.createTextNode(translatorSettingLanguage === 0 ? "==>目标语言:" : "==>Destination:"));
    languageChooseParagraph.appendChild(dstLanguageSelector);
    var btnQuery=document.createElement("button");
    btnQuery.onclick=queryIt;
    btnQuery.innerText = translatorSettingLanguage === 0 ? "查询" : "Query";
    var btnExit=document.createElement("button");
    btnExit.onclick=function (e) {
        quickSearchDiv.style.display = "none";
    }
    btnExit.innerText = translatorSettingLanguage === 0 ? "退出" : "Exit";
    var btnParagraph=document.createElement("p");
    btnParagraph.appendChild(btnQuery);
    btnParagraph.appendChild(btnExit);
    quickSearchDiv.appendChild(hintText);
    quickSearchDiv.appendChild(searchBox);
    quickSearchDiv.appendChild(languageChooseParagraph);
    quickSearchDiv.appendChild(btnParagraph);
    searchBox.focus();
    return;
}
if (quickSearchDiv.style.display === "none"){
    quickSearchDiv.style.display = "block";
    searchBox.focus();
}
else quickSearchDiv.style.display="none";
}
function toggleQuickSearch(e) {
    if (e.keyCode === hotKey_Code_forQS && (hotKey_Alt_forQS ? e.altKey : e.altKey === false) && (hotKey_Ctrl_forQS ? e.ctrlKey : e.ctrlKey === false)) {
      showQuickSearch();
    }
}

function GetTranslation(queryStr, mx, my) {
    currentTranslateLanguage = parseInt(GM_getValue(targetTranslateLanguageNameInStorage, defaultTranslateLanguage));
    currentSourceLanguage = parseInt(GM_getValue(sourceTranslateLanguageNameInStorage, defaultSourceLanguage));
    queryStr=optimizeQueryString(queryStr);
    if (lingoes_isEnabled){
        var url=null;
        if (lingoes_showingWay<2){
            if (!/\s+/gi.test(queryStr)) {
                switch(lingoes_showingWay){
                    case 0:
                        url = `http://${lingoes_serverIp}:${lingoes_serverPort}/lingoes?cmd=mini_search&text=${encodeURI(queryStr)}&pos_x=${mx}&pos_y=${my}`;
                        break;
                    case 1:
                        url = `http://${lingoes_serverIp}:${lingoes_serverPort}/lingoes?cmd=main_search&text=${encodeURI(queryStr)}&pos_x=${mx}&pos_y=${my}`;
                        break;
                }
            }
        }
        else{
            url = `http://${lingoes_serverIp}:${lingoes_serverPort}/lingoes?cmd=main_translator&text=${encodeURI(queryStr)}&pos_x=${mx}&pos_y=${my}`;
        }
        if (url!=null){
            GM_xmlhttpRequest({
                method:"GET",
                url:url,
                headers: {
                    "User-Agent": UA,
                    "Accept": "application/json"
                },
                onerror: function (err) {
                    alert(translatorSettingLanguage===0 ? "与灵格斯API服务器的通信失败,已自动禁用灵格斯词典调用功能!\n请保证您的电脑安装有灵格斯词典软件,并在设置中启用了API服务器,且正确的设置了IP与端口地址!":"Failed to fetch from lingoes API sever, disable the query from lingoes automatically!\n Please ensure you got a lingoes, and enabled the API server from it's setting, and sets the right ip and port number in the setting of this plugin.");
                    console.log("failed to fetch from lingoes sever, disable lingoes server automatically.",err);
                    saveLingoesSettings(false,lingoes_showingWay,lingoes_serverIp,lingoes_serverPort);
                }
            });
        }
    }
    translateIt(currentSourceLanguage < 0 ? "auto" : uLanguageCode[currentSourceLanguage], uLanguageCode[currentTranslateLanguage], queryStr, mx, my);
}

function checkIsSoundIconClicked(e) {
    return (e.target.className === "gt_prefs_img_for_play_sound"||e.target.id==="gt_prefs_show_or_hide_examples");
    //return e.target.id === "gt_prefs_img_for_play_sound1" || e.target.id === "gt_prefs_img_for_play_sound2" || e.target.id === "gt_prefs_img_for_play_sound3";
}

function mouseDown(e){
    window.addEventListener('mousemove', divMove, true);
    isToolBarMoving=!0;
    var div=$("translatorDiv");
    tBarOffsetX=e.clientX-div.offsetLeft;
    tBarOffsetY=e.clientY-div.offsetTop;
}

function divMove(e){
    var div = $("translatorDiv");
    div.style.position = 'absolute';
    let xpos=e.clientX - tBarOffsetX;
    let ypos=e.clientY - tBarOffsetY;
    div.style.top = ypos + "px";
    div.style.left = xpos + "px";
}
function optimizeQueryString(t){
    return t.replace('-\n', '').replace('\n', ' ').replace(/[&]+/g, currentSourceLanguage >= 0 && currentSourceLanguage < 3 ? "和" : " and ").replace(/[\+]+/g, currentSourceLanguage >= 0 && currentSourceLanguage < 3 ? "加" : " plus ");
}
function googleTranslate(e) {
    if(isToolBarMoving){
        window.removeEventListener("mousemove", divMove, true);
        isToolBarMoving=!1;
        return;
    }
    if (checkIsSoundIconClicked(e))return;
    var selectedText = window.getSelection().toString().trim();
    if(selectedText){
        if(!isEnableRealtimeTranslationMode){
            let rti=realtimeTranslatorUI.get();
            rti.style.top=(e.clientY+15)+"px";
            rti.style.left=(e.clientX+15)+"px";
            translatorDivUI.hide();
            rti.style.display="block";
            realtimeTranslatorUI.destroy();
            realtimeTranslatorUI.delay();
            return;
        }
        if(isTranslatorDisabledTemporarily){
            let ci=createTranslatorIcon();
            ci.style.top=(e.clientY+15)+"px";
            ci.style.left=(e.clientX+15)+"px";
            translatorDivUI.hide();
            ci.style.display="block";
            setTimeout(function(){
                createTranslatorIcon().style.display="none";
            },5000);
            return;
        }
        if (selectedText === oldText && $('iconPrevious').style.display==="block"){
            if(!translatorDivUI.isShowing())translatorDivUI.show(e.clientX,e.clientY);
            return;
        }
        oldText = selectedText;
        searchedTextProcessor.addText(oldText);
        GetTranslation(oldText, e.clientX, e.clientY);
    }
    else{
        if(!isPinned)translatorDivUI.hide();
        if(!isEnableRealtimeTranslationMode) realtimeTranslatorUI.hide();
        if(isTranslatorDisabledTemporarily)createTranslatorIcon().style.display="none";
    }
}

var translatorDivUI={
	show(mx,my){
		var translatorDiv = $("translatorDiv");
		if(translatorDiv){
			translatorDiv.style.display="block";
            if(mx!=null && my!=null){
                translatorDiv.style.left = mx + "px";
                if (mx + 400 + 30 >= window.innerWidth) {
                    translatorDiv.style.left = parseInt(translatorDiv.style.left) - 400 + "px";
                }
                if(translatorDiv.offsetHeight>=window.innerHeight){
                    translatorDiv.style.height=(window.innerHeight/2)+"px";
                    translatorDiv.style.overflow="auto";
                }
                else{
                    translatorDiv.style.height="auto";
                    translatorDiv.style.overflow="visible";
					if(translatorDiv.offsetHeight>=window.innerHeight){
						translatorDiv.style.height=(window.innerHeight/2)+"px";
						translatorDiv.style.overflow="auto";
					}
                }
                translatorDiv.style.top=(my>(window.innerHeight-translatorDiv.offsetHeight) ? window.innerHeight-translatorDiv.offsetHeight+self.pageYOffset:my+self.pageYOffset)+"px";
            }
		}
	},
	hide(){
		var translatorDiv = $("translatorDiv");
		if(translatorDiv){
			translatorDiv.style.display="none";
		}
    },
    isShowing(){
		var translatorDiv = $("translatorDiv");
        return translatorDiv!=null ? translatorDiv.style.display==="block":!1;
    }
};

var timerHide=-1;
function popup(mx, my, result) {
    loadingIconUI.hide();
    var translatorDiv = $("translatorDiv");
    var contentDiv=$("contentDiv");
    var clearTimerHide=function () {
        if (timerHide > 0){
            clearTimeout(timerHide);
            timerHide=-1;
        }
    }
    if (!translatorDiv){
        translatorDiv = document.createElement('div');
        translatorDiv.id = "gt_prefs_translatorDiv";
        document.body.appendChild(translatorDiv);
        translatorDiv.style.color = "black";
		translatorDiv.style.fontSize="12px";
        translatorDiv.style.textAlign = "left";
        translatorDiv.style.display = "block";
        translatorDiv.style.position = "absolute";
        translatorDiv.style.background = "radial-gradient(ellipse at center, #EDF4FC 0%,#e3edf9 60%,#c9d7e5 80%, #c3cedb 90%, #bac6d3 95%, #adb5bc 100%)";
        translatorDiv.style.borderRadius = "5px";
		translatorDiv.style.boxShadow = "-2px 0px 9px 5px #898D91";
        translatorDiv.style.opacity = "0.9";
        translatorDiv.style.padding="5px";
        translatorDiv.style.margin="0";
		translatorDiv.style.zIndex = 900;
        translatorDiv.style.width = "400px";
        translatorDiv.style.height="auto";
        translatorDiv.style.wordWrap = "break-word";
        translatorDiv.onmouseleave=function (e) {
            if(!isPinned){
                timerHide=setTimeout(function(){translatorDiv.style.display = "none"},10000);
            }
        }
        translatorDiv.onmouseenter= clearTimerHide;
        GM_addStyle(`
            .gt_prefs_img_for_play_sound{width:16px;height:16px;}
            .gt_prefs_translator_div_li{list-style:none;margin:0;padding:2px;background:none;width:100%;color:inherit;font-family:Tahoma;font-size:14px;font-weight:bold;}
            .gt_prefs_translator_div_li b{color:Green;}
            .gt_prefs_translator_div_li a{color:Blue;}
            .gt_prefs_translator_div_li span{color:#39538c;font-weight:normal;}
            .gt_prefs_translator_div_li p{color:Red;font-size:16px;}
            .gt_prefs_translator_div_li em{color:#131930;font-style:normal;}
            .gt_prefs_translator_div_li h1{color:#771b1b;font-size:18px;}
            #gt_prefs_sample_ul li{font-weight:normal;list-style-type:upper-roman;}
            .gt_prefs_main_word{font-weight:bold;color:#116f89;};
        `);
        let tBar=document.createElement('div');
        tBar.id="gt_prefs_tBar";
        tBar.style.width="100%";
        tBar.style.height="20px";
		tBar.style.borderRadius="5px";
        tBar.onmouseenter=function(e){
            tBar.style.background="linear-gradient(90deg, #ABCDEF 0%, #ABCDEF 40%, #E3EDF9 50%,#C3CEDB 100%)";
            tBar.style.opacity="0.8";
            toolTip.show(this,e);
        }
        tBar.onmouseout=function(e){
            tBar.style.background="transparent";
            toolTip.hide();
        }
        on(tBar,'mousedown', mouseDown);
        let iconAccurate=document.createElement('img');
        let iconNonAccurate=document.createElement('img');
        let iconRealtime=document.createElement('img');
        let iconNotRealtime=document.createElement('img');
        let iconForbidden=document.createElement('img');
        let iconSimplified=document.createElement('img');
        let iconDetailed=document.createElement('img');
        let iconPrevious=document.createElement('img');
        let iconSetting=document.createElement('img');
        let iconSearch=document.createElement('img');
        let iconClose=document.createElement('img');
        let iconNext=document.createElement('img');
        let iconCopy=document.createElement('img');
        let iconPin=document.createElement('img');
        tBar.style.margin=iconAccurate.style.margin=iconNonAccurate.style.margin=iconRealtime.style.margin=iconNotRealtime.style.margin=iconForbidden.style.margin=iconSimplified.style.margin=iconDetailed.style.margin=iconPrevious.style.margin=iconSetting.style.margin=iconSearch.style.margin=iconClose.style.margin=iconNext.style.margin=iconCopy.style.margin=iconPin.style.margin="0";
        tBar.style.padding=iconAccurate.style.padding=iconNonAccurate.style.padding=iconRealtime.style.padding=iconNotRealtime.style.padding=iconForbidden.style.padding=iconSimplified.style.padding=iconDetailed.style.padding=iconPrevious.style.padding=iconSetting.style.padding=iconSearch.style.padding=iconClose.style.padding=iconNext.style.padding=iconCopy.style.padding=iconPin.style.padding="0";
        iconRealtime.setAttribute('src',realtimeIconBase64Data);
        iconAccurate.setAttribute('src',accurateIconBase64Data);
        iconNonAccurate.setAttribute('src',nonAccurateIconBase64Data);
        iconNotRealtime.setAttribute('src',notRealtimeIconBase64Data);
        iconForbidden.setAttribute('src',forbiddenIconBase64Data);
        iconSimplified.setAttribute('src',simplifiedIconBase64Data);
        iconDetailed.setAttribute('src',detailedIconBase64Data);
        iconPrevious.setAttribute('src',previousIconBase64Data);
        iconSetting.setAttribute('src',settingIconBase64Data);
        iconSearch.setAttribute('src',searchIconBase64Data);
        iconClose.setAttribute('src',closeIconBase64Data);
        iconNext.setAttribute('src',nextIconBase64Data);
        iconCopy.setAttribute('src',copyIconBase64Data);
        iconPin.setAttribute('src',pinIconBase64Data);
        iconNonAccurate.width=iconAccurate.width=iconForbidden.width=iconRealtime.width=iconNotRealtime.width=iconSimplified.width=iconDetailed.width=iconPrevious.width=iconSetting.width=iconSearch.width=iconClose.width=iconNext.width=iconCopy.width=iconPin.width=20;
        iconNonAccurate.height=iconAccurate.height=iconForbidden.height=iconRealtime.height=iconNotRealtime.height=iconSimplified.height=iconDetailed.height=iconPrevious.height=iconSetting.height=iconSearch.height=iconClose.height=iconNext.height=iconCopy.height=iconPin.height=20;
        iconForbidden.style.cssFloat=iconAccurate.style.cssFloat=iconNonAccurate.style.cssFloat=iconRealtime.style.cssFloat=iconNotRealtime.style.cssFloat=iconSimplified.style.cssFloat=iconDetailed.style.cssFloat=iconPrevious.style.cssFloat=iconSetting.style.cssFloat=iconSearch.style.cssFloat=iconClose.style.cssFloat=iconNext.style.cssFloat=iconCopy.style.cssFloat=iconPin.style.cssFloat="right";
        iconForbidden.id="gt_prefs_iconForbidden";
        iconForbidden.style.border=(isEnabled ? "none":"1px solid red");
        iconForbidden.onclick=function(e){
            isTranslatorDisabledTemporarily=!0;
            $("translatorDiv").style.display="none";
        }
        iconForbidden.onmouseenter=function(e){
            toolTip.show(this,e);
        }
        iconForbidden.onmouseleave=function(e){
            toolTip.hide();
        }
        iconAccurate.id="gt_prefs_iconAccurate";
        iconAccurate.onclick=function(e){
            this.style.display="none";
            saveModeSettings(isEnableAccurateModeConfigString,(isEnableAccurateMode=false));
            $("iconNonAccurate").style.display="block";
        }
        iconAccurate.onmouseenter=function(e){
            toolTip.show(this,e);
        }
        iconAccurate.onmouseleave=function(e){
            toolTip.hide();
        }
        iconNonAccurate.id="gt_prefs_iconNonAccurate";
        iconNonAccurate.onclick=function(e){
            this.style.display="none";
            saveModeSettings(isEnableAccurateModeConfigString,(isEnableAccurateMode=true));
            $("iconAccurate").style.display="block";
        }
        iconNonAccurate.onmouseenter=function(e){
            toolTip.show(this,e);
        }
        iconNonAccurate.onmouseleave=function(e){
            toolTip.hide();
        }
        isEnableAccurateMode ? iconNonAccurate.style.display="none":iconAccurate.style.display="none";
        iconRealtime.id="gt_prefs_iconRealtime";
        iconRealtime.onclick=function(e){
            saveModeSettings(isEnableRealtimeTranslationModeConfigString,isEnableRealtimeTranslationMode=false);
            this.style.display="none";
            $("iconNotRealtime").style.display="block";
            $("iconForbidden").style.display="none";
        }
        iconRealtime.onmouseenter=function(e){
            toolTip.show(this,e);
        }
        iconRealtime.onmouseleave=function(e){
            toolTip.hide();
        }
        iconNotRealtime.id="gt_prefs_iconNotRealtime";
        iconNotRealtime.onclick=function(e){
            saveModeSettings(isEnableRealtimeTranslationModeConfigString,isEnableRealtimeTranslationMode=true);
            this.style.display="none";
            $("iconRealtime").style.display="block";
            $("iconForbidden").style.display="block";
        }
        iconNotRealtime.onmouseenter=function(e){
            toolTip.show(this,e);
        }
        iconNotRealtime.onmouseleave=function(e){
            toolTip.hide();
        }
        if(isEnableRealtimeTranslationMode){
            iconNotRealtime.style.display="none";
        }
        else{
            iconRealtime.style.display="none";
            iconForbidden.style.display="none";
        }
        iconSimplified.id="gt_prefs_iconSimplified";
        iconSimplified.onclick=function(e){
            this.style.display="none";
            $("iconDetailed").style.display="block";
            saveModeSettings(isEnableSimpleModeConfigString,(isEnableSimpleMode=false));
        }
        iconSimplified.onmouseenter=function(e){
            toolTip.show(this,e);
        }
        iconSimplified.onmouseleave=function(e){
            toolTip.hide();
        }
        iconDetailed.id="gt_prefs_iconDetailed";
        iconDetailed.onclick=function(e){
            this.style.display="none";
            $("iconSimplified").style.display="block";
            saveModeSettings(isEnableSimpleModeConfigString,(isEnableSimpleMode=true));
        }
        iconDetailed.onmouseenter=function(e){
            toolTip.show(this,e);
        }
        iconDetailed.onmouseleave=function(e){
            toolTip.hide();
        }
        isEnableSimpleMode==!1 ? iconSimplified.style.display="none":iconDetailed.style.display="none";
        iconPrevious.id="gt_prefs_iconPrevious";
        iconPrevious.style.display="none";
        iconPrevious.onmouseenter=function(e){
            toolTip.show(this,e);
        }
        iconPrevious.onmouseleave=function(e){
            toolTip.hide();
        }
        iconPrevious.onclick=function(e){
            searchedTextProcessor.showPreviousText();
        }
        iconNext.id="gt_prefs_iconNext";
        iconNext.style.display="none";
        iconNext.onmouseenter=function(e){
            toolTip.show(this,e);
        }
        iconNext.onmouseleave=function(e){
            toolTip.hide();
        }
        iconNext.onclick=function(e){
            searchedTextProcessor.showNextText();
        }
        iconSearch.id="gt_prefs_iconSearch";
        iconSearch.onmouseenter=function(e){
            toolTip.show(this,e);
        }
        iconSearch.onmouseleave=function(e){
            toolTip.hide();
        }
        iconSearch.onclick=function(e){
            showQuickSearch();
        }
        iconSetting.id="gt_prefs_iconSetting";
        iconSetting.onmouseenter=function(e){
            toolTip.show(this,e);
        }
        iconSetting.onmouseleave=function(e){
            toolTip.hide();
        }
        iconSetting.onclick=function(e){
            setup();
            $("setup").style.display= $("setup").style.display==="block" ? "none":"block";

        }
        iconClose.id="gt_prefs_iconClose";
        iconClose.onmouseenter=function(e){
            toolTip.show(this,e);
        }
        iconClose.onmouseleave=function(e){
            toolTip.hide();
        }
        iconClose.onclick=function(e){
            $("translatorDiv").style.display="none";
        }
        iconCopy.id="gt_prefs_iconCopy";
        iconCopy.onmouseenter=function(e){
            toolTip.show(this,e);
        }
        iconCopy.onmouseleave=function(e){
            toolTip.hide();
        }
        iconCopy.onclick=function(e){
            if(window.getSelection){
                let range = document.createRange();
                range.selectNode($("contentDiv"));
                window.getSelection().removeAllRanges();
                window.getSelection().addRange(range);
                document.execCommand("Copy",false,null);
				window.getSelection().removeAllRanges();
                alert(translatorSettingLanguage===0 ? "复制成功":"Copy Done");
            }
        }
        iconPin.id="gt_prefs_iconPin";
        iconPin.style.border="1px none";
        iconPin.onmouseenter=function(e){
            toolTip.show(this,e);
        }
        iconPin.onmouseleave=function(e){
            toolTip.hide();
        }
        iconPin.onclick=function(e){
            iconPin.style.border=((isPinned=!isPinned) ? "solid":"none");
        }
        tBar.appendChild(iconClose);
        tBar.appendChild(iconPin);
        tBar.appendChild(iconSetting);
        tBar.appendChild(iconSearch);
        tBar.appendChild(iconForbidden);
        tBar.appendChild(iconSimplified);
        tBar.appendChild(iconDetailed);
        tBar.appendChild(iconAccurate);
        tBar.appendChild(iconNonAccurate);
        tBar.appendChild(iconRealtime);
        tBar.appendChild(iconNotRealtime);
        tBar.appendChild(iconCopy);
        tBar.appendChild(iconNext);
        tBar.appendChild(iconPrevious);
        translatorDiv.appendChild(tBar);
        contentDiv=document.createElement("div");
        contentDiv.id="gt_prefs_contentDiv";
        contentDiv.style.margin=contentDiv.style.padding="0";
        contentDiv.onclick = function (e) {
            if(!isPinned){
                if(!checkIsSoundIconClicked(e))translatorDiv.style.display="none";
            }
        }
        translatorDiv.appendChild(contentDiv);
    }
    else{
        contentDiv.innerHTML="";
        clearTimerHide();
        translatorDiv.style.display="block";
    }
    // parse
    var resultTxt = getTargetAnswer(result);
    if (resultTxt) createShower();
    else {
        console.log("resultTxt is null!");
        return;
    }
    // main window
    // first insert into dom then there is offsetHeight!IMPORTANT!
    if(!isPinned){
        translatorDivUI.show(mx,my);
    }

    function createShower() {
        var el = null;
        switch (resultTxt[0]) {
            case ANS_TYPE_ACCURATE:
                    el = document.createElement("div");
                    el.innerHTML=resultTxt[1];
                    el.style.fontSize="14px";
                    el.style.fontWeight="normal";
                    el.style.color="Green";
                break;
            case ANS_TYPE_ZDIC_HTML:
                el = document.createElement("div");
                el.id="shiyi_content";
                el.innerHTML=zdictStyle+resultTxt[1];
                el.style.height = "500px";
                el.style.width="100%";
                el.style.margin = "0";
                el.style.padding = "0";
                el.style.border="none";
                el.style.color="black";
                el.style.textDecoration="none";
                el.style.overflow = "auto";
                break;
            case ANS_TYPE_YOUDAO_SENTENCE:
                el = document.createElement('ul');
                el.style.margin = "0";
                el.style.padding = "0";
                resultTxt[1].translation.map(function (trans) {
                    var li = document.createElement('li');
                    li.className="gt_prefs_translator_div_li";
                    li.appendChild(document.createTextNode(trans));
                    el.appendChild(li);
                });
                break;
            case ANS_TYPE_YOUDAO_WORD:
                el = document.createElement("div");
                el.style.fontSize = "12px";
                el.style.fontFamily="Tahoma";
                el.style.margin = "0";
                el.style.padding = "0";
                var basic = resultTxt[1].basic;
                var header = document.createElement('p');
                // header
                var span = document.createElement('span');
                span.innerHTML = resultTxt[1].query;
                header.appendChild(span);
                // phonetic if there is
                var phonetic = basic.phonetic;
                if (phonetic) {
                    var phoneticNode = document.createElement('span');
                    phoneticNode.innerHTML = '[' + phonetic + ']&nbsp;&nbsp;';
                    phoneticNode.style.cursor = "pointer";
                    header.appendChild(phoneticNode);
                    var img3 = document.createElement('img');
                    img3.setAttribute('src', speakerIconBase64Data);
                    img3.className = "gt_prefs_img_for_play_sound";
                    img3.onclick = function (e) {
                        if (e.target === img3) {
                            e.stopPropagation();
                            YouDaoPlay(resultTxt[1].query);
                        }
                    }
                    header.appendChild(img3);
                }
                header.style.color = "darkBlue";
                header.style.margin = "0";
                header.style.padding = "0";
                span.style.fontweight = "900";
                span.style.color = "black";

                el.appendChild(header);
                var hr = document.createElement('hr');
                hr.style.margin = "0";
                hr.style.padding = "0";
                hr.style.height = "1px";
                hr.style.borderTop = "dashed 1px black";
                el.appendChild(hr);
                var ul = document.createElement('ul');
                // ul style
                ul.style.margin = "0";
                ul.style.padding = "0";
                basic.explains.map(function (trans) {
                    var li = document.createElement('li');
                    li.style.listStyle = "none";
                    li.style.margin = "0";
                    li.style.padding = "0";
                    li.style.background = "none";
                    li.style.color = "inherit";
                    li.appendChild(document.createTextNode(trans));
                    ul.appendChild(li);
                });
                el.appendChild(ul);
                break;
            case ANS_TYPE_GOOGLE_RESULT:
                el=processGoogleResult(JSON.parse(resultTxt[1]));
                break;
            default:
                return;
        }
        contentDiv.appendChild(el);
    }
}

function processGoogleResult(arr){
    let el = document.createElement('ul');
    el.className="gt_prefs_translator_div_li";
    el.style.padding = el.style.margin = "0";
    let z={
        sb_details:["【翻译】","<< Translation >>"],
        sb_meaning:["【释义】","<< Meaning >>"],
        sb_suggestedTranslation:["【可能的翻译】","<< Other Translation >>"],
        sb_more:["【点击显示例句】","<< Click to show examples >>"],
        sb_hideMore:["【点击隐藏例句】","<< Click to hide examples >>"],
        ce(tpe){
            let n=document.createElement(tpe);
            if(tpe==="li")n.className = "gt_prefs_translator_div_li";
            return n;
        },
        ap(elm){
            if(elm){
                el.appendChild(elm);
                return el;
            }
            return null;
        },
        app(els,eld){
            if(els){
                if(eld){
                    els.appendChild(eld);
                    return els;
                }
            }
            return null;
        },
        aps(ela,tpe,innerStr){
            if(innerStr){
                if(tpe==="pr"){
                    innerStr="["+innerStr+"]";
                    tpe="a";
                }
                let s=z.ce(tpe);
                s.style.padding=s.style.margin="0";
                s.innerHTML= innerStr;
                ela.appendChild(s);
                return ela;
            }
            return null;
        },
        cv(txt,lan){
            if(txt){
                var img1 = z.ce('img');
                img1.setAttribute('src', speakerIconBase64Data);
                img1.className = "gt_prefs_img_for_play_sound";
                img1.onclick=function () {
                    playTTS(lan,txt);
                }
                return img1;
            }
        },
        apv(ela,txt,lan){
            if(txt){
                ela.appendChild(z.cv(txt,lan));
                return ela;
            }
            return null;
        },
        gor(arr,el,isShowTitle){
            if(arr[5]){
                if(arr[5][0][2]){
                    if(isShowTitle)z.app(el,z.aps(z.ce("li"),"h1",z.sb_suggestedTranslation[translatorSettingLanguage]));
                    for(let i=0;i<arr[5][0][2].length;i++){
                        let lis=z.ce("li");
                        lis.innerHTML=`<i>${i+1}.&nbsp</i>`;
                        for(let ii=0;ii<arr[5].length;ii++){
                            if(arr[5][ii][2]){
                                if(arr[5][ii][2][i]){
                                    z.aps(lis,"span",arr[5][ii][2][i][0]);
                                }
                            }
                        }
                        z.app(el,lis);
                    }
                    return true;
                }
            }
            return false;
        }
    };
    if(arr){
        let len=arr.length;
        if(len>8){
            if(isEnableSimpleMode)if(z.gor(arr,el,false))return el;
            if(arr[0]){
                let totalRet=arr[0].length-1;
                let b1=new Array(totalRet);
                let b2=new Array(totalRet);
                let v1=new Array(totalRet);
                let v2=new Array(totalRet);
                for(let k=0;k<totalRet;k++){
                        if(arr[0][k]){
                            if(arr[0][k][1]){
                                b1[k] = z.ce("b");
                                b1[k].innerHTML=arr[0][k][1];
                                v1[k]=z.cv(arr[0][k][1],arr[2]);
                            }
                            if(arr[0][k][0]){
                                b2[k]=z.ce("b");
                                b2[k].innerHTML=arr[0][k][0];
                                v2[k]=z.cv(arr[0][k][0],curTarLanForSpeaker);
                            }
                        }
                }
                let li1=z.ce("li");
                if(isEnableSimpleMode){
                    for(let i=0;i<totalRet;i++){
                        z.app(li1,b2[i]);
                    }
                    z.ap(li1);
                    return el;
                }
                let li2=z.ce("li");
                switch(totalRet){
                    case -1:
                        console.log("Error occured. Google result return an unnormal data.");
                        break;
                    case 0:
                            if(arr[0][0]){
                                if(arr[0][0][1]){
                                    let l1=z.ce("li");
                                    z.aps(l1,"b",arr[0][0][1]);
                                    z.apv(l1,arr[0][0][1],arr[2]);
                                    z.ap(l1);
                                }
                                if(arr[0][0][0]){
                                    let l2=z.ce("li");
                                    z.aps(l2,"b",arr[0][0][0]);
                                    z.apv(l2,arr[0][0][0],curTarLanForSpeaker);
                                    z.ap(l2);
                                }
                            }
                        break;
                    case 1:
                            z.app(li1,b1[0]);
                            z.app(li2,b2[0]);
                            if(arr[0][1]){
                                if(arr[0][1][0]){
                                    z.app(li1,v1[0]);
                                    z.aps(li1,"b",arr[0][1][1]);
                                    z.apv(li1,arr[0][1][1],arr[2]);
                                    z.app(li2,v2[0]);
                                    z.aps(li2,"b",arr[0][1][0]);
                                    z.apv(li2,arr[0][1][0],curTarLanForSpeaker);
                                    z.ap(li1);
                                    z.ap(li2);
                                    break;
                                }
                                z.aps(li1,"pr",arr[0][1][3]);
                                z.aps(li2,"pr",arr[0][1][2]);
                            }
                            z.ap(z.app(li1,v1[0]));
                            z.ap(z.app(li2,v2[0]));
                        break;
                    default:
                            for(let k=0;k<totalRet;k++){
                                z.app(li1,b1[k]);
                                z.app(li1,v1[k]);
                                z.app(li2,b2[k]);
                                z.app(li2,v2[k]);
                            }
                            if(arr[0][totalRet]){
                                z.ap(li1);
                                z.ap(z.aps(z.ce("p"),"pr",arr[0][totalRet][3]));
                                z.ap(li2);
                                z.ap(z.aps(z.ce("p"),"pr",arr[0][totalRet][2]));
                            }
                            else{
                                z.ap(li1);
                                z.ap(li2);
                            }
                        break;
                }
            }
            if(arr[1]){
                z.ap(z.aps(z.ce("li"),"h1",z.sb_details[translatorSettingLanguage]));
                for(let i=0;i<arr[1].length;i++){
                    let lit=z.ce("li");
                    z.aps(lit,"p",arr[1][i][0]);
                    for(let ii=0;ii<arr[1][i][2].length;ii++){
                        z.aps(lit,"em",arr[1][i][2][ii][0]);
                        let t="("
                        for(let iii=0;iii<arr[1][i][2][ii][1].length;iii++){
                            t+=arr[1][i][2][ii][1][iii]+", ";
                        }
                        t=t.substr(0,t.length-2)+");&nbsp;";
                        z.aps(lit,"span",t);
                    }
                    z.ap(lit);
                }
            }
            z.gor(arr,el,true);
        }
        if(len>12){
            if(arr[12]){
                z.ap(z.aps(z.ce("li"),"h1",z.sb_meaning[translatorSettingLanguage]));
                for(let o=0;o<arr[12].length;o++){
                    z.ap(z.aps(z.ce("li"),"p",arr[12][o][0]));
                    for(let oo=0;oo<arr[12][o][1].length;oo++){
                        z.ap(z.aps(z.ce("li"),"b",arr[12][o][1][oo][0]));
                        if(arr[12][o][1][oo][2])z.ap(z.aps(z.ce("li"),"span",arr[12][o][1][oo][2]));
                    }
                }
            }
        }
        if(len>13){
            if(arr[13]){
                let liSample=z.ce("li");
                liSample.id="gt_prefs_liSample";
                liSample.onclick=function(e){
                    let divSample=$('dSample');
                    let lSample=$('liSample');
                    if(divSample){
                        if(divSample.style.display==="none"){
                            divSample.style.display="block";
                            liSample.innerHTML=`<h1 id="gt_prefs_show_or_hide_examples">${z.sb_hideMore[translatorSettingLanguage]}<h1>`;
                        }
                        else{
                            divSample.style.display="none";
                            liSample.innerHTML=`<h1 id="gt_prefs_show_or_hide_examples">${z.sb_more[translatorSettingLanguage]}<h1>`;
                        }
                    }
                }
                liSample.innerHTML=`<h1 id="gt_prefs_show_or_hide_examples">${z.sb_more[translatorSettingLanguage]}<h1>`;
                z.ap(liSample);
                let dSample=z.ce("li");
                dSample.id="gt_prefs_dSample";
                let ulSample=z.ce("ul");
                ulSample.id="gt_prefs_sample_ul";
                for(let j=0;j<arr[13][0].length;j++){
                    z.aps(ulSample,"li",arr[13][0][j][0]);
                }
                dSample.appendChild(ulSample);
                z.ap(dSample);
                dSample.style.display="none";
            }
        }
        return el;
    }
    return null;
}

var searchedTextProcessor={
        addText:function(txt){
            if(searchedTextProcessor.isTextNotExisted(txt)){
                searchedTextCache.push(txt);
                searchedTextIndex=searchedTextCache.length-1;
                let iconNext=$('iconNext');
                if(iconNext)iconNext.style.display="none";
            }
            if(searchedTextIndex>0){
                let iconPrevious=$('iconPrevious');
                if(iconPrevious)iconPrevious.style.display="block";
            }
        },
        getCurrentText:function(){
            return searchedTextCache[searchedTextIndex];
        },
        isTextNotExisted:function(txt){
                for(let n=0;n<searchedTextCache.length;n++){
                    if(searchedTextCache[n]===txt)return false;
                }
                return true;
        },
        showTranslation:function(){
            let translatorDiv=document.getElementById('gt_prefs_translatorDiv');
            GetTranslation(searchedTextCache[searchedTextIndex],translatorDiv.offsetLeft,translatorDiv.offsetTop);
        },
        showPreviousText:function(){
            let iconPrevious=document.getElementById('gt_prefs_iconPrevious');
            let iconNext=document.getElementById('gt_prefs_iconNext');
            if(--searchedTextIndex<0){
                iconPrevious.style.display="none";
                searchedTextIndex=0;
            }
            else{
                if(searchedTextIndex===0){
                    iconPrevious.style.display="none";
                }
                if(searchedTextIndex<searchedTextCache.length-1){
                    iconNext.style.display="block";
                }
                this.showTranslation();
            }
        },
        showNextText:function(){
            let iconPrevious=document.getElementById('gt_prefs_iconPrevious');
            let iconNext=document.getElementById('gt_prefs_iconNext');
            if(++searchedTextIndex>searchedTextCache.length-1){
                iconNext.style.display="none";
                searchedTextIndex=searchedTextCache.length-1;
            }
            else{
                if(searchedTextIndex===searchedTextCache.length-1){
                    iconNext.style.display="none";
                }
                if(searchedTextIndex>0){
                    iconPrevious.style.display="block";
                }
                this.showTranslation();
            }
        }
};

function checkIsWordOrNot(txt,maxWordLength, isChineseWord) {
    if (isChineseWord)return txt.length <= maxWordLength && /^([\u4E00-\u9FA5]|[\uFF00-\uFF20]|[\u3000-\u301C])+$/g.test(txt);
    else return txt.length <= maxWordLength && !/\s+/gi.test(txt);
}

function translateIt(srcLanguage, dstLanguage, queryStr, mx, my) {
    queryStr = queryStr.trim();
    if (queryStr === "") return;
    curTarLanForSpeaker=dstLanguage;
    var targetMd5 = MD5(queryStr, srcLanguage + dstLanguage, null);
    if (translatedDataMap.has(targetMd5)) {
        popup(mx, my, translatedDataMap.get(targetMd5));
    }
    else {
        loadingIconUI.show({"mx":mx,"my":my});
        if(isEnableAccurateMode){
            accurateData.md5=targetMd5;
            accurateData.mx=mx;
            accurateData.my=my;
            accurateData.dy=maxTimesToDestroy;
            accurateData.wh=null;
        }
        var googleCallBackFunc = function (arrayTxt) {
            //console.log("返回值为:" + arrayTxt);
            if (arrayTxt != 'undefined' && arrayTxt != null) {
                translatedDataMap.set(targetMd5,[CACHE_TYPE_GOOGLE_RESULT, arrayTxt]);
                popup(mx, my, [CACHE_TYPE_GOOGLE_RESULT, arrayTxt]);
            }
        };
        var youdaoCallBackFunc=function (repArray, bIsSuccess) {
            if (bIsSuccess) {
                if (repArray != null || repArray != "undefined") {
                    var dictJson = JSON.parse(repArray);
                    translatedDataMap.set(targetMd5,[dictJson.basic ? CACHE_TYPE_YOUDAO_WORD:CACHE_TYPE_YOUDAO_SENTENCE, dictJson]);
                    popup(mx, my, [dictJson.basic ? CACHE_TYPE_YOUDAO_WORD : CACHE_TYPE_YOUDAO_SENTENCE, dictJson]);
                    return;
                }
            }
            GoogleRequest(queryStr, srcLanguage, dstLanguage, googleCallBackFunc);
        };
        var getYoudaoTranslation=function (maxWordLength) {
            if (youdao_isEnabled) {
                if (youdao_isOnlyForSingleWord) {
                    if (checkIsWordOrNot(queryStr, maxWordLength, false)) YoudaoRequest(queryStr, youdaoCallBackFunc);
                    else GoogleRequest(queryStr, srcLanguage, dstLanguage, googleCallBackFunc);
                }
                else YoudaoRequest(queryStr, youdaoCallBackFunc);
            }
            else GoogleRequest(queryStr, srcLanguage, dstLanguage, googleCallBackFunc);
        };
        switch (dstLanguage){
            case "zh-cn":
            case "zh-tw":
            case "zh-hk":
                //if query string is chinese word with max four characters
                if (checkIsWordOrNot(queryStr, 4, true)) {
                    ZdicRequest(queryStr, function (repHtml, finalUrl, bIsSuccess) {
                        if (bIsSuccess) {
                            if (repHtml != null && repHtml != "undefined" && repHtml.trim()!="") {
                                translatedDataMap.set(targetMd5,[CACHE_TYPE_ZDIC_HTML, repHtml]);
                                popup(mx, my, [CACHE_TYPE_ZDIC_HTML, repHtml]);
                                return;
                            }
                        }
                        getYoudaoTranslation(8);
                    });
                    return;
                }
                else getYoudaoTranslation(8);
                return;
            case "en-hk":
            case "en-us":
            case "en-gb":
            case "en-ww":
            case "en-ca":
            case "en-au":
                //if translate from Chinese to English
                if (/([\u4E00-\u9FA5]|[\uFF00-\uFF20]|[\u3000-\u301C])+/g.test(queryStr)){
                    getYoudaoTranslation(30);
                    return;
                }
                break;
            default:
                break;
        }
        GoogleRequest(queryStr, srcLanguage, dstLanguage, googleCallBackFunc);
    }
}

function playSound(buffer) {
    window.AudioContext = window.AudioContext || window.webkitAudioContext;
    var source = audioContext.createBufferSource();
    source.buffer = buffer;
    source.connect(audioContext.destination);
    source.start(0);
}

function YouDaoPlay(word) {
    var txtMd5 = MD5(word, "YouDaoEnToCn" + CACHE_TYPE_YOUDAO_WORD, null);
    if (translatedSoundMap.has(txtMd5)) {
        playSound(translatedSoundMap.get(txtMd5));
        return;
    }
    GM_xmlhttpRequest({
        method: "GET",
        url: `https://dict.youdao.com/dictvoice?type=2&audio=${encodeURI(word)}`,
        responseType: 'arraybuffer',
        onload: function(resp) {
            try {
                audioContext.decodeAudioData(resp.response, function (buffer) {
                    translatedSoundMap.set(txtMd5,buffer);
                    playSound(buffer);
                });
            } catch (e) {
                console.log(e);
            }
        }
    });
}

function YoudaoRequest(queryStr,callBackFunc) {
    GM_xmlhttpRequest({
        method: "GET",
        url: `http://fanyi.youdao.com/openapi.do?type=data&doctype=json&version=1.1&relatedUrl=http%3A%2F%2Ffanyi.youdao.com%2F%23&keyfrom=fanyiweb&key=null&translate=on&q=${queryStr}&ts=${(new Date().getTime()).toString()}`,
        headers: {
            "Accept": "application/json"
        },
        onload: function (resp) {
            if (resp.statusText==="OK"){
                callBackFunc(resp.responseText,true);
                return;
            }
            callBackFunc(null,false);
        }
    });
}

function ZdicRequest(queryStr,callBackFunc) {
    GM_xmlhttpRequest({
        method: "GET",
        url: "https://www.zdic.net/hans/"+encodeURI(queryStr),
        headers:{
            "User-Agent": UA,
            "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
            "Accept-Encoding": "GBK,gzip,deflate"
        },
        onload: function (resp) {
                try {
                    if (resp.readyState === 4) {
						let repTxt=resp.responseText;
                        //if got the right answer
                        if (resp.responseText.indexOf("<title>查无此结果</title>") < 0) {
                            if (resp.responseText.indexOf("<title>全站搜索</title>") < 0) {
                                let beginIndex=repTxt.indexOf(`<div class="homograph-entry">`);
                                let endIndex=repTxt.lastIndexOf(`<div class="res_c_right">`)-7;
                                var result1=repTxt.substring(beginIndex,endIndex);//.replace(/src="\/\/img\.zdic\.net/gi,`src="https://img.zdic.net`).replace(/data-original="\/\/img\.zdic\.net\//gi,`data-original="https://img.zdic.net/`);
                                callBackFunc(result1, resp.finalUrl, true);
                                return;
                            }
                        }
                    }
                } catch (e) {
                    console.log(e);
                }
               callBackFunc(null, null, false);
        }
    });
}

function getTargetAnswer(resultObj) {
    if (resultObj) {
        switch(resultObj[0]){
            case CACHE_TYPE_ZDIC_HTML:
                return [ANS_TYPE_ZDIC_HTML, resultObj[1]];
            case CACHE_TYPE_YOUDAO_SENTENCE:
                return [ANS_TYPE_YOUDAO_SENTENCE, resultObj[1]];
            case CACHE_TYPE_YOUDAO_WORD:
                return [ANS_TYPE_YOUDAO_WORD, resultObj[1]];
            case CACHE_TYPE_GOOGLE_RESULT:
                return [ANS_TYPE_GOOGLE_RESULT, resultObj[1]];
            case CACHE_TYPE_ACCURATE:
                return[ANS_TYPE_ACCURATE,resultObj[1]];
            default:
                break;
        }
    }
    return null;
}

function init_google_value_tk() {
    var url = "https://" + googleDomain[translatorSettingLanguage];
    GM_xmlhttpRequest({
        method: "GET",
        url: url,
        onreadystatechange: function (resp) {
            if (resp.readyState == 4) {
                if (resp.status == 200) {
                    if(init_google_value_tk_parse(resp.responseText)){
                        location.reload();
                    }
                    else{
						alert(translatorSettingLanguage===0 ? "谷歌令牌初始化失败,转为使用有道翻译,请联系作者改进程序。":"Google token initialized failed, use youdao translator instead. Please contact the author to fix this problem.");
					}
                }
            }
        }
    });
}

function init_google_value_tk_parse(responseText) {
	let indexStr=",tkk:'";
	let bIdx=responseText.indexOf(indexStr);
	if(bIdx>0){
		bIdx+=indexStr.length;
		let eIdx=responseText.indexOf("',",bIdx);
		if(eIdx>0){
			let tkk=responseText.substring(bIdx,eIdx);
			if(tkk!=null){
				GM_setValue(tokenNameInStorage[translatorSettingLanguage], tkk)
				return true;
			}
		}
	}
	return false;
}

function googleTK(text) {
    var uM = GM_getValue(tokenNameInStorage[translatorSettingLanguage],null);
    if (uM == 'undefined' || uM == null) {
        init_google_value_tk();
		return null;
    }
    var cb = "&";
    var k = "";
    var Gf = "=";
    var Vb = "+-a^+6";
    var t = "a";
    var Yb = "+";
    var Zb = "+-3^+b+-f";
    var jd = ".";
    var sM = function (a) {
        return function () {
            return a;
        };
    };
    var tM = function (a, b) {
        for (var c = 0; c < b.length - 2; c += 3) {
            var d = b.charAt(c + 2);
			d = d >= t ? d.charCodeAt(0) - 87 : Number(d);
            d = b.charAt(c + 1) == Yb ? a >>> d : a << d;
            a = b.charAt(c) == Yb ? a + d & 4294967295 : a ^ d;
        }
        return a;
    };
    var vM = function (a) {
		try{
			var b;
			if (null !== uM) {
				b = uM;
			} else {
				b = sM(String.fromCharCode(84));
				var c = sM(String.fromCharCode(75));
				b = [b(), b()];
				b[1] = c();
				b = (uM = window[b.join(c())] || k) || k;
			}
			var d = sM(String.fromCharCode(116));
			c = sM(String.fromCharCode(107));
			d = [d(), d()];
			d[1] = c();
			c = cb + d.join(k) + Gf;
			d = b.split(jd);
			b = Number(d[0]) || 0;

			for (var e = [], f = 0, g = 0; g < a.length; g++) {
				var m = a.charCodeAt(g);
				128 > m ? e[f++] = m : (2048 > m ? e[f++] = m >> 6 | 192 : (55296 == (m & 64512) && g + 1 < a.length && 56320 == (a.charCodeAt(g + 1) & 64512) ? (m = 65536 + ((m & 1023) << 10) + (a.charCodeAt(++g) & 1023), e[f++] = m >> 18 | 240, e[f++] = m >> 12 & 63 | 128) : e[f++] = m >> 12 | 224, e[f++] = m >> 6 & 63 | 128), e[f++] = m & 63 | 128);
			}
			a = b || 0;
			for (f = 0; f < e.length; f++) {
				a += e[f];
				a = tM(a, Vb);
			}
			a = tM(a, Zb);
			a ^= Number(d[1]) || 0;
			0 > a && (a = (a & 2147483647) + 2147483648);
			a %= 1E6;
			return a.toString() + jd + (a ^ b);
		}
		catch(err){
			console.log(err);
		}
    };
    return vM(text);
}

function translationTaskProcessor(){
    if(accurateData.dy-->0){
        if(!isExistsTranslationTask.get()){
            translationTaskTimout=0;
            let s=GM_getValue(translatedDataConfigString,"");
            if(s.length>0){
                accurateData.wh.close();
                accurateData.wh=null;
                translatedDataMap.set(accurateData.md5,[CACHE_TYPE_ACCURATE,s]);
                GM_setValue(translatedDataConfigString,"");
                popup(accurateData.mx,accurateData.my,[CACHE_TYPE_ACCURATE,s]);
            }
        }
        else translationTaskTimout=setTimeout(translationTaskProcessor,translationTaskInterval);
    }
    else{
        translationTaskTimout=0;
        isExistsTranslationTask.set(false);
        GM_setValue(translatedDataConfigString,"");
        loadingIconUI.hide();
    }
}

// Google Translate Request
function GoogleRequest(txt, sl, tl, parse) {
    if(isEnableAccurateMode){
        if(!isExistsTranslationTask.get()){
            let iN=/\s+/g.test(txt);
            if(!iN){
                if(/([\u4E00-\u9FA5]|[\uFF00-\uFF20]|[\u3000-\u301C])+/g.test(txt))iN=(txt.length>4);
			}
            if(iN){
                if(isTMode){
                    if(tLanguageCode[currentSourceLanguage+1]!=="xxx" && tLanguageCode[currentTranslateLanguage+1]!=="xxx"){
                        GM_setValue(translatedDataConfigString,`${tLanguageCode[currentSourceLanguage+1]}|${tLanguageCode[currentTranslateLanguage+1]}|${encodeURI(txt)}`);
                        if((accurateData.wh=window.open("https://fanyi.qq.com/","_blank","height=100,width=100,top="+window.screen.height+",left="+window.screen.width+",location=0,menubar=0,status=0,titlebar=0,toolbar=0"))){
                            isExistsTranslationTask.set(true);
                            translationTaskTimout=setTimeout(translationTaskProcessor,translationTaskInterval);
                            return;
                        }
                    }
                }
                let vlUrl=alURL+ "&sl=" + sl + "&tl=" + tl + "&text=" + encodeURI(txt);
                if((accurateData.wh=window.open(vlUrl,"_blank","height=100,width=100,top="+window.screen.height+",left="+window.screen.width+",location=0,menubar=0,status=0,titlebar=0,toolbar=0"))){
                    isExistsTranslationTask.set(true);
                    translationTaskTimout=setTimeout(translationTaskProcessor,translationTaskInterval);
                    return;
                }
                else{
                    saveModeSettings(isEnableAccurateModeConfigString,false);
                    $("iconAccurate").style.display="none";
                    $("iconNonAccurate").style.display="block";
                }
            }
        }
        else{
            if(accurateData.wh){
                    accurateData.wh.close();
                    accurateData.wh=null;
            }
            if(translationTaskTimout!==0){
                clearTimeout(translationTaskTimout);
                translationTaskTimout=0;
            }
            isExistsTranslationTask.set(false);
        }
    }
    var tk = googleTK(txt);
    if(!tk){
        loadingIconUI.hide();
        return;
    }
    var Url = dictURL +
        "&hl=auto" +
        "&sl=" + sl + "&tl=" + tl +
        "&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&dt=at&ie=UTF-8&oe=UTF-8&otf=2&trs=1&inputm=1&ssel=0&tsel=0&source=btn&kc=3" +
        "&tk=" + tk +
        "&q=" + encodeURI(txt);
    var method = 'POST';
    var Data = '';
    var Hdr = {
        "User-Agent": UA,
        "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
        "Accept-Encoding": "gzip, deflate"
    };
    var Q = Url.split('&q=');
    Url = Q[0];
    Data = '&q=' + Q[1];
    Hdr["Content-Length"] = Data.length + '';
    Hdr["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
    GM_xmlhttpRequest({
        method: method,
        url: Url,
        data: Data,
        headers: Hdr,
        onload: function (resp) {
            try {
				//console.log(resp.responseText);
                parse(resp.responseText, tl);
            } catch (e) {
                console.log(e);
            }
        }
    });
}


function playTTS(lang,text) {
    text = text.replace(/[«»'"]/g, ' ');
    var txtMd5 = MD5(text, lang + CACHE_TYPE_GOOGLE_RESULT, null);
    if (translatedSoundMap.has(txtMd5)){
        playSound(translatedSoundMap.get(txtMd5));
        return;
    }
    var tk = googleTK(text);
    var Url = ttsURL + "&ie=UTF-8&total=1&idx=0" +
        "&tl=" + lang +
        "&q=" + text +
        "&textlen=" + text.length +
        "&tk=" + tk;
    GM_xmlhttpRequest({
        method: "GET",
        url: Url,
        responseType: 'arraybuffer',
        onload: function (response) {
            try {
                audioContext.decodeAudioData(response.response, function (buffer) {
                    translatedSoundMap.set(txtMd5,buffer);
                    playSound(buffer);
                });
            } catch (e) {
                console.log(e);
            }
        }
    });
}


'use strict';

/*
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
* to work around bugs in some JS interpreters.
*/
function safe_add(x, y) {
    var lsw = (x & 0xFFFF) + (y & 0xFFFF),
        msw = (x >> 16) + (y >> 16) + (lsw >> 16);
    return (msw << 16) | (lsw & 0xFFFF);
}

/*
* Bitwise rotate a 32-bit number to the left.
*/
function bit_rol(num, cnt) {
    return (num << cnt) | (num >>> (32 - cnt));
}

/*
* These functions implement the four basic operations the algorithm uses.
*/
function md5_cmn(q, a, b, x, s, t) {
    return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b);
}

function md5_ff(a, b, c, d, x, s, t) {
    return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
}

function md5_gg(a, b, c, d, x, s, t) {
    return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
}

function md5_hh(a, b, c, d, x, s, t) {
    return md5_cmn(b ^ c ^ d, a, b, x, s, t);
}

function md5_ii(a, b, c, d, x, s, t) {
    return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
}

/*
* Calculate the MD5 of an array of little-endian words, and a bit length.
*/
function binl_md5(x, len) {
    /* append padding */
    x[len >> 5] |= 0x80 << ((len) % 32);
    x[(((len + 64) >>> 9) << 4) + 14] = len;

    var i, olda, oldb, oldc, oldd,
        a = 1732584193,
        b = -271733879,
        c = -1732584194,
        d = 271733878;

    for (i = 0; i < x.length; i += 16) {
        olda = a;
        oldb = b;
        oldc = c;
        oldd = d;

        a = md5_ff(a, b, c, d, x[i], 7, -680876936);
        d = md5_ff(d, a, b, c, x[i + 1], 12, -389564586);
        c = md5_ff(c, d, a, b, x[i + 2], 17, 606105819);
        b = md5_ff(b, c, d, a, x[i + 3], 22, -1044525330);
        a = md5_ff(a, b, c, d, x[i + 4], 7, -176418897);
        d = md5_ff(d, a, b, c, x[i + 5], 12, 1200080426);
        c = md5_ff(c, d, a, b, x[i + 6], 17, -1473231341);
        b = md5_ff(b, c, d, a, x[i + 7], 22, -45705983);
        a = md5_ff(a, b, c, d, x[i + 8], 7, 1770035416);
        d = md5_ff(d, a, b, c, x[i + 9], 12, -1958414417);
        c = md5_ff(c, d, a, b, x[i + 10], 17, -42063);
        b = md5_ff(b, c, d, a, x[i + 11], 22, -1990404162);
        a = md5_ff(a, b, c, d, x[i + 12], 7, 1804603682);
        d = md5_ff(d, a, b, c, x[i + 13], 12, -40341101);
        c = md5_ff(c, d, a, b, x[i + 14], 17, -1502002290);
        b = md5_ff(b, c, d, a, x[i + 15], 22, 1236535329);

        a = md5_gg(a, b, c, d, x[i + 1], 5, -165796510);
        d = md5_gg(d, a, b, c, x[i + 6], 9, -1069501632);
        c = md5_gg(c, d, a, b, x[i + 11], 14, 643717713);
        b = md5_gg(b, c, d, a, x[i], 20, -373897302);
        a = md5_gg(a, b, c, d, x[i + 5], 5, -701558691);
        d = md5_gg(d, a, b, c, x[i + 10], 9, 38016083);
        c = md5_gg(c, d, a, b, x[i + 15], 14, -660478335);
        b = md5_gg(b, c, d, a, x[i + 4], 20, -405537848);
        a = md5_gg(a, b, c, d, x[i + 9], 5, 568446438);
        d = md5_gg(d, a, b, c, x[i + 14], 9, -1019803690);
        c = md5_gg(c, d, a, b, x[i + 3], 14, -187363961);
        b = md5_gg(b, c, d, a, x[i + 8], 20, 1163531501);
        a = md5_gg(a, b, c, d, x[i + 13], 5, -1444681467);
        d = md5_gg(d, a, b, c, x[i + 2], 9, -51403784);
        c = md5_gg(c, d, a, b, x[i + 7], 14, 1735328473);
        b = md5_gg(b, c, d, a, x[i + 12], 20, -1926607734);

        a = md5_hh(a, b, c, d, x[i + 5], 4, -378558);
        d = md5_hh(d, a, b, c, x[i + 8], 11, -2022574463);
        c = md5_hh(c, d, a, b, x[i + 11], 16, 1839030562);
        b = md5_hh(b, c, d, a, x[i + 14], 23, -35309556);
        a = md5_hh(a, b, c, d, x[i + 1], 4, -1530992060);
        d = md5_hh(d, a, b, c, x[i + 4], 11, 1272893353);
        c = md5_hh(c, d, a, b, x[i + 7], 16, -155497632);
        b = md5_hh(b, c, d, a, x[i + 10], 23, -1094730640);
        a = md5_hh(a, b, c, d, x[i + 13], 4, 681279174);
        d = md5_hh(d, a, b, c, x[i], 11, -358537222);
        c = md5_hh(c, d, a, b, x[i + 3], 16, -722521979);
        b = md5_hh(b, c, d, a, x[i + 6], 23, 76029189);
        a = md5_hh(a, b, c, d, x[i + 9], 4, -640364487);
        d = md5_hh(d, a, b, c, x[i + 12], 11, -421815835);
        c = md5_hh(c, d, a, b, x[i + 15], 16, 530742520);
        b = md5_hh(b, c, d, a, x[i + 2], 23, -995338651);

        a = md5_ii(a, b, c, d, x[i], 6, -198630844);
        d = md5_ii(d, a, b, c, x[i + 7], 10, 1126891415);
        c = md5_ii(c, d, a, b, x[i + 14], 15, -1416354905);
        b = md5_ii(b, c, d, a, x[i + 5], 21, -57434055);
        a = md5_ii(a, b, c, d, x[i + 12], 6, 1700485571);
        d = md5_ii(d, a, b, c, x[i + 3], 10, -1894986606);
        c = md5_ii(c, d, a, b, x[i + 10], 15, -1051523);
        b = md5_ii(b, c, d, a, x[i + 1], 21, -2054922799);
        a = md5_ii(a, b, c, d, x[i + 8], 6, 1873313359);
        d = md5_ii(d, a, b, c, x[i + 15], 10, -30611744);
        c = md5_ii(c, d, a, b, x[i + 6], 15, -1560198380);
        b = md5_ii(b, c, d, a, x[i + 13], 21, 1309151649);
        a = md5_ii(a, b, c, d, x[i + 4], 6, -145523070);
        d = md5_ii(d, a, b, c, x[i + 11], 10, -1120210379);
        c = md5_ii(c, d, a, b, x[i + 2], 15, 718787259);
        b = md5_ii(b, c, d, a, x[i + 9], 21, -343485551);

        a = safe_add(a, olda);
        b = safe_add(b, oldb);
        c = safe_add(c, oldc);
        d = safe_add(d, oldd);
    }
    return [a, b, c, d];
}

/*
* Convert an array of little-endian words to a string
*/
function binl2rstr(input) {
    var i,
        output = '';
    for (i = 0; i < input.length * 32; i += 8) {
        output += String.fromCharCode((input[i >> 5] >>> (i % 32)) & 0xFF);
    }
    return output;
}

/*
* Convert a raw string to an array of little-endian words
* Characters >255 have their high-byte silently ignored.
*/
function rstr2binl(input) {
    var i,
        output = [];
    output[(input.length >> 2) - 1] = undefined;
    for (i = 0; i < output.length; i += 1) {
        output[i] = 0;
    }
    for (i = 0; i < input.length * 8; i += 8) {
        output[i >> 5] |= (input.charCodeAt(i / 8) & 0xFF) << (i % 32);
    }
    return output;
}

/*
* Calculate the MD5 of a raw string
*/
function rstr_md5(s) {
    return binl2rstr(binl_md5(rstr2binl(s), s.length * 8));
}

/*
* Calculate the HMAC-MD5, of a key and some data (raw strings)
*/
function rstr_hmac_md5(key, data) {
    var i,
        bkey = rstr2binl(key),
        ipad = [],
        opad = [],
        hash;
    ipad[15] = opad[15] = undefined;
    if (bkey.length > 16) {
        bkey = binl_md5(bkey, key.length * 8);
    }
    for (i = 0; i < 16; i += 1) {
        ipad[i] = bkey[i] ^ 0x36363636;
        opad[i] = bkey[i] ^ 0x5C5C5C5C;
    }
    hash = binl_md5(ipad.concat(rstr2binl(data)), 512 + data.length * 8);
    return binl2rstr(binl_md5(opad.concat(hash), 512 + 128));
}

/*
* Convert a raw string to a hex string
*/
function rstr2hex(input) {
    var hex_tab = '0123456789abcdef',
        output = '',
        x,
        i;
    for (i = 0; i < input.length; i += 1) {
        x = input.charCodeAt(i);
        output += hex_tab.charAt((x >>> 4) & 0x0F) +
            hex_tab.charAt(x & 0x0F);
    }
    return output;
}

/*
* Encode a string as utf-8
*/
function str2rstr_utf8(input) {
    return unescape(encodeURIComponent(input));
}

/*
* Take string arguments and return either raw or hex encoded strings
*/
function raw_md5(s) {
    return rstr_md5(str2rstr_utf8(s));
}

function hex_md5(s) {
    return rstr2hex(raw_md5(s));
}

function raw_hmac_md5(k, d) {
    return rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d));
}

function hex_hmac_md5(k, d) {
    return rstr2hex(raw_hmac_md5(k, d));
}

function MD5(string, key, raw) {
    if (!key) {
        if (!raw) {
            return hex_md5(string);
        } else {
            return raw_md5(string);
        }
    }
    if (!raw) {
        return hex_hmac_md5(key, string);
    } else {
        return raw_hmac_md5(key, string);
    }
}
function triggerEvent(el,evtName){
	var evt;
	if(document.createEvent){
		evt = document.createEvent("HTMLEvents");
		evt.initEvent(evtName, true, true);
		evt.eventName = evtName;
		el.dispatchEvent(evt);
	} else {
		evt = document.createEventObject();
		evt.eventName = evtName;
		evt.eventType = evtName;
		el.fireEvent("on" + evt.eventType, evt);
	}
}
function removeWebsiteSelectingRestriction(){
    GM_addStyle(`*{-webkit-user-select:text !important;-moz-user-select:text !important;-ms-user-select:text !important;user-select:text !important;}`);
    [].forEach.call(['copy', 'cut', 'paste', 'select', 'selectstart'],function(event) {document.addEventListener(event, function(e) { e.stopPropagation(); }, true);});
    isWebsiteRestrictionRemoved=true;
}
if(isRemoveWebsiteSelectingRestriction){
    removeWebsiteSelectingRestriction();
}
var zdictStyle=`
<style type="text/css">
#shiyi_content{height: 500px; width: 100%; margin: 0px; padding: 0px; border: none; color: black; text-decoration: none; overflow: auto;background:transparent;}
#shiyi_content .homograph-entry{margin: 0px; padding: 0px; border: none;word-wrap:break-word;box-sizing:border-box;}
#shiyi_content  .page{font-size:16px;}
#shiyi_content .nr-box{ padding-top: 0;border: 1px solid #af9a87;padding: 15px;background: transparent;margin-bottom: 20px;-webkit-column-break-inside: avoid;page-break-inside: avoid;break-inside: avoid;}
#shiyi_content .nr-box-shiyi .jbjs {border-right: solid 4px #c99464;}
#shiyi_content .nr-box-header {background: #f3e8df;padding: 10px 15px;margin: 0 -15px 1em -15px;font-size: 12px;}
#shiyi_content .zib-title {float: right;font-size: 16px;}
#shiyi_content .nr-box-shiyi h2.h2_entry {font-size: 1.8em;margin-bottom: 0;}
#shiyi_content .h2_entry {font-size: 1.4em;margin-bottom: .5em;}
#shiyi_content .page .dictname {font-size: .7em;}
#shiyi_content .page .zdict .definitions, .page .zdict .derivs, .page .zdict .etyms {margin-bottom: 1em;}
#shiyi_content span.z_ts2, span.z_ts3, span.z_ts4 {background-image:transparent;height: 18px;line-height: 18px;color: #660000;font-size: 12px;text-align: center;display: inline-block;font-weight: normal;margin-right: 5px;padding: 0;}
#shiyi_content span.z_ts2 {background-position: 0 -78px;width: 33px;}
#shiyi_content .jnr, .bknr, .wknr {margin: .5em;line-height: 1.5em;}
#shiyi_content .p, p {margin-bottom: 1em;}
#shiyi_content .dicpy {font-size: 20px;font-family: Arial;color: #660000;font-weight: normal;}
#shiyi_content .encs {color: #339900;}
#shiyi_content .diczx1 {color: #660000;}
#shiyi_content .h_line1 {clear: both;height: 3px;width: 98%; margin-bottom: 3px;background-color:gray;text-indent: -9999px;}
#shiyi_content span.z_ts4 {background-position: 0 -114px;width: 55px;}
#shiyi_content span.z_ts2, span.z_ts3, span.z_ts4 {background-color:#F1DED6;border:1px #B07D7E solid;border-radius:3px;height: 18px;line-height: 18px;color: #660000;font-size: 12px;text-align: center;display: inline-block;font-weight: normal;margin-right: 5px;padding: 0;}
#shiyi_content .gnr .gycd {line-height: 1.5;padding-bottom: 5px;}
#shiyi_content .pz {border-bottom: 1px dashed #F1E9E7;padding-bottom: 5px;}
#shiyi_content ruby {display: inline-table;text-align: center;white-space: nowrap;text-indent: 0;margin: 0;vertical-align: -20%;}
#shiyi_content ruby > rb, ruby > rbc {display: table-row-group;line-height: 90%;}
#shiyi_content rbc > rb, rtc > rt {display: table-cell;letter-spacing: 0;}
#shiyi_content rt {text-indent: 0px;line-height: normal;-webkit-text-emphasis: none;}
#shiyi_content .gnr .pz ruby rtc {font-size: 12px;color: #8F6652;line-height: 30px;}
#shiyi_content .pz ruby rtc {font-size: 12px;color: #8F6652;line-height: 30px;}
#shiyi_content ruby > rt, ruby > rbc + rtc {display: table-header-group;font-size: 60%;line-height: 40%;letter-spacing: 0;}
#shiyi_content ruby > rbc + rtc + rtc {display: table-footer-group;font-size: 60%;line-height: 40%;letter-spacing: 0;}
#shiyi_content ol, ul {list-style-type: none;}
#shiyi_content .gnr .gycd {line-height: 1.5;padding-bottom: 5px;}
#shiyi_content .gnr .gc_uono {list-style: outside none none;text-indent: 2em;}
#shiyi_content .gnr .def {margin: 5px 0 5px;line-height: 1.6em;}
#shiyi_content .gnr .gc_sy {clear: both;display: block;margin-bottom: 2pt;}
#shiyi_content .gnr .gc_lz {clear: both;display: block;}
#shiyi_content .gnr .gc_fy, .gc_jy {clear: both;display: block;font-size: 85%;margin-top: 2px;font-weight: 700;color: #666;}
#shiyi_content .gnr .gc_jfy_i {background-color: #633;border-radius: 4px;color: white;font-size: 100%;line-height: 1;padding: 2px;margin-right: 5px;}
#shiyi_content .page .copyright {color: gray;font-size: small;margin-top: 10px;}
#shiyi_content .contentslot, .mpuslot_b {margin-top: 20px;text-align: center;}
#shiyi_content .nr-box-shiyi.wljs {border-right: solid 4px #aea4a4;}
#shiyi_content .page .zdict .definitions, .page .zdict .derivs, .page .zdict .etyms {margin-bottom: 1em;}
#shiyi_content .cnr h3 {color: #660000;font-size: 16px;line-height: 2em;font-weight: bold;}
#shiyi_content .jnr, .bknr, .wknr {margin: .5em;line-height: 1.5em;}
#shiyi_content .cnr li {counter-increment: li;}
#shiyi_content .jnr ol {list-style: none;counter-reset: li;}
#shiyi_content .jnr li {counter-increment: li;}
#shiyi_content .dichr {margin-top: 5px;width: 100%;clear: both;color: #af9a87;border-bottom: solid 1px;}
#shiyi_content .enbox {padding: 10px 0 5px 0;border-top: 1px solid #efe3e3;margin: 5px;background:transparent;}
#shiyi_content .jnr p {margin-bottom: .5em;line-height: 1.5em;}
#shiyi_content .enbox p {font-size: 14px;color: #327311;}
#shiyi_content .wytl{display:none;}
</style>
`;