From 61cdd92214721925ee95ac17cf8ad6e853aac80d Mon Sep 17 00:00:00 2001 From: fishjar Date: Sun, 16 Nov 2025 13:06:36 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20fishjar/?= =?UTF-8?q?kiss-translator@d0320884153913703254d1c364b1c12aa871d6d9=20?= =?UTF-8?q?=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kiss-translator-ios-safari.user.js | 51 +++++++++++++++--------------- kiss-translator.user.js | 51 +++++++++++++++--------------- main.js | 4 +-- manifest.firefox.json | 2 +- manifest.json | 2 +- manifest.thunderbird.json | 2 +- options.js | 20 ++++++------ version.txt | 2 +- 8 files changed, 66 insertions(+), 68 deletions(-) diff --git a/kiss-translator-ios-safari.user.js b/kiss-translator-ios-safari.user.js index 1133c12..b516399 100644 --- a/kiss-translator-ios-safari.user.js +++ b/kiss-translator-ios-safari.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name KISS Translator // @namespace https://github.com/fishjar/kiss-translator -// @version 2.0.10 +// @version 2.0.11 // @description A simple bilingual translation extension & Greasemonkey script (一个简约的双语对照翻译扩展 & 油猴脚本) // @author Gabe // @homepageURL https://github.com/fishjar/kiss-translator @@ -29407,7 +29407,7 @@ __webpack_require__.d(base_namespaceObject, { }); ;// CONCATENATED MODULE: ./src/config/app.js -const APP_NAME="KISS Translator".trim().split(/\s+/).join("-");const APP_LCNAME=APP_NAME.toLowerCase();const APP_UPNAME=APP_NAME.toUpperCase();const APP_CONSTS={fabID:"".concat(APP_LCNAME,"-fab"),boxID:"".concat(APP_LCNAME,"-box"),popupID:"".concat(APP_LCNAME,"-popup")};const APP_VERSION="2.0.10".split(".");const THEME_LIGHT="light";const THEME_DARK="dark"; +const APP_NAME="KISS Translator".trim().split(/\s+/).join("-");const APP_LCNAME=APP_NAME.toLowerCase();const APP_UPNAME=APP_NAME.toUpperCase();const APP_CONSTS={fabID:"".concat(APP_LCNAME,"-fab"),boxID:"".concat(APP_LCNAME,"-box"),popupID:"".concat(APP_LCNAME,"-popup")};const APP_VERSION="2.0.11".split(".");const THEME_LIGHT="light";const THEME_DARK="dark"; ;// CONCATENATED MODULE: ./node_modules/.pnpm/@babel+runtime@7.24.4/node_modules/@babel/runtime/helpers/esm/typeof.js function _typeof(o) { "@babel/helpers - typeof"; @@ -30142,7 +30142,7 @@ return fnPolyfill({fn:fetchHandle,input,init,opts});}; const MSG_GM_xmlHttpRequest="xmlHttpRequest";const MSG_GM_setValue="setValue";const MSG_GM_getValue="getValue";const MSG_GM_deleteValue="deleteValue";const MSG_GM_info="info";/** * 注入页面的脚本,请求并接受GM接口信息 * @param {*} param0 - */const injectScript=ping=>{window.APP_INFO={name:"KISS Translator",version:"2.0.10",eventName:ping};};/** + */const injectScript=ping=>{window.APP_INFO={name:"KISS Translator",version:"2.0.11",eventName:ping};};/** * 适配GM脚本 */const adaptScript=ping=>{const promiseGM=function(action,args){let timeout=arguments.length>2&&arguments[2]!==undefined?arguments[2]:5000;return new Promise((resolve,reject)=>{const pong=genEventName();const handleEvent=e=>{window.removeEventListener(pong,handleEvent);const{data,error}=e.detail;if(error){reject(new Error(error));}else{resolve(data);}};window.addEventListener(pong,handleEvent);window.dispatchEvent(new CustomEvent(ping,{detail:{action,args,pong}}));setTimeout(()=>{window.removeEventListener(pong,handleEvent);reject(new Error("timeout"));},timeout);});};window.KISS_GM={fetch:(input,init)=>promiseGM(MSG_GM_xmlHttpRequest,{input,init}),setValue:(key,val)=>promiseGM(MSG_GM_setValue,{key,val}),getValue:key=>promiseGM(MSG_GM_getValue,{key}),deleteValue:key=>promiseGM(MSG_GM_deleteValue,{key}),getInfo:async()=>{if(!window.GM_info){window.GM_info=await promiseGM(MSG_GM_info);}return window.GM_info;}};};/** * 监听并回应页面对GM接口的请求 @@ -30850,7 +30850,7 @@ keyfrom:"webdict"});const init={headers:{accept:"application/json, text/plain, * * @param {*} param0 * @returns */const apiTranslate=async _ref2=>{let{text,fromLang="auto",toLang,apiSetting=DEFAULT_API_SETTING,docInfo={},glossary,useCache=true,usePool=true}=_ref2;if(!text){throw new Error("The text cannot be empty.");}const{apiType,apiSlug,useBatchFetch}=apiSetting;const langMap=OPT_LANGS_TO_SPEC[apiType]||OPT_LANGS_SPEC_DEFAULT;const from=langMap.get(fromLang);const to=langMap.get(toLang);if(!to){throw new Error("The target lang: ".concat(toLang," not support"));}// todo: 优化缓存失效因素 -const[v1,v2]="2.0.10".split(".");const cacheOpts={apiSlug,text,fromLang,toLang,version:[v1,v2].join(".")};const cacheInput="".concat(URL_CACHE_TRAN,"?").concat(query_string.stringify(cacheOpts));// 查询缓存数据 +const[v1,v2]="2.0.11".split(".");const cacheOpts={apiSlug,text,fromLang,toLang,version:[v1,v2].join(".")};const cacheInput="".concat(URL_CACHE_TRAN,"?").concat(query_string.stringify(cacheOpts));// 查询缓存数据 if(useCache){const cache=await getHttpCachePolyfill(cacheInput);if(cache!==null&&cache!==void 0&&cache.trText){return cache;}}// 请求接口数据 let tranlation=[];if(apiType===OPT_TRANS_BUILTINAI){tranlation=await apiBuiltinAITranslate({text,from,to,apiSetting});}else if(useBatchFetch&&API_SPE_TYPES.batch.has(apiType)){const{apiSlug,batchInterval,batchSize,batchLength}=apiSetting;const key="".concat(apiSlug,"_").concat(fromLang,"_").concat(toLang);const queue=getBatchQueue(key,handleTranslate,{batchInterval,batchSize,batchLength});tranlation=await queue.addTask(text,{from,to,fromLang,toLang,langMap,docInfo,glossary,apiSetting,usePool});}else{[tranlation]=await handleTranslate([text],{from,to,fromLang,toLang,langMap,docInfo,glossary,apiSetting,usePool});}let trText="";let srLang="";let srCode="";if(Array.isArray(tranlation)){[trText,srLang=""]=tranlation;if(srLang){srCode=OPT_LANGS_TO_CODE[apiType].get(srLang)||"";}}else if(typeof tranlation==="string"){trText=tranlation;}if(!trText){throw new Error("tanslate api got empty trtext");}const isSame=fromLang==="auto"&&srLang===to;// 插入缓存 if(useCache){putHttpCachePolyfill(cacheInput,null,{trText,isSame,srLang,srCode});}return{trText,srLang,srCode,isSame};};// 字幕处理/翻译 @@ -33690,7 +33690,7 @@ var n = {}; return t.length === e && "." !== t && ".." !== t; }; }, - te = "object" === ("undefined" == typeof process ? "undefined" : Nt(process)) && process ? "object" === Nt(({"NODE_ENV":"production","PUBLIC_URL":"","WDS_SOCKET_HOST":undefined,"WDS_SOCKET_PATH":undefined,"WDS_SOCKET_PORT":undefined,"FAST_REFRESH":true,"REACT_APP_CLIENT":"userscript","REACT_APP_NAME":"KISS Translator","REACT_APP_NAME_CN":"简约翻译","REACT_APP_VERSION":"2.0.10","REACT_APP_HOMEPAGE":"https://github.com/fishjar/kiss-translator","REACT_APP_OPTIONSPAGE":"https://fishjar.github.io/kiss-translator/options.html","REACT_APP_OPTIONSPAGE_DEV":"http://localhost:3000/options.html","REACT_APP_LOGOURL":"https://fishjar.github.io/kiss-translator/images/logo192.png","REACT_APP_RULESURL":"https://fishjar.github.io/kiss-rules/kiss-rules_v2.json","REACT_APP_RULESURL_ON":"https://fishjar.github.io/kiss-rules/kiss-rules-on_v2.json","REACT_APP_RULESURL_OFF":"https://fishjar.github.io/kiss-rules/kiss-rules-off_v2.json","REACT_APP_USERSCRIPT_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator.user.js","REACT_APP_USERSCRIPT_IOS_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js"})) && ({"NODE_ENV":"production","PUBLIC_URL":"","WDS_SOCKET_HOST":undefined,"WDS_SOCKET_PATH":undefined,"WDS_SOCKET_PORT":undefined,"FAST_REFRESH":true,"REACT_APP_CLIENT":"userscript","REACT_APP_NAME":"KISS Translator","REACT_APP_NAME_CN":"简约翻译","REACT_APP_VERSION":"2.0.10","REACT_APP_HOMEPAGE":"https://github.com/fishjar/kiss-translator","REACT_APP_OPTIONSPAGE":"https://fishjar.github.io/kiss-translator/options.html","REACT_APP_OPTIONSPAGE_DEV":"http://localhost:3000/options.html","REACT_APP_LOGOURL":"https://fishjar.github.io/kiss-translator/images/logo192.png","REACT_APP_RULESURL":"https://fishjar.github.io/kiss-rules/kiss-rules_v2.json","REACT_APP_RULESURL_ON":"https://fishjar.github.io/kiss-rules/kiss-rules-on_v2.json","REACT_APP_RULESURL_OFF":"https://fishjar.github.io/kiss-rules/kiss-rules-off_v2.json","REACT_APP_USERSCRIPT_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator.user.js","REACT_APP_USERSCRIPT_IOS_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js"}) && ({"NODE_ENV":"production","PUBLIC_URL":"","WDS_SOCKET_HOST":undefined,"WDS_SOCKET_PATH":undefined,"WDS_SOCKET_PORT":undefined,"FAST_REFRESH":true,"REACT_APP_CLIENT":"userscript","REACT_APP_NAME":"KISS Translator","REACT_APP_NAME_CN":"简约翻译","REACT_APP_VERSION":"2.0.10","REACT_APP_HOMEPAGE":"https://github.com/fishjar/kiss-translator","REACT_APP_OPTIONSPAGE":"https://fishjar.github.io/kiss-translator/options.html","REACT_APP_OPTIONSPAGE_DEV":"http://localhost:3000/options.html","REACT_APP_LOGOURL":"https://fishjar.github.io/kiss-translator/images/logo192.png","REACT_APP_RULESURL":"https://fishjar.github.io/kiss-rules/kiss-rules_v2.json","REACT_APP_RULESURL_ON":"https://fishjar.github.io/kiss-rules/kiss-rules-on_v2.json","REACT_APP_RULESURL_OFF":"https://fishjar.github.io/kiss-rules/kiss-rules-off_v2.json","REACT_APP_USERSCRIPT_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator.user.js","REACT_APP_USERSCRIPT_IOS_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js"}).__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix"; + te = "object" === ("undefined" == typeof process ? "undefined" : Nt(process)) && process ? "object" === Nt(({"NODE_ENV":"production","PUBLIC_URL":"","WDS_SOCKET_HOST":undefined,"WDS_SOCKET_PATH":undefined,"WDS_SOCKET_PORT":undefined,"FAST_REFRESH":true,"REACT_APP_CLIENT":"userscript","REACT_APP_NAME":"KISS Translator","REACT_APP_NAME_CN":"简约翻译","REACT_APP_VERSION":"2.0.11","REACT_APP_HOMEPAGE":"https://github.com/fishjar/kiss-translator","REACT_APP_OPTIONSPAGE":"https://fishjar.github.io/kiss-translator/options.html","REACT_APP_OPTIONSPAGE_DEV":"http://localhost:3000/options.html","REACT_APP_LOGOURL":"https://fishjar.github.io/kiss-translator/images/logo192.png","REACT_APP_RULESURL":"https://fishjar.github.io/kiss-rules/kiss-rules_v2.json","REACT_APP_RULESURL_ON":"https://fishjar.github.io/kiss-rules/kiss-rules-on_v2.json","REACT_APP_RULESURL_OFF":"https://fishjar.github.io/kiss-rules/kiss-rules-off_v2.json","REACT_APP_USERSCRIPT_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator.user.js","REACT_APP_USERSCRIPT_IOS_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js"})) && ({"NODE_ENV":"production","PUBLIC_URL":"","WDS_SOCKET_HOST":undefined,"WDS_SOCKET_PATH":undefined,"WDS_SOCKET_PORT":undefined,"FAST_REFRESH":true,"REACT_APP_CLIENT":"userscript","REACT_APP_NAME":"KISS Translator","REACT_APP_NAME_CN":"简约翻译","REACT_APP_VERSION":"2.0.11","REACT_APP_HOMEPAGE":"https://github.com/fishjar/kiss-translator","REACT_APP_OPTIONSPAGE":"https://fishjar.github.io/kiss-translator/options.html","REACT_APP_OPTIONSPAGE_DEV":"http://localhost:3000/options.html","REACT_APP_LOGOURL":"https://fishjar.github.io/kiss-translator/images/logo192.png","REACT_APP_RULESURL":"https://fishjar.github.io/kiss-rules/kiss-rules_v2.json","REACT_APP_RULESURL_ON":"https://fishjar.github.io/kiss-rules/kiss-rules-on_v2.json","REACT_APP_RULESURL_OFF":"https://fishjar.github.io/kiss-rules/kiss-rules-off_v2.json","REACT_APP_USERSCRIPT_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator.user.js","REACT_APP_USERSCRIPT_IOS_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js"}) && ({"NODE_ENV":"production","PUBLIC_URL":"","WDS_SOCKET_HOST":undefined,"WDS_SOCKET_PATH":undefined,"WDS_SOCKET_PORT":undefined,"FAST_REFRESH":true,"REACT_APP_CLIENT":"userscript","REACT_APP_NAME":"KISS Translator","REACT_APP_NAME_CN":"简约翻译","REACT_APP_VERSION":"2.0.11","REACT_APP_HOMEPAGE":"https://github.com/fishjar/kiss-translator","REACT_APP_OPTIONSPAGE":"https://fishjar.github.io/kiss-translator/options.html","REACT_APP_OPTIONSPAGE_DEV":"http://localhost:3000/options.html","REACT_APP_LOGOURL":"https://fishjar.github.io/kiss-translator/images/logo192.png","REACT_APP_RULESURL":"https://fishjar.github.io/kiss-rules/kiss-rules_v2.json","REACT_APP_RULESURL_ON":"https://fishjar.github.io/kiss-rules/kiss-rules-on_v2.json","REACT_APP_RULESURL_OFF":"https://fishjar.github.io/kiss-rules/kiss-rules-off_v2.json","REACT_APP_USERSCRIPT_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator.user.js","REACT_APP_USERSCRIPT_IOS_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js"}).__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix"; It.sep = "win32" === te ? "\\" : "/"; var ee = Symbol("globstar **"); It.GLOBSTAR = ee; @@ -35602,8 +35602,8 @@ if(isAISegment&&segApiSetting){logger.info("Youtube Provider: Starting AI ..."); const trustedTypesHelper=(()=>{const POLICY_NAME="kiss-translator-policy";let policy=null;if(globalThis.trustedTypes&&globalThis.trustedTypes.createPolicy){try{policy=globalThis.trustedTypes.createPolicy(POLICY_NAME,{createHTML:string=>string,createScript:string=>string,createScriptURL:string=>string});}catch(err){if(err.message.includes("already exists")){policy=globalThis.trustedTypes.policies.get(POLICY_NAME);}else{logger.info("cont create Trusted Types",err);}}}return{createHTML:htmlString=>{return policy?policy.createHTML(htmlString):htmlString;},createScript:scriptString=>{return policy?policy.createScript(scriptString):scriptString;},createScriptURL:urlString=>{return policy?policy.createScriptURL(urlString):urlString;},isEnabled:()=>policy!==null};})(); ;// CONCATENATED MODULE: ./src/libs/injector.js // Function to inject inline JavaScript code -const injectInlineJs=function(code){let id=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"kiss-translator-inline-js";if(document.getElementById(id)){return;}const el=document.createElement("script");el.type="text/javascript";el.id=id;el.textContent=trustedTypesHelper.createScript(code);(document.head||document.documentElement).appendChild(el);};const injectInlineJsBg=function(code){let id=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"kiss-translator-inline-js";if(document.getElementById(id)){return;}const el=document.createElement("script");el.type="text/javascript";el.id=id;el.textContent=code;(document.head||document.documentElement).appendChild(el);};// Function to inject external JavaScript file -const injectExternalJs=function(src){let id=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"kiss-translator-external-js";if(document.getElementById(id)){return;}const el=document.createElement("script");el.type="text/javascript";el.id=id;el.src=trustedTypesHelper.createScriptURL(src);(document.head||document.documentElement).appendChild(el);};// Function to inject internal CSS code +const injectInlineJs=function(code){let id=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"kiss-translator-inline-js";if(document.getElementById(id)){return;}const el=document.createElement("script");el.setAttribute("data-source","kiss-inject injectInlineJs");el.type="text/javascript";el.id=id;el.textContent=trustedTypesHelper.createScript(code);(document.head||document.documentElement).appendChild(el);};const injectInlineJsBg=function(code){let id=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"kiss-translator-inline-js";if(document.getElementById(id)){return;}const el=document.createElement("script");el.setAttribute("data-source","kiss-inject injectInlineJsBg");el.type="text/javascript";el.id=id;el.textContent=code;(document.head||document.documentElement).appendChild(el);};// Function to inject external JavaScript file +const injectExternalJs=function(src){let id=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"kiss-translator-external-js";if(document.getElementById(id)){return;}const el=document.createElement("script");el.setAttribute("data-source","kiss-inject injectExternalJs");el.type="text/javascript";el.id=id;el.src=trustedTypesHelper.createScriptURL(src);(document.head||document.documentElement).appendChild(el);};// Function to inject internal CSS code const injectInternalCss=styles=>{var _document$head;const el=document.createElement("style");el.setAttribute("data-source","kiss-inject injectInternalCss");el.textContent=styles;(_document$head=document.head)===null||_document$head===void 0?void 0:_document$head.appendChild(el);};// Function to inject external CSS file const injectExternalCss=href=>{var _document$head2;const el=document.createElement("link");el.setAttribute("data-source","kiss-inject injectExternalCss");el.setAttribute("rel","stylesheet");el.setAttribute("type","text/css");el.setAttribute("href",href);(_document$head2=document.head)===null||_document$head2===void 0?void 0:_document$head2.appendChild(el);}; ;// CONCATENATED MODULE: ./src/injectors/shadowroot.js @@ -36687,7 +36687,7 @@ var _class;/** * @description 翻译核心逻辑封装 */var translator_setting=/*#__PURE__*/_classPrivateFieldKey("setting");var _rule=/*#__PURE__*/_classPrivateFieldKey("rule");var _isInitialized=/*#__PURE__*/_classPrivateFieldKey("isInitialized");var _isJsInjected=/*#__PURE__*/_classPrivateFieldKey("isJsInjected");var _isShadowRootJsInjected=/*#__PURE__*/_classPrivateFieldKey("isShadowRootJsInjected");var _mouseHoverEnabled=/*#__PURE__*/_classPrivateFieldKey("mouseHoverEnabled");var _enabled=/*#__PURE__*/_classPrivateFieldKey("enabled");var _runId=/*#__PURE__*/_classPrivateFieldKey("runId");var _termValues=/*#__PURE__*/_classPrivateFieldKey("termValues");var _combinedTermsRegex=/*#__PURE__*/_classPrivateFieldKey("combinedTermsRegex");var _combinedSkipsRegex=/*#__PURE__*/_classPrivateFieldKey("combinedSkipsRegex");var _placeholderRegex=/*#__PURE__*/_classPrivateFieldKey("placeholderRegex");var _translationTagName=/*#__PURE__*/_classPrivateFieldKey("translationTagName");var _eventName=/*#__PURE__*/_classPrivateFieldKey("eventName");var _docInfo=/*#__PURE__*/_classPrivateFieldKey("docInfo");var _glossary=/*#__PURE__*/_classPrivateFieldKey("glossary");var _textClass=/*#__PURE__*/_classPrivateFieldKey("textClass");var _textSheet=/*#__PURE__*/_classPrivateFieldKey("textSheet");var _apisMap=/*#__PURE__*/_classPrivateFieldKey("apisMap");var _favWords=/*#__PURE__*/_classPrivateFieldKey("favWords");var _observedNodes=/*#__PURE__*/_classPrivateFieldKey("observedNodes");var _translationNodes=/*#__PURE__*/_classPrivateFieldKey("translationNodes");var _viewNodes=/*#__PURE__*/_classPrivateFieldKey("viewNodes");var _processedNodes=/*#__PURE__*/_classPrivateFieldKey("processedNodes");var _rootNodes=/*#__PURE__*/_classPrivateFieldKey("rootNodes");var _skipMoNodes=/*#__PURE__*/_classPrivateFieldKey("skipMoNodes");var _removeKeydownHandler=/*#__PURE__*/_classPrivateFieldKey("removeKeydownHandler");var _hoveredNode=/*#__PURE__*/_classPrivateFieldKey("hoveredNode");var _boundMouseMoveHandler=/*#__PURE__*/_classPrivateFieldKey("boundMouseMoveHandler");var _boundKeyDownHandler=/*#__PURE__*/_classPrivateFieldKey("boundKeyDownHandler");var _windowMessageHandler=/*#__PURE__*/_classPrivateFieldKey("windowMessageHandler");var _debouncedFindShadowRoot=/*#__PURE__*/_classPrivateFieldKey("debouncedFindShadowRoot");var _io=/*#__PURE__*/_classPrivateFieldKey("io");var _mo=/*#__PURE__*/_classPrivateFieldKey("mo");var _dmm=/*#__PURE__*/_classPrivateFieldKey("dmm");var _rescanQueue=/*#__PURE__*/_classPrivateFieldKey("rescanQueue");var _isQueueProcessing=/*#__PURE__*/_classPrivateFieldKey("isQueueProcessing");var _ignoreSelector=/*#__PURE__*/_classPrivateFieldKey("ignoreSelector");var _apiSetting=/*#__PURE__*/_classPrivateFieldKey("apiSetting");var _placeholder=/*#__PURE__*/_classPrivateFieldKey("placeholder");var _run=/*#__PURE__*/_classPrivateFieldKey("run");var _init=/*#__PURE__*/_classPrivateFieldKey("init");var _handleWindowMessage=/*#__PURE__*/_classPrivateFieldKey("handleWindowMessage");var _attachShadowRootListener=/*#__PURE__*/_classPrivateFieldKey("attachShadowRootListener");var _removeShadowRootListener=/*#__PURE__*/_classPrivateFieldKey("removeShadowRootListener");var _findAndObserveShadowRoot=/*#__PURE__*/_classPrivateFieldKey("findAndObserveShadowRoot");var _createPlaceholderRegex=/*#__PURE__*/_classPrivateFieldKey("createPlaceholderRegex");var _createTextStyles=/*#__PURE__*/_classPrivateFieldKey("createTextStyles");var _injectSheet=/*#__PURE__*/_classPrivateFieldKey("injectSheet");var _parseTerms=/*#__PURE__*/_classPrivateFieldKey("parseTerms");var _parseAITerms=/*#__PURE__*/_classPrivateFieldKey("parseAITerms");var _getDocDescription=/*#__PURE__*/_classPrivateFieldKey("getDocDescription");var _createIntersectionObserver=/*#__PURE__*/_classPrivateFieldKey("createIntersectionObserver");var _createMutationObserver=/*#__PURE__*/_classPrivateFieldKey("createMutationObserver");var _createDebounceMouseMover=/*#__PURE__*/_classPrivateFieldKey("createDebounceMouseMover");var _handleMouseMove=/*#__PURE__*/_classPrivateFieldKey("handleMouseMove");var _handleKeyDown=/*#__PURE__*/_classPrivateFieldKey("handleKeyDown");var _toggleTargetNode=/*#__PURE__*/_classPrivateFieldKey("toggleTargetNode");var _findAllShadowRoots=/*#__PURE__*/_classPrivateFieldKey("findAllShadowRoots");var _findChangeContainer=/*#__PURE__*/_classPrivateFieldKey("findChangeContainer");var _queueForRescan=/*#__PURE__*/_classPrivateFieldKey("queueForRescan");var _rescanContainer=/*#__PURE__*/_classPrivateFieldKey("rescanContainer");var _reIO=/*#__PURE__*/_classPrivateFieldKey("reIO");var _reIOViewNodes=/*#__PURE__*/_classPrivateFieldKey("reIOViewNodes");var _startObserveShadowRoot=/*#__PURE__*/_classPrivateFieldKey("startObserveShadowRoot");var _startObserveRoot=/*#__PURE__*/_classPrivateFieldKey("startObserveRoot");var _startObserveNode=/*#__PURE__*/_classPrivateFieldKey("startObserveNode");var _queryNode=/*#__PURE__*/_classPrivateFieldKey("queryNode");var _scanNode=/*#__PURE__*/_classPrivateFieldKey("scanNode");var _processNode=/*#__PURE__*/_classPrivateFieldKey("processNode");var _highlightTextNode=/*#__PURE__*/_classPrivateFieldKey("highlightTextNode");var _highlightWordsDeeply=/*#__PURE__*/_classPrivateFieldKey("highlightWordsDeeply");var _splitTextNodesBySentence=/*#__PURE__*/_classPrivateFieldKey("splitTextNodesBySentence");var _removeHighlights=/*#__PURE__*/_classPrivateFieldKey("removeHighlights");var _removeBrTags=/*#__PURE__*/_classPrivateFieldKey("removeBrTags");var _shouldBreak=/*#__PURE__*/_classPrivateFieldKey("shouldBreak");var _isInvalidText=/*#__PURE__*/_classPrivateFieldKey("isInvalidText");var _translateNodeGroup=/*#__PURE__*/_classPrivateFieldKey("translateNodeGroup");var _serializeForTranslation=/*#__PURE__*/_classPrivateFieldKey("serializeForTranslation");var _restoreFromTranslation=/*#__PURE__*/_classPrivateFieldKey("restoreFromTranslation");var _translateFetch=/*#__PURE__*/_classPrivateFieldKey("translateFetch");var _findTranslationWrappers=/*#__PURE__*/_classPrivateFieldKey("findTranslationWrappers");var _cleanupAllNodes=/*#__PURE__*/_classPrivateFieldKey("cleanupAllNodes");var _cleanupAllTranslations=/*#__PURE__*/_classPrivateFieldKey("cleanupAllTranslations");var _cleanupDirectTranslations=/*#__PURE__*/_classPrivateFieldKey("cleanupDirectTranslations");var _removeTranslationElement=/*#__PURE__*/_classPrivateFieldKey("removeTranslationElement");var _restoreOriginal=/*#__PURE__*/_classPrivateFieldKey("restoreOriginal");var _removeNodes=/*#__PURE__*/_classPrivateFieldKey("removeNodes");var _toggleTranslationOnly=/*#__PURE__*/_classPrivateFieldKey("toggleTranslationOnly");var _updateStyle=/*#__PURE__*/_classPrivateFieldKey("updateStyle");var _refreshNode=/*#__PURE__*/_classPrivateFieldKey("refreshNode");var _performSyncNode=/*#__PURE__*/_classPrivateFieldKey("performSyncNode");var _resetOptions=/*#__PURE__*/_classPrivateFieldKey("resetOptions");var _enableMouseHover=/*#__PURE__*/_classPrivateFieldKey("enableMouseHover");var _disableMouseHover=/*#__PURE__*/_classPrivateFieldKey("disableMouseHover");var _initInjector=/*#__PURE__*/_classPrivateFieldKey("initInjector");var _removeInjector=/*#__PURE__*/_classPrivateFieldKey("removeInjector");var _translateTitle=/*#__PURE__*/_classPrivateFieldKey("translateTitle");class translator_Translator{// 默认规则 static isElement(el){return el instanceof Element;}static isElementOrFragment(el){return el instanceof Element||el instanceof DocumentFragment;}// 判断是否块级元素 -static isBlockNode(el){var _el$attributes,_el$attributes$displa,_el$attributes$displa2;if(!translator_Translator.isElementOrFragment(el))return false;if(translator_Translator.TAGS.INLINE.has(el.nodeName))return false;if(translator_Translator.TAGS.BLOCK.has(el.nodeName))return true;if((_el$attributes=el.attributes)!==null&&_el$attributes!==void 0&&(_el$attributes$displa=_el$attributes.display)!==null&&_el$attributes$displa!==void 0&&(_el$attributes$displa2=_el$attributes$displa.value)!==null&&_el$attributes$displa2!==void 0&&_el$attributes$displa2.includes("inline"))return false;if(translator_Translator.displayCache.has(el)){return translator_Translator.displayCache.get(el);}const isBlock=!window.getComputedStyle(el).display.startsWith("inline");translator_Translator.displayCache.set(el,isBlock);return isBlock;}// 判断是否包含块级子元素 +static isBlockNode(el){var _el$nodeName,_el$nodeName2,_el$attributes,_el$attributes$displa,_el$attributes$displa2;if(!translator_Translator.isElementOrFragment(el))return false;if(translator_Translator.TAGS.INLINE.has((_el$nodeName=el.nodeName)===null||_el$nodeName===void 0?void 0:_el$nodeName.toUpperCase()))return false;if(translator_Translator.TAGS.BLOCK.has((_el$nodeName2=el.nodeName)===null||_el$nodeName2===void 0?void 0:_el$nodeName2.toUpperCase()))return true;if((_el$attributes=el.attributes)!==null&&_el$attributes!==void 0&&(_el$attributes$displa=_el$attributes.display)!==null&&_el$attributes$displa!==void 0&&(_el$attributes$displa2=_el$attributes$displa.value)!==null&&_el$attributes$displa2!==void 0&&_el$attributes$displa2.includes("inline"))return false;if(translator_Translator.displayCache.has(el)){return translator_Translator.displayCache.get(el);}const isBlock=!window.getComputedStyle(el).display.startsWith("inline");translator_Translator.displayCache.set(el,isBlock);return isBlock;}// 判断是否包含块级子元素 static hasBlockNode(el){if(!translator_Translator.isElementOrFragment(el))return false;for(const child of el.childNodes){if(translator_Translator.isBlockNode(child)){return true;}}return false;}// 判断是否直接包含非空文本节点 static hasTextNode(el){if(!translator_Translator.isElementOrFragment(el))return false;for(const child of el.childNodes){if(child.nodeType===Node.TEXT_NODE&&/\S/.test(child.nodeValue)){return true;}}return false;}// 特殊字符转义 static escapeRegex(str){return str.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");}// 内置忽略元素 @@ -36761,7 +36761,7 @@ Object.defineProperty(this,_termValues,{writable:true,value:[]});// 按顺序存 Object.defineProperty(this,_combinedTermsRegex,{writable:true,value:void 0});// 专业术语正则表达式 Object.defineProperty(this,_combinedSkipsRegex,{writable:true,value:void 0});// 跳过文本正则表达式 Object.defineProperty(this,_placeholderRegex,{writable:true,value:void 0});// 恢复htnml正则表达式 -Object.defineProperty(this,_translationTagName,{writable:true,value:APP_UPNAME});// 翻译容器的标签名 +Object.defineProperty(this,_translationTagName,{writable:true,value:APP_LCNAME});// 翻译容器的标签名 Object.defineProperty(this,_eventName,{writable:true,value:""});// 通信事件名称 Object.defineProperty(this,_docInfo,{writable:true,value:{}});// 网页信息 Object.defineProperty(this,_glossary,{writable:true,value:{}});// AI词典 @@ -36805,7 +36805,7 @@ return _classPrivateFieldBase(this,_apisMap)[_apisMap].get(_classPrivateFieldBas _classPrivateFieldBase(this,_initInjector)[_initInjector]();// 纯文本预处理 if(_classPrivateFieldBase(this,_rule)[_rule].isPlainText){document.querySelectorAll("pre").forEach(pre=>{var _pre$innerHTML;return pre.innerHTML=(_pre$innerHTML=pre.innerHTML)===null||_pre$innerHTML===void 0?void 0:_pre$innerHTML.replace(/(?:\r\n|\r|\n)/g,"
");});}// 查找根节点并扫描 document.querySelectorAll(_classPrivateFieldBase(this,_rule)[_rule].rootsSelector||"body").forEach(root=>{_classPrivateFieldBase(this,_startObserveRoot)[_startObserveRoot](root);});if(_classPrivateFieldBase(this,_rule)[_rule].hasShadowroot==="true"){_classPrivateFieldBase(this,_attachShadowRootListener)[_attachShadowRootListener]();_classPrivateFieldBase(this,_findAndObserveShadowRoot)[_findAndObserveShadowRoot]();}}function _handleWindowMessage2(event){var _event$data;if(((_event$data=event.data)===null||_event$data===void 0?void 0:_event$data.type)==="KISS_SHADOW_ROOT_CREATED"){_classPrivateFieldBase(this,_debouncedFindShadowRoot)[_debouncedFindShadowRoot]();}}function _attachShadowRootListener2(){if(!_classPrivateFieldBase(this,_isShadowRootJsInjected)[_isShadowRootJsInjected]){const id="kiss-translator-inject-shadowroot-js";injectJs(INJECTOR.shadowroot,id);_classPrivateFieldBase(this,_isShadowRootJsInjected)[_isShadowRootJsInjected]=true;}window.addEventListener("message",_classPrivateFieldBase(this,_windowMessageHandler)[_windowMessageHandler]);}function _removeShadowRootListener2(){window.removeEventListener("message",_classPrivateFieldBase(this,_windowMessageHandler)[_windowMessageHandler]);}function _findAndObserveShadowRoot2(){try{_classPrivateFieldBase(this,_findAllShadowRoots)[_findAllShadowRoots]().forEach(shadowRoot=>{_classPrivateFieldBase(this,_startObserveShadowRoot)[_startObserveShadowRoot](shadowRoot);});}catch(err){log_kissLog("findAllShadowRoots",err);}}function _createPlaceholderRegex2(){const escapedStart=_class.escapeRegex(_classPrivateFieldBase(this,_placeholder)[_placeholder].startDelimiter);const escapedEnd=_class.escapeRegex(_classPrivateFieldBase(this,_placeholder)[_placeholder].endDelimiter);const patternString="(".concat(escapedStart,"\\d+").concat(escapedEnd,"|<\\/?\\w+\\d+>)");const flags="g";return new RegExp(patternString,flags);}function _createTextStyles2(){const[textClass,textStyles]=genTextClass(_classPrivateFieldBase(this,translator_setting)[translator_setting].customStyles);const textSheet=new CSSStyleSheet();textSheet.replaceSync(textStyles);_classPrivateFieldBase(this,_textClass)[_textClass]=textClass;_classPrivateFieldBase(this,_textSheet)[_textSheet]=textSheet;}function _injectSheet2(shadowRoot){if(!shadowRoot.adoptedStyleSheets.includes(_classPrivateFieldBase(this,_textSheet)[_textSheet])){shadowRoot.adoptedStyleSheets=[...shadowRoot.adoptedStyleSheets,_classPrivateFieldBase(this,_textSheet)[_textSheet]];}}function _parseTerms2(termsString){_classPrivateFieldBase(this,_termValues)[_termValues]=[];_classPrivateFieldBase(this,_combinedTermsRegex)[_combinedTermsRegex]=null;if(!termsString||typeof termsString!=="string")return;const termPatterns=[];const lines=termsString.split(/\n|;/);// 按换行或分号分割 -for(const line of lines){const trimmedLine=line.trim();if(!trimmedLine)continue;let lastCommaIndex=trimmedLine.lastIndexOf(",");if(lastCommaIndex===-1){lastCommaIndex=trimmedLine.length;}const key=trimmedLine.substring(0,lastCommaIndex).trim();const value=trimmedLine.substring(lastCommaIndex+1).trim();if(key){try{new RegExp(key);termPatterns.push("(".concat(key,")"));_classPrivateFieldBase(this,_termValues)[_termValues].push(value);}catch(err){log_kissLog("Invalid RegExp for term: \"".concat(key,"\""),err);}}}if(termPatterns.length>0){_classPrivateFieldBase(this,_combinedTermsRegex)[_combinedTermsRegex]=new RegExp(termPatterns.join("|"),"g");}}function _parseAITerms2(termsString){if(!termsString||typeof termsString!=="string")return;try{_classPrivateFieldBase(this,_glossary)[_glossary]=Object.fromEntries(termsString.split(/\n|;/).map(line=>{const[k="",v=""]=line.split(",").map(s=>s.trim());return[k,v];}).filter(_ref2=>{let[k]=_ref2;return k;}));}catch(err){log_kissLog("parse aiterms",err);}}function _getDocDescription2(){try{const meta=document.querySelector('meta[name="description"]');const description=(meta===null||meta===void 0?void 0:meta.getAttribute("content"))||"";return truncateWords(description);}catch(err){log_kissLog("get description",err);}return"";}function _createIntersectionObserver2(){const{transInterval,rootMargin=500}=_classPrivateFieldBase(this,translator_setting)[translator_setting];const pending=new Set();const flush=debounce(()=>{pending.forEach(node=>_classPrivateFieldBase(this,_performSyncNode)[_performSyncNode](node));pending.clear();},transInterval);return new IntersectionObserver(entries=>{entries.forEach(entry=>{if(entry.isIntersecting){_classPrivateFieldBase(this,_viewNodes)[_viewNodes].add(entry.target);pending.add(entry.target);flush();}else{_classPrivateFieldBase(this,_viewNodes)[_viewNodes].delete(entry.target);}});},{threshold:0.01,rootMargin:"".concat(rootMargin,"px 0px ").concat(rootMargin,"px 0px")});}function _createMutationObserver2(){return new MutationObserver(mutations=>{for(const mutation of mutations){var _mutation$nextSibling;if(_classPrivateFieldBase(this,_skipMoNodes)[_skipMoNodes].has(mutation.target)||((_mutation$nextSibling=mutation.nextSibling)===null||_mutation$nextSibling===void 0?void 0:_mutation$nextSibling.tagName)===_classPrivateFieldBase(this,_translationTagName)[_translationTagName]){continue;}if(mutation.type==="characterData"){if(mutation.oldValue!==mutation.target.nodeValue&&!_classPrivateFieldBase(this,_combinedSkipsRegex)[_combinedSkipsRegex].test(mutation.target.nodeValue)){_classPrivateFieldBase(this,_queueForRescan)[_queueForRescan](mutation.target.parentElement);}}else if(mutation.type==="childList"){let nodes=new Set();let hasText=false;mutation.addedNodes.forEach(node=>{if(_classPrivateFieldBase(this,_skipMoNodes)[_skipMoNodes].has(node)||node.nodeName===_classPrivateFieldBase(this,_translationTagName)[_translationTagName]){return;}if(node.nodeType===Node.TEXT_NODE){hasText=true;}else if(_class.isElementOrFragment(node)){nodes.add(node);}});if(hasText){_classPrivateFieldBase(this,_queueForRescan)[_queueForRescan](mutation.target);}else{nodes.forEach(node=>_classPrivateFieldBase(this,_queueForRescan)[_queueForRescan](node));}}}});}function _createDebounceMouseMover2(){return debounce(targetNode=>{const startNode=targetNode;let foundNode=null;while(targetNode&&targetNode!==document.body){if(_classPrivateFieldBase(this,_observedNodes)[_observedNodes].has(targetNode)){foundNode=targetNode;break;}targetNode=targetNode.parentElement;}_classPrivateFieldBase(this,_hoveredNode)[_hoveredNode]=foundNode||startNode;const{mouseHoverKey}=_classPrivateFieldBase(this,translator_setting)[translator_setting].mouseHoverSetting;if(mouseHoverKey.length===0&&!_classPrivateFieldBase(this,_isInitialized)[_isInitialized]){_classPrivateFieldBase(this,_init)[_init]();}if(mouseHoverKey.length===0&&foundNode){_classPrivateFieldBase(this,_processNode)[_processNode](foundNode);}},100);}function _handleMouseMove2(event){let targetNode=event.composedPath()[0];_classPrivateFieldBase(this,_dmm)[_dmm](targetNode);}function _handleKeyDown2(){if(!_classPrivateFieldBase(this,_isInitialized)[_isInitialized]){_classPrivateFieldBase(this,_init)[_init]();}let targetNode=_classPrivateFieldBase(this,_hoveredNode)[_hoveredNode];if(!targetNode||!_classPrivateFieldBase(this,_observedNodes)[_observedNodes].has(targetNode))return;_classPrivateFieldBase(this,_toggleTargetNode)[_toggleTargetNode](targetNode);}function _toggleTargetNode2(targetNode){if(_classPrivateFieldBase(this,_processedNodes)[_processedNodes].has(targetNode)){_classPrivateFieldBase(this,_cleanupDirectTranslations)[_cleanupDirectTranslations](targetNode);}else{_classPrivateFieldBase(this,_processNode)[_processNode](targetNode);}}function _findAllShadowRoots2(){let root=arguments.length>0&&arguments[0]!==undefined?arguments[0]:document.body;let results=arguments.length>1&&arguments[1]!==undefined?arguments[1]:new Set();// const start = performance.now(); +for(const line of lines){const trimmedLine=line.trim();if(!trimmedLine)continue;let lastCommaIndex=trimmedLine.lastIndexOf(",");if(lastCommaIndex===-1){lastCommaIndex=trimmedLine.length;}const key=trimmedLine.substring(0,lastCommaIndex).trim();const value=trimmedLine.substring(lastCommaIndex+1).trim();if(key){try{new RegExp(key);termPatterns.push("(".concat(key,")"));_classPrivateFieldBase(this,_termValues)[_termValues].push(value);}catch(err){log_kissLog("Invalid RegExp for term: \"".concat(key,"\""),err);}}}if(termPatterns.length>0){_classPrivateFieldBase(this,_combinedTermsRegex)[_combinedTermsRegex]=new RegExp(termPatterns.join("|"),"g");}}function _parseAITerms2(termsString){if(!termsString||typeof termsString!=="string")return;try{_classPrivateFieldBase(this,_glossary)[_glossary]=Object.fromEntries(termsString.split(/\n|;/).map(line=>{const[k="",v=""]=line.split(",").map(s=>s.trim());return[k,v];}).filter(_ref2=>{let[k]=_ref2;return k;}));}catch(err){log_kissLog("parse aiterms",err);}}function _getDocDescription2(){try{const meta=document.querySelector('meta[name="description"]');const description=(meta===null||meta===void 0?void 0:meta.getAttribute("content"))||"";return truncateWords(description);}catch(err){log_kissLog("get description",err);}return"";}function _createIntersectionObserver2(){const{transInterval,rootMargin=500}=_classPrivateFieldBase(this,translator_setting)[translator_setting];const pending=new Set();const flush=debounce(()=>{pending.forEach(node=>_classPrivateFieldBase(this,_performSyncNode)[_performSyncNode](node));pending.clear();},transInterval);return new IntersectionObserver(entries=>{entries.forEach(entry=>{if(entry.isIntersecting){_classPrivateFieldBase(this,_viewNodes)[_viewNodes].add(entry.target);pending.add(entry.target);flush();}else{_classPrivateFieldBase(this,_viewNodes)[_viewNodes].delete(entry.target);}});},{threshold:0.01,rootMargin:"".concat(rootMargin,"px 0px ").concat(rootMargin,"px 0px")});}function _createMutationObserver2(){return new MutationObserver(mutations=>{for(const mutation of mutations){var _mutation$nextSibling,_mutation$nextSibling2;if(_classPrivateFieldBase(this,_skipMoNodes)[_skipMoNodes].has(mutation.target)||((_mutation$nextSibling=mutation.nextSibling)===null||_mutation$nextSibling===void 0?void 0:(_mutation$nextSibling2=_mutation$nextSibling.tagName)===null||_mutation$nextSibling2===void 0?void 0:_mutation$nextSibling2.toLowerCase())===_classPrivateFieldBase(this,_translationTagName)[_translationTagName]){continue;}if(mutation.type==="characterData"){if(mutation.oldValue!==mutation.target.nodeValue&&!_classPrivateFieldBase(this,_combinedSkipsRegex)[_combinedSkipsRegex].test(mutation.target.nodeValue)){_classPrivateFieldBase(this,_queueForRescan)[_queueForRescan](mutation.target.parentElement);}}else if(mutation.type==="childList"){let nodes=new Set();let hasText=false;mutation.addedNodes.forEach(node=>{var _node$nodeName;if(_classPrivateFieldBase(this,_skipMoNodes)[_skipMoNodes].has(node)||((_node$nodeName=node.nodeName)===null||_node$nodeName===void 0?void 0:_node$nodeName.toLowerCase())===_classPrivateFieldBase(this,_translationTagName)[_translationTagName]){return;}if(node.nodeType===Node.TEXT_NODE){hasText=true;}else if(_class.isElementOrFragment(node)){nodes.add(node);}});if(hasText){_classPrivateFieldBase(this,_queueForRescan)[_queueForRescan](mutation.target);}else{nodes.forEach(node=>_classPrivateFieldBase(this,_queueForRescan)[_queueForRescan](node));}}}});}function _createDebounceMouseMover2(){return debounce(targetNode=>{const startNode=targetNode;let foundNode=null;while(targetNode&&targetNode!==document.body){if(_classPrivateFieldBase(this,_observedNodes)[_observedNodes].has(targetNode)){foundNode=targetNode;break;}targetNode=targetNode.parentElement;}_classPrivateFieldBase(this,_hoveredNode)[_hoveredNode]=foundNode||startNode;const{mouseHoverKey}=_classPrivateFieldBase(this,translator_setting)[translator_setting].mouseHoverSetting;if(mouseHoverKey.length===0&&!_classPrivateFieldBase(this,_isInitialized)[_isInitialized]){_classPrivateFieldBase(this,_init)[_init]();}if(mouseHoverKey.length===0&&foundNode){_classPrivateFieldBase(this,_processNode)[_processNode](foundNode);}},100);}function _handleMouseMove2(event){let targetNode=event.composedPath()[0];_classPrivateFieldBase(this,_dmm)[_dmm](targetNode);}function _handleKeyDown2(){if(!_classPrivateFieldBase(this,_isInitialized)[_isInitialized]){_classPrivateFieldBase(this,_init)[_init]();}let targetNode=_classPrivateFieldBase(this,_hoveredNode)[_hoveredNode];if(!targetNode||!_classPrivateFieldBase(this,_observedNodes)[_observedNodes].has(targetNode))return;_classPrivateFieldBase(this,_toggleTargetNode)[_toggleTargetNode](targetNode);}function _toggleTargetNode2(targetNode){if(_classPrivateFieldBase(this,_processedNodes)[_processedNodes].has(targetNode)){_classPrivateFieldBase(this,_cleanupDirectTranslations)[_cleanupDirectTranslations](targetNode);}else{_classPrivateFieldBase(this,_processNode)[_processNode](targetNode);}}function _findAllShadowRoots2(){let root=arguments.length>0&&arguments[0]!==undefined?arguments[0]:document.body;let results=arguments.length>1&&arguments[1]!==undefined?arguments[1]:new Set();// const start = performance.now(); try{const walker=document.createTreeWalker(root,NodeFilter.SHOW_ELEMENT);while(walker.nextNode()){const node=walker.currentNode;if(node.shadowRoot){results.add(node.shadowRoot);_classPrivateFieldBase(this,_findAllShadowRoots)[_findAllShadowRoots](node.shadowRoot,results);}}}catch(err){log_kissLog("无法访问某个 shadowRoot",err);}// const end = performance.now(); // const duration = end - start; // console.log(`findAllShadowRoots 耗时:${duration} 毫秒`); @@ -36822,7 +36822,7 @@ let deLang="";const{fromLang="auto",toLang,splitParagraph=OPT_SPLIT_PARAGRAPH_DI return;}}// 切分长段落 if(splitParagraph!==OPT_SPLIT_PARAGRAPH_DISABLE){_classPrivateFieldBase(this,_splitTextNodesBySentence)[_splitTextNodesBySentence](node,splitParagraph,splitLength);}let nodeGroup=[];[...node.childNodes].forEach(child=>{const shouldBreak=_classPrivateFieldBase(this,_shouldBreak)[_shouldBreak](child);const shouldGroup=child.nodeType===Node.ELEMENT_NODE||child.nodeType===Node.TEXT_NODE;if(!shouldBreak&&shouldGroup){nodeGroup.push(child);}else if(shouldBreak&&nodeGroup.length){_classPrivateFieldBase(this,_translateNodeGroup)[_translateNodeGroup](nodeGroup,node,deLang);nodeGroup=[];}});if(nodeGroup.length){_classPrivateFieldBase(this,_translateNodeGroup)[_translateNodeGroup](nodeGroup,node,deLang);}}function _highlightTextNode2(textNode,wordRegex){var _textNode$parentNode;if(((_textNode$parentNode=textNode.parentNode)===null||_textNode$parentNode===void 0?void 0:_textNode$parentNode.nodeName.toLowerCase())==="b"){return;}if(!wordRegex.test(textNode.textContent)){return;}wordRegex.lastIndex=0;const fragments=textNode.textContent.split(wordRegex);const newNodes=[];fragments.forEach((fragment,i)=>{if(!fragment)return;if(i%2===1){// 奇数索引是匹配到的关键词 const bTag=document.createElement("b");bTag.className=_class.KISS_CLASS.highlight;bTag.style.cssText=_classPrivateFieldBase(this,_rule)[_rule].highlightStyle||"";bTag.textContent=fragment;_classPrivateFieldBase(this,_skipMoNodes)[_skipMoNodes].add(bTag);newNodes.push(bTag);}else{// 偶数索引是普通文本 -const newTextNode=document.createTextNode(fragment);_classPrivateFieldBase(this,_skipMoNodes)[_skipMoNodes].add(newTextNode);newNodes.push(newTextNode);}});if(newNodes.length>0){textNode.replaceWith(...newNodes);}}function _highlightWordsDeeply2(parentNode){if(!parentNode||_classPrivateFieldBase(this,_favWords)[_favWords].length===0){return;}const escapeRegex=str=>str.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");const escapedWords=_classPrivateFieldBase(this,_favWords)[_favWords].map(escapeRegex);const wordRegex=new RegExp("\\b(".concat(escapedWords.join("|"),")\\b"),"gi");if(parentNode.nodeType===Node.ELEMENT_NODE){const walker=document.createTreeWalker(parentNode,NodeFilter.SHOW_TEXT,null,false);const nodesToProcess=[];let node;while(node=walker.nextNode()){nodesToProcess.push(node);}nodesToProcess.forEach(textNode=>{_classPrivateFieldBase(this,_highlightTextNode)[_highlightTextNode](textNode,wordRegex);});}else if(parentNode.nodeType===Node.TEXT_NODE){_classPrivateFieldBase(this,_highlightTextNode)[_highlightTextNode](parentNode,wordRegex);}}function _splitTextNodesBySentence2(parentNode,splitParagraph,splitLength){const sentenceEndRegexForSplit=/[。!?]+|[.?!]+(?=\s+|$)/g;[...parentNode.childNodes].forEach(node=>{if(node.nodeType!==Node.TEXT_NODE||node.textContent.trim()===""){return;}const text=node.textContent;const parts=[];let lastIndex=0;let match;while((match=sentenceEndRegexForSplit.exec(text))!==null){let realEndIndex=match.index+match[0].length;while(realEndIndexpart.trim().length>0);if(validParts.length<=1){return;}const newNodes=validParts.map(part=>{const newNode=document.createTextNode(part);_classPrivateFieldBase(this,_skipMoNodes)[_skipMoNodes].add(newNode);return newNode;});node.replaceWith(...newNodes);});const sentenceEndRegexForTest=/(?:[。!??!]+|(?{var _node$nextSibling;textLength+=node.textContent.length;const isSentenceEnd=sentenceEndRegexForTest.test(node.textContent);if(!isSentenceEnd||((_node$nextSibling=node.nextSibling)===null||_node$nextSibling===void 0?void 0:_node$nextSibling.nodeName)==="BR"){return;}if(splitParagraph===OPT_SPLIT_PARAGRAPH_PUNCTUATION||splitParagraph===OPT_SPLIT_PARAGRAPH_TEXTLENGTH&&textLength>=splitLength){textLength=0;const br=document.createElement("br");br.className=_class.KISS_CLASS.br;_classPrivateFieldBase(this,_skipMoNodes)[_skipMoNodes].add(br);node.after(br);}});}function _removeHighlights2(parentNode){if(!parentNode)return;const highlightedElements=parentNode.querySelectorAll(".".concat(_class.KISS_CLASS.highlight));highlightedElements.forEach(element=>{const textNode=document.createTextNode(element.textContent);element.replaceWith(textNode);});parentNode.normalize();}function _removeBrTags2(parentNode){if(!parentNode)return;parentNode.querySelectorAll(".".concat(_class.KISS_CLASS.br)).forEach(br=>br.remove());parentNode.normalize();}function _shouldBreak2(node){var _node$matches;if(!_class.isElementOrFragment(node))return false;if(node.matches(_classPrivateFieldBase(this,_rule)[_rule].keepSelector))return false;if(_class.TAGS.BREAK_LINE.has(node.nodeName)||(_node$matches=node.matches)!==null&&_node$matches!==void 0&&_node$matches.call(node,_classPrivateFieldBase(this,_ignoreSelector)[_ignoreSelector])||node.nodeName===_classPrivateFieldBase(this,_translationTagName)[_translationTagName]){return true;}if(_classPrivateFieldBase(this,_rule)[_rule].autoScan&&_class.isBlockNode(node)){return true;}if(!_classPrivateFieldBase(this,_rule)[_rule].autoScan&&(node.matches(_classPrivateFieldBase(this,_rule)[_rule].selector)||node.querySelector(_classPrivateFieldBase(this,_rule)[_rule].selector))){return true;}return false;}function _isInvalidText2(text){if(typeof text!=="string"){return true;}const trimmedText=text.trim();// 文本长度 +const newTextNode=document.createTextNode(fragment);_classPrivateFieldBase(this,_skipMoNodes)[_skipMoNodes].add(newTextNode);newNodes.push(newTextNode);}});if(newNodes.length>0){textNode.replaceWith(...newNodes);}}function _highlightWordsDeeply2(parentNode){if(!parentNode||_classPrivateFieldBase(this,_favWords)[_favWords].length===0){return;}const escapeRegex=str=>str.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");const escapedWords=_classPrivateFieldBase(this,_favWords)[_favWords].map(escapeRegex);const wordRegex=new RegExp("\\b(".concat(escapedWords.join("|"),")\\b"),"gi");if(parentNode.nodeType===Node.ELEMENT_NODE){const walker=document.createTreeWalker(parentNode,NodeFilter.SHOW_TEXT,null,false);const nodesToProcess=[];let node;while(node=walker.nextNode()){nodesToProcess.push(node);}nodesToProcess.forEach(textNode=>{_classPrivateFieldBase(this,_highlightTextNode)[_highlightTextNode](textNode,wordRegex);});}else if(parentNode.nodeType===Node.TEXT_NODE){_classPrivateFieldBase(this,_highlightTextNode)[_highlightTextNode](parentNode,wordRegex);}}function _splitTextNodesBySentence2(parentNode,splitParagraph,splitLength){const sentenceEndRegexForSplit=/[。!?]+|[.?!]+(?=\s+|$)/g;[...parentNode.childNodes].forEach(node=>{if(node.nodeType!==Node.TEXT_NODE||node.textContent.trim()===""){return;}const text=node.textContent;const parts=[];let lastIndex=0;let match;while((match=sentenceEndRegexForSplit.exec(text))!==null){let realEndIndex=match.index+match[0].length;while(realEndIndexpart.trim().length>0);if(validParts.length<=1){return;}const newNodes=validParts.map(part=>{const newNode=document.createTextNode(part);_classPrivateFieldBase(this,_skipMoNodes)[_skipMoNodes].add(newNode);return newNode;});node.replaceWith(...newNodes);});const sentenceEndRegexForTest=/(?:[。!??!]+|(?{var _node$nextSibling,_node$nextSibling$nod;textLength+=node.textContent.length;const isSentenceEnd=sentenceEndRegexForTest.test(node.textContent);if(!isSentenceEnd||((_node$nextSibling=node.nextSibling)===null||_node$nextSibling===void 0?void 0:(_node$nextSibling$nod=_node$nextSibling.nodeName)===null||_node$nextSibling$nod===void 0?void 0:_node$nextSibling$nod.toUpperCase())==="BR"){return;}if(splitParagraph===OPT_SPLIT_PARAGRAPH_PUNCTUATION||splitParagraph===OPT_SPLIT_PARAGRAPH_TEXTLENGTH&&textLength>=splitLength){textLength=0;const br=document.createElement("br");br.className=_class.KISS_CLASS.br;_classPrivateFieldBase(this,_skipMoNodes)[_skipMoNodes].add(br);node.after(br);}});}function _removeHighlights2(parentNode){if(!parentNode)return;const highlightedElements=parentNode.querySelectorAll(".".concat(_class.KISS_CLASS.highlight));highlightedElements.forEach(element=>{const textNode=document.createTextNode(element.textContent);element.replaceWith(textNode);});parentNode.normalize();}function _removeBrTags2(parentNode){if(!parentNode)return;parentNode.querySelectorAll(".".concat(_class.KISS_CLASS.br)).forEach(br=>br.remove());parentNode.normalize();}function _shouldBreak2(node){var _node$nodeName2,_node$matches,_node$nodeName3;if(!_class.isElementOrFragment(node))return false;if(node.matches(_classPrivateFieldBase(this,_rule)[_rule].keepSelector))return false;if(_class.TAGS.BREAK_LINE.has((_node$nodeName2=node.nodeName)===null||_node$nodeName2===void 0?void 0:_node$nodeName2.toUpperCase())||(_node$matches=node.matches)!==null&&_node$matches!==void 0&&_node$matches.call(node,_classPrivateFieldBase(this,_ignoreSelector)[_ignoreSelector])||((_node$nodeName3=node.nodeName)===null||_node$nodeName3===void 0?void 0:_node$nodeName3.toLowerCase())===_classPrivateFieldBase(this,_translationTagName)[_translationTagName]){return true;}if(_classPrivateFieldBase(this,_rule)[_rule].autoScan&&_class.isBlockNode(node)){return true;}if(!_classPrivateFieldBase(this,_rule)[_rule].autoScan&&(node.matches(_classPrivateFieldBase(this,_rule)[_rule].selector)||node.querySelector(_classPrivateFieldBase(this,_rule)[_rule].selector))){return true;}return false;}function _isInvalidText2(text){if(typeof text!=="string"){return true;}const trimmedText=text.trim();// 文本长度 if(trimmedText.length<_classPrivateFieldBase(this,translator_setting)[translator_setting].minLength||trimmedText.length>_classPrivateFieldBase(this,translator_setting)[translator_setting].maxLength){return true;}// 单个非字母数字字符。 if(trimmedText.length===1&&!trimmedText.match(/[a-zA-Z]/)){return true;}// 只是一个数字 if(!isNaN(parseFloat(trimmedText))&&isFinite(trimmedText)){return true;}// 正则匹配 @@ -36830,8 +36830,7 @@ if(_classPrivateFieldBase(this,_combinedSkipsRegex)[_combinedSkipsRegex].test(tr // toLang, // skipLangs = [], highlightWords}=_classPrivateFieldBase(this,_rule)[_rule];const{newlineLength// langDetector, -}=_classPrivateFieldBase(this,translator_setting)[translator_setting];const parentNode=hostNode.parentElement;const hideOrigin=transOnly==="true";try{const[processedString,placeholderMap]=_classPrivateFieldBase(this,_serializeForTranslation)[_serializeForTranslation](nodes,termsStyle);// console.log("processedString", processedString); -if(_classPrivateFieldBase(this,_isInvalidText)[_isInvalidText](processedString))return;const wrapper=document.createElement(_classPrivateFieldBase(this,_translationTagName)[_translationTagName]);wrapper.className=_class.KISS_CLASS.warpper;if(processedString.length>newlineLength){const br=document.createElement("br");br.hidden=hideOrigin;wrapper.appendChild(br);}const inner=document.createElement(transTag);inner.className="".concat(_class.KISS_CLASS.inner," ").concat(_classPrivateFieldBase(this,_textClass)[_textClass][textStyle]||"");if(textExtStyle!==null&&textExtStyle!==void 0&&textExtStyle.trim()){inner.style.cssText=textExtStyle;// 附加内联样式 +}=_classPrivateFieldBase(this,translator_setting)[translator_setting];const parentNode=hostNode.parentElement;const hideOrigin=transOnly==="true";try{const[processedString,placeholderMap]=_classPrivateFieldBase(this,_serializeForTranslation)[_serializeForTranslation](nodes,termsStyle);if(_classPrivateFieldBase(this,_isInvalidText)[_isInvalidText](processedString))return;const wrapper=document.createElement(_classPrivateFieldBase(this,_translationTagName)[_translationTagName]);wrapper.className="".concat(_class.KISS_CLASS.warpper," notranslate");if(processedString.length>newlineLength){const br=document.createElement("br");br.hidden=hideOrigin;wrapper.appendChild(br);}const inner=document.createElement(transTag);inner.className="".concat(_class.KISS_CLASS.inner," ").concat(_classPrivateFieldBase(this,_textClass)[_textClass][textStyle]||"");if(textExtStyle!==null&&textExtStyle!==void 0&&textExtStyle.trim()){inner.style.cssText=textExtStyle;// 附加内联样式 }inner.appendChild(createLoadingSVG());wrapper.appendChild(inner);nodes[nodes.length-1].after(wrapper);const currentRunId=_classPrivateFieldBase(this,_runId)[_runId];const{trText:translatedText,isSame:isSameLang}=await _classPrivateFieldBase(this,_translateFetch)[_translateFetch](processedString,deLang);if(_classPrivateFieldBase(this,_runId)[_runId]!==currentRunId){throw new Error("Request terminated");}if(!translatedText||isSameLang){wrapper.remove();return;}const htmlString=_classPrivateFieldBase(this,_restoreFromTranslation)[_restoreFromTranslation](translatedText,placeholderMap);const trustedHTML=trustedTypesHelper.createHTML(htmlString);// const parser = new DOMParser(); // const doc = parser.parseFromString(trustedHTML, "text/html"); // const innerElement = doc.body.firstChild; @@ -36848,7 +36847,7 @@ if(node.nodeType===Node.TEXT_NODE){let text=node.textContent;// 专业术语替 if(_classPrivateFieldBase(this,_combinedTermsRegex)[_combinedTermsRegex]){_classPrivateFieldBase(this,_combinedTermsRegex)[_combinedTermsRegex].lastIndex=0;text=text.replace(_classPrivateFieldBase(this,_combinedTermsRegex)[_combinedTermsRegex],function(){for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}const groups=args.slice(1,-2);const matchedIndex=groups.findIndex(group=>group!==undefined);const fullMatch=args[0];const termValue=_classPrivateFieldBase(_this,_termValues)[_termValues][matchedIndex];return pushReplace("").concat(termValue||fullMatch,""));});}return text;}// 元素节点 if(node.nodeType===Node.ELEMENT_NODE){var _node$tagName3;if(_classPrivateFieldBase(this,_rule)[_rule].hasRichText==="true"&&_class.TAGS.REPLACE.has(node.tagName)||node.matches(_classPrivateFieldBase(this,_rule)[_rule].keepSelector)||// node.matches(this.#ignoreSelector) || !node.textContent.trim()){var _node$tagName,_node$tagName2;if(((_node$tagName=node.tagName)===null||_node$tagName===void 0?void 0:_node$tagName.toUpperCase())==="IMG"||((_node$tagName2=node.tagName)===null||_node$tagName2===void 0?void 0:_node$tagName2.toUpperCase())==="SVG"){node.style.width="".concat(node.offsetWidth,"px");node.style.height="".concat(node.offsetHeight,"px");}return pushReplace(node.outerHTML);}let innerContent="";node.childNodes.forEach(child=>{innerContent+=traverse(child);});if(_classPrivateFieldBase(this,_rule)[_rule].hasRichText==="true"&&_class.TAGS.WARP.has((_node$tagName3=node.tagName)===null||_node$tagName3===void 0?void 0:_node$tagName3.toUpperCase())){wrapCounter++;const startPlaceholder="<".concat(_classPrivateFieldBase(this,_placeholder)[_placeholder].tagName).concat(wrapCounter,">");const endPlaceholder="");placeholderMap.set(startPlaceholder,buildOpeningTag(node));placeholderMap.set(endPlaceholder,""));return"".concat(startPlaceholder).concat(innerContent).concat(endPlaceholder);}return innerContent;}return"";};function buildOpeningTag(node){const escapeAttr=str=>str.replace(/"/g,""");let tag="<".concat(node.tagName.toLowerCase());for(const attr of node.attributes){tag+=" ".concat(attr.name,"=\"").concat(escapeAttr(attr.value),"\"");}tag+=">";return tag;}const processedString=nodes.map(traverse).join("").trim();return[processedString,placeholderMap];}function _restoreFromTranslation2(translatedText,placeholderMap){if(!placeholderMap.size){return translatedText;}if(!translatedText)return"";return translatedText.replace(_classPrivateFieldBase(this,_placeholderRegex)[_placeholderRegex],match=>placeholderMap.get(match)||match);}function _translateFetch2(text){let deLang=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"";const{toLang,transStartHook}=_classPrivateFieldBase(this,_rule)[_rule];const fromLang=deLang||_classPrivateFieldBase(this,_rule)[_rule].fromLang;const apiSetting=_objectSpread2({},_classPrivateFieldBase(this,_apiSetting)[_apiSetting]);const docInfo=_objectSpread2({},_classPrivateFieldBase(this,_docInfo)[_docInfo]);const glossary=_objectSpread2({},_classPrivateFieldBase(this,_glossary)[_glossary]);const apisMap=_classPrivateFieldBase(this,_apisMap)[_apisMap];const args={text,fromLang,toLang,apiSetting,docInfo,glossary};// 翻译开始钩子函数 -if(transStartHook!==null&&transStartHook!==void 0&&transStartHook.trim()){try{interpreter.run("exports.transStartHook = ".concat(transStartHook));const hookResult=interpreter.exports.transStartHook(_objectSpread2(_objectSpread2({},args),{},{apisMap}));if(hookResult){Object.assign(args,hookResult);}}catch(err){log_kissLog("transStartHook",err);}}return apiTranslate(args);}function _findTranslationWrappers2(parentNode){return parentNode.querySelectorAll(":scope > ".concat(APP_LCNAME));}function _cleanupAllNodes2(){_classPrivateFieldBase(this,_rootNodes)[_rootNodes].forEach(root=>_classPrivateFieldBase(this,_cleanupAllTranslations)[_cleanupAllTranslations](root));}function _cleanupAllTranslations2(root){root.querySelectorAll(APP_LCNAME).forEach(el=>_classPrivateFieldBase(this,_removeTranslationElement)[_removeTranslationElement](el));}function _cleanupDirectTranslations2(node){_classPrivateFieldBase(this,_findTranslationWrappers)[_findTranslationWrappers](node).forEach(el=>{_classPrivateFieldBase(this,_removeTranslationElement)[_removeTranslationElement](el);});}function _removeTranslationElement2(el){const parentElement=el.parentElement;_classPrivateFieldBase(this,_processedNodes)[_processedNodes].delete(parentElement);// 如果是仅显示译文模式,先恢复原文 +if(transStartHook!==null&&transStartHook!==void 0&&transStartHook.trim()){try{interpreter.run("exports.transStartHook = ".concat(transStartHook));const hookResult=interpreter.exports.transStartHook(_objectSpread2(_objectSpread2({},args),{},{apisMap}));if(hookResult){Object.assign(args,hookResult);}}catch(err){log_kissLog("transStartHook",err);}}return apiTranslate(args);}function _findTranslationWrappers2(parentNode){return parentNode.querySelectorAll(":scope > .".concat(_class.KISS_CLASS.warpper));}function _cleanupAllNodes2(){_classPrivateFieldBase(this,_rootNodes)[_rootNodes].forEach(root=>_classPrivateFieldBase(this,_cleanupAllTranslations)[_cleanupAllTranslations](root));}function _cleanupAllTranslations2(root){root.querySelectorAll(".".concat(_class.KISS_CLASS.warpper)).forEach(el=>_classPrivateFieldBase(this,_removeTranslationElement)[_removeTranslationElement](el));}function _cleanupDirectTranslations2(node){_classPrivateFieldBase(this,_findTranslationWrappers)[_findTranslationWrappers](node).forEach(el=>{_classPrivateFieldBase(this,_removeTranslationElement)[_removeTranslationElement](el);});}function _removeTranslationElement2(el){const parentElement=el.parentElement;_classPrivateFieldBase(this,_processedNodes)[_processedNodes].delete(parentElement);// 如果是仅显示译文模式,先恢复原文 const{nodes,isHide}=_classPrivateFieldBase(this,_translationNodes)[_translationNodes].get(el)||{};if(isHide){_classPrivateFieldBase(this,_restoreOriginal)[_restoreOriginal](el,nodes);}_classPrivateFieldBase(this,_translationNodes)[_translationNodes].delete(el);el.remove();// todo: 可能不应深度清除 if(_classPrivateFieldBase(this,_rule)[_rule].highlightWords===OPT_HIGHLIGHT_WORDS_AFTERTRANS){_classPrivateFieldBase(this,_removeHighlights)[_removeHighlights](parentElement);}_classPrivateFieldBase(this,_removeBrTags)[_removeBrTags](parentElement);}function _restoreOriginal2(el,nodes){if(nodes){const frag=document.createDocumentFragment();nodes.forEach(n=>frag.appendChild(n));const parent=el.parentElement;parent===null||parent===void 0?void 0:parent.insertBefore(frag,el);}}function _removeNodes2(nodes){if(nodes){const frag=document.createDocumentFragment();nodes.forEach(n=>frag.appendChild(n));}}function _toggleTranslationOnly2(node,transOnly){_classPrivateFieldBase(this,_findTranslationWrappers)[_findTranslationWrappers](node).forEach(el=>{const br=el.querySelector(":scope > br");const{nodes}=_classPrivateFieldBase(this,_translationNodes)[_translationNodes].get(el)||{};if(transOnly==="true"){// 双语变为仅译文 if(br)br.hidden=true;_classPrivateFieldBase(this,_removeNodes)[_removeNodes](nodes);_classPrivateFieldBase(this,_translationNodes)[_translationNodes].set(el,{nodes,isHide:true});}else{// 仅译文变为双语 @@ -36869,7 +36868,7 @@ return;}_classPrivateFieldBase(this,_removeKeydownHandler)[_removeKeydownHandler const{injectJs,injectCss,toLang}=_classPrivateFieldBase(this,_rule)[_rule];if(isExt){injectCss&&sendBgMsg(MSG_INJECT_CSS,injectCss);}else{injectCss&&injectInternalCss(injectCss);}if(injectJs!==null&&injectJs!==void 0&&injectJs.trim()){const apiSetting=_objectSpread2({},_classPrivateFieldBase(this,_apiSetting)[_apiSetting]);const docInfo=_objectSpread2({},_classPrivateFieldBase(this,_docInfo)[_docInfo]);const glossary=_objectSpread2({},_classPrivateFieldBase(this,_glossary)[_glossary]);const apisMap=_classPrivateFieldBase(this,_apisMap)[_apisMap];const apiDectect=tryDetectLang;interpreter.import({KT:{apiTranslate: apiTranslate,apiDectect,apiSetting,apisMap,toLang,docInfo,glossary}});interpreter.run(injectJs);}}catch(err){log_kissLog("inject js",err);}}function _removeInjector2(){var _document$querySelect;(_document$querySelect=document.querySelectorAll("[data-source^=\"kiss-inject\"]"))===null||_document$querySelect===void 0?void 0:_document$querySelect.forEach(el=>el.remove());}async function _translateTitle2(){const title=document.title;_classPrivateFieldBase(this,_docInfo)[_docInfo].title=truncateWords(title);if(!title)return;try{const deLang=await tryDetectLang(title);const{trText}=await _classPrivateFieldBase(this,_translateFetch)[_translateFetch](title,deLang);document.title=trText||title;}catch(err){log_kissLog("tanslate title",err);}}translator_Translator.displayCache=new WeakMap();translator_Translator.TAGS={BREAK_LINE:new Set(["BR","WBR"]),BLOCK:new Set(["ADDRESS","ARTICLE","ASIDE","BLOCKQUOTE","CANVAS","DD","DIV","DL","DT","FIELDSET","FIGCAPTION","FIGURE","FOOTER","FORM","H1","H2","H3","H4","H5","H6","HEADER","HR","LI","MAIN","NAV","NOSCRIPT","OL","P","PRE","SECTION","TABLE","TFOOT","UL","VIDEO"]),INLINE:new Set([// "A", "ABBR","ACRONYM","B","BDO","BIG","BR","BUTTON","CITE","CODE","DFN","DEL","FONT","EM","I","IMG","INPUT","INS","KBD","LABEL","MAP","MARK","OBJECT","OUTPUT","Q","SAMP","SCRIPT","SELECT","SMALL",// "SPAN", "STRONG","SUB","SUP","TEXTAREA","TIME","TT","U","VAR"]),REPLACE:new Set(["ABBR","CODE","DFN","IMG","KBD","OUTPUT","SAMP","SUB","SUP","SVG","TIME","VAR"]),WARP:new Set(["A","B","BDO","BDI","BIG","CITE","DEL","EM","FONT","I","INS","MARK","Q","S","SMALL","SPAN","STRONG","U"])};// 译文相关class -translator_Translator.KISS_CLASS={warpper:"".concat(APP_LCNAME,"-wrapper notranslate"),inner:"".concat(APP_LCNAME,"-inner"),term:"".concat(APP_LCNAME,"-term"),br:"".concat(APP_LCNAME,"-br"),highlight:"".concat(APP_LCNAME,"-highlight")};// 内置跳过翻译文本 +translator_Translator.KISS_CLASS={warpper:"".concat(APP_LCNAME,"-wrapper"),inner:"".concat(APP_LCNAME,"-inner"),term:"".concat(APP_LCNAME,"-term"),br:"".concat(APP_LCNAME,"-br"),highlight:"".concat(APP_LCNAME,"-highlight")};// 内置跳过翻译文本 // todo: 验证有效性 translator_Translator.BUILTIN_SKIP_PATTERNS=[// 1. URL (覆盖 http, https, ftp, file 协议) /^(?:(?:https?|ftp|file):\/\/|www\.)[^\s/$.?#].[^\s]*$/i,// 2. 邮箱地址 @@ -36888,9 +36887,9 @@ translator_Translator.BUILTIN_SKIP_PATTERNS=[// 1. URL (覆盖 http, https, ftp, /^\d{1,2}:\d{2}(:\d{2})?$/,// 14. 包含常见扩展名的文件名 (例如: document.pdf, image.jpeg) /^[^\s\\/:]+?\.[a-zA-Z0-9]{2,5}$/ // todo: 数字和特殊字符组成的字符串 ];translator_Translator.DEFAULT_OPTIONS=setting_DEFAULT_SETTING;// 默认配置 -translator_Translator.DEFAULT_RULE=GLOBLA_RULE;translator_Translator.KISS_IGNORE_SELECTOR="".concat(APP_LCNAME,", .kiss-caption-container, .kiss-subtitle-controls\n #").concat(APP_CONSTS.fabID,", .").concat(APP_CONSTS.fabID,"_warpper,\n #").concat(APP_CONSTS.boxID,", .").concat(APP_CONSTS.boxID,"_warpper,\n #").concat(APP_CONSTS.popupID,", .").concat(APP_CONSTS.popupID,"_warpper");translator_Translator.BUILTIN_IGNORE_SELECTOR="address, area, audio, br, canvas, \n data, datalist, embed, head, iframe, input, noscript, map, \n object, option, param, picture, progress, \n select, script, style, track, textarea, template, \n video, wbr, .notranslate, [contenteditable='true'], [translate='no']"; +translator_Translator.DEFAULT_RULE=GLOBLA_RULE;translator_Translator.KISS_IGNORE_SELECTOR=".".concat(_class.KISS_CLASS.warpper,", .kiss-caption-container, .kiss-subtitle-controls\n #").concat(APP_CONSTS.fabID,", .").concat(APP_CONSTS.fabID,"_warpper,\n #").concat(APP_CONSTS.boxID,", .").concat(APP_CONSTS.boxID,"_warpper,\n #").concat(APP_CONSTS.popupID,", .").concat(APP_CONSTS.popupID,"_warpper");translator_Translator.BUILTIN_IGNORE_SELECTOR="address, area, audio, br, canvas, \n data, datalist, embed, head, iframe, input, noscript, map, \n object, option, param, picture, progress, \n select, script, style, track, textarea, template, \n video, wbr, .notranslate, [contenteditable='true'], [translate='no']"; ;// CONCATENATED MODULE: ./src/libs/inputTranslate.js -function isInputNode(node){return node.nodeName==="INPUT"||node.nodeName==="TEXTAREA";}function isEditAbleNode(node){return node.hasAttribute("contenteditable");}async function replaceContentEditableText(node,newText){try{logger.debug("try replace editable 1: pasteEvent");node.focus();const selection=window.getSelection();if(!selection)throw new Error("window.getSelection() is not available.");const targetNode=node.querySelector("p")||node;const range=document.createRange();range.selectNodeContents(targetNode);selection.removeAllRanges();selection.addRange(range);const dataTransfer=new DataTransfer();dataTransfer.setData("text/plain",newText);const pasteEvent=new ClipboardEvent("paste",{clipboardData:dataTransfer,bubbles:true,cancelable:true});node.dispatchEvent(pasteEvent);await sleep(50);if(node.innerText.trim()===newText){return true;}throw new Error("Strategy 1 failed to replace text correctly.");}catch(error){logger.debug("Strategy 1 Failed:",error.message);}try{logger.debug("try replace editable 2: execCommand");node.focus();const selection=window.getSelection();if(!selection)throw new Error("window.getSelection() is not available.");const targetNode=node.querySelector("p")||node;const range=document.createRange();range.selectNodeContents(targetNode);selection.removeAllRanges();selection.addRange(range);document.execCommand("insertText",false,newText);await sleep(50);if(node.innerText.trim()===newText){return true;}throw new Error("Strategy 2 failed to replace text correctly.");}catch(error){logger.debug("Strategy 2 Failed:",error.message);}try{logger.debug("try replace editable 3: textContent");node.focus();const targetNode=node.querySelector("p")||node;const textSpan=targetNode.querySelector('span[data-lexical-text="true"]');if(textSpan){textSpan.textContent=newText;}else{targetNode.textContent=newText;}node.dispatchEvent(new Event("input",{bubbles:true,cancelable:true}));await sleep(50);if(node.innerText.trim()===newText){return true;}throw new Error("Strategy 3 failed to replace text correctly.");}catch(error){logger.debug("Strategy 3 Failed:",error.message);}return false;}function getNodeText(node){if(isInputNode(node)){return node.value;}return node.innerText||node.textContent||"";}function addLoading(node,loadingId){const rect=node.getBoundingClientRect();const div=document.createElement("div");div.id=loadingId;div.appendChild(createLoadingSVG());div.style.cssText="\n position: fixed;\n left: ".concat(rect.left,"px;\n top: ").concat(rect.top,"px;\n width: ").concat(rect.width,"px;\n height: ").concat(rect.height,"px;\n line-height: ").concat(rect.height,"px;\n text-align: center;\n z-index: 2147483647;\n pointer-events: none; /* \u5141\u8BB8\u70B9\u51FB\u7A7F\u900F */\n ");document.body.appendChild(div);}function removeLoading(loadingId){const div=document.getElementById(loadingId);if(div)div.remove();}/** +function isInputNode(node){var _node$nodeName,_node$nodeName2;return((_node$nodeName=node.nodeName)===null||_node$nodeName===void 0?void 0:_node$nodeName.toUpperCase())==="INPUT"||((_node$nodeName2=node.nodeName)===null||_node$nodeName2===void 0?void 0:_node$nodeName2.toUpperCase())==="TEXTAREA";}function isEditAbleNode(node){return node.hasAttribute("contenteditable");}async function replaceContentEditableText(node,newText){try{logger.debug("try replace editable 1: pasteEvent");node.focus();const selection=window.getSelection();if(!selection)throw new Error("window.getSelection() is not available.");const targetNode=node.querySelector("p")||node;const range=document.createRange();range.selectNodeContents(targetNode);selection.removeAllRanges();selection.addRange(range);const dataTransfer=new DataTransfer();dataTransfer.setData("text/plain",newText);const pasteEvent=new ClipboardEvent("paste",{clipboardData:dataTransfer,bubbles:true,cancelable:true});node.dispatchEvent(pasteEvent);await sleep(50);if(node.innerText.trim()===newText){return true;}throw new Error("Strategy 1 failed to replace text correctly.");}catch(error){logger.debug("Strategy 1 Failed:",error.message);}try{logger.debug("try replace editable 2: execCommand");node.focus();const selection=window.getSelection();if(!selection)throw new Error("window.getSelection() is not available.");const targetNode=node.querySelector("p")||node;const range=document.createRange();range.selectNodeContents(targetNode);selection.removeAllRanges();selection.addRange(range);document.execCommand("insertText",false,newText);await sleep(50);if(node.innerText.trim()===newText){return true;}throw new Error("Strategy 2 failed to replace text correctly.");}catch(error){logger.debug("Strategy 2 Failed:",error.message);}try{logger.debug("try replace editable 3: textContent");node.focus();const targetNode=node.querySelector("p")||node;const textSpan=targetNode.querySelector('span[data-lexical-text="true"]');if(textSpan){textSpan.textContent=newText;}else{targetNode.textContent=newText;}node.dispatchEvent(new Event("input",{bubbles:true,cancelable:true}));await sleep(50);if(node.innerText.trim()===newText){return true;}throw new Error("Strategy 3 failed to replace text correctly.");}catch(error){logger.debug("Strategy 3 Failed:",error.message);}return false;}function getNodeText(node){if(isInputNode(node)){return node.value;}return node.innerText||node.textContent||"";}function addLoading(node,loadingId){const rect=node.getBoundingClientRect();const div=document.createElement("div");div.id=loadingId;div.appendChild(createLoadingSVG());div.style.cssText="\n position: fixed;\n left: ".concat(rect.left,"px;\n top: ").concat(rect.top,"px;\n width: ").concat(rect.width,"px;\n height: ").concat(rect.height,"px;\n line-height: ").concat(rect.height,"px;\n text-align: center;\n z-index: 2147483647;\n pointer-events: none; /* \u5141\u8BB8\u70B9\u51FB\u7A7F\u900F */\n ");document.body.appendChild(div);}function removeLoading(loadingId){const div=document.getElementById(loadingId);if(div)div.remove();}/** * 输入框翻译 */var _config=/*#__PURE__*/_classPrivateFieldKey("config");var _unregisterShortcut=/*#__PURE__*/_classPrivateFieldKey("unregisterShortcut");var _isEnabled=/*#__PURE__*/_classPrivateFieldKey("isEnabled");var _triggerShortcut=/*#__PURE__*/_classPrivateFieldKey("triggerShortcut");var _handleTranslate=/*#__PURE__*/_classPrivateFieldKey("handleTranslate");class InputTranslator{// 用于缓存快捷键 constructor(){let{inputRule=DEFAULT_INPUT_RULE,transApis=[]}=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};/** @@ -39469,7 +39468,7 @@ Divider.muiSkipListHighlight = true; false ? 0 : void 0; /* harmony default export */ const Divider_Divider = (Divider); ;// CONCATENATED MODULE: ./src/hooks/Loading.js -function Loading(){return/*#__PURE__*/(0,jsx_runtime.jsxs)("center",{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Divider_Divider,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(Link_Link,{href:"https://github.com/fishjar/kiss-translator",children:"KISS Translator v".concat("2.0.10")})}),/*#__PURE__*/(0,jsx_runtime.jsx)(CircularProgress_CircularProgress,{})]});} +function Loading(){return/*#__PURE__*/(0,jsx_runtime.jsxs)("center",{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Divider_Divider,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(Link_Link,{href:"https://github.com/fishjar/kiss-translator",children:"KISS Translator v".concat("2.0.11")})}),/*#__PURE__*/(0,jsx_runtime.jsx)(CircularProgress_CircularProgress,{})]});} ;// CONCATENATED MODULE: ./src/hooks/Setting.js const SettingContext=/*#__PURE__*/(0,react.createContext)({setting:setting_DEFAULT_SETTING,updateSetting:()=>{},reloadSetting:()=>{}});function SettingProvider(_ref){let{children,isSettingPage}=_ref;const{data:setting,isLoading,update,reload}=useStorage(storage_STOKEY_SETTING,setting_DEFAULT_SETTING,isSettingPage?storage_KV_SETTING_KEY:"");(0,react.useEffect)(()=>{if(typeof(setting===null||setting===void 0?void 0:setting.darkMode)==="boolean"){update(currentSetting=>_objectSpread2(_objectSpread2({},currentSetting),{},{darkMode:currentSetting.darkMode?"dark":"light"}));}},[setting===null||setting===void 0?void 0:setting.darkMode,update]);(0,react.useEffect)(()=>{if(!isSettingPage)return;(async()=>{try{logger.setLevel(setting===null||setting===void 0?void 0:setting.logLevel);if(isExt){await sendBgMsg(MSG_SET_LOGLEVEL,setting===null||setting===void 0?void 0:setting.logLevel);}}catch(error){logger.error("Failed to fetch log level, using default.",error);}})();},[isSettingPage,setting===null||setting===void 0?void 0:setting.logLevel]);const updateSetting=(0,react.useCallback)(objOrFn=>{update(objOrFn);debounceSyncMeta(storage_KV_SETTING_KEY);},[update]);const updateChild=(0,react.useCallback)(key=>async obj=>{updateSetting(prev=>_objectSpread2(_objectSpread2({},prev),{},{[key]:_objectSpread2(_objectSpread2({},(prev===null||prev===void 0?void 0:prev[key])||{}),obj)}));},[updateSetting]);const value=(0,react.useMemo)(()=>({setting,updateSetting,updateChild,reloadSetting:reload}),[setting,updateSetting,updateChild,reload]);if(isLoading){return/*#__PURE__*/(0,jsx_runtime.jsx)(Loading,{});}if(!setting){/*#__PURE__*/(0,jsx_runtime.jsx)("center",{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(Alert_Alert,{severity:"error",sx:{maxWidth:600,margin:"60px auto"},children:[/*#__PURE__*/(0,jsx_runtime.jsx)("p",{children:"\u6570\u636E\u52A0\u8F7D\u51FA\u9519\uFF0C\u8BF7\u5237\u65B0\u9875\u9762\u6216\u5378\u8F7D\u540E\u91CD\u65B0\u5B89\u88C5\u3002"}),/*#__PURE__*/(0,jsx_runtime.jsx)("p",{children:"Data loading error, please refresh the page or uninstall and reinstall."})]})});}return/*#__PURE__*/(0,jsx_runtime.jsx)(SettingContext.Provider,{value:value,children:children});}/** * 设置 hook @@ -47042,7 +47041,7 @@ function SugBaidu(_ref){let{text}=_ref;const{loading,error,data}=useAsyncNow(api function TranForm(_ref){let{text,setText,apiSlugs:initApiSlugs,fromLang:initFromLang,toLang:initToLang,toLang2:initToLang2,transApis,simpleStyle=false,langDetector:initLangDetector="-",enDict:initEnDict="-",enSug:initEnSug="-",isPlaygound=false}=_ref;const i18n=useI18n();const[editMode,setEditMode]=(0,react.useState)(false);const[editText,setEditText]=(0,react.useState)(text);const[apiSlugs,setApiSlugs]=(0,react.useState)(initApiSlugs);const[fromLang,setFromLang]=(0,react.useState)(initFromLang);const[toLang,setToLang]=(0,react.useState)(initToLang);const[toLang2,setToLang2]=(0,react.useState)(initToLang2);const[langDetector,setLangDetector]=(0,react.useState)(initLangDetector);const[enDict,setEnDict]=(0,react.useState)(initEnDict);const[enSug,setEnSug]=(0,react.useState)(initEnSug);const[deLang,setDeLang]=(0,react.useState)("");const[deLoading,setDeLoading]=(0,react.useState)(false);(0,react.useEffect)(()=>{if(!editMode){setEditText(text);}},[text,editMode]);(0,react.useEffect)(()=>{if(!text.trim()){setDeLang("");return;}(async()=>{try{setDeLoading(true);const deLang=await tryDetectLang(text,langDetector);if(deLang){setDeLang(deLang);}}catch(err){log_kissLog("tranbox: detect lang",err);}finally{setDeLoading(false);}})();},[text,langDetector,setDeLang,setDeLoading]);// todo: 语言变化后,realToLang引发二次翻译请求 const realToLang=(0,react.useMemo)(()=>{if(fromLang==="auto"&&toLang!==toLang2&&toLang2!=="-"&&deLang===toLang){return toLang2;}return toLang;},[fromLang,toLang,toLang2,deLang]);const optApis=(0,react.useMemo)(()=>transApis.filter(api=>!api.isDisabled).map(api=>({key:api.apiSlug,name:api.apiName||api.apiSlug})),[transApis]);const isWord=(0,react.useMemo)(()=>isValidWord(text),[text]);const xs=(0,react.useMemo)(()=>isPlaygound?3:4,[isPlaygound]);return/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{spacing:simpleStyle?1:2,children:[!simpleStyle&&/*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Box_Box,{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(Grid_Grid,{container:true,spacing:2,columns:12,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Grid_Grid,{item:true,xs:xs,children:/*#__PURE__*/(0,jsx_runtime.jsx)(TextField_TextField,{select:true,SelectProps:{multiple:true,MenuProps:{disablePortal:!isPlaygound}},fullWidth:true,size:"small",value:apiSlugs,name:"apiSlugs",label:i18n("translate_service_multiple"),onChange:e=>{setApiSlugs(e.target.value);},children:optApis.map(_ref2=>{let{key,name}=_ref2;return/*#__PURE__*/(0,jsx_runtime.jsx)(material_MenuItem_MenuItem,{value:key,children:name},key);})})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Grid_Grid,{item:true,xs:xs,children:/*#__PURE__*/(0,jsx_runtime.jsx)(TextField_TextField,{select:true,SelectProps:{MenuProps:{disablePortal:!isPlaygound}},fullWidth:true,size:"small",name:"fromLang",value:fromLang,label:i18n("from_lang"),onChange:e=>{setFromLang(e.target.value);},children:OPT_LANGS_FROM.map(_ref3=>{let[lang,name]=_ref3;return/*#__PURE__*/(0,jsx_runtime.jsx)(material_MenuItem_MenuItem,{value:lang,children:name},lang);})})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Grid_Grid,{item:true,xs:xs,children:/*#__PURE__*/(0,jsx_runtime.jsx)(TextField_TextField,{select:true,SelectProps:{MenuProps:{disablePortal:!isPlaygound}},fullWidth:true,size:"small",name:"toLang",value:toLang,label:i18n("to_lang"),onChange:e=>{setToLang(e.target.value);},children:OPT_LANGS_TO.map(_ref4=>{let[lang,name]=_ref4;return/*#__PURE__*/(0,jsx_runtime.jsx)(material_MenuItem_MenuItem,{value:lang,children:name},lang);})})}),isPlaygound&&/*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Grid_Grid,{item:true,xs:xs,children:/*#__PURE__*/(0,jsx_runtime.jsx)(TextField_TextField,{select:true,SelectProps:{MenuProps:{disablePortal:!isPlaygound}},fullWidth:true,size:"small",name:"toLang2",value:toLang2,label:i18n("to_lang2"),onChange:e=>{setToLang2(e.target.value);},children:OPT_LANGS_TO.map(_ref5=>{let[lang,name]=_ref5;return/*#__PURE__*/(0,jsx_runtime.jsx)(material_MenuItem_MenuItem,{value:lang,children:name},lang);})})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Grid_Grid,{item:true,xs:xs,children:/*#__PURE__*/(0,jsx_runtime.jsxs)(TextField_TextField,{select:true,SelectProps:{MenuProps:{disablePortal:!isPlaygound}},fullWidth:true,size:"small",name:"enDict",value:enDict,label:i18n("english_dict"),onChange:e=>{setEnDict(e.target.value);},children:[/*#__PURE__*/(0,jsx_runtime.jsx)(material_MenuItem_MenuItem,{value:"-",children:i18n("disable")}),OPT_DICT_ALL.map(item=>/*#__PURE__*/(0,jsx_runtime.jsx)(material_MenuItem_MenuItem,{value:item,children:item},item))]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Grid_Grid,{item:true,xs:xs,children:/*#__PURE__*/(0,jsx_runtime.jsxs)(TextField_TextField,{select:true,SelectProps:{MenuProps:{disablePortal:!isPlaygound}},fullWidth:true,size:"small",name:"enSug",value:enSug,label:i18n("english_suggest"),onChange:e=>{setEnSug(e.target.value);},children:[/*#__PURE__*/(0,jsx_runtime.jsx)(material_MenuItem_MenuItem,{value:"-",children:i18n("disable")}),OPT_SUG_ALL.map(item=>/*#__PURE__*/(0,jsx_runtime.jsx)(material_MenuItem_MenuItem,{value:item,children:item},item))]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Grid_Grid,{item:true,xs:xs,children:/*#__PURE__*/(0,jsx_runtime.jsxs)(TextField_TextField,{select:true,SelectProps:{MenuProps:{disablePortal:!isPlaygound}},fullWidth:true,size:"small",name:"langDetector",value:langDetector,label:i18n("detected_lang"),onChange:e=>{setLangDetector(e.target.value);},children:[/*#__PURE__*/(0,jsx_runtime.jsx)(material_MenuItem_MenuItem,{value:"-",children:i18n("disable")}),OPT_LANGDETECTOR_ALL.map(item=>/*#__PURE__*/(0,jsx_runtime.jsx)(material_MenuItem_MenuItem,{value:item,children:item},item))]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Grid_Grid,{item:true,xs:xs,children:/*#__PURE__*/(0,jsx_runtime.jsx)(TextField_TextField,{fullWidth:true,size:"small",name:"deLang",value:deLang&&OPT_LANGS_MAP.get(deLang),label:i18n("detected_result"),disabled:true,InputProps:{startAdornment:deLoading?/*#__PURE__*/(0,jsx_runtime.jsx)(CircularProgress_CircularProgress,{size:16}):null}})})]})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Box_Box,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(TextField_TextField,{size:"small",label:i18n("original_text"),fullWidth:true,multiline:true,minRows:isPlaygound?2:1,maxRows:10,value:editText,onChange:e=>{setEditText(e.target.value);},onFocus:()=>{setEditMode(true);},onBlur:()=>{setEditMode(false);setText(editText.trim());},InputProps:{endAdornment:/*#__PURE__*/(0,jsx_runtime.jsx)(Stack_Stack,{direction:"row",sx:{position:"absolute",right:0,top:0},children:editMode?/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{size:"small",onClick:e=>{e.stopPropagation();setEditMode(false);setText(editText.trim());},children:/*#__PURE__*/(0,jsx_runtime.jsx)(Done/* default */.Z,{fontSize:"inherit"})}):/*#__PURE__*/(0,jsx_runtime.jsx)(CopyBtn,{text:text})})}})})]}),apiSlugs.map(slug=>/*#__PURE__*/(0,jsx_runtime.jsx)(TranCont,{text:text,fromLang:fromLang,toLang:realToLang,simpleStyle:simpleStyle,apiSlug:slug,transApis:transApis},slug)),isWord&&OPT_DICT_MAP.has(enDict)&&/*#__PURE__*/(0,jsx_runtime.jsx)(DictCont,{text:text,enDict:enDict}),isWord&&OPT_SUG_MAP.has(enSug)&&/*#__PURE__*/(0,jsx_runtime.jsx)(SugCont,{text:text,enSug:enSug})]});} ;// CONCATENATED MODULE: ./src/views/Selection/TranBox.js -function Header(_ref){let{setShowBox,simpleStyle,setSimpleStyle,hideClickAway,setHideClickAway,followSelection,setFollowSelection,mouseHover}=_ref;const i18n=useI18n();if(!isMobile&&simpleStyle&&!mouseHover){return;}return/*#__PURE__*/(0,jsx_runtime.jsxs)(Box_Box,{onMouseUp:e=>e.stopPropagation(),onTouchEnd:e=>e.stopPropagation(),children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{direction:"row",alignItems:"center",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(DragIndicator/* default */.Z,{fontSize:"small"}),/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{variant:"body2",sx:{userSelect:"none",WebkitUserSelect:"none",fontWeight:"bold"},children:"".concat("KISS Translator"," v").concat("2.0.10")})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{direction:"row",alignItems:"center",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{size:"small",title:i18n("btn_tip_click_away"),onClick:()=>{setHideClickAway(pre=>!pre);},children:hideClickAway?/*#__PURE__*/(0,jsx_runtime.jsx)(LockOpen/* default */.Z,{fontSize:"small"}):/*#__PURE__*/(0,jsx_runtime.jsx)(Lock/* default */.Z,{fontSize:"small"})}),/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{size:"small",title:i18n("btn_tip_follow_selection"),onClick:()=>{setFollowSelection(pre=>!pre);},children:followSelection?/*#__PURE__*/(0,jsx_runtime.jsx)(PushPinOutlined/* default */.Z,{fontSize:"small"}):/*#__PURE__*/(0,jsx_runtime.jsx)(PushPin/* default */.Z,{fontSize:"small"})}),/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{size:"small",title:i18n("btn_tip_simple_style"),onClick:()=>{setSimpleStyle(pre=>!pre);},children:simpleStyle?/*#__PURE__*/(0,jsx_runtime.jsx)(UnfoldMore/* default */.Z,{fontSize:"small"}):/*#__PURE__*/(0,jsx_runtime.jsx)(UnfoldLess/* default */.Z,{fontSize:"small"})}),/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{size:"small",onClick:()=>{setShowBox(false);},children:/*#__PURE__*/(0,jsx_runtime.jsx)(icons_material_Close/* default */.Z,{fontSize:"small"})})]})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(Divider_Divider,{})]});}function TranBox(_ref2){let{showBox,text,setText,setShowBox,tranboxSetting:{enDict,enSug,apiSlugs,fromLang,toLang,toLang2,autoHeight},transApis,boxSize,setBoxSize,boxPosition,setBoxPosition,simpleStyle,setSimpleStyle,hideClickAway,setHideClickAway,followSelection,setFollowSelection,extStyles="",langDetector}=_ref2;const[mouseHover,setMouseHover]=(0,react.useState)(false);// todo: 这里的 SettingProvider 不应和 background 的共用 +function Header(_ref){let{setShowBox,simpleStyle,setSimpleStyle,hideClickAway,setHideClickAway,followSelection,setFollowSelection,mouseHover}=_ref;const i18n=useI18n();if(!isMobile&&simpleStyle&&!mouseHover){return;}return/*#__PURE__*/(0,jsx_runtime.jsxs)(Box_Box,{onMouseUp:e=>e.stopPropagation(),onTouchEnd:e=>e.stopPropagation(),children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{direction:"row",alignItems:"center",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(DragIndicator/* default */.Z,{fontSize:"small"}),/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{variant:"body2",sx:{userSelect:"none",WebkitUserSelect:"none",fontWeight:"bold"},children:"".concat("KISS Translator"," v").concat("2.0.11")})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{direction:"row",alignItems:"center",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{size:"small",title:i18n("btn_tip_click_away"),onClick:()=>{setHideClickAway(pre=>!pre);},children:hideClickAway?/*#__PURE__*/(0,jsx_runtime.jsx)(LockOpen/* default */.Z,{fontSize:"small"}):/*#__PURE__*/(0,jsx_runtime.jsx)(Lock/* default */.Z,{fontSize:"small"})}),/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{size:"small",title:i18n("btn_tip_follow_selection"),onClick:()=>{setFollowSelection(pre=>!pre);},children:followSelection?/*#__PURE__*/(0,jsx_runtime.jsx)(PushPinOutlined/* default */.Z,{fontSize:"small"}):/*#__PURE__*/(0,jsx_runtime.jsx)(PushPin/* default */.Z,{fontSize:"small"})}),/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{size:"small",title:i18n("btn_tip_simple_style"),onClick:()=>{setSimpleStyle(pre=>!pre);},children:simpleStyle?/*#__PURE__*/(0,jsx_runtime.jsx)(UnfoldMore/* default */.Z,{fontSize:"small"}):/*#__PURE__*/(0,jsx_runtime.jsx)(UnfoldLess/* default */.Z,{fontSize:"small"})}),/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{size:"small",onClick:()=>{setShowBox(false);},children:/*#__PURE__*/(0,jsx_runtime.jsx)(icons_material_Close/* default */.Z,{fontSize:"small"})})]})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(Divider_Divider,{})]});}function TranBox(_ref2){let{showBox,text,setText,setShowBox,tranboxSetting:{enDict,enSug,apiSlugs,fromLang,toLang,toLang2,autoHeight},transApis,boxSize,setBoxSize,boxPosition,setBoxPosition,simpleStyle,setSimpleStyle,hideClickAway,setHideClickAway,followSelection,setFollowSelection,extStyles="",langDetector}=_ref2;const[mouseHover,setMouseHover]=(0,react.useState)(false);// todo: 这里的 SettingProvider 不应和 background 的共用 return/*#__PURE__*/(0,jsx_runtime.jsx)(SettingProvider,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(Theme,{styles:extStyles,children:showBox&&/*#__PURE__*/(0,jsx_runtime.jsx)(DraggableResizable,{position:boxPosition,size:boxSize,setSize:setBoxSize,setPosition:setBoxPosition,autoHeight:autoHeight,header:/*#__PURE__*/(0,jsx_runtime.jsx)(Header,{setShowBox:setShowBox,simpleStyle:simpleStyle,setSimpleStyle:setSimpleStyle,hideClickAway:hideClickAway,setHideClickAway:setHideClickAway,followSelection:followSelection,setFollowSelection:setFollowSelection,mouseHover:mouseHover}),onClick:e=>e.stopPropagation(),onMouseEnter:()=>setMouseHover(true),onMouseLeave:()=>setMouseHover(false),children:/*#__PURE__*/(0,jsx_runtime.jsx)(Box_Box,{sx:{p:simpleStyle?1:2},children:/*#__PURE__*/(0,jsx_runtime.jsx)(TranForm,{text:text,setText:setText,apiSlugs:apiSlugs,fromLang:fromLang,toLang:toLang,toLang2:toLang2,transApis:transApis,simpleStyle:simpleStyle,langDetector:langDetector,enDict:enDict,enSug:enSug})})})})});} ;// CONCATENATED MODULE: ./src/views/Selection/index.js function Slection(_ref){let{contextMenuType,tranboxSetting,transApis,uiLang,langDetector}=_ref;const{hideTranBtn=false,simpleStyle:initSimpleStyle=false,hideClickAway:initHideClickAway=false,followSelection:initFollowMouse=false,tranboxShortcut=DEFAULT_TRANBOX_SHORTCUT,triggerMode=OPT_TRANBOX_TRIGGER_CLICK,// extStyles, @@ -47069,7 +47068,7 @@ var BrightnessAuto = __webpack_require__(4080); ;// CONCATENATED MODULE: ./src/views/Options/DarkModeButton.js function DarkModeButton(){const{darkMode,toggleDarkMode}=useDarkMode();return/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{sx:{ml:1},onClick:toggleDarkMode,color:"inherit",children:darkMode==="dark"?/*#__PURE__*/(0,jsx_runtime.jsx)(DarkMode/* default */.Z,{}):darkMode==="light"?/*#__PURE__*/(0,jsx_runtime.jsx)(LightMode/* default */.Z,{}):/*#__PURE__*/(0,jsx_runtime.jsx)(BrightnessAuto/* default */.Z,{})});} ;// CONCATENATED MODULE: ./src/views/Popup/Header.js -function Header_Header(_ref){let{onClose}=_ref;const handleHomepage=()=>{window.open("https://github.com/fishjar/kiss-translator","_blank");};return/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{direction:"row",justifyContent:"space-between",alignItems:"center",spacing:2,children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{direction:"row",justifyContent:"flex-start",alignItems:"center",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{onClick:handleHomepage,children:/*#__PURE__*/(0,jsx_runtime.jsx)(Home/* default */.Z,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{component:"div",sx:{userSelect:"none",WebkitUserSelect:"none",fontWeight:"bold"},children:"".concat("KISS Translator"," v").concat("2.0.10")})]}),onClose?/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{onClick:()=>{onClose();},children:/*#__PURE__*/(0,jsx_runtime.jsx)(icons_material_Close/* default */.Z,{})}):/*#__PURE__*/(0,jsx_runtime.jsx)(DarkModeButton,{})]});} +function Header_Header(_ref){let{onClose}=_ref;const handleHomepage=()=>{window.open("https://github.com/fishjar/kiss-translator","_blank");};return/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{direction:"row",justifyContent:"space-between",alignItems:"center",spacing:2,children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{direction:"row",justifyContent:"flex-start",alignItems:"center",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{onClick:handleHomepage,children:/*#__PURE__*/(0,jsx_runtime.jsx)(Home/* default */.Z,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{component:"div",sx:{userSelect:"none",WebkitUserSelect:"none",fontWeight:"bold"},children:"".concat("KISS Translator"," v").concat("2.0.11")})]}),onClose?/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{onClick:()=>{onClose();},children:/*#__PURE__*/(0,jsx_runtime.jsx)(icons_material_Close/* default */.Z,{})}):/*#__PURE__*/(0,jsx_runtime.jsx)(DarkModeButton,{})]});} ;// CONCATENATED MODULE: ./src/hooks/WindowSize.js function useWindowSize(){const[windowSize,setWindowSize]=(0,react.useState)({w:window.innerWidth,h:window.innerHeight});const debounceWindowResize=useDebouncedCallback(()=>{setWindowSize({w:window.innerWidth,h:window.innerHeight});},200);(0,react.useEffect)(()=>{debounceWindowResize();window.addEventListener("resize",debounceWindowResize);return()=>{window.removeEventListener("resize",debounceWindowResize);};},[debounceWindowResize]);return windowSize;}/* harmony default export */ const WindowSize = (useWindowSize); ;// CONCATENATED MODULE: ./node_modules/.pnpm/@mui+material@5.15.15_@emotion+react@11.11.1_@types+react@18.2.79_react@18.2.0__@emotion+styl_fuwy6huc4pjbdb446idbihjqyi/node_modules/@mui/material/FormControlLabel/formControlLabelClasses.js @@ -48230,22 +48229,22 @@ if(_classPrivateFieldBase(this,_isUserscript)[_isUserscript]){window.removeEvent _classPrivateFieldBase(this,_clearShortcuts)[_clearShortcuts].forEach(clear=>clear());_classPrivateFieldBase(this,_clearShortcuts)[_clearShortcuts]=[];// 触屏 _classPrivateFieldBase(this,_clearTouchListeners)[_clearTouchListeners].forEach(clear=>clear());_classPrivateFieldBase(this,_clearTouchListeners)[_clearTouchListeners]=[];// 油猴菜单 if(globalThis.GM&&_classPrivateFieldBase(this,_menuCommandIds)[_menuCommandIds].length>0){_classPrivateFieldBase(this,_menuCommandIds)[_menuCommandIds].forEach(id=>globalThis.GM.unregisterMenuCommand(id));_classPrivateFieldBase(this,_menuCommandIds)[_menuCommandIds]=[];}// 子模块 -(_this$_popupManager=this._popupManager)===null||_this$_popupManager===void 0?void 0:_this$_popupManager.destroy();(_this$_fabManager=this._fabManager)===null||_this$_fabManager===void 0?void 0:_this$_fabManager.destroy();(_this$_transboxManage=this._transboxManager)===null||_this$_transboxManage===void 0?void 0:_this$_transboxManage.disable();(_this$_inputTranslato=this._inputTranslator)===null||_this$_inputTranslato===void 0?void 0:_this$_inputTranslato.disable();this._translator.stop();_classPrivateFieldBase(this,_isActive)[_isActive]=false;logger.info("TranslatorManager stopped.");}}function _setupMessageListeners2(){if(_classPrivateFieldBase(this,_isUserscript)[_isUserscript]){window.addEventListener("message",_classPrivateFieldBase(this,translatorManager_windowMessageHandler)[translatorManager_windowMessageHandler]);}else{browser.runtime.onMessage.addListener(_classPrivateFieldBase(this,_browserMessageHandler)[_browserMessageHandler]);if(_classPrivateFieldBase(this,_isIframe)[_isIframe]){window.addEventListener("message",_classPrivateFieldBase(this,translatorManager_windowMessageHandler)[translatorManager_windowMessageHandler]);}}}function _setupTouchOperations2(){if(_classPrivateFieldBase(this,_isIframe)[_isIframe])return;const{touchModes=[2]}=this._translator.setting;if(touchModes.length===0){return;}const handleTap=()=>{_classPrivateFieldBase(this,_processActions)[_processActions]({action:MSG_TRANS_TOGGLE});};const handleListener=mode=>{let options=null;switch(mode){case 2:case 3:case 4:options={taps:1,fingers:mode};break;case 5:options={taps:2,fingers:1};break;case 6:options={taps:3,fingers:1};break;case 7:options={taps:2,fingers:2};break;default:}if(options){_classPrivateFieldBase(this,_clearTouchListeners)[_clearTouchListeners].push(touchTapListener(handleTap,options));}};touchModes.forEach(mode=>handleListener(mode));}function translatorManager_handleWindowMessage2(event){_classPrivateFieldBase(this,_processActions)[_processActions](event.data);}function _handleBrowserMessage2(message,sender,sendResponse){const result=_classPrivateFieldBase(this,_processActions)[_processActions](message,true);const response=result||{rule:this._translator.rule,setting:this._translator.setting};sendResponse(response);return true;}function _registerShortcuts2(){const{shortcuts}=this._translator.setting;_classPrivateFieldBase(this,_clearShortcuts)[_clearShortcuts]=[shortcutRegister(shortcuts[OPT_SHORTCUT_TRANSLATE],()=>_classPrivateFieldBase(this,_processActions)[_processActions]({action:MSG_TRANS_TOGGLE})),shortcutRegister(shortcuts[OPT_SHORTCUT_STYLE],()=>_classPrivateFieldBase(this,_processActions)[_processActions]({action:MSG_TRANS_TOGGLE_STYLE})),shortcutRegister(shortcuts[OPT_SHORTCUT_POPUP],()=>_classPrivateFieldBase(this,_processActions)[_processActions]({action:MSG_POPUP_TOGGLE})),shortcutRegister(shortcuts[OPT_SHORTCUT_SETTING],()=>window.open("https://fishjar.github.io/kiss-translator/options.html","_blank"))];}function _registerMenus2(){if(!globalThis.GM)return;const{contextMenuType,uiLang}=this._translator.setting;if(contextMenuType===0)return;const i18n=newI18n(uiLang||"zh");const GM=globalThis.GM;_classPrivateFieldBase(this,_menuCommandIds)[_menuCommandIds]=[GM.registerMenuCommand(i18n("translate_switch"),()=>_classPrivateFieldBase(this,_processActions)[_processActions]({action:MSG_TRANS_TOGGLE}),"Q"),GM.registerMenuCommand(i18n("toggle_style"),()=>_classPrivateFieldBase(this,_processActions)[_processActions]({action:MSG_TRANS_TOGGLE_STYLE}),"C"),GM.registerMenuCommand(i18n("open_menu"),()=>_classPrivateFieldBase(this,_processActions)[_processActions]({action:MSG_POPUP_TOGGLE}),"K"),GM.registerMenuCommand(i18n("open_setting"),()=>window.open("https://fishjar.github.io/kiss-translator/options.html","_blank"),"O")];}function _processActions2(){var _this$_popupManager2,_this$_transboxManage2,_this$_inputTranslato2;let{action,args}=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};let fromExt=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;if(!action)return;if(!fromExt){sendIframeMsg(action,args);}switch(action){case MSG_TRANS_TOGGLE:this._translator.toggle();break;case MSG_TRANS_TOGGLE_STYLE:this._translator.toggleStyle();break;case MSG_TRANS_GETRULE:break;case MSG_TRANS_PUTRULE:this._translator.updateRule(args);break;case MSG_OPEN_TRANBOX:document.dispatchEvent(new CustomEvent(EVENT_KISS,{detail:{action:MSG_OPEN_TRANBOX}}));break;case MSG_POPUP_TOGGLE:(_this$_popupManager2=this._popupManager)===null||_this$_popupManager2===void 0?void 0:_this$_popupManager2.toggle();break;case MSG_TRANSBOX_TOGGLE:(_this$_transboxManage2=this._transboxManager)===null||_this$_transboxManage2===void 0?void 0:_this$_transboxManage2.toggle();this._translator.toggleTransbox();break;case MSG_MOUSEHOVER_TOGGLE:this._translator.toggleMouseHover();break;case MSG_TRANSINPUT_TOGGLE:(_this$_inputTranslato2=this._inputTranslator)===null||_this$_inputTranslato2===void 0?void 0:_this$_inputTranslato2.toggle();this._translator.toggleInputTranslate();break;default:logger.info("Message action is unavailable: ".concat(action));return{error:"Message action is unavailable: ".concat(action)};}} +(_this$_popupManager=this._popupManager)===null||_this$_popupManager===void 0?void 0:_this$_popupManager.destroy();(_this$_fabManager=this._fabManager)===null||_this$_fabManager===void 0?void 0:_this$_fabManager.destroy();(_this$_transboxManage=this._transboxManager)===null||_this$_transboxManage===void 0?void 0:_this$_transboxManage.disable();(_this$_inputTranslato=this._inputTranslator)===null||_this$_inputTranslato===void 0?void 0:_this$_inputTranslato.disable();this._translator.stop();_classPrivateFieldBase(this,_isActive)[_isActive]=false;logger.info("TranslatorManager stopped.");}}function _setupMessageListeners2(){if(_classPrivateFieldBase(this,_isUserscript)[_isUserscript]){window.addEventListener("message",_classPrivateFieldBase(this,translatorManager_windowMessageHandler)[translatorManager_windowMessageHandler]);}else{browser.runtime.onMessage.addListener(_classPrivateFieldBase(this,_browserMessageHandler)[_browserMessageHandler]);if(_classPrivateFieldBase(this,_isIframe)[_isIframe]){window.addEventListener("message",_classPrivateFieldBase(this,translatorManager_windowMessageHandler)[translatorManager_windowMessageHandler]);}}}function _setupTouchOperations2(){if(_classPrivateFieldBase(this,_isIframe)[_isIframe])return;const{touchModes=[2]}=this._translator.setting;if(touchModes.length===0){return;}const handleTap=()=>{_classPrivateFieldBase(this,_processActions)[_processActions]({action:MSG_TRANS_TOGGLE});};const handleListener=mode=>{let options=null;switch(mode){case 2:case 3:case 4:options={taps:1,fingers:mode};break;case 5:options={taps:2,fingers:1};break;case 6:options={taps:3,fingers:1};break;case 7:options={taps:2,fingers:2};break;default:}if(options){_classPrivateFieldBase(this,_clearTouchListeners)[_clearTouchListeners].push(touchTapListener(handleTap,options));}};touchModes.forEach(mode=>handleListener(mode));}function translatorManager_handleWindowMessage2(event){_classPrivateFieldBase(this,_processActions)[_processActions](event.data);}function _handleBrowserMessage2(message,sender,sendResponse){const result=_classPrivateFieldBase(this,_processActions)[_processActions](message,true);const response=result||{rule:this._translator.rule,setting:this._translator.setting};sendResponse(response);return true;}function _registerShortcuts2(){const{shortcuts}=this._translator.setting;_classPrivateFieldBase(this,_clearShortcuts)[_clearShortcuts]=[shortcutRegister(shortcuts[OPT_SHORTCUT_TRANSLATE],()=>_classPrivateFieldBase(this,_processActions)[_processActions]({action:MSG_TRANS_TOGGLE})),shortcutRegister(shortcuts[OPT_SHORTCUT_STYLE],()=>_classPrivateFieldBase(this,_processActions)[_processActions]({action:MSG_TRANS_TOGGLE_STYLE})),shortcutRegister(shortcuts[OPT_SHORTCUT_POPUP],()=>_classPrivateFieldBase(this,_processActions)[_processActions]({action:MSG_POPUP_TOGGLE})),shortcutRegister(shortcuts[OPT_SHORTCUT_SETTING],()=>window.open("https://fishjar.github.io/kiss-translator/options.html","_blank"))];}function _registerMenus2(){if(!globalThis.GM)return;const{contextMenuType,uiLang}=this._translator.setting;if(contextMenuType===0)return;const i18n=newI18n(uiLang||"zh");const GM=globalThis.GM;_classPrivateFieldBase(this,_menuCommandIds)[_menuCommandIds]=[GM.registerMenuCommand(i18n("translate_switch"),()=>_classPrivateFieldBase(this,_processActions)[_processActions]({action:MSG_TRANS_TOGGLE}),"Q"),GM.registerMenuCommand(i18n("toggle_style"),()=>_classPrivateFieldBase(this,_processActions)[_processActions]({action:MSG_TRANS_TOGGLE_STYLE}),"C"),GM.registerMenuCommand(i18n("open_menu"),()=>_classPrivateFieldBase(this,_processActions)[_processActions]({action:MSG_POPUP_TOGGLE}),"K"),GM.registerMenuCommand(i18n("open_setting"),()=>window.open("https://fishjar.github.io/kiss-translator/options.html","_blank"),"O")];}function _processActions2(){var _this$_popupManager2,_this$_transboxManage2,_this$_inputTranslato2;let{action,args}=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};let fromExt=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;if(!action)return;if(!fromExt){sendIframeMsg(action,args);}logger.debug("process action:",action,args);switch(action){case MSG_TRANS_TOGGLE:this._translator.toggle();break;case MSG_TRANS_TOGGLE_STYLE:this._translator.toggleStyle();break;case MSG_TRANS_GETRULE:break;case MSG_TRANS_PUTRULE:this._translator.updateRule(args);break;case MSG_OPEN_TRANBOX:document.dispatchEvent(new CustomEvent(EVENT_KISS,{detail:{action:MSG_OPEN_TRANBOX}}));break;case MSG_POPUP_TOGGLE:(_this$_popupManager2=this._popupManager)===null||_this$_popupManager2===void 0?void 0:_this$_popupManager2.toggle();break;case MSG_TRANSBOX_TOGGLE:(_this$_transboxManage2=this._transboxManager)===null||_this$_transboxManage2===void 0?void 0:_this$_transboxManage2.toggle();this._translator.toggleTransbox();break;case MSG_MOUSEHOVER_TOGGLE:this._translator.toggleMouseHover();break;case MSG_TRANSINPUT_TOGGLE:(_this$_inputTranslato2=this._inputTranslator)===null||_this$_inputTranslato2===void 0?void 0:_this$_inputTranslato2.toggle();this._translator.toggleInputTranslate();break;default:logger.info("Message action is unavailable: ".concat(action));return{error:"Message action is unavailable: ".concat(action)};}} ;// CONCATENATED MODULE: ./src/common.js /** * 油猴脚本设置页面 - */function runSettingPage(){var _GM,_GM$info,_GM$info$script,_GM$info$script$grant;if((_GM=GM)!==null&&_GM!==void 0&&(_GM$info=_GM.info)!==null&&_GM$info!==void 0&&(_GM$info$script=_GM$info.script)!==null&&_GM$info$script!==void 0&&(_GM$info$script$grant=_GM$info$script.grant)!==null&&_GM$info$script$grant!==void 0&&_GM$info$script$grant.includes("unsafeWindow")){unsafeWindow.GM=GM;unsafeWindow.APP_INFO={name:"KISS Translator",version:"2.0.10"};}else{const ping=utils_genEventName();window.addEventListener(ping,handlePing);// window.eval(`(${injectScript})("${ping}")`); // eslint-disable-line + */function runSettingPage(){var _GM,_GM$info,_GM$info$script,_GM$info$script$grant;if((_GM=GM)!==null&&_GM!==void 0&&(_GM$info=_GM.info)!==null&&_GM$info!==void 0&&(_GM$info$script=_GM$info.script)!==null&&_GM$info$script!==void 0&&(_GM$info$script$grant=_GM$info$script.grant)!==null&&_GM$info$script$grant!==void 0&&_GM$info$script$grant.includes("unsafeWindow")){unsafeWindow.GM=GM;unsafeWindow.APP_INFO={name:"KISS Translator",version:"2.0.11"};}else{const ping=utils_genEventName();window.addEventListener(ping,handlePing);// window.eval(`(${injectScript})("${ping}")`); // eslint-disable-line injectInlineJs("(".concat(injectScript,")(\"").concat(ping,"\")"),"kiss-translator-options-injector");}}/** * 显示错误信息到页面顶部 * @param {*} message */function showErr(message){const bannerId="KISS-Translator-Message";const existingBanner=document.getElementById(bannerId);if(existingBanner){existingBanner.remove();}const banner=document.createElement("div");banner.id=bannerId;Object.assign(banner.style,{position:"fixed",top:"0",left:"0",width:"100%",backgroundColor:"#f44336",color:"white",textAlign:"center",padding:"8px 16px",zIndex:"1001",boxSizing:"border-box",fontSize:"16px",boxShadow:"0 2px 5px rgba(0,0,0,0.2)"});const closeButton=document.createElement("span");closeButton.textContent="×";Object.assign(closeButton.style,{position:"absolute",top:"50%",right:"20px",transform:"translateY(-50%)",cursor:"pointer",fontSize:"22px",fontWeight:"bold"});const messageText=document.createTextNode("KISS-Translator: ".concat(message));banner.appendChild(messageText);banner.appendChild(closeButton);document.body.appendChild(banner);const removeBanner=()=>{banner.style.transition="opacity 0.5s ease";banner.style.opacity="0";setTimeout(()=>{if(banner&&banner.parentNode){banner.parentNode.removeChild(banner);}},500);};closeButton.onclick=removeBanner;setTimeout(removeBanner,10000);}async function getFavWords(rule){if(rule.highlightWords&&rule.highlightWords!==OPT_HIGHLIGHT_WORDS_DISABLE){try{return Object.keys(await storage_getWordsWithDefault());}catch(err){logger.info("get fav words",err);}}return[];}/** * 入口函数 - */async function run(){let isUserscript=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;try{var _document,_document$contentType;// if (document?.documentElement?.tagName?.toUpperCase() !== "HTML") { + */async function run(){let isUserscript=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;try{var _document,_document$contentType,_document2,_document2$location;// 读取设置信息 +const setting=await storage_getSettingWithDefault();// 日志 +logger.setLevel(setting.logLevel);// if (document?.documentElement?.tagName?.toUpperCase() !== "HTML") { // return; // } -if(!((_document=document)!==null&&_document!==void 0&&(_document$contentType=_document.contentType)!==null&&_document$contentType!==void 0&&_document$contentType.includes("text"))){return;}// 读取设置信息 -const setting=await storage_getSettingWithDefault();// 日志 -logger.setLevel(setting.logLevel);const href=document.location.href;// 设置页面 +const contentType=((_document=document)===null||_document===void 0?void 0:(_document$contentType=_document.contentType)===null||_document$contentType===void 0?void 0:_document$contentType.toLowerCase())||"";if(!contentType.includes("text")&&!contentType.includes("html")){logger.info("Skip running in document content type: ",contentType);return;}const href=((_document2=document)===null||_document2===void 0?void 0:(_document2$location=_document2.location)===null||_document2$location===void 0?void 0:_document2$location.href)||"";// 设置页面 if(isUserscript&&(href.includes("http://localhost:3000/options.html")||href.includes("https://fishjar.github.io/kiss-translator/options.html"))){runSettingPage();return;}// 黑名单 if(isInBlacklist(href,setting)){return;}// 翻译网页 const rule=await matchRule(href,setting);const favWords=await getFavWords(rule);const fabConfig=await getFabWithDefault();const translatorManager=new TranslatorManager({setting,rule,fabConfig,favWords,isIframe: isIframe,isUserscript});translatorManager.start();if(isIframe){return;}// 字幕翻译 diff --git a/kiss-translator.user.js b/kiss-translator.user.js index cd87061..d985ecc 100644 --- a/kiss-translator.user.js +++ b/kiss-translator.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name KISS Translator // @namespace https://github.com/fishjar/kiss-translator -// @version 2.0.10 +// @version 2.0.11 // @description A simple bilingual translation extension & Greasemonkey script (一个简约的双语对照翻译扩展 & 油猴脚本) // @author Gabe // @homepageURL https://github.com/fishjar/kiss-translator @@ -29407,7 +29407,7 @@ __webpack_require__.d(base_namespaceObject, { }); ;// CONCATENATED MODULE: ./src/config/app.js -const APP_NAME="KISS Translator".trim().split(/\s+/).join("-");const APP_LCNAME=APP_NAME.toLowerCase();const APP_UPNAME=APP_NAME.toUpperCase();const APP_CONSTS={fabID:"".concat(APP_LCNAME,"-fab"),boxID:"".concat(APP_LCNAME,"-box"),popupID:"".concat(APP_LCNAME,"-popup")};const APP_VERSION="2.0.10".split(".");const THEME_LIGHT="light";const THEME_DARK="dark"; +const APP_NAME="KISS Translator".trim().split(/\s+/).join("-");const APP_LCNAME=APP_NAME.toLowerCase();const APP_UPNAME=APP_NAME.toUpperCase();const APP_CONSTS={fabID:"".concat(APP_LCNAME,"-fab"),boxID:"".concat(APP_LCNAME,"-box"),popupID:"".concat(APP_LCNAME,"-popup")};const APP_VERSION="2.0.11".split(".");const THEME_LIGHT="light";const THEME_DARK="dark"; ;// CONCATENATED MODULE: ./node_modules/.pnpm/@babel+runtime@7.24.4/node_modules/@babel/runtime/helpers/esm/typeof.js function _typeof(o) { "@babel/helpers - typeof"; @@ -30142,7 +30142,7 @@ return fnPolyfill({fn:fetchHandle,input,init,opts});}; const MSG_GM_xmlHttpRequest="xmlHttpRequest";const MSG_GM_setValue="setValue";const MSG_GM_getValue="getValue";const MSG_GM_deleteValue="deleteValue";const MSG_GM_info="info";/** * 注入页面的脚本,请求并接受GM接口信息 * @param {*} param0 - */const injectScript=ping=>{window.APP_INFO={name:"KISS Translator",version:"2.0.10",eventName:ping};};/** + */const injectScript=ping=>{window.APP_INFO={name:"KISS Translator",version:"2.0.11",eventName:ping};};/** * 适配GM脚本 */const adaptScript=ping=>{const promiseGM=function(action,args){let timeout=arguments.length>2&&arguments[2]!==undefined?arguments[2]:5000;return new Promise((resolve,reject)=>{const pong=genEventName();const handleEvent=e=>{window.removeEventListener(pong,handleEvent);const{data,error}=e.detail;if(error){reject(new Error(error));}else{resolve(data);}};window.addEventListener(pong,handleEvent);window.dispatchEvent(new CustomEvent(ping,{detail:{action,args,pong}}));setTimeout(()=>{window.removeEventListener(pong,handleEvent);reject(new Error("timeout"));},timeout);});};window.KISS_GM={fetch:(input,init)=>promiseGM(MSG_GM_xmlHttpRequest,{input,init}),setValue:(key,val)=>promiseGM(MSG_GM_setValue,{key,val}),getValue:key=>promiseGM(MSG_GM_getValue,{key}),deleteValue:key=>promiseGM(MSG_GM_deleteValue,{key}),getInfo:async()=>{if(!window.GM_info){window.GM_info=await promiseGM(MSG_GM_info);}return window.GM_info;}};};/** * 监听并回应页面对GM接口的请求 @@ -30850,7 +30850,7 @@ keyfrom:"webdict"});const init={headers:{accept:"application/json, text/plain, * * @param {*} param0 * @returns */const apiTranslate=async _ref2=>{let{text,fromLang="auto",toLang,apiSetting=DEFAULT_API_SETTING,docInfo={},glossary,useCache=true,usePool=true}=_ref2;if(!text){throw new Error("The text cannot be empty.");}const{apiType,apiSlug,useBatchFetch}=apiSetting;const langMap=OPT_LANGS_TO_SPEC[apiType]||OPT_LANGS_SPEC_DEFAULT;const from=langMap.get(fromLang);const to=langMap.get(toLang);if(!to){throw new Error("The target lang: ".concat(toLang," not support"));}// todo: 优化缓存失效因素 -const[v1,v2]="2.0.10".split(".");const cacheOpts={apiSlug,text,fromLang,toLang,version:[v1,v2].join(".")};const cacheInput="".concat(URL_CACHE_TRAN,"?").concat(query_string.stringify(cacheOpts));// 查询缓存数据 +const[v1,v2]="2.0.11".split(".");const cacheOpts={apiSlug,text,fromLang,toLang,version:[v1,v2].join(".")};const cacheInput="".concat(URL_CACHE_TRAN,"?").concat(query_string.stringify(cacheOpts));// 查询缓存数据 if(useCache){const cache=await getHttpCachePolyfill(cacheInput);if(cache!==null&&cache!==void 0&&cache.trText){return cache;}}// 请求接口数据 let tranlation=[];if(apiType===OPT_TRANS_BUILTINAI){tranlation=await apiBuiltinAITranslate({text,from,to,apiSetting});}else if(useBatchFetch&&API_SPE_TYPES.batch.has(apiType)){const{apiSlug,batchInterval,batchSize,batchLength}=apiSetting;const key="".concat(apiSlug,"_").concat(fromLang,"_").concat(toLang);const queue=getBatchQueue(key,handleTranslate,{batchInterval,batchSize,batchLength});tranlation=await queue.addTask(text,{from,to,fromLang,toLang,langMap,docInfo,glossary,apiSetting,usePool});}else{[tranlation]=await handleTranslate([text],{from,to,fromLang,toLang,langMap,docInfo,glossary,apiSetting,usePool});}let trText="";let srLang="";let srCode="";if(Array.isArray(tranlation)){[trText,srLang=""]=tranlation;if(srLang){srCode=OPT_LANGS_TO_CODE[apiType].get(srLang)||"";}}else if(typeof tranlation==="string"){trText=tranlation;}if(!trText){throw new Error("tanslate api got empty trtext");}const isSame=fromLang==="auto"&&srLang===to;// 插入缓存 if(useCache){putHttpCachePolyfill(cacheInput,null,{trText,isSame,srLang,srCode});}return{trText,srLang,srCode,isSame};};// 字幕处理/翻译 @@ -33690,7 +33690,7 @@ var n = {}; return t.length === e && "." !== t && ".." !== t; }; }, - te = "object" === ("undefined" == typeof process ? "undefined" : Nt(process)) && process ? "object" === Nt(({"NODE_ENV":"production","PUBLIC_URL":"","WDS_SOCKET_HOST":undefined,"WDS_SOCKET_PATH":undefined,"WDS_SOCKET_PORT":undefined,"FAST_REFRESH":true,"REACT_APP_CLIENT":"userscript","REACT_APP_NAME":"KISS Translator","REACT_APP_NAME_CN":"简约翻译","REACT_APP_VERSION":"2.0.10","REACT_APP_HOMEPAGE":"https://github.com/fishjar/kiss-translator","REACT_APP_OPTIONSPAGE":"https://fishjar.github.io/kiss-translator/options.html","REACT_APP_OPTIONSPAGE_DEV":"http://localhost:3000/options.html","REACT_APP_LOGOURL":"https://fishjar.github.io/kiss-translator/images/logo192.png","REACT_APP_RULESURL":"https://fishjar.github.io/kiss-rules/kiss-rules_v2.json","REACT_APP_RULESURL_ON":"https://fishjar.github.io/kiss-rules/kiss-rules-on_v2.json","REACT_APP_RULESURL_OFF":"https://fishjar.github.io/kiss-rules/kiss-rules-off_v2.json","REACT_APP_USERSCRIPT_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator.user.js","REACT_APP_USERSCRIPT_IOS_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js"})) && ({"NODE_ENV":"production","PUBLIC_URL":"","WDS_SOCKET_HOST":undefined,"WDS_SOCKET_PATH":undefined,"WDS_SOCKET_PORT":undefined,"FAST_REFRESH":true,"REACT_APP_CLIENT":"userscript","REACT_APP_NAME":"KISS Translator","REACT_APP_NAME_CN":"简约翻译","REACT_APP_VERSION":"2.0.10","REACT_APP_HOMEPAGE":"https://github.com/fishjar/kiss-translator","REACT_APP_OPTIONSPAGE":"https://fishjar.github.io/kiss-translator/options.html","REACT_APP_OPTIONSPAGE_DEV":"http://localhost:3000/options.html","REACT_APP_LOGOURL":"https://fishjar.github.io/kiss-translator/images/logo192.png","REACT_APP_RULESURL":"https://fishjar.github.io/kiss-rules/kiss-rules_v2.json","REACT_APP_RULESURL_ON":"https://fishjar.github.io/kiss-rules/kiss-rules-on_v2.json","REACT_APP_RULESURL_OFF":"https://fishjar.github.io/kiss-rules/kiss-rules-off_v2.json","REACT_APP_USERSCRIPT_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator.user.js","REACT_APP_USERSCRIPT_IOS_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js"}) && ({"NODE_ENV":"production","PUBLIC_URL":"","WDS_SOCKET_HOST":undefined,"WDS_SOCKET_PATH":undefined,"WDS_SOCKET_PORT":undefined,"FAST_REFRESH":true,"REACT_APP_CLIENT":"userscript","REACT_APP_NAME":"KISS Translator","REACT_APP_NAME_CN":"简约翻译","REACT_APP_VERSION":"2.0.10","REACT_APP_HOMEPAGE":"https://github.com/fishjar/kiss-translator","REACT_APP_OPTIONSPAGE":"https://fishjar.github.io/kiss-translator/options.html","REACT_APP_OPTIONSPAGE_DEV":"http://localhost:3000/options.html","REACT_APP_LOGOURL":"https://fishjar.github.io/kiss-translator/images/logo192.png","REACT_APP_RULESURL":"https://fishjar.github.io/kiss-rules/kiss-rules_v2.json","REACT_APP_RULESURL_ON":"https://fishjar.github.io/kiss-rules/kiss-rules-on_v2.json","REACT_APP_RULESURL_OFF":"https://fishjar.github.io/kiss-rules/kiss-rules-off_v2.json","REACT_APP_USERSCRIPT_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator.user.js","REACT_APP_USERSCRIPT_IOS_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js"}).__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix"; + te = "object" === ("undefined" == typeof process ? "undefined" : Nt(process)) && process ? "object" === Nt(({"NODE_ENV":"production","PUBLIC_URL":"","WDS_SOCKET_HOST":undefined,"WDS_SOCKET_PATH":undefined,"WDS_SOCKET_PORT":undefined,"FAST_REFRESH":true,"REACT_APP_CLIENT":"userscript","REACT_APP_NAME":"KISS Translator","REACT_APP_NAME_CN":"简约翻译","REACT_APP_VERSION":"2.0.11","REACT_APP_HOMEPAGE":"https://github.com/fishjar/kiss-translator","REACT_APP_OPTIONSPAGE":"https://fishjar.github.io/kiss-translator/options.html","REACT_APP_OPTIONSPAGE_DEV":"http://localhost:3000/options.html","REACT_APP_LOGOURL":"https://fishjar.github.io/kiss-translator/images/logo192.png","REACT_APP_RULESURL":"https://fishjar.github.io/kiss-rules/kiss-rules_v2.json","REACT_APP_RULESURL_ON":"https://fishjar.github.io/kiss-rules/kiss-rules-on_v2.json","REACT_APP_RULESURL_OFF":"https://fishjar.github.io/kiss-rules/kiss-rules-off_v2.json","REACT_APP_USERSCRIPT_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator.user.js","REACT_APP_USERSCRIPT_IOS_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js"})) && ({"NODE_ENV":"production","PUBLIC_URL":"","WDS_SOCKET_HOST":undefined,"WDS_SOCKET_PATH":undefined,"WDS_SOCKET_PORT":undefined,"FAST_REFRESH":true,"REACT_APP_CLIENT":"userscript","REACT_APP_NAME":"KISS Translator","REACT_APP_NAME_CN":"简约翻译","REACT_APP_VERSION":"2.0.11","REACT_APP_HOMEPAGE":"https://github.com/fishjar/kiss-translator","REACT_APP_OPTIONSPAGE":"https://fishjar.github.io/kiss-translator/options.html","REACT_APP_OPTIONSPAGE_DEV":"http://localhost:3000/options.html","REACT_APP_LOGOURL":"https://fishjar.github.io/kiss-translator/images/logo192.png","REACT_APP_RULESURL":"https://fishjar.github.io/kiss-rules/kiss-rules_v2.json","REACT_APP_RULESURL_ON":"https://fishjar.github.io/kiss-rules/kiss-rules-on_v2.json","REACT_APP_RULESURL_OFF":"https://fishjar.github.io/kiss-rules/kiss-rules-off_v2.json","REACT_APP_USERSCRIPT_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator.user.js","REACT_APP_USERSCRIPT_IOS_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js"}) && ({"NODE_ENV":"production","PUBLIC_URL":"","WDS_SOCKET_HOST":undefined,"WDS_SOCKET_PATH":undefined,"WDS_SOCKET_PORT":undefined,"FAST_REFRESH":true,"REACT_APP_CLIENT":"userscript","REACT_APP_NAME":"KISS Translator","REACT_APP_NAME_CN":"简约翻译","REACT_APP_VERSION":"2.0.11","REACT_APP_HOMEPAGE":"https://github.com/fishjar/kiss-translator","REACT_APP_OPTIONSPAGE":"https://fishjar.github.io/kiss-translator/options.html","REACT_APP_OPTIONSPAGE_DEV":"http://localhost:3000/options.html","REACT_APP_LOGOURL":"https://fishjar.github.io/kiss-translator/images/logo192.png","REACT_APP_RULESURL":"https://fishjar.github.io/kiss-rules/kiss-rules_v2.json","REACT_APP_RULESURL_ON":"https://fishjar.github.io/kiss-rules/kiss-rules-on_v2.json","REACT_APP_RULESURL_OFF":"https://fishjar.github.io/kiss-rules/kiss-rules-off_v2.json","REACT_APP_USERSCRIPT_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator.user.js","REACT_APP_USERSCRIPT_IOS_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js"}).__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix"; It.sep = "win32" === te ? "\\" : "/"; var ee = Symbol("globstar **"); It.GLOBSTAR = ee; @@ -35602,8 +35602,8 @@ if(isAISegment&&segApiSetting){logger.info("Youtube Provider: Starting AI ..."); const trustedTypesHelper=(()=>{const POLICY_NAME="kiss-translator-policy";let policy=null;if(globalThis.trustedTypes&&globalThis.trustedTypes.createPolicy){try{policy=globalThis.trustedTypes.createPolicy(POLICY_NAME,{createHTML:string=>string,createScript:string=>string,createScriptURL:string=>string});}catch(err){if(err.message.includes("already exists")){policy=globalThis.trustedTypes.policies.get(POLICY_NAME);}else{logger.info("cont create Trusted Types",err);}}}return{createHTML:htmlString=>{return policy?policy.createHTML(htmlString):htmlString;},createScript:scriptString=>{return policy?policy.createScript(scriptString):scriptString;},createScriptURL:urlString=>{return policy?policy.createScriptURL(urlString):urlString;},isEnabled:()=>policy!==null};})(); ;// CONCATENATED MODULE: ./src/libs/injector.js // Function to inject inline JavaScript code -const injectInlineJs=function(code){let id=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"kiss-translator-inline-js";if(document.getElementById(id)){return;}const el=document.createElement("script");el.type="text/javascript";el.id=id;el.textContent=trustedTypesHelper.createScript(code);(document.head||document.documentElement).appendChild(el);};const injectInlineJsBg=function(code){let id=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"kiss-translator-inline-js";if(document.getElementById(id)){return;}const el=document.createElement("script");el.type="text/javascript";el.id=id;el.textContent=code;(document.head||document.documentElement).appendChild(el);};// Function to inject external JavaScript file -const injectExternalJs=function(src){let id=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"kiss-translator-external-js";if(document.getElementById(id)){return;}const el=document.createElement("script");el.type="text/javascript";el.id=id;el.src=trustedTypesHelper.createScriptURL(src);(document.head||document.documentElement).appendChild(el);};// Function to inject internal CSS code +const injectInlineJs=function(code){let id=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"kiss-translator-inline-js";if(document.getElementById(id)){return;}const el=document.createElement("script");el.setAttribute("data-source","kiss-inject injectInlineJs");el.type="text/javascript";el.id=id;el.textContent=trustedTypesHelper.createScript(code);(document.head||document.documentElement).appendChild(el);};const injectInlineJsBg=function(code){let id=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"kiss-translator-inline-js";if(document.getElementById(id)){return;}const el=document.createElement("script");el.setAttribute("data-source","kiss-inject injectInlineJsBg");el.type="text/javascript";el.id=id;el.textContent=code;(document.head||document.documentElement).appendChild(el);};// Function to inject external JavaScript file +const injectExternalJs=function(src){let id=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"kiss-translator-external-js";if(document.getElementById(id)){return;}const el=document.createElement("script");el.setAttribute("data-source","kiss-inject injectExternalJs");el.type="text/javascript";el.id=id;el.src=trustedTypesHelper.createScriptURL(src);(document.head||document.documentElement).appendChild(el);};// Function to inject internal CSS code const injectInternalCss=styles=>{var _document$head;const el=document.createElement("style");el.setAttribute("data-source","kiss-inject injectInternalCss");el.textContent=styles;(_document$head=document.head)===null||_document$head===void 0?void 0:_document$head.appendChild(el);};// Function to inject external CSS file const injectExternalCss=href=>{var _document$head2;const el=document.createElement("link");el.setAttribute("data-source","kiss-inject injectExternalCss");el.setAttribute("rel","stylesheet");el.setAttribute("type","text/css");el.setAttribute("href",href);(_document$head2=document.head)===null||_document$head2===void 0?void 0:_document$head2.appendChild(el);}; ;// CONCATENATED MODULE: ./src/injectors/shadowroot.js @@ -36687,7 +36687,7 @@ var _class;/** * @description 翻译核心逻辑封装 */var translator_setting=/*#__PURE__*/_classPrivateFieldKey("setting");var _rule=/*#__PURE__*/_classPrivateFieldKey("rule");var _isInitialized=/*#__PURE__*/_classPrivateFieldKey("isInitialized");var _isJsInjected=/*#__PURE__*/_classPrivateFieldKey("isJsInjected");var _isShadowRootJsInjected=/*#__PURE__*/_classPrivateFieldKey("isShadowRootJsInjected");var _mouseHoverEnabled=/*#__PURE__*/_classPrivateFieldKey("mouseHoverEnabled");var _enabled=/*#__PURE__*/_classPrivateFieldKey("enabled");var _runId=/*#__PURE__*/_classPrivateFieldKey("runId");var _termValues=/*#__PURE__*/_classPrivateFieldKey("termValues");var _combinedTermsRegex=/*#__PURE__*/_classPrivateFieldKey("combinedTermsRegex");var _combinedSkipsRegex=/*#__PURE__*/_classPrivateFieldKey("combinedSkipsRegex");var _placeholderRegex=/*#__PURE__*/_classPrivateFieldKey("placeholderRegex");var _translationTagName=/*#__PURE__*/_classPrivateFieldKey("translationTagName");var _eventName=/*#__PURE__*/_classPrivateFieldKey("eventName");var _docInfo=/*#__PURE__*/_classPrivateFieldKey("docInfo");var _glossary=/*#__PURE__*/_classPrivateFieldKey("glossary");var _textClass=/*#__PURE__*/_classPrivateFieldKey("textClass");var _textSheet=/*#__PURE__*/_classPrivateFieldKey("textSheet");var _apisMap=/*#__PURE__*/_classPrivateFieldKey("apisMap");var _favWords=/*#__PURE__*/_classPrivateFieldKey("favWords");var _observedNodes=/*#__PURE__*/_classPrivateFieldKey("observedNodes");var _translationNodes=/*#__PURE__*/_classPrivateFieldKey("translationNodes");var _viewNodes=/*#__PURE__*/_classPrivateFieldKey("viewNodes");var _processedNodes=/*#__PURE__*/_classPrivateFieldKey("processedNodes");var _rootNodes=/*#__PURE__*/_classPrivateFieldKey("rootNodes");var _skipMoNodes=/*#__PURE__*/_classPrivateFieldKey("skipMoNodes");var _removeKeydownHandler=/*#__PURE__*/_classPrivateFieldKey("removeKeydownHandler");var _hoveredNode=/*#__PURE__*/_classPrivateFieldKey("hoveredNode");var _boundMouseMoveHandler=/*#__PURE__*/_classPrivateFieldKey("boundMouseMoveHandler");var _boundKeyDownHandler=/*#__PURE__*/_classPrivateFieldKey("boundKeyDownHandler");var _windowMessageHandler=/*#__PURE__*/_classPrivateFieldKey("windowMessageHandler");var _debouncedFindShadowRoot=/*#__PURE__*/_classPrivateFieldKey("debouncedFindShadowRoot");var _io=/*#__PURE__*/_classPrivateFieldKey("io");var _mo=/*#__PURE__*/_classPrivateFieldKey("mo");var _dmm=/*#__PURE__*/_classPrivateFieldKey("dmm");var _rescanQueue=/*#__PURE__*/_classPrivateFieldKey("rescanQueue");var _isQueueProcessing=/*#__PURE__*/_classPrivateFieldKey("isQueueProcessing");var _ignoreSelector=/*#__PURE__*/_classPrivateFieldKey("ignoreSelector");var _apiSetting=/*#__PURE__*/_classPrivateFieldKey("apiSetting");var _placeholder=/*#__PURE__*/_classPrivateFieldKey("placeholder");var _run=/*#__PURE__*/_classPrivateFieldKey("run");var _init=/*#__PURE__*/_classPrivateFieldKey("init");var _handleWindowMessage=/*#__PURE__*/_classPrivateFieldKey("handleWindowMessage");var _attachShadowRootListener=/*#__PURE__*/_classPrivateFieldKey("attachShadowRootListener");var _removeShadowRootListener=/*#__PURE__*/_classPrivateFieldKey("removeShadowRootListener");var _findAndObserveShadowRoot=/*#__PURE__*/_classPrivateFieldKey("findAndObserveShadowRoot");var _createPlaceholderRegex=/*#__PURE__*/_classPrivateFieldKey("createPlaceholderRegex");var _createTextStyles=/*#__PURE__*/_classPrivateFieldKey("createTextStyles");var _injectSheet=/*#__PURE__*/_classPrivateFieldKey("injectSheet");var _parseTerms=/*#__PURE__*/_classPrivateFieldKey("parseTerms");var _parseAITerms=/*#__PURE__*/_classPrivateFieldKey("parseAITerms");var _getDocDescription=/*#__PURE__*/_classPrivateFieldKey("getDocDescription");var _createIntersectionObserver=/*#__PURE__*/_classPrivateFieldKey("createIntersectionObserver");var _createMutationObserver=/*#__PURE__*/_classPrivateFieldKey("createMutationObserver");var _createDebounceMouseMover=/*#__PURE__*/_classPrivateFieldKey("createDebounceMouseMover");var _handleMouseMove=/*#__PURE__*/_classPrivateFieldKey("handleMouseMove");var _handleKeyDown=/*#__PURE__*/_classPrivateFieldKey("handleKeyDown");var _toggleTargetNode=/*#__PURE__*/_classPrivateFieldKey("toggleTargetNode");var _findAllShadowRoots=/*#__PURE__*/_classPrivateFieldKey("findAllShadowRoots");var _findChangeContainer=/*#__PURE__*/_classPrivateFieldKey("findChangeContainer");var _queueForRescan=/*#__PURE__*/_classPrivateFieldKey("queueForRescan");var _rescanContainer=/*#__PURE__*/_classPrivateFieldKey("rescanContainer");var _reIO=/*#__PURE__*/_classPrivateFieldKey("reIO");var _reIOViewNodes=/*#__PURE__*/_classPrivateFieldKey("reIOViewNodes");var _startObserveShadowRoot=/*#__PURE__*/_classPrivateFieldKey("startObserveShadowRoot");var _startObserveRoot=/*#__PURE__*/_classPrivateFieldKey("startObserveRoot");var _startObserveNode=/*#__PURE__*/_classPrivateFieldKey("startObserveNode");var _queryNode=/*#__PURE__*/_classPrivateFieldKey("queryNode");var _scanNode=/*#__PURE__*/_classPrivateFieldKey("scanNode");var _processNode=/*#__PURE__*/_classPrivateFieldKey("processNode");var _highlightTextNode=/*#__PURE__*/_classPrivateFieldKey("highlightTextNode");var _highlightWordsDeeply=/*#__PURE__*/_classPrivateFieldKey("highlightWordsDeeply");var _splitTextNodesBySentence=/*#__PURE__*/_classPrivateFieldKey("splitTextNodesBySentence");var _removeHighlights=/*#__PURE__*/_classPrivateFieldKey("removeHighlights");var _removeBrTags=/*#__PURE__*/_classPrivateFieldKey("removeBrTags");var _shouldBreak=/*#__PURE__*/_classPrivateFieldKey("shouldBreak");var _isInvalidText=/*#__PURE__*/_classPrivateFieldKey("isInvalidText");var _translateNodeGroup=/*#__PURE__*/_classPrivateFieldKey("translateNodeGroup");var _serializeForTranslation=/*#__PURE__*/_classPrivateFieldKey("serializeForTranslation");var _restoreFromTranslation=/*#__PURE__*/_classPrivateFieldKey("restoreFromTranslation");var _translateFetch=/*#__PURE__*/_classPrivateFieldKey("translateFetch");var _findTranslationWrappers=/*#__PURE__*/_classPrivateFieldKey("findTranslationWrappers");var _cleanupAllNodes=/*#__PURE__*/_classPrivateFieldKey("cleanupAllNodes");var _cleanupAllTranslations=/*#__PURE__*/_classPrivateFieldKey("cleanupAllTranslations");var _cleanupDirectTranslations=/*#__PURE__*/_classPrivateFieldKey("cleanupDirectTranslations");var _removeTranslationElement=/*#__PURE__*/_classPrivateFieldKey("removeTranslationElement");var _restoreOriginal=/*#__PURE__*/_classPrivateFieldKey("restoreOriginal");var _removeNodes=/*#__PURE__*/_classPrivateFieldKey("removeNodes");var _toggleTranslationOnly=/*#__PURE__*/_classPrivateFieldKey("toggleTranslationOnly");var _updateStyle=/*#__PURE__*/_classPrivateFieldKey("updateStyle");var _refreshNode=/*#__PURE__*/_classPrivateFieldKey("refreshNode");var _performSyncNode=/*#__PURE__*/_classPrivateFieldKey("performSyncNode");var _resetOptions=/*#__PURE__*/_classPrivateFieldKey("resetOptions");var _enableMouseHover=/*#__PURE__*/_classPrivateFieldKey("enableMouseHover");var _disableMouseHover=/*#__PURE__*/_classPrivateFieldKey("disableMouseHover");var _initInjector=/*#__PURE__*/_classPrivateFieldKey("initInjector");var _removeInjector=/*#__PURE__*/_classPrivateFieldKey("removeInjector");var _translateTitle=/*#__PURE__*/_classPrivateFieldKey("translateTitle");class translator_Translator{// 默认规则 static isElement(el){return el instanceof Element;}static isElementOrFragment(el){return el instanceof Element||el instanceof DocumentFragment;}// 判断是否块级元素 -static isBlockNode(el){var _el$attributes,_el$attributes$displa,_el$attributes$displa2;if(!translator_Translator.isElementOrFragment(el))return false;if(translator_Translator.TAGS.INLINE.has(el.nodeName))return false;if(translator_Translator.TAGS.BLOCK.has(el.nodeName))return true;if((_el$attributes=el.attributes)!==null&&_el$attributes!==void 0&&(_el$attributes$displa=_el$attributes.display)!==null&&_el$attributes$displa!==void 0&&(_el$attributes$displa2=_el$attributes$displa.value)!==null&&_el$attributes$displa2!==void 0&&_el$attributes$displa2.includes("inline"))return false;if(translator_Translator.displayCache.has(el)){return translator_Translator.displayCache.get(el);}const isBlock=!window.getComputedStyle(el).display.startsWith("inline");translator_Translator.displayCache.set(el,isBlock);return isBlock;}// 判断是否包含块级子元素 +static isBlockNode(el){var _el$nodeName,_el$nodeName2,_el$attributes,_el$attributes$displa,_el$attributes$displa2;if(!translator_Translator.isElementOrFragment(el))return false;if(translator_Translator.TAGS.INLINE.has((_el$nodeName=el.nodeName)===null||_el$nodeName===void 0?void 0:_el$nodeName.toUpperCase()))return false;if(translator_Translator.TAGS.BLOCK.has((_el$nodeName2=el.nodeName)===null||_el$nodeName2===void 0?void 0:_el$nodeName2.toUpperCase()))return true;if((_el$attributes=el.attributes)!==null&&_el$attributes!==void 0&&(_el$attributes$displa=_el$attributes.display)!==null&&_el$attributes$displa!==void 0&&(_el$attributes$displa2=_el$attributes$displa.value)!==null&&_el$attributes$displa2!==void 0&&_el$attributes$displa2.includes("inline"))return false;if(translator_Translator.displayCache.has(el)){return translator_Translator.displayCache.get(el);}const isBlock=!window.getComputedStyle(el).display.startsWith("inline");translator_Translator.displayCache.set(el,isBlock);return isBlock;}// 判断是否包含块级子元素 static hasBlockNode(el){if(!translator_Translator.isElementOrFragment(el))return false;for(const child of el.childNodes){if(translator_Translator.isBlockNode(child)){return true;}}return false;}// 判断是否直接包含非空文本节点 static hasTextNode(el){if(!translator_Translator.isElementOrFragment(el))return false;for(const child of el.childNodes){if(child.nodeType===Node.TEXT_NODE&&/\S/.test(child.nodeValue)){return true;}}return false;}// 特殊字符转义 static escapeRegex(str){return str.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");}// 内置忽略元素 @@ -36761,7 +36761,7 @@ Object.defineProperty(this,_termValues,{writable:true,value:[]});// 按顺序存 Object.defineProperty(this,_combinedTermsRegex,{writable:true,value:void 0});// 专业术语正则表达式 Object.defineProperty(this,_combinedSkipsRegex,{writable:true,value:void 0});// 跳过文本正则表达式 Object.defineProperty(this,_placeholderRegex,{writable:true,value:void 0});// 恢复htnml正则表达式 -Object.defineProperty(this,_translationTagName,{writable:true,value:APP_UPNAME});// 翻译容器的标签名 +Object.defineProperty(this,_translationTagName,{writable:true,value:APP_LCNAME});// 翻译容器的标签名 Object.defineProperty(this,_eventName,{writable:true,value:""});// 通信事件名称 Object.defineProperty(this,_docInfo,{writable:true,value:{}});// 网页信息 Object.defineProperty(this,_glossary,{writable:true,value:{}});// AI词典 @@ -36805,7 +36805,7 @@ return _classPrivateFieldBase(this,_apisMap)[_apisMap].get(_classPrivateFieldBas _classPrivateFieldBase(this,_initInjector)[_initInjector]();// 纯文本预处理 if(_classPrivateFieldBase(this,_rule)[_rule].isPlainText){document.querySelectorAll("pre").forEach(pre=>{var _pre$innerHTML;return pre.innerHTML=(_pre$innerHTML=pre.innerHTML)===null||_pre$innerHTML===void 0?void 0:_pre$innerHTML.replace(/(?:\r\n|\r|\n)/g,"
");});}// 查找根节点并扫描 document.querySelectorAll(_classPrivateFieldBase(this,_rule)[_rule].rootsSelector||"body").forEach(root=>{_classPrivateFieldBase(this,_startObserveRoot)[_startObserveRoot](root);});if(_classPrivateFieldBase(this,_rule)[_rule].hasShadowroot==="true"){_classPrivateFieldBase(this,_attachShadowRootListener)[_attachShadowRootListener]();_classPrivateFieldBase(this,_findAndObserveShadowRoot)[_findAndObserveShadowRoot]();}}function _handleWindowMessage2(event){var _event$data;if(((_event$data=event.data)===null||_event$data===void 0?void 0:_event$data.type)==="KISS_SHADOW_ROOT_CREATED"){_classPrivateFieldBase(this,_debouncedFindShadowRoot)[_debouncedFindShadowRoot]();}}function _attachShadowRootListener2(){if(!_classPrivateFieldBase(this,_isShadowRootJsInjected)[_isShadowRootJsInjected]){const id="kiss-translator-inject-shadowroot-js";injectJs(INJECTOR.shadowroot,id);_classPrivateFieldBase(this,_isShadowRootJsInjected)[_isShadowRootJsInjected]=true;}window.addEventListener("message",_classPrivateFieldBase(this,_windowMessageHandler)[_windowMessageHandler]);}function _removeShadowRootListener2(){window.removeEventListener("message",_classPrivateFieldBase(this,_windowMessageHandler)[_windowMessageHandler]);}function _findAndObserveShadowRoot2(){try{_classPrivateFieldBase(this,_findAllShadowRoots)[_findAllShadowRoots]().forEach(shadowRoot=>{_classPrivateFieldBase(this,_startObserveShadowRoot)[_startObserveShadowRoot](shadowRoot);});}catch(err){log_kissLog("findAllShadowRoots",err);}}function _createPlaceholderRegex2(){const escapedStart=_class.escapeRegex(_classPrivateFieldBase(this,_placeholder)[_placeholder].startDelimiter);const escapedEnd=_class.escapeRegex(_classPrivateFieldBase(this,_placeholder)[_placeholder].endDelimiter);const patternString="(".concat(escapedStart,"\\d+").concat(escapedEnd,"|<\\/?\\w+\\d+>)");const flags="g";return new RegExp(patternString,flags);}function _createTextStyles2(){const[textClass,textStyles]=genTextClass(_classPrivateFieldBase(this,translator_setting)[translator_setting].customStyles);const textSheet=new CSSStyleSheet();textSheet.replaceSync(textStyles);_classPrivateFieldBase(this,_textClass)[_textClass]=textClass;_classPrivateFieldBase(this,_textSheet)[_textSheet]=textSheet;}function _injectSheet2(shadowRoot){if(!shadowRoot.adoptedStyleSheets.includes(_classPrivateFieldBase(this,_textSheet)[_textSheet])){shadowRoot.adoptedStyleSheets=[...shadowRoot.adoptedStyleSheets,_classPrivateFieldBase(this,_textSheet)[_textSheet]];}}function _parseTerms2(termsString){_classPrivateFieldBase(this,_termValues)[_termValues]=[];_classPrivateFieldBase(this,_combinedTermsRegex)[_combinedTermsRegex]=null;if(!termsString||typeof termsString!=="string")return;const termPatterns=[];const lines=termsString.split(/\n|;/);// 按换行或分号分割 -for(const line of lines){const trimmedLine=line.trim();if(!trimmedLine)continue;let lastCommaIndex=trimmedLine.lastIndexOf(",");if(lastCommaIndex===-1){lastCommaIndex=trimmedLine.length;}const key=trimmedLine.substring(0,lastCommaIndex).trim();const value=trimmedLine.substring(lastCommaIndex+1).trim();if(key){try{new RegExp(key);termPatterns.push("(".concat(key,")"));_classPrivateFieldBase(this,_termValues)[_termValues].push(value);}catch(err){log_kissLog("Invalid RegExp for term: \"".concat(key,"\""),err);}}}if(termPatterns.length>0){_classPrivateFieldBase(this,_combinedTermsRegex)[_combinedTermsRegex]=new RegExp(termPatterns.join("|"),"g");}}function _parseAITerms2(termsString){if(!termsString||typeof termsString!=="string")return;try{_classPrivateFieldBase(this,_glossary)[_glossary]=Object.fromEntries(termsString.split(/\n|;/).map(line=>{const[k="",v=""]=line.split(",").map(s=>s.trim());return[k,v];}).filter(_ref2=>{let[k]=_ref2;return k;}));}catch(err){log_kissLog("parse aiterms",err);}}function _getDocDescription2(){try{const meta=document.querySelector('meta[name="description"]');const description=(meta===null||meta===void 0?void 0:meta.getAttribute("content"))||"";return truncateWords(description);}catch(err){log_kissLog("get description",err);}return"";}function _createIntersectionObserver2(){const{transInterval,rootMargin=500}=_classPrivateFieldBase(this,translator_setting)[translator_setting];const pending=new Set();const flush=debounce(()=>{pending.forEach(node=>_classPrivateFieldBase(this,_performSyncNode)[_performSyncNode](node));pending.clear();},transInterval);return new IntersectionObserver(entries=>{entries.forEach(entry=>{if(entry.isIntersecting){_classPrivateFieldBase(this,_viewNodes)[_viewNodes].add(entry.target);pending.add(entry.target);flush();}else{_classPrivateFieldBase(this,_viewNodes)[_viewNodes].delete(entry.target);}});},{threshold:0.01,rootMargin:"".concat(rootMargin,"px 0px ").concat(rootMargin,"px 0px")});}function _createMutationObserver2(){return new MutationObserver(mutations=>{for(const mutation of mutations){var _mutation$nextSibling;if(_classPrivateFieldBase(this,_skipMoNodes)[_skipMoNodes].has(mutation.target)||((_mutation$nextSibling=mutation.nextSibling)===null||_mutation$nextSibling===void 0?void 0:_mutation$nextSibling.tagName)===_classPrivateFieldBase(this,_translationTagName)[_translationTagName]){continue;}if(mutation.type==="characterData"){if(mutation.oldValue!==mutation.target.nodeValue&&!_classPrivateFieldBase(this,_combinedSkipsRegex)[_combinedSkipsRegex].test(mutation.target.nodeValue)){_classPrivateFieldBase(this,_queueForRescan)[_queueForRescan](mutation.target.parentElement);}}else if(mutation.type==="childList"){let nodes=new Set();let hasText=false;mutation.addedNodes.forEach(node=>{if(_classPrivateFieldBase(this,_skipMoNodes)[_skipMoNodes].has(node)||node.nodeName===_classPrivateFieldBase(this,_translationTagName)[_translationTagName]){return;}if(node.nodeType===Node.TEXT_NODE){hasText=true;}else if(_class.isElementOrFragment(node)){nodes.add(node);}});if(hasText){_classPrivateFieldBase(this,_queueForRescan)[_queueForRescan](mutation.target);}else{nodes.forEach(node=>_classPrivateFieldBase(this,_queueForRescan)[_queueForRescan](node));}}}});}function _createDebounceMouseMover2(){return debounce(targetNode=>{const startNode=targetNode;let foundNode=null;while(targetNode&&targetNode!==document.body){if(_classPrivateFieldBase(this,_observedNodes)[_observedNodes].has(targetNode)){foundNode=targetNode;break;}targetNode=targetNode.parentElement;}_classPrivateFieldBase(this,_hoveredNode)[_hoveredNode]=foundNode||startNode;const{mouseHoverKey}=_classPrivateFieldBase(this,translator_setting)[translator_setting].mouseHoverSetting;if(mouseHoverKey.length===0&&!_classPrivateFieldBase(this,_isInitialized)[_isInitialized]){_classPrivateFieldBase(this,_init)[_init]();}if(mouseHoverKey.length===0&&foundNode){_classPrivateFieldBase(this,_processNode)[_processNode](foundNode);}},100);}function _handleMouseMove2(event){let targetNode=event.composedPath()[0];_classPrivateFieldBase(this,_dmm)[_dmm](targetNode);}function _handleKeyDown2(){if(!_classPrivateFieldBase(this,_isInitialized)[_isInitialized]){_classPrivateFieldBase(this,_init)[_init]();}let targetNode=_classPrivateFieldBase(this,_hoveredNode)[_hoveredNode];if(!targetNode||!_classPrivateFieldBase(this,_observedNodes)[_observedNodes].has(targetNode))return;_classPrivateFieldBase(this,_toggleTargetNode)[_toggleTargetNode](targetNode);}function _toggleTargetNode2(targetNode){if(_classPrivateFieldBase(this,_processedNodes)[_processedNodes].has(targetNode)){_classPrivateFieldBase(this,_cleanupDirectTranslations)[_cleanupDirectTranslations](targetNode);}else{_classPrivateFieldBase(this,_processNode)[_processNode](targetNode);}}function _findAllShadowRoots2(){let root=arguments.length>0&&arguments[0]!==undefined?arguments[0]:document.body;let results=arguments.length>1&&arguments[1]!==undefined?arguments[1]:new Set();// const start = performance.now(); +for(const line of lines){const trimmedLine=line.trim();if(!trimmedLine)continue;let lastCommaIndex=trimmedLine.lastIndexOf(",");if(lastCommaIndex===-1){lastCommaIndex=trimmedLine.length;}const key=trimmedLine.substring(0,lastCommaIndex).trim();const value=trimmedLine.substring(lastCommaIndex+1).trim();if(key){try{new RegExp(key);termPatterns.push("(".concat(key,")"));_classPrivateFieldBase(this,_termValues)[_termValues].push(value);}catch(err){log_kissLog("Invalid RegExp for term: \"".concat(key,"\""),err);}}}if(termPatterns.length>0){_classPrivateFieldBase(this,_combinedTermsRegex)[_combinedTermsRegex]=new RegExp(termPatterns.join("|"),"g");}}function _parseAITerms2(termsString){if(!termsString||typeof termsString!=="string")return;try{_classPrivateFieldBase(this,_glossary)[_glossary]=Object.fromEntries(termsString.split(/\n|;/).map(line=>{const[k="",v=""]=line.split(",").map(s=>s.trim());return[k,v];}).filter(_ref2=>{let[k]=_ref2;return k;}));}catch(err){log_kissLog("parse aiterms",err);}}function _getDocDescription2(){try{const meta=document.querySelector('meta[name="description"]');const description=(meta===null||meta===void 0?void 0:meta.getAttribute("content"))||"";return truncateWords(description);}catch(err){log_kissLog("get description",err);}return"";}function _createIntersectionObserver2(){const{transInterval,rootMargin=500}=_classPrivateFieldBase(this,translator_setting)[translator_setting];const pending=new Set();const flush=debounce(()=>{pending.forEach(node=>_classPrivateFieldBase(this,_performSyncNode)[_performSyncNode](node));pending.clear();},transInterval);return new IntersectionObserver(entries=>{entries.forEach(entry=>{if(entry.isIntersecting){_classPrivateFieldBase(this,_viewNodes)[_viewNodes].add(entry.target);pending.add(entry.target);flush();}else{_classPrivateFieldBase(this,_viewNodes)[_viewNodes].delete(entry.target);}});},{threshold:0.01,rootMargin:"".concat(rootMargin,"px 0px ").concat(rootMargin,"px 0px")});}function _createMutationObserver2(){return new MutationObserver(mutations=>{for(const mutation of mutations){var _mutation$nextSibling,_mutation$nextSibling2;if(_classPrivateFieldBase(this,_skipMoNodes)[_skipMoNodes].has(mutation.target)||((_mutation$nextSibling=mutation.nextSibling)===null||_mutation$nextSibling===void 0?void 0:(_mutation$nextSibling2=_mutation$nextSibling.tagName)===null||_mutation$nextSibling2===void 0?void 0:_mutation$nextSibling2.toLowerCase())===_classPrivateFieldBase(this,_translationTagName)[_translationTagName]){continue;}if(mutation.type==="characterData"){if(mutation.oldValue!==mutation.target.nodeValue&&!_classPrivateFieldBase(this,_combinedSkipsRegex)[_combinedSkipsRegex].test(mutation.target.nodeValue)){_classPrivateFieldBase(this,_queueForRescan)[_queueForRescan](mutation.target.parentElement);}}else if(mutation.type==="childList"){let nodes=new Set();let hasText=false;mutation.addedNodes.forEach(node=>{var _node$nodeName;if(_classPrivateFieldBase(this,_skipMoNodes)[_skipMoNodes].has(node)||((_node$nodeName=node.nodeName)===null||_node$nodeName===void 0?void 0:_node$nodeName.toLowerCase())===_classPrivateFieldBase(this,_translationTagName)[_translationTagName]){return;}if(node.nodeType===Node.TEXT_NODE){hasText=true;}else if(_class.isElementOrFragment(node)){nodes.add(node);}});if(hasText){_classPrivateFieldBase(this,_queueForRescan)[_queueForRescan](mutation.target);}else{nodes.forEach(node=>_classPrivateFieldBase(this,_queueForRescan)[_queueForRescan](node));}}}});}function _createDebounceMouseMover2(){return debounce(targetNode=>{const startNode=targetNode;let foundNode=null;while(targetNode&&targetNode!==document.body){if(_classPrivateFieldBase(this,_observedNodes)[_observedNodes].has(targetNode)){foundNode=targetNode;break;}targetNode=targetNode.parentElement;}_classPrivateFieldBase(this,_hoveredNode)[_hoveredNode]=foundNode||startNode;const{mouseHoverKey}=_classPrivateFieldBase(this,translator_setting)[translator_setting].mouseHoverSetting;if(mouseHoverKey.length===0&&!_classPrivateFieldBase(this,_isInitialized)[_isInitialized]){_classPrivateFieldBase(this,_init)[_init]();}if(mouseHoverKey.length===0&&foundNode){_classPrivateFieldBase(this,_processNode)[_processNode](foundNode);}},100);}function _handleMouseMove2(event){let targetNode=event.composedPath()[0];_classPrivateFieldBase(this,_dmm)[_dmm](targetNode);}function _handleKeyDown2(){if(!_classPrivateFieldBase(this,_isInitialized)[_isInitialized]){_classPrivateFieldBase(this,_init)[_init]();}let targetNode=_classPrivateFieldBase(this,_hoveredNode)[_hoveredNode];if(!targetNode||!_classPrivateFieldBase(this,_observedNodes)[_observedNodes].has(targetNode))return;_classPrivateFieldBase(this,_toggleTargetNode)[_toggleTargetNode](targetNode);}function _toggleTargetNode2(targetNode){if(_classPrivateFieldBase(this,_processedNodes)[_processedNodes].has(targetNode)){_classPrivateFieldBase(this,_cleanupDirectTranslations)[_cleanupDirectTranslations](targetNode);}else{_classPrivateFieldBase(this,_processNode)[_processNode](targetNode);}}function _findAllShadowRoots2(){let root=arguments.length>0&&arguments[0]!==undefined?arguments[0]:document.body;let results=arguments.length>1&&arguments[1]!==undefined?arguments[1]:new Set();// const start = performance.now(); try{const walker=document.createTreeWalker(root,NodeFilter.SHOW_ELEMENT);while(walker.nextNode()){const node=walker.currentNode;if(node.shadowRoot){results.add(node.shadowRoot);_classPrivateFieldBase(this,_findAllShadowRoots)[_findAllShadowRoots](node.shadowRoot,results);}}}catch(err){log_kissLog("无法访问某个 shadowRoot",err);}// const end = performance.now(); // const duration = end - start; // console.log(`findAllShadowRoots 耗时:${duration} 毫秒`); @@ -36822,7 +36822,7 @@ let deLang="";const{fromLang="auto",toLang,splitParagraph=OPT_SPLIT_PARAGRAPH_DI return;}}// 切分长段落 if(splitParagraph!==OPT_SPLIT_PARAGRAPH_DISABLE){_classPrivateFieldBase(this,_splitTextNodesBySentence)[_splitTextNodesBySentence](node,splitParagraph,splitLength);}let nodeGroup=[];[...node.childNodes].forEach(child=>{const shouldBreak=_classPrivateFieldBase(this,_shouldBreak)[_shouldBreak](child);const shouldGroup=child.nodeType===Node.ELEMENT_NODE||child.nodeType===Node.TEXT_NODE;if(!shouldBreak&&shouldGroup){nodeGroup.push(child);}else if(shouldBreak&&nodeGroup.length){_classPrivateFieldBase(this,_translateNodeGroup)[_translateNodeGroup](nodeGroup,node,deLang);nodeGroup=[];}});if(nodeGroup.length){_classPrivateFieldBase(this,_translateNodeGroup)[_translateNodeGroup](nodeGroup,node,deLang);}}function _highlightTextNode2(textNode,wordRegex){var _textNode$parentNode;if(((_textNode$parentNode=textNode.parentNode)===null||_textNode$parentNode===void 0?void 0:_textNode$parentNode.nodeName.toLowerCase())==="b"){return;}if(!wordRegex.test(textNode.textContent)){return;}wordRegex.lastIndex=0;const fragments=textNode.textContent.split(wordRegex);const newNodes=[];fragments.forEach((fragment,i)=>{if(!fragment)return;if(i%2===1){// 奇数索引是匹配到的关键词 const bTag=document.createElement("b");bTag.className=_class.KISS_CLASS.highlight;bTag.style.cssText=_classPrivateFieldBase(this,_rule)[_rule].highlightStyle||"";bTag.textContent=fragment;_classPrivateFieldBase(this,_skipMoNodes)[_skipMoNodes].add(bTag);newNodes.push(bTag);}else{// 偶数索引是普通文本 -const newTextNode=document.createTextNode(fragment);_classPrivateFieldBase(this,_skipMoNodes)[_skipMoNodes].add(newTextNode);newNodes.push(newTextNode);}});if(newNodes.length>0){textNode.replaceWith(...newNodes);}}function _highlightWordsDeeply2(parentNode){if(!parentNode||_classPrivateFieldBase(this,_favWords)[_favWords].length===0){return;}const escapeRegex=str=>str.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");const escapedWords=_classPrivateFieldBase(this,_favWords)[_favWords].map(escapeRegex);const wordRegex=new RegExp("\\b(".concat(escapedWords.join("|"),")\\b"),"gi");if(parentNode.nodeType===Node.ELEMENT_NODE){const walker=document.createTreeWalker(parentNode,NodeFilter.SHOW_TEXT,null,false);const nodesToProcess=[];let node;while(node=walker.nextNode()){nodesToProcess.push(node);}nodesToProcess.forEach(textNode=>{_classPrivateFieldBase(this,_highlightTextNode)[_highlightTextNode](textNode,wordRegex);});}else if(parentNode.nodeType===Node.TEXT_NODE){_classPrivateFieldBase(this,_highlightTextNode)[_highlightTextNode](parentNode,wordRegex);}}function _splitTextNodesBySentence2(parentNode,splitParagraph,splitLength){const sentenceEndRegexForSplit=/[。!?]+|[.?!]+(?=\s+|$)/g;[...parentNode.childNodes].forEach(node=>{if(node.nodeType!==Node.TEXT_NODE||node.textContent.trim()===""){return;}const text=node.textContent;const parts=[];let lastIndex=0;let match;while((match=sentenceEndRegexForSplit.exec(text))!==null){let realEndIndex=match.index+match[0].length;while(realEndIndexpart.trim().length>0);if(validParts.length<=1){return;}const newNodes=validParts.map(part=>{const newNode=document.createTextNode(part);_classPrivateFieldBase(this,_skipMoNodes)[_skipMoNodes].add(newNode);return newNode;});node.replaceWith(...newNodes);});const sentenceEndRegexForTest=/(?:[。!??!]+|(?{var _node$nextSibling;textLength+=node.textContent.length;const isSentenceEnd=sentenceEndRegexForTest.test(node.textContent);if(!isSentenceEnd||((_node$nextSibling=node.nextSibling)===null||_node$nextSibling===void 0?void 0:_node$nextSibling.nodeName)==="BR"){return;}if(splitParagraph===OPT_SPLIT_PARAGRAPH_PUNCTUATION||splitParagraph===OPT_SPLIT_PARAGRAPH_TEXTLENGTH&&textLength>=splitLength){textLength=0;const br=document.createElement("br");br.className=_class.KISS_CLASS.br;_classPrivateFieldBase(this,_skipMoNodes)[_skipMoNodes].add(br);node.after(br);}});}function _removeHighlights2(parentNode){if(!parentNode)return;const highlightedElements=parentNode.querySelectorAll(".".concat(_class.KISS_CLASS.highlight));highlightedElements.forEach(element=>{const textNode=document.createTextNode(element.textContent);element.replaceWith(textNode);});parentNode.normalize();}function _removeBrTags2(parentNode){if(!parentNode)return;parentNode.querySelectorAll(".".concat(_class.KISS_CLASS.br)).forEach(br=>br.remove());parentNode.normalize();}function _shouldBreak2(node){var _node$matches;if(!_class.isElementOrFragment(node))return false;if(node.matches(_classPrivateFieldBase(this,_rule)[_rule].keepSelector))return false;if(_class.TAGS.BREAK_LINE.has(node.nodeName)||(_node$matches=node.matches)!==null&&_node$matches!==void 0&&_node$matches.call(node,_classPrivateFieldBase(this,_ignoreSelector)[_ignoreSelector])||node.nodeName===_classPrivateFieldBase(this,_translationTagName)[_translationTagName]){return true;}if(_classPrivateFieldBase(this,_rule)[_rule].autoScan&&_class.isBlockNode(node)){return true;}if(!_classPrivateFieldBase(this,_rule)[_rule].autoScan&&(node.matches(_classPrivateFieldBase(this,_rule)[_rule].selector)||node.querySelector(_classPrivateFieldBase(this,_rule)[_rule].selector))){return true;}return false;}function _isInvalidText2(text){if(typeof text!=="string"){return true;}const trimmedText=text.trim();// 文本长度 +const newTextNode=document.createTextNode(fragment);_classPrivateFieldBase(this,_skipMoNodes)[_skipMoNodes].add(newTextNode);newNodes.push(newTextNode);}});if(newNodes.length>0){textNode.replaceWith(...newNodes);}}function _highlightWordsDeeply2(parentNode){if(!parentNode||_classPrivateFieldBase(this,_favWords)[_favWords].length===0){return;}const escapeRegex=str=>str.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");const escapedWords=_classPrivateFieldBase(this,_favWords)[_favWords].map(escapeRegex);const wordRegex=new RegExp("\\b(".concat(escapedWords.join("|"),")\\b"),"gi");if(parentNode.nodeType===Node.ELEMENT_NODE){const walker=document.createTreeWalker(parentNode,NodeFilter.SHOW_TEXT,null,false);const nodesToProcess=[];let node;while(node=walker.nextNode()){nodesToProcess.push(node);}nodesToProcess.forEach(textNode=>{_classPrivateFieldBase(this,_highlightTextNode)[_highlightTextNode](textNode,wordRegex);});}else if(parentNode.nodeType===Node.TEXT_NODE){_classPrivateFieldBase(this,_highlightTextNode)[_highlightTextNode](parentNode,wordRegex);}}function _splitTextNodesBySentence2(parentNode,splitParagraph,splitLength){const sentenceEndRegexForSplit=/[。!?]+|[.?!]+(?=\s+|$)/g;[...parentNode.childNodes].forEach(node=>{if(node.nodeType!==Node.TEXT_NODE||node.textContent.trim()===""){return;}const text=node.textContent;const parts=[];let lastIndex=0;let match;while((match=sentenceEndRegexForSplit.exec(text))!==null){let realEndIndex=match.index+match[0].length;while(realEndIndexpart.trim().length>0);if(validParts.length<=1){return;}const newNodes=validParts.map(part=>{const newNode=document.createTextNode(part);_classPrivateFieldBase(this,_skipMoNodes)[_skipMoNodes].add(newNode);return newNode;});node.replaceWith(...newNodes);});const sentenceEndRegexForTest=/(?:[。!??!]+|(?{var _node$nextSibling,_node$nextSibling$nod;textLength+=node.textContent.length;const isSentenceEnd=sentenceEndRegexForTest.test(node.textContent);if(!isSentenceEnd||((_node$nextSibling=node.nextSibling)===null||_node$nextSibling===void 0?void 0:(_node$nextSibling$nod=_node$nextSibling.nodeName)===null||_node$nextSibling$nod===void 0?void 0:_node$nextSibling$nod.toUpperCase())==="BR"){return;}if(splitParagraph===OPT_SPLIT_PARAGRAPH_PUNCTUATION||splitParagraph===OPT_SPLIT_PARAGRAPH_TEXTLENGTH&&textLength>=splitLength){textLength=0;const br=document.createElement("br");br.className=_class.KISS_CLASS.br;_classPrivateFieldBase(this,_skipMoNodes)[_skipMoNodes].add(br);node.after(br);}});}function _removeHighlights2(parentNode){if(!parentNode)return;const highlightedElements=parentNode.querySelectorAll(".".concat(_class.KISS_CLASS.highlight));highlightedElements.forEach(element=>{const textNode=document.createTextNode(element.textContent);element.replaceWith(textNode);});parentNode.normalize();}function _removeBrTags2(parentNode){if(!parentNode)return;parentNode.querySelectorAll(".".concat(_class.KISS_CLASS.br)).forEach(br=>br.remove());parentNode.normalize();}function _shouldBreak2(node){var _node$nodeName2,_node$matches,_node$nodeName3;if(!_class.isElementOrFragment(node))return false;if(node.matches(_classPrivateFieldBase(this,_rule)[_rule].keepSelector))return false;if(_class.TAGS.BREAK_LINE.has((_node$nodeName2=node.nodeName)===null||_node$nodeName2===void 0?void 0:_node$nodeName2.toUpperCase())||(_node$matches=node.matches)!==null&&_node$matches!==void 0&&_node$matches.call(node,_classPrivateFieldBase(this,_ignoreSelector)[_ignoreSelector])||((_node$nodeName3=node.nodeName)===null||_node$nodeName3===void 0?void 0:_node$nodeName3.toLowerCase())===_classPrivateFieldBase(this,_translationTagName)[_translationTagName]){return true;}if(_classPrivateFieldBase(this,_rule)[_rule].autoScan&&_class.isBlockNode(node)){return true;}if(!_classPrivateFieldBase(this,_rule)[_rule].autoScan&&(node.matches(_classPrivateFieldBase(this,_rule)[_rule].selector)||node.querySelector(_classPrivateFieldBase(this,_rule)[_rule].selector))){return true;}return false;}function _isInvalidText2(text){if(typeof text!=="string"){return true;}const trimmedText=text.trim();// 文本长度 if(trimmedText.length<_classPrivateFieldBase(this,translator_setting)[translator_setting].minLength||trimmedText.length>_classPrivateFieldBase(this,translator_setting)[translator_setting].maxLength){return true;}// 单个非字母数字字符。 if(trimmedText.length===1&&!trimmedText.match(/[a-zA-Z]/)){return true;}// 只是一个数字 if(!isNaN(parseFloat(trimmedText))&&isFinite(trimmedText)){return true;}// 正则匹配 @@ -36830,8 +36830,7 @@ if(_classPrivateFieldBase(this,_combinedSkipsRegex)[_combinedSkipsRegex].test(tr // toLang, // skipLangs = [], highlightWords}=_classPrivateFieldBase(this,_rule)[_rule];const{newlineLength// langDetector, -}=_classPrivateFieldBase(this,translator_setting)[translator_setting];const parentNode=hostNode.parentElement;const hideOrigin=transOnly==="true";try{const[processedString,placeholderMap]=_classPrivateFieldBase(this,_serializeForTranslation)[_serializeForTranslation](nodes,termsStyle);// console.log("processedString", processedString); -if(_classPrivateFieldBase(this,_isInvalidText)[_isInvalidText](processedString))return;const wrapper=document.createElement(_classPrivateFieldBase(this,_translationTagName)[_translationTagName]);wrapper.className=_class.KISS_CLASS.warpper;if(processedString.length>newlineLength){const br=document.createElement("br");br.hidden=hideOrigin;wrapper.appendChild(br);}const inner=document.createElement(transTag);inner.className="".concat(_class.KISS_CLASS.inner," ").concat(_classPrivateFieldBase(this,_textClass)[_textClass][textStyle]||"");if(textExtStyle!==null&&textExtStyle!==void 0&&textExtStyle.trim()){inner.style.cssText=textExtStyle;// 附加内联样式 +}=_classPrivateFieldBase(this,translator_setting)[translator_setting];const parentNode=hostNode.parentElement;const hideOrigin=transOnly==="true";try{const[processedString,placeholderMap]=_classPrivateFieldBase(this,_serializeForTranslation)[_serializeForTranslation](nodes,termsStyle);if(_classPrivateFieldBase(this,_isInvalidText)[_isInvalidText](processedString))return;const wrapper=document.createElement(_classPrivateFieldBase(this,_translationTagName)[_translationTagName]);wrapper.className="".concat(_class.KISS_CLASS.warpper," notranslate");if(processedString.length>newlineLength){const br=document.createElement("br");br.hidden=hideOrigin;wrapper.appendChild(br);}const inner=document.createElement(transTag);inner.className="".concat(_class.KISS_CLASS.inner," ").concat(_classPrivateFieldBase(this,_textClass)[_textClass][textStyle]||"");if(textExtStyle!==null&&textExtStyle!==void 0&&textExtStyle.trim()){inner.style.cssText=textExtStyle;// 附加内联样式 }inner.appendChild(createLoadingSVG());wrapper.appendChild(inner);nodes[nodes.length-1].after(wrapper);const currentRunId=_classPrivateFieldBase(this,_runId)[_runId];const{trText:translatedText,isSame:isSameLang}=await _classPrivateFieldBase(this,_translateFetch)[_translateFetch](processedString,deLang);if(_classPrivateFieldBase(this,_runId)[_runId]!==currentRunId){throw new Error("Request terminated");}if(!translatedText||isSameLang){wrapper.remove();return;}const htmlString=_classPrivateFieldBase(this,_restoreFromTranslation)[_restoreFromTranslation](translatedText,placeholderMap);const trustedHTML=trustedTypesHelper.createHTML(htmlString);// const parser = new DOMParser(); // const doc = parser.parseFromString(trustedHTML, "text/html"); // const innerElement = doc.body.firstChild; @@ -36848,7 +36847,7 @@ if(node.nodeType===Node.TEXT_NODE){let text=node.textContent;// 专业术语替 if(_classPrivateFieldBase(this,_combinedTermsRegex)[_combinedTermsRegex]){_classPrivateFieldBase(this,_combinedTermsRegex)[_combinedTermsRegex].lastIndex=0;text=text.replace(_classPrivateFieldBase(this,_combinedTermsRegex)[_combinedTermsRegex],function(){for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}const groups=args.slice(1,-2);const matchedIndex=groups.findIndex(group=>group!==undefined);const fullMatch=args[0];const termValue=_classPrivateFieldBase(_this,_termValues)[_termValues][matchedIndex];return pushReplace("").concat(termValue||fullMatch,""));});}return text;}// 元素节点 if(node.nodeType===Node.ELEMENT_NODE){var _node$tagName3;if(_classPrivateFieldBase(this,_rule)[_rule].hasRichText==="true"&&_class.TAGS.REPLACE.has(node.tagName)||node.matches(_classPrivateFieldBase(this,_rule)[_rule].keepSelector)||// node.matches(this.#ignoreSelector) || !node.textContent.trim()){var _node$tagName,_node$tagName2;if(((_node$tagName=node.tagName)===null||_node$tagName===void 0?void 0:_node$tagName.toUpperCase())==="IMG"||((_node$tagName2=node.tagName)===null||_node$tagName2===void 0?void 0:_node$tagName2.toUpperCase())==="SVG"){node.style.width="".concat(node.offsetWidth,"px");node.style.height="".concat(node.offsetHeight,"px");}return pushReplace(node.outerHTML);}let innerContent="";node.childNodes.forEach(child=>{innerContent+=traverse(child);});if(_classPrivateFieldBase(this,_rule)[_rule].hasRichText==="true"&&_class.TAGS.WARP.has((_node$tagName3=node.tagName)===null||_node$tagName3===void 0?void 0:_node$tagName3.toUpperCase())){wrapCounter++;const startPlaceholder="<".concat(_classPrivateFieldBase(this,_placeholder)[_placeholder].tagName).concat(wrapCounter,">");const endPlaceholder="");placeholderMap.set(startPlaceholder,buildOpeningTag(node));placeholderMap.set(endPlaceholder,""));return"".concat(startPlaceholder).concat(innerContent).concat(endPlaceholder);}return innerContent;}return"";};function buildOpeningTag(node){const escapeAttr=str=>str.replace(/"/g,""");let tag="<".concat(node.tagName.toLowerCase());for(const attr of node.attributes){tag+=" ".concat(attr.name,"=\"").concat(escapeAttr(attr.value),"\"");}tag+=">";return tag;}const processedString=nodes.map(traverse).join("").trim();return[processedString,placeholderMap];}function _restoreFromTranslation2(translatedText,placeholderMap){if(!placeholderMap.size){return translatedText;}if(!translatedText)return"";return translatedText.replace(_classPrivateFieldBase(this,_placeholderRegex)[_placeholderRegex],match=>placeholderMap.get(match)||match);}function _translateFetch2(text){let deLang=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"";const{toLang,transStartHook}=_classPrivateFieldBase(this,_rule)[_rule];const fromLang=deLang||_classPrivateFieldBase(this,_rule)[_rule].fromLang;const apiSetting=_objectSpread2({},_classPrivateFieldBase(this,_apiSetting)[_apiSetting]);const docInfo=_objectSpread2({},_classPrivateFieldBase(this,_docInfo)[_docInfo]);const glossary=_objectSpread2({},_classPrivateFieldBase(this,_glossary)[_glossary]);const apisMap=_classPrivateFieldBase(this,_apisMap)[_apisMap];const args={text,fromLang,toLang,apiSetting,docInfo,glossary};// 翻译开始钩子函数 -if(transStartHook!==null&&transStartHook!==void 0&&transStartHook.trim()){try{interpreter.run("exports.transStartHook = ".concat(transStartHook));const hookResult=interpreter.exports.transStartHook(_objectSpread2(_objectSpread2({},args),{},{apisMap}));if(hookResult){Object.assign(args,hookResult);}}catch(err){log_kissLog("transStartHook",err);}}return apiTranslate(args);}function _findTranslationWrappers2(parentNode){return parentNode.querySelectorAll(":scope > ".concat(APP_LCNAME));}function _cleanupAllNodes2(){_classPrivateFieldBase(this,_rootNodes)[_rootNodes].forEach(root=>_classPrivateFieldBase(this,_cleanupAllTranslations)[_cleanupAllTranslations](root));}function _cleanupAllTranslations2(root){root.querySelectorAll(APP_LCNAME).forEach(el=>_classPrivateFieldBase(this,_removeTranslationElement)[_removeTranslationElement](el));}function _cleanupDirectTranslations2(node){_classPrivateFieldBase(this,_findTranslationWrappers)[_findTranslationWrappers](node).forEach(el=>{_classPrivateFieldBase(this,_removeTranslationElement)[_removeTranslationElement](el);});}function _removeTranslationElement2(el){const parentElement=el.parentElement;_classPrivateFieldBase(this,_processedNodes)[_processedNodes].delete(parentElement);// 如果是仅显示译文模式,先恢复原文 +if(transStartHook!==null&&transStartHook!==void 0&&transStartHook.trim()){try{interpreter.run("exports.transStartHook = ".concat(transStartHook));const hookResult=interpreter.exports.transStartHook(_objectSpread2(_objectSpread2({},args),{},{apisMap}));if(hookResult){Object.assign(args,hookResult);}}catch(err){log_kissLog("transStartHook",err);}}return apiTranslate(args);}function _findTranslationWrappers2(parentNode){return parentNode.querySelectorAll(":scope > .".concat(_class.KISS_CLASS.warpper));}function _cleanupAllNodes2(){_classPrivateFieldBase(this,_rootNodes)[_rootNodes].forEach(root=>_classPrivateFieldBase(this,_cleanupAllTranslations)[_cleanupAllTranslations](root));}function _cleanupAllTranslations2(root){root.querySelectorAll(".".concat(_class.KISS_CLASS.warpper)).forEach(el=>_classPrivateFieldBase(this,_removeTranslationElement)[_removeTranslationElement](el));}function _cleanupDirectTranslations2(node){_classPrivateFieldBase(this,_findTranslationWrappers)[_findTranslationWrappers](node).forEach(el=>{_classPrivateFieldBase(this,_removeTranslationElement)[_removeTranslationElement](el);});}function _removeTranslationElement2(el){const parentElement=el.parentElement;_classPrivateFieldBase(this,_processedNodes)[_processedNodes].delete(parentElement);// 如果是仅显示译文模式,先恢复原文 const{nodes,isHide}=_classPrivateFieldBase(this,_translationNodes)[_translationNodes].get(el)||{};if(isHide){_classPrivateFieldBase(this,_restoreOriginal)[_restoreOriginal](el,nodes);}_classPrivateFieldBase(this,_translationNodes)[_translationNodes].delete(el);el.remove();// todo: 可能不应深度清除 if(_classPrivateFieldBase(this,_rule)[_rule].highlightWords===OPT_HIGHLIGHT_WORDS_AFTERTRANS){_classPrivateFieldBase(this,_removeHighlights)[_removeHighlights](parentElement);}_classPrivateFieldBase(this,_removeBrTags)[_removeBrTags](parentElement);}function _restoreOriginal2(el,nodes){if(nodes){const frag=document.createDocumentFragment();nodes.forEach(n=>frag.appendChild(n));const parent=el.parentElement;parent===null||parent===void 0?void 0:parent.insertBefore(frag,el);}}function _removeNodes2(nodes){if(nodes){const frag=document.createDocumentFragment();nodes.forEach(n=>frag.appendChild(n));}}function _toggleTranslationOnly2(node,transOnly){_classPrivateFieldBase(this,_findTranslationWrappers)[_findTranslationWrappers](node).forEach(el=>{const br=el.querySelector(":scope > br");const{nodes}=_classPrivateFieldBase(this,_translationNodes)[_translationNodes].get(el)||{};if(transOnly==="true"){// 双语变为仅译文 if(br)br.hidden=true;_classPrivateFieldBase(this,_removeNodes)[_removeNodes](nodes);_classPrivateFieldBase(this,_translationNodes)[_translationNodes].set(el,{nodes,isHide:true});}else{// 仅译文变为双语 @@ -36869,7 +36868,7 @@ return;}_classPrivateFieldBase(this,_removeKeydownHandler)[_removeKeydownHandler const{injectJs,injectCss,toLang}=_classPrivateFieldBase(this,_rule)[_rule];if(isExt){injectCss&&sendBgMsg(MSG_INJECT_CSS,injectCss);}else{injectCss&&injectInternalCss(injectCss);}if(injectJs!==null&&injectJs!==void 0&&injectJs.trim()){const apiSetting=_objectSpread2({},_classPrivateFieldBase(this,_apiSetting)[_apiSetting]);const docInfo=_objectSpread2({},_classPrivateFieldBase(this,_docInfo)[_docInfo]);const glossary=_objectSpread2({},_classPrivateFieldBase(this,_glossary)[_glossary]);const apisMap=_classPrivateFieldBase(this,_apisMap)[_apisMap];const apiDectect=tryDetectLang;interpreter.import({KT:{apiTranslate: apiTranslate,apiDectect,apiSetting,apisMap,toLang,docInfo,glossary}});interpreter.run(injectJs);}}catch(err){log_kissLog("inject js",err);}}function _removeInjector2(){var _document$querySelect;(_document$querySelect=document.querySelectorAll("[data-source^=\"kiss-inject\"]"))===null||_document$querySelect===void 0?void 0:_document$querySelect.forEach(el=>el.remove());}async function _translateTitle2(){const title=document.title;_classPrivateFieldBase(this,_docInfo)[_docInfo].title=truncateWords(title);if(!title)return;try{const deLang=await tryDetectLang(title);const{trText}=await _classPrivateFieldBase(this,_translateFetch)[_translateFetch](title,deLang);document.title=trText||title;}catch(err){log_kissLog("tanslate title",err);}}translator_Translator.displayCache=new WeakMap();translator_Translator.TAGS={BREAK_LINE:new Set(["BR","WBR"]),BLOCK:new Set(["ADDRESS","ARTICLE","ASIDE","BLOCKQUOTE","CANVAS","DD","DIV","DL","DT","FIELDSET","FIGCAPTION","FIGURE","FOOTER","FORM","H1","H2","H3","H4","H5","H6","HEADER","HR","LI","MAIN","NAV","NOSCRIPT","OL","P","PRE","SECTION","TABLE","TFOOT","UL","VIDEO"]),INLINE:new Set([// "A", "ABBR","ACRONYM","B","BDO","BIG","BR","BUTTON","CITE","CODE","DFN","DEL","FONT","EM","I","IMG","INPUT","INS","KBD","LABEL","MAP","MARK","OBJECT","OUTPUT","Q","SAMP","SCRIPT","SELECT","SMALL",// "SPAN", "STRONG","SUB","SUP","TEXTAREA","TIME","TT","U","VAR"]),REPLACE:new Set(["ABBR","CODE","DFN","IMG","KBD","OUTPUT","SAMP","SUB","SUP","SVG","TIME","VAR"]),WARP:new Set(["A","B","BDO","BDI","BIG","CITE","DEL","EM","FONT","I","INS","MARK","Q","S","SMALL","SPAN","STRONG","U"])};// 译文相关class -translator_Translator.KISS_CLASS={warpper:"".concat(APP_LCNAME,"-wrapper notranslate"),inner:"".concat(APP_LCNAME,"-inner"),term:"".concat(APP_LCNAME,"-term"),br:"".concat(APP_LCNAME,"-br"),highlight:"".concat(APP_LCNAME,"-highlight")};// 内置跳过翻译文本 +translator_Translator.KISS_CLASS={warpper:"".concat(APP_LCNAME,"-wrapper"),inner:"".concat(APP_LCNAME,"-inner"),term:"".concat(APP_LCNAME,"-term"),br:"".concat(APP_LCNAME,"-br"),highlight:"".concat(APP_LCNAME,"-highlight")};// 内置跳过翻译文本 // todo: 验证有效性 translator_Translator.BUILTIN_SKIP_PATTERNS=[// 1. URL (覆盖 http, https, ftp, file 协议) /^(?:(?:https?|ftp|file):\/\/|www\.)[^\s/$.?#].[^\s]*$/i,// 2. 邮箱地址 @@ -36888,9 +36887,9 @@ translator_Translator.BUILTIN_SKIP_PATTERNS=[// 1. URL (覆盖 http, https, ftp, /^\d{1,2}:\d{2}(:\d{2})?$/,// 14. 包含常见扩展名的文件名 (例如: document.pdf, image.jpeg) /^[^\s\\/:]+?\.[a-zA-Z0-9]{2,5}$/ // todo: 数字和特殊字符组成的字符串 ];translator_Translator.DEFAULT_OPTIONS=setting_DEFAULT_SETTING;// 默认配置 -translator_Translator.DEFAULT_RULE=GLOBLA_RULE;translator_Translator.KISS_IGNORE_SELECTOR="".concat(APP_LCNAME,", .kiss-caption-container, .kiss-subtitle-controls\n #").concat(APP_CONSTS.fabID,", .").concat(APP_CONSTS.fabID,"_warpper,\n #").concat(APP_CONSTS.boxID,", .").concat(APP_CONSTS.boxID,"_warpper,\n #").concat(APP_CONSTS.popupID,", .").concat(APP_CONSTS.popupID,"_warpper");translator_Translator.BUILTIN_IGNORE_SELECTOR="address, area, audio, br, canvas, \n data, datalist, embed, head, iframe, input, noscript, map, \n object, option, param, picture, progress, \n select, script, style, track, textarea, template, \n video, wbr, .notranslate, [contenteditable='true'], [translate='no']"; +translator_Translator.DEFAULT_RULE=GLOBLA_RULE;translator_Translator.KISS_IGNORE_SELECTOR=".".concat(_class.KISS_CLASS.warpper,", .kiss-caption-container, .kiss-subtitle-controls\n #").concat(APP_CONSTS.fabID,", .").concat(APP_CONSTS.fabID,"_warpper,\n #").concat(APP_CONSTS.boxID,", .").concat(APP_CONSTS.boxID,"_warpper,\n #").concat(APP_CONSTS.popupID,", .").concat(APP_CONSTS.popupID,"_warpper");translator_Translator.BUILTIN_IGNORE_SELECTOR="address, area, audio, br, canvas, \n data, datalist, embed, head, iframe, input, noscript, map, \n object, option, param, picture, progress, \n select, script, style, track, textarea, template, \n video, wbr, .notranslate, [contenteditable='true'], [translate='no']"; ;// CONCATENATED MODULE: ./src/libs/inputTranslate.js -function isInputNode(node){return node.nodeName==="INPUT"||node.nodeName==="TEXTAREA";}function isEditAbleNode(node){return node.hasAttribute("contenteditable");}async function replaceContentEditableText(node,newText){try{logger.debug("try replace editable 1: pasteEvent");node.focus();const selection=window.getSelection();if(!selection)throw new Error("window.getSelection() is not available.");const targetNode=node.querySelector("p")||node;const range=document.createRange();range.selectNodeContents(targetNode);selection.removeAllRanges();selection.addRange(range);const dataTransfer=new DataTransfer();dataTransfer.setData("text/plain",newText);const pasteEvent=new ClipboardEvent("paste",{clipboardData:dataTransfer,bubbles:true,cancelable:true});node.dispatchEvent(pasteEvent);await sleep(50);if(node.innerText.trim()===newText){return true;}throw new Error("Strategy 1 failed to replace text correctly.");}catch(error){logger.debug("Strategy 1 Failed:",error.message);}try{logger.debug("try replace editable 2: execCommand");node.focus();const selection=window.getSelection();if(!selection)throw new Error("window.getSelection() is not available.");const targetNode=node.querySelector("p")||node;const range=document.createRange();range.selectNodeContents(targetNode);selection.removeAllRanges();selection.addRange(range);document.execCommand("insertText",false,newText);await sleep(50);if(node.innerText.trim()===newText){return true;}throw new Error("Strategy 2 failed to replace text correctly.");}catch(error){logger.debug("Strategy 2 Failed:",error.message);}try{logger.debug("try replace editable 3: textContent");node.focus();const targetNode=node.querySelector("p")||node;const textSpan=targetNode.querySelector('span[data-lexical-text="true"]');if(textSpan){textSpan.textContent=newText;}else{targetNode.textContent=newText;}node.dispatchEvent(new Event("input",{bubbles:true,cancelable:true}));await sleep(50);if(node.innerText.trim()===newText){return true;}throw new Error("Strategy 3 failed to replace text correctly.");}catch(error){logger.debug("Strategy 3 Failed:",error.message);}return false;}function getNodeText(node){if(isInputNode(node)){return node.value;}return node.innerText||node.textContent||"";}function addLoading(node,loadingId){const rect=node.getBoundingClientRect();const div=document.createElement("div");div.id=loadingId;div.appendChild(createLoadingSVG());div.style.cssText="\n position: fixed;\n left: ".concat(rect.left,"px;\n top: ").concat(rect.top,"px;\n width: ").concat(rect.width,"px;\n height: ").concat(rect.height,"px;\n line-height: ").concat(rect.height,"px;\n text-align: center;\n z-index: 2147483647;\n pointer-events: none; /* \u5141\u8BB8\u70B9\u51FB\u7A7F\u900F */\n ");document.body.appendChild(div);}function removeLoading(loadingId){const div=document.getElementById(loadingId);if(div)div.remove();}/** +function isInputNode(node){var _node$nodeName,_node$nodeName2;return((_node$nodeName=node.nodeName)===null||_node$nodeName===void 0?void 0:_node$nodeName.toUpperCase())==="INPUT"||((_node$nodeName2=node.nodeName)===null||_node$nodeName2===void 0?void 0:_node$nodeName2.toUpperCase())==="TEXTAREA";}function isEditAbleNode(node){return node.hasAttribute("contenteditable");}async function replaceContentEditableText(node,newText){try{logger.debug("try replace editable 1: pasteEvent");node.focus();const selection=window.getSelection();if(!selection)throw new Error("window.getSelection() is not available.");const targetNode=node.querySelector("p")||node;const range=document.createRange();range.selectNodeContents(targetNode);selection.removeAllRanges();selection.addRange(range);const dataTransfer=new DataTransfer();dataTransfer.setData("text/plain",newText);const pasteEvent=new ClipboardEvent("paste",{clipboardData:dataTransfer,bubbles:true,cancelable:true});node.dispatchEvent(pasteEvent);await sleep(50);if(node.innerText.trim()===newText){return true;}throw new Error("Strategy 1 failed to replace text correctly.");}catch(error){logger.debug("Strategy 1 Failed:",error.message);}try{logger.debug("try replace editable 2: execCommand");node.focus();const selection=window.getSelection();if(!selection)throw new Error("window.getSelection() is not available.");const targetNode=node.querySelector("p")||node;const range=document.createRange();range.selectNodeContents(targetNode);selection.removeAllRanges();selection.addRange(range);document.execCommand("insertText",false,newText);await sleep(50);if(node.innerText.trim()===newText){return true;}throw new Error("Strategy 2 failed to replace text correctly.");}catch(error){logger.debug("Strategy 2 Failed:",error.message);}try{logger.debug("try replace editable 3: textContent");node.focus();const targetNode=node.querySelector("p")||node;const textSpan=targetNode.querySelector('span[data-lexical-text="true"]');if(textSpan){textSpan.textContent=newText;}else{targetNode.textContent=newText;}node.dispatchEvent(new Event("input",{bubbles:true,cancelable:true}));await sleep(50);if(node.innerText.trim()===newText){return true;}throw new Error("Strategy 3 failed to replace text correctly.");}catch(error){logger.debug("Strategy 3 Failed:",error.message);}return false;}function getNodeText(node){if(isInputNode(node)){return node.value;}return node.innerText||node.textContent||"";}function addLoading(node,loadingId){const rect=node.getBoundingClientRect();const div=document.createElement("div");div.id=loadingId;div.appendChild(createLoadingSVG());div.style.cssText="\n position: fixed;\n left: ".concat(rect.left,"px;\n top: ").concat(rect.top,"px;\n width: ").concat(rect.width,"px;\n height: ").concat(rect.height,"px;\n line-height: ").concat(rect.height,"px;\n text-align: center;\n z-index: 2147483647;\n pointer-events: none; /* \u5141\u8BB8\u70B9\u51FB\u7A7F\u900F */\n ");document.body.appendChild(div);}function removeLoading(loadingId){const div=document.getElementById(loadingId);if(div)div.remove();}/** * 输入框翻译 */var _config=/*#__PURE__*/_classPrivateFieldKey("config");var _unregisterShortcut=/*#__PURE__*/_classPrivateFieldKey("unregisterShortcut");var _isEnabled=/*#__PURE__*/_classPrivateFieldKey("isEnabled");var _triggerShortcut=/*#__PURE__*/_classPrivateFieldKey("triggerShortcut");var _handleTranslate=/*#__PURE__*/_classPrivateFieldKey("handleTranslate");class InputTranslator{// 用于缓存快捷键 constructor(){let{inputRule=DEFAULT_INPUT_RULE,transApis=[]}=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};/** @@ -39469,7 +39468,7 @@ Divider.muiSkipListHighlight = true; false ? 0 : void 0; /* harmony default export */ const Divider_Divider = (Divider); ;// CONCATENATED MODULE: ./src/hooks/Loading.js -function Loading(){return/*#__PURE__*/(0,jsx_runtime.jsxs)("center",{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Divider_Divider,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(Link_Link,{href:"https://github.com/fishjar/kiss-translator",children:"KISS Translator v".concat("2.0.10")})}),/*#__PURE__*/(0,jsx_runtime.jsx)(CircularProgress_CircularProgress,{})]});} +function Loading(){return/*#__PURE__*/(0,jsx_runtime.jsxs)("center",{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Divider_Divider,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(Link_Link,{href:"https://github.com/fishjar/kiss-translator",children:"KISS Translator v".concat("2.0.11")})}),/*#__PURE__*/(0,jsx_runtime.jsx)(CircularProgress_CircularProgress,{})]});} ;// CONCATENATED MODULE: ./src/hooks/Setting.js const SettingContext=/*#__PURE__*/(0,react.createContext)({setting:setting_DEFAULT_SETTING,updateSetting:()=>{},reloadSetting:()=>{}});function SettingProvider(_ref){let{children,isSettingPage}=_ref;const{data:setting,isLoading,update,reload}=useStorage(storage_STOKEY_SETTING,setting_DEFAULT_SETTING,isSettingPage?storage_KV_SETTING_KEY:"");(0,react.useEffect)(()=>{if(typeof(setting===null||setting===void 0?void 0:setting.darkMode)==="boolean"){update(currentSetting=>_objectSpread2(_objectSpread2({},currentSetting),{},{darkMode:currentSetting.darkMode?"dark":"light"}));}},[setting===null||setting===void 0?void 0:setting.darkMode,update]);(0,react.useEffect)(()=>{if(!isSettingPage)return;(async()=>{try{logger.setLevel(setting===null||setting===void 0?void 0:setting.logLevel);if(isExt){await sendBgMsg(MSG_SET_LOGLEVEL,setting===null||setting===void 0?void 0:setting.logLevel);}}catch(error){logger.error("Failed to fetch log level, using default.",error);}})();},[isSettingPage,setting===null||setting===void 0?void 0:setting.logLevel]);const updateSetting=(0,react.useCallback)(objOrFn=>{update(objOrFn);debounceSyncMeta(storage_KV_SETTING_KEY);},[update]);const updateChild=(0,react.useCallback)(key=>async obj=>{updateSetting(prev=>_objectSpread2(_objectSpread2({},prev),{},{[key]:_objectSpread2(_objectSpread2({},(prev===null||prev===void 0?void 0:prev[key])||{}),obj)}));},[updateSetting]);const value=(0,react.useMemo)(()=>({setting,updateSetting,updateChild,reloadSetting:reload}),[setting,updateSetting,updateChild,reload]);if(isLoading){return/*#__PURE__*/(0,jsx_runtime.jsx)(Loading,{});}if(!setting){/*#__PURE__*/(0,jsx_runtime.jsx)("center",{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(Alert_Alert,{severity:"error",sx:{maxWidth:600,margin:"60px auto"},children:[/*#__PURE__*/(0,jsx_runtime.jsx)("p",{children:"\u6570\u636E\u52A0\u8F7D\u51FA\u9519\uFF0C\u8BF7\u5237\u65B0\u9875\u9762\u6216\u5378\u8F7D\u540E\u91CD\u65B0\u5B89\u88C5\u3002"}),/*#__PURE__*/(0,jsx_runtime.jsx)("p",{children:"Data loading error, please refresh the page or uninstall and reinstall."})]})});}return/*#__PURE__*/(0,jsx_runtime.jsx)(SettingContext.Provider,{value:value,children:children});}/** * 设置 hook @@ -47042,7 +47041,7 @@ function SugBaidu(_ref){let{text}=_ref;const{loading,error,data}=useAsyncNow(api function TranForm(_ref){let{text,setText,apiSlugs:initApiSlugs,fromLang:initFromLang,toLang:initToLang,toLang2:initToLang2,transApis,simpleStyle=false,langDetector:initLangDetector="-",enDict:initEnDict="-",enSug:initEnSug="-",isPlaygound=false}=_ref;const i18n=useI18n();const[editMode,setEditMode]=(0,react.useState)(false);const[editText,setEditText]=(0,react.useState)(text);const[apiSlugs,setApiSlugs]=(0,react.useState)(initApiSlugs);const[fromLang,setFromLang]=(0,react.useState)(initFromLang);const[toLang,setToLang]=(0,react.useState)(initToLang);const[toLang2,setToLang2]=(0,react.useState)(initToLang2);const[langDetector,setLangDetector]=(0,react.useState)(initLangDetector);const[enDict,setEnDict]=(0,react.useState)(initEnDict);const[enSug,setEnSug]=(0,react.useState)(initEnSug);const[deLang,setDeLang]=(0,react.useState)("");const[deLoading,setDeLoading]=(0,react.useState)(false);(0,react.useEffect)(()=>{if(!editMode){setEditText(text);}},[text,editMode]);(0,react.useEffect)(()=>{if(!text.trim()){setDeLang("");return;}(async()=>{try{setDeLoading(true);const deLang=await tryDetectLang(text,langDetector);if(deLang){setDeLang(deLang);}}catch(err){log_kissLog("tranbox: detect lang",err);}finally{setDeLoading(false);}})();},[text,langDetector,setDeLang,setDeLoading]);// todo: 语言变化后,realToLang引发二次翻译请求 const realToLang=(0,react.useMemo)(()=>{if(fromLang==="auto"&&toLang!==toLang2&&toLang2!=="-"&&deLang===toLang){return toLang2;}return toLang;},[fromLang,toLang,toLang2,deLang]);const optApis=(0,react.useMemo)(()=>transApis.filter(api=>!api.isDisabled).map(api=>({key:api.apiSlug,name:api.apiName||api.apiSlug})),[transApis]);const isWord=(0,react.useMemo)(()=>isValidWord(text),[text]);const xs=(0,react.useMemo)(()=>isPlaygound?3:4,[isPlaygound]);return/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{spacing:simpleStyle?1:2,children:[!simpleStyle&&/*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Box_Box,{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(Grid_Grid,{container:true,spacing:2,columns:12,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Grid_Grid,{item:true,xs:xs,children:/*#__PURE__*/(0,jsx_runtime.jsx)(TextField_TextField,{select:true,SelectProps:{multiple:true,MenuProps:{disablePortal:!isPlaygound}},fullWidth:true,size:"small",value:apiSlugs,name:"apiSlugs",label:i18n("translate_service_multiple"),onChange:e=>{setApiSlugs(e.target.value);},children:optApis.map(_ref2=>{let{key,name}=_ref2;return/*#__PURE__*/(0,jsx_runtime.jsx)(material_MenuItem_MenuItem,{value:key,children:name},key);})})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Grid_Grid,{item:true,xs:xs,children:/*#__PURE__*/(0,jsx_runtime.jsx)(TextField_TextField,{select:true,SelectProps:{MenuProps:{disablePortal:!isPlaygound}},fullWidth:true,size:"small",name:"fromLang",value:fromLang,label:i18n("from_lang"),onChange:e=>{setFromLang(e.target.value);},children:OPT_LANGS_FROM.map(_ref3=>{let[lang,name]=_ref3;return/*#__PURE__*/(0,jsx_runtime.jsx)(material_MenuItem_MenuItem,{value:lang,children:name},lang);})})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Grid_Grid,{item:true,xs:xs,children:/*#__PURE__*/(0,jsx_runtime.jsx)(TextField_TextField,{select:true,SelectProps:{MenuProps:{disablePortal:!isPlaygound}},fullWidth:true,size:"small",name:"toLang",value:toLang,label:i18n("to_lang"),onChange:e=>{setToLang(e.target.value);},children:OPT_LANGS_TO.map(_ref4=>{let[lang,name]=_ref4;return/*#__PURE__*/(0,jsx_runtime.jsx)(material_MenuItem_MenuItem,{value:lang,children:name},lang);})})}),isPlaygound&&/*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Grid_Grid,{item:true,xs:xs,children:/*#__PURE__*/(0,jsx_runtime.jsx)(TextField_TextField,{select:true,SelectProps:{MenuProps:{disablePortal:!isPlaygound}},fullWidth:true,size:"small",name:"toLang2",value:toLang2,label:i18n("to_lang2"),onChange:e=>{setToLang2(e.target.value);},children:OPT_LANGS_TO.map(_ref5=>{let[lang,name]=_ref5;return/*#__PURE__*/(0,jsx_runtime.jsx)(material_MenuItem_MenuItem,{value:lang,children:name},lang);})})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Grid_Grid,{item:true,xs:xs,children:/*#__PURE__*/(0,jsx_runtime.jsxs)(TextField_TextField,{select:true,SelectProps:{MenuProps:{disablePortal:!isPlaygound}},fullWidth:true,size:"small",name:"enDict",value:enDict,label:i18n("english_dict"),onChange:e=>{setEnDict(e.target.value);},children:[/*#__PURE__*/(0,jsx_runtime.jsx)(material_MenuItem_MenuItem,{value:"-",children:i18n("disable")}),OPT_DICT_ALL.map(item=>/*#__PURE__*/(0,jsx_runtime.jsx)(material_MenuItem_MenuItem,{value:item,children:item},item))]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Grid_Grid,{item:true,xs:xs,children:/*#__PURE__*/(0,jsx_runtime.jsxs)(TextField_TextField,{select:true,SelectProps:{MenuProps:{disablePortal:!isPlaygound}},fullWidth:true,size:"small",name:"enSug",value:enSug,label:i18n("english_suggest"),onChange:e=>{setEnSug(e.target.value);},children:[/*#__PURE__*/(0,jsx_runtime.jsx)(material_MenuItem_MenuItem,{value:"-",children:i18n("disable")}),OPT_SUG_ALL.map(item=>/*#__PURE__*/(0,jsx_runtime.jsx)(material_MenuItem_MenuItem,{value:item,children:item},item))]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Grid_Grid,{item:true,xs:xs,children:/*#__PURE__*/(0,jsx_runtime.jsxs)(TextField_TextField,{select:true,SelectProps:{MenuProps:{disablePortal:!isPlaygound}},fullWidth:true,size:"small",name:"langDetector",value:langDetector,label:i18n("detected_lang"),onChange:e=>{setLangDetector(e.target.value);},children:[/*#__PURE__*/(0,jsx_runtime.jsx)(material_MenuItem_MenuItem,{value:"-",children:i18n("disable")}),OPT_LANGDETECTOR_ALL.map(item=>/*#__PURE__*/(0,jsx_runtime.jsx)(material_MenuItem_MenuItem,{value:item,children:item},item))]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Grid_Grid,{item:true,xs:xs,children:/*#__PURE__*/(0,jsx_runtime.jsx)(TextField_TextField,{fullWidth:true,size:"small",name:"deLang",value:deLang&&OPT_LANGS_MAP.get(deLang),label:i18n("detected_result"),disabled:true,InputProps:{startAdornment:deLoading?/*#__PURE__*/(0,jsx_runtime.jsx)(CircularProgress_CircularProgress,{size:16}):null}})})]})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Box_Box,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(TextField_TextField,{size:"small",label:i18n("original_text"),fullWidth:true,multiline:true,minRows:isPlaygound?2:1,maxRows:10,value:editText,onChange:e=>{setEditText(e.target.value);},onFocus:()=>{setEditMode(true);},onBlur:()=>{setEditMode(false);setText(editText.trim());},InputProps:{endAdornment:/*#__PURE__*/(0,jsx_runtime.jsx)(Stack_Stack,{direction:"row",sx:{position:"absolute",right:0,top:0},children:editMode?/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{size:"small",onClick:e=>{e.stopPropagation();setEditMode(false);setText(editText.trim());},children:/*#__PURE__*/(0,jsx_runtime.jsx)(Done/* default */.Z,{fontSize:"inherit"})}):/*#__PURE__*/(0,jsx_runtime.jsx)(CopyBtn,{text:text})})}})})]}),apiSlugs.map(slug=>/*#__PURE__*/(0,jsx_runtime.jsx)(TranCont,{text:text,fromLang:fromLang,toLang:realToLang,simpleStyle:simpleStyle,apiSlug:slug,transApis:transApis},slug)),isWord&&OPT_DICT_MAP.has(enDict)&&/*#__PURE__*/(0,jsx_runtime.jsx)(DictCont,{text:text,enDict:enDict}),isWord&&OPT_SUG_MAP.has(enSug)&&/*#__PURE__*/(0,jsx_runtime.jsx)(SugCont,{text:text,enSug:enSug})]});} ;// CONCATENATED MODULE: ./src/views/Selection/TranBox.js -function Header(_ref){let{setShowBox,simpleStyle,setSimpleStyle,hideClickAway,setHideClickAway,followSelection,setFollowSelection,mouseHover}=_ref;const i18n=useI18n();if(!isMobile&&simpleStyle&&!mouseHover){return;}return/*#__PURE__*/(0,jsx_runtime.jsxs)(Box_Box,{onMouseUp:e=>e.stopPropagation(),onTouchEnd:e=>e.stopPropagation(),children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{direction:"row",alignItems:"center",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(DragIndicator/* default */.Z,{fontSize:"small"}),/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{variant:"body2",sx:{userSelect:"none",WebkitUserSelect:"none",fontWeight:"bold"},children:"".concat("KISS Translator"," v").concat("2.0.10")})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{direction:"row",alignItems:"center",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{size:"small",title:i18n("btn_tip_click_away"),onClick:()=>{setHideClickAway(pre=>!pre);},children:hideClickAway?/*#__PURE__*/(0,jsx_runtime.jsx)(LockOpen/* default */.Z,{fontSize:"small"}):/*#__PURE__*/(0,jsx_runtime.jsx)(Lock/* default */.Z,{fontSize:"small"})}),/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{size:"small",title:i18n("btn_tip_follow_selection"),onClick:()=>{setFollowSelection(pre=>!pre);},children:followSelection?/*#__PURE__*/(0,jsx_runtime.jsx)(PushPinOutlined/* default */.Z,{fontSize:"small"}):/*#__PURE__*/(0,jsx_runtime.jsx)(PushPin/* default */.Z,{fontSize:"small"})}),/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{size:"small",title:i18n("btn_tip_simple_style"),onClick:()=>{setSimpleStyle(pre=>!pre);},children:simpleStyle?/*#__PURE__*/(0,jsx_runtime.jsx)(UnfoldMore/* default */.Z,{fontSize:"small"}):/*#__PURE__*/(0,jsx_runtime.jsx)(UnfoldLess/* default */.Z,{fontSize:"small"})}),/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{size:"small",onClick:()=>{setShowBox(false);},children:/*#__PURE__*/(0,jsx_runtime.jsx)(icons_material_Close/* default */.Z,{fontSize:"small"})})]})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(Divider_Divider,{})]});}function TranBox(_ref2){let{showBox,text,setText,setShowBox,tranboxSetting:{enDict,enSug,apiSlugs,fromLang,toLang,toLang2,autoHeight},transApis,boxSize,setBoxSize,boxPosition,setBoxPosition,simpleStyle,setSimpleStyle,hideClickAway,setHideClickAway,followSelection,setFollowSelection,extStyles="",langDetector}=_ref2;const[mouseHover,setMouseHover]=(0,react.useState)(false);// todo: 这里的 SettingProvider 不应和 background 的共用 +function Header(_ref){let{setShowBox,simpleStyle,setSimpleStyle,hideClickAway,setHideClickAway,followSelection,setFollowSelection,mouseHover}=_ref;const i18n=useI18n();if(!isMobile&&simpleStyle&&!mouseHover){return;}return/*#__PURE__*/(0,jsx_runtime.jsxs)(Box_Box,{onMouseUp:e=>e.stopPropagation(),onTouchEnd:e=>e.stopPropagation(),children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{direction:"row",alignItems:"center",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(DragIndicator/* default */.Z,{fontSize:"small"}),/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{variant:"body2",sx:{userSelect:"none",WebkitUserSelect:"none",fontWeight:"bold"},children:"".concat("KISS Translator"," v").concat("2.0.11")})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{direction:"row",alignItems:"center",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{size:"small",title:i18n("btn_tip_click_away"),onClick:()=>{setHideClickAway(pre=>!pre);},children:hideClickAway?/*#__PURE__*/(0,jsx_runtime.jsx)(LockOpen/* default */.Z,{fontSize:"small"}):/*#__PURE__*/(0,jsx_runtime.jsx)(Lock/* default */.Z,{fontSize:"small"})}),/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{size:"small",title:i18n("btn_tip_follow_selection"),onClick:()=>{setFollowSelection(pre=>!pre);},children:followSelection?/*#__PURE__*/(0,jsx_runtime.jsx)(PushPinOutlined/* default */.Z,{fontSize:"small"}):/*#__PURE__*/(0,jsx_runtime.jsx)(PushPin/* default */.Z,{fontSize:"small"})}),/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{size:"small",title:i18n("btn_tip_simple_style"),onClick:()=>{setSimpleStyle(pre=>!pre);},children:simpleStyle?/*#__PURE__*/(0,jsx_runtime.jsx)(UnfoldMore/* default */.Z,{fontSize:"small"}):/*#__PURE__*/(0,jsx_runtime.jsx)(UnfoldLess/* default */.Z,{fontSize:"small"})}),/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{size:"small",onClick:()=>{setShowBox(false);},children:/*#__PURE__*/(0,jsx_runtime.jsx)(icons_material_Close/* default */.Z,{fontSize:"small"})})]})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(Divider_Divider,{})]});}function TranBox(_ref2){let{showBox,text,setText,setShowBox,tranboxSetting:{enDict,enSug,apiSlugs,fromLang,toLang,toLang2,autoHeight},transApis,boxSize,setBoxSize,boxPosition,setBoxPosition,simpleStyle,setSimpleStyle,hideClickAway,setHideClickAway,followSelection,setFollowSelection,extStyles="",langDetector}=_ref2;const[mouseHover,setMouseHover]=(0,react.useState)(false);// todo: 这里的 SettingProvider 不应和 background 的共用 return/*#__PURE__*/(0,jsx_runtime.jsx)(SettingProvider,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(Theme,{styles:extStyles,children:showBox&&/*#__PURE__*/(0,jsx_runtime.jsx)(DraggableResizable,{position:boxPosition,size:boxSize,setSize:setBoxSize,setPosition:setBoxPosition,autoHeight:autoHeight,header:/*#__PURE__*/(0,jsx_runtime.jsx)(Header,{setShowBox:setShowBox,simpleStyle:simpleStyle,setSimpleStyle:setSimpleStyle,hideClickAway:hideClickAway,setHideClickAway:setHideClickAway,followSelection:followSelection,setFollowSelection:setFollowSelection,mouseHover:mouseHover}),onClick:e=>e.stopPropagation(),onMouseEnter:()=>setMouseHover(true),onMouseLeave:()=>setMouseHover(false),children:/*#__PURE__*/(0,jsx_runtime.jsx)(Box_Box,{sx:{p:simpleStyle?1:2},children:/*#__PURE__*/(0,jsx_runtime.jsx)(TranForm,{text:text,setText:setText,apiSlugs:apiSlugs,fromLang:fromLang,toLang:toLang,toLang2:toLang2,transApis:transApis,simpleStyle:simpleStyle,langDetector:langDetector,enDict:enDict,enSug:enSug})})})})});} ;// CONCATENATED MODULE: ./src/views/Selection/index.js function Slection(_ref){let{contextMenuType,tranboxSetting,transApis,uiLang,langDetector}=_ref;const{hideTranBtn=false,simpleStyle:initSimpleStyle=false,hideClickAway:initHideClickAway=false,followSelection:initFollowMouse=false,tranboxShortcut=DEFAULT_TRANBOX_SHORTCUT,triggerMode=OPT_TRANBOX_TRIGGER_CLICK,// extStyles, @@ -47069,7 +47068,7 @@ var BrightnessAuto = __webpack_require__(4080); ;// CONCATENATED MODULE: ./src/views/Options/DarkModeButton.js function DarkModeButton(){const{darkMode,toggleDarkMode}=useDarkMode();return/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{sx:{ml:1},onClick:toggleDarkMode,color:"inherit",children:darkMode==="dark"?/*#__PURE__*/(0,jsx_runtime.jsx)(DarkMode/* default */.Z,{}):darkMode==="light"?/*#__PURE__*/(0,jsx_runtime.jsx)(LightMode/* default */.Z,{}):/*#__PURE__*/(0,jsx_runtime.jsx)(BrightnessAuto/* default */.Z,{})});} ;// CONCATENATED MODULE: ./src/views/Popup/Header.js -function Header_Header(_ref){let{onClose}=_ref;const handleHomepage=()=>{window.open("https://github.com/fishjar/kiss-translator","_blank");};return/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{direction:"row",justifyContent:"space-between",alignItems:"center",spacing:2,children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{direction:"row",justifyContent:"flex-start",alignItems:"center",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{onClick:handleHomepage,children:/*#__PURE__*/(0,jsx_runtime.jsx)(Home/* default */.Z,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{component:"div",sx:{userSelect:"none",WebkitUserSelect:"none",fontWeight:"bold"},children:"".concat("KISS Translator"," v").concat("2.0.10")})]}),onClose?/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{onClick:()=>{onClose();},children:/*#__PURE__*/(0,jsx_runtime.jsx)(icons_material_Close/* default */.Z,{})}):/*#__PURE__*/(0,jsx_runtime.jsx)(DarkModeButton,{})]});} +function Header_Header(_ref){let{onClose}=_ref;const handleHomepage=()=>{window.open("https://github.com/fishjar/kiss-translator","_blank");};return/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{direction:"row",justifyContent:"space-between",alignItems:"center",spacing:2,children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{direction:"row",justifyContent:"flex-start",alignItems:"center",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{onClick:handleHomepage,children:/*#__PURE__*/(0,jsx_runtime.jsx)(Home/* default */.Z,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{component:"div",sx:{userSelect:"none",WebkitUserSelect:"none",fontWeight:"bold"},children:"".concat("KISS Translator"," v").concat("2.0.11")})]}),onClose?/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{onClick:()=>{onClose();},children:/*#__PURE__*/(0,jsx_runtime.jsx)(icons_material_Close/* default */.Z,{})}):/*#__PURE__*/(0,jsx_runtime.jsx)(DarkModeButton,{})]});} ;// CONCATENATED MODULE: ./src/hooks/WindowSize.js function useWindowSize(){const[windowSize,setWindowSize]=(0,react.useState)({w:window.innerWidth,h:window.innerHeight});const debounceWindowResize=useDebouncedCallback(()=>{setWindowSize({w:window.innerWidth,h:window.innerHeight});},200);(0,react.useEffect)(()=>{debounceWindowResize();window.addEventListener("resize",debounceWindowResize);return()=>{window.removeEventListener("resize",debounceWindowResize);};},[debounceWindowResize]);return windowSize;}/* harmony default export */ const WindowSize = (useWindowSize); ;// CONCATENATED MODULE: ./node_modules/.pnpm/@mui+material@5.15.15_@emotion+react@11.11.1_@types+react@18.2.79_react@18.2.0__@emotion+styl_fuwy6huc4pjbdb446idbihjqyi/node_modules/@mui/material/FormControlLabel/formControlLabelClasses.js @@ -48230,22 +48229,22 @@ if(_classPrivateFieldBase(this,_isUserscript)[_isUserscript]){window.removeEvent _classPrivateFieldBase(this,_clearShortcuts)[_clearShortcuts].forEach(clear=>clear());_classPrivateFieldBase(this,_clearShortcuts)[_clearShortcuts]=[];// 触屏 _classPrivateFieldBase(this,_clearTouchListeners)[_clearTouchListeners].forEach(clear=>clear());_classPrivateFieldBase(this,_clearTouchListeners)[_clearTouchListeners]=[];// 油猴菜单 if(globalThis.GM&&_classPrivateFieldBase(this,_menuCommandIds)[_menuCommandIds].length>0){_classPrivateFieldBase(this,_menuCommandIds)[_menuCommandIds].forEach(id=>globalThis.GM.unregisterMenuCommand(id));_classPrivateFieldBase(this,_menuCommandIds)[_menuCommandIds]=[];}// 子模块 -(_this$_popupManager=this._popupManager)===null||_this$_popupManager===void 0?void 0:_this$_popupManager.destroy();(_this$_fabManager=this._fabManager)===null||_this$_fabManager===void 0?void 0:_this$_fabManager.destroy();(_this$_transboxManage=this._transboxManager)===null||_this$_transboxManage===void 0?void 0:_this$_transboxManage.disable();(_this$_inputTranslato=this._inputTranslator)===null||_this$_inputTranslato===void 0?void 0:_this$_inputTranslato.disable();this._translator.stop();_classPrivateFieldBase(this,_isActive)[_isActive]=false;logger.info("TranslatorManager stopped.");}}function _setupMessageListeners2(){if(_classPrivateFieldBase(this,_isUserscript)[_isUserscript]){window.addEventListener("message",_classPrivateFieldBase(this,translatorManager_windowMessageHandler)[translatorManager_windowMessageHandler]);}else{browser.runtime.onMessage.addListener(_classPrivateFieldBase(this,_browserMessageHandler)[_browserMessageHandler]);if(_classPrivateFieldBase(this,_isIframe)[_isIframe]){window.addEventListener("message",_classPrivateFieldBase(this,translatorManager_windowMessageHandler)[translatorManager_windowMessageHandler]);}}}function _setupTouchOperations2(){if(_classPrivateFieldBase(this,_isIframe)[_isIframe])return;const{touchModes=[2]}=this._translator.setting;if(touchModes.length===0){return;}const handleTap=()=>{_classPrivateFieldBase(this,_processActions)[_processActions]({action:MSG_TRANS_TOGGLE});};const handleListener=mode=>{let options=null;switch(mode){case 2:case 3:case 4:options={taps:1,fingers:mode};break;case 5:options={taps:2,fingers:1};break;case 6:options={taps:3,fingers:1};break;case 7:options={taps:2,fingers:2};break;default:}if(options){_classPrivateFieldBase(this,_clearTouchListeners)[_clearTouchListeners].push(touchTapListener(handleTap,options));}};touchModes.forEach(mode=>handleListener(mode));}function translatorManager_handleWindowMessage2(event){_classPrivateFieldBase(this,_processActions)[_processActions](event.data);}function _handleBrowserMessage2(message,sender,sendResponse){const result=_classPrivateFieldBase(this,_processActions)[_processActions](message,true);const response=result||{rule:this._translator.rule,setting:this._translator.setting};sendResponse(response);return true;}function _registerShortcuts2(){const{shortcuts}=this._translator.setting;_classPrivateFieldBase(this,_clearShortcuts)[_clearShortcuts]=[shortcutRegister(shortcuts[OPT_SHORTCUT_TRANSLATE],()=>_classPrivateFieldBase(this,_processActions)[_processActions]({action:MSG_TRANS_TOGGLE})),shortcutRegister(shortcuts[OPT_SHORTCUT_STYLE],()=>_classPrivateFieldBase(this,_processActions)[_processActions]({action:MSG_TRANS_TOGGLE_STYLE})),shortcutRegister(shortcuts[OPT_SHORTCUT_POPUP],()=>_classPrivateFieldBase(this,_processActions)[_processActions]({action:MSG_POPUP_TOGGLE})),shortcutRegister(shortcuts[OPT_SHORTCUT_SETTING],()=>window.open("https://fishjar.github.io/kiss-translator/options.html","_blank"))];}function _registerMenus2(){if(!globalThis.GM)return;const{contextMenuType,uiLang}=this._translator.setting;if(contextMenuType===0)return;const i18n=newI18n(uiLang||"zh");const GM=globalThis.GM;_classPrivateFieldBase(this,_menuCommandIds)[_menuCommandIds]=[GM.registerMenuCommand(i18n("translate_switch"),()=>_classPrivateFieldBase(this,_processActions)[_processActions]({action:MSG_TRANS_TOGGLE}),"Q"),GM.registerMenuCommand(i18n("toggle_style"),()=>_classPrivateFieldBase(this,_processActions)[_processActions]({action:MSG_TRANS_TOGGLE_STYLE}),"C"),GM.registerMenuCommand(i18n("open_menu"),()=>_classPrivateFieldBase(this,_processActions)[_processActions]({action:MSG_POPUP_TOGGLE}),"K"),GM.registerMenuCommand(i18n("open_setting"),()=>window.open("https://fishjar.github.io/kiss-translator/options.html","_blank"),"O")];}function _processActions2(){var _this$_popupManager2,_this$_transboxManage2,_this$_inputTranslato2;let{action,args}=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};let fromExt=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;if(!action)return;if(!fromExt){sendIframeMsg(action,args);}switch(action){case MSG_TRANS_TOGGLE:this._translator.toggle();break;case MSG_TRANS_TOGGLE_STYLE:this._translator.toggleStyle();break;case MSG_TRANS_GETRULE:break;case MSG_TRANS_PUTRULE:this._translator.updateRule(args);break;case MSG_OPEN_TRANBOX:document.dispatchEvent(new CustomEvent(EVENT_KISS,{detail:{action:MSG_OPEN_TRANBOX}}));break;case MSG_POPUP_TOGGLE:(_this$_popupManager2=this._popupManager)===null||_this$_popupManager2===void 0?void 0:_this$_popupManager2.toggle();break;case MSG_TRANSBOX_TOGGLE:(_this$_transboxManage2=this._transboxManager)===null||_this$_transboxManage2===void 0?void 0:_this$_transboxManage2.toggle();this._translator.toggleTransbox();break;case MSG_MOUSEHOVER_TOGGLE:this._translator.toggleMouseHover();break;case MSG_TRANSINPUT_TOGGLE:(_this$_inputTranslato2=this._inputTranslator)===null||_this$_inputTranslato2===void 0?void 0:_this$_inputTranslato2.toggle();this._translator.toggleInputTranslate();break;default:logger.info("Message action is unavailable: ".concat(action));return{error:"Message action is unavailable: ".concat(action)};}} +(_this$_popupManager=this._popupManager)===null||_this$_popupManager===void 0?void 0:_this$_popupManager.destroy();(_this$_fabManager=this._fabManager)===null||_this$_fabManager===void 0?void 0:_this$_fabManager.destroy();(_this$_transboxManage=this._transboxManager)===null||_this$_transboxManage===void 0?void 0:_this$_transboxManage.disable();(_this$_inputTranslato=this._inputTranslator)===null||_this$_inputTranslato===void 0?void 0:_this$_inputTranslato.disable();this._translator.stop();_classPrivateFieldBase(this,_isActive)[_isActive]=false;logger.info("TranslatorManager stopped.");}}function _setupMessageListeners2(){if(_classPrivateFieldBase(this,_isUserscript)[_isUserscript]){window.addEventListener("message",_classPrivateFieldBase(this,translatorManager_windowMessageHandler)[translatorManager_windowMessageHandler]);}else{browser.runtime.onMessage.addListener(_classPrivateFieldBase(this,_browserMessageHandler)[_browserMessageHandler]);if(_classPrivateFieldBase(this,_isIframe)[_isIframe]){window.addEventListener("message",_classPrivateFieldBase(this,translatorManager_windowMessageHandler)[translatorManager_windowMessageHandler]);}}}function _setupTouchOperations2(){if(_classPrivateFieldBase(this,_isIframe)[_isIframe])return;const{touchModes=[2]}=this._translator.setting;if(touchModes.length===0){return;}const handleTap=()=>{_classPrivateFieldBase(this,_processActions)[_processActions]({action:MSG_TRANS_TOGGLE});};const handleListener=mode=>{let options=null;switch(mode){case 2:case 3:case 4:options={taps:1,fingers:mode};break;case 5:options={taps:2,fingers:1};break;case 6:options={taps:3,fingers:1};break;case 7:options={taps:2,fingers:2};break;default:}if(options){_classPrivateFieldBase(this,_clearTouchListeners)[_clearTouchListeners].push(touchTapListener(handleTap,options));}};touchModes.forEach(mode=>handleListener(mode));}function translatorManager_handleWindowMessage2(event){_classPrivateFieldBase(this,_processActions)[_processActions](event.data);}function _handleBrowserMessage2(message,sender,sendResponse){const result=_classPrivateFieldBase(this,_processActions)[_processActions](message,true);const response=result||{rule:this._translator.rule,setting:this._translator.setting};sendResponse(response);return true;}function _registerShortcuts2(){const{shortcuts}=this._translator.setting;_classPrivateFieldBase(this,_clearShortcuts)[_clearShortcuts]=[shortcutRegister(shortcuts[OPT_SHORTCUT_TRANSLATE],()=>_classPrivateFieldBase(this,_processActions)[_processActions]({action:MSG_TRANS_TOGGLE})),shortcutRegister(shortcuts[OPT_SHORTCUT_STYLE],()=>_classPrivateFieldBase(this,_processActions)[_processActions]({action:MSG_TRANS_TOGGLE_STYLE})),shortcutRegister(shortcuts[OPT_SHORTCUT_POPUP],()=>_classPrivateFieldBase(this,_processActions)[_processActions]({action:MSG_POPUP_TOGGLE})),shortcutRegister(shortcuts[OPT_SHORTCUT_SETTING],()=>window.open("https://fishjar.github.io/kiss-translator/options.html","_blank"))];}function _registerMenus2(){if(!globalThis.GM)return;const{contextMenuType,uiLang}=this._translator.setting;if(contextMenuType===0)return;const i18n=newI18n(uiLang||"zh");const GM=globalThis.GM;_classPrivateFieldBase(this,_menuCommandIds)[_menuCommandIds]=[GM.registerMenuCommand(i18n("translate_switch"),()=>_classPrivateFieldBase(this,_processActions)[_processActions]({action:MSG_TRANS_TOGGLE}),"Q"),GM.registerMenuCommand(i18n("toggle_style"),()=>_classPrivateFieldBase(this,_processActions)[_processActions]({action:MSG_TRANS_TOGGLE_STYLE}),"C"),GM.registerMenuCommand(i18n("open_menu"),()=>_classPrivateFieldBase(this,_processActions)[_processActions]({action:MSG_POPUP_TOGGLE}),"K"),GM.registerMenuCommand(i18n("open_setting"),()=>window.open("https://fishjar.github.io/kiss-translator/options.html","_blank"),"O")];}function _processActions2(){var _this$_popupManager2,_this$_transboxManage2,_this$_inputTranslato2;let{action,args}=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};let fromExt=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;if(!action)return;if(!fromExt){sendIframeMsg(action,args);}logger.debug("process action:",action,args);switch(action){case MSG_TRANS_TOGGLE:this._translator.toggle();break;case MSG_TRANS_TOGGLE_STYLE:this._translator.toggleStyle();break;case MSG_TRANS_GETRULE:break;case MSG_TRANS_PUTRULE:this._translator.updateRule(args);break;case MSG_OPEN_TRANBOX:document.dispatchEvent(new CustomEvent(EVENT_KISS,{detail:{action:MSG_OPEN_TRANBOX}}));break;case MSG_POPUP_TOGGLE:(_this$_popupManager2=this._popupManager)===null||_this$_popupManager2===void 0?void 0:_this$_popupManager2.toggle();break;case MSG_TRANSBOX_TOGGLE:(_this$_transboxManage2=this._transboxManager)===null||_this$_transboxManage2===void 0?void 0:_this$_transboxManage2.toggle();this._translator.toggleTransbox();break;case MSG_MOUSEHOVER_TOGGLE:this._translator.toggleMouseHover();break;case MSG_TRANSINPUT_TOGGLE:(_this$_inputTranslato2=this._inputTranslator)===null||_this$_inputTranslato2===void 0?void 0:_this$_inputTranslato2.toggle();this._translator.toggleInputTranslate();break;default:logger.info("Message action is unavailable: ".concat(action));return{error:"Message action is unavailable: ".concat(action)};}} ;// CONCATENATED MODULE: ./src/common.js /** * 油猴脚本设置页面 - */function runSettingPage(){var _GM,_GM$info,_GM$info$script,_GM$info$script$grant;if((_GM=GM)!==null&&_GM!==void 0&&(_GM$info=_GM.info)!==null&&_GM$info!==void 0&&(_GM$info$script=_GM$info.script)!==null&&_GM$info$script!==void 0&&(_GM$info$script$grant=_GM$info$script.grant)!==null&&_GM$info$script$grant!==void 0&&_GM$info$script$grant.includes("unsafeWindow")){unsafeWindow.GM=GM;unsafeWindow.APP_INFO={name:"KISS Translator",version:"2.0.10"};}else{const ping=utils_genEventName();window.addEventListener(ping,handlePing);// window.eval(`(${injectScript})("${ping}")`); // eslint-disable-line + */function runSettingPage(){var _GM,_GM$info,_GM$info$script,_GM$info$script$grant;if((_GM=GM)!==null&&_GM!==void 0&&(_GM$info=_GM.info)!==null&&_GM$info!==void 0&&(_GM$info$script=_GM$info.script)!==null&&_GM$info$script!==void 0&&(_GM$info$script$grant=_GM$info$script.grant)!==null&&_GM$info$script$grant!==void 0&&_GM$info$script$grant.includes("unsafeWindow")){unsafeWindow.GM=GM;unsafeWindow.APP_INFO={name:"KISS Translator",version:"2.0.11"};}else{const ping=utils_genEventName();window.addEventListener(ping,handlePing);// window.eval(`(${injectScript})("${ping}")`); // eslint-disable-line injectInlineJs("(".concat(injectScript,")(\"").concat(ping,"\")"),"kiss-translator-options-injector");}}/** * 显示错误信息到页面顶部 * @param {*} message */function showErr(message){const bannerId="KISS-Translator-Message";const existingBanner=document.getElementById(bannerId);if(existingBanner){existingBanner.remove();}const banner=document.createElement("div");banner.id=bannerId;Object.assign(banner.style,{position:"fixed",top:"0",left:"0",width:"100%",backgroundColor:"#f44336",color:"white",textAlign:"center",padding:"8px 16px",zIndex:"1001",boxSizing:"border-box",fontSize:"16px",boxShadow:"0 2px 5px rgba(0,0,0,0.2)"});const closeButton=document.createElement("span");closeButton.textContent="×";Object.assign(closeButton.style,{position:"absolute",top:"50%",right:"20px",transform:"translateY(-50%)",cursor:"pointer",fontSize:"22px",fontWeight:"bold"});const messageText=document.createTextNode("KISS-Translator: ".concat(message));banner.appendChild(messageText);banner.appendChild(closeButton);document.body.appendChild(banner);const removeBanner=()=>{banner.style.transition="opacity 0.5s ease";banner.style.opacity="0";setTimeout(()=>{if(banner&&banner.parentNode){banner.parentNode.removeChild(banner);}},500);};closeButton.onclick=removeBanner;setTimeout(removeBanner,10000);}async function getFavWords(rule){if(rule.highlightWords&&rule.highlightWords!==OPT_HIGHLIGHT_WORDS_DISABLE){try{return Object.keys(await storage_getWordsWithDefault());}catch(err){logger.info("get fav words",err);}}return[];}/** * 入口函数 - */async function run(){let isUserscript=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;try{var _document,_document$contentType;// if (document?.documentElement?.tagName?.toUpperCase() !== "HTML") { + */async function run(){let isUserscript=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;try{var _document,_document$contentType,_document2,_document2$location;// 读取设置信息 +const setting=await storage_getSettingWithDefault();// 日志 +logger.setLevel(setting.logLevel);// if (document?.documentElement?.tagName?.toUpperCase() !== "HTML") { // return; // } -if(!((_document=document)!==null&&_document!==void 0&&(_document$contentType=_document.contentType)!==null&&_document$contentType!==void 0&&_document$contentType.includes("text"))){return;}// 读取设置信息 -const setting=await storage_getSettingWithDefault();// 日志 -logger.setLevel(setting.logLevel);const href=document.location.href;// 设置页面 +const contentType=((_document=document)===null||_document===void 0?void 0:(_document$contentType=_document.contentType)===null||_document$contentType===void 0?void 0:_document$contentType.toLowerCase())||"";if(!contentType.includes("text")&&!contentType.includes("html")){logger.info("Skip running in document content type: ",contentType);return;}const href=((_document2=document)===null||_document2===void 0?void 0:(_document2$location=_document2.location)===null||_document2$location===void 0?void 0:_document2$location.href)||"";// 设置页面 if(isUserscript&&(href.includes("http://localhost:3000/options.html")||href.includes("https://fishjar.github.io/kiss-translator/options.html"))){runSettingPage();return;}// 黑名单 if(isInBlacklist(href,setting)){return;}// 翻译网页 const rule=await matchRule(href,setting);const favWords=await getFavWords(rule);const fabConfig=await getFabWithDefault();const translatorManager=new TranslatorManager({setting,rule,fabConfig,favWords,isIframe: isIframe,isUserscript});translatorManager.start();if(isIframe){return;}// 字幕翻译 diff --git a/main.js b/main.js index d3f0b75..9e8b9a5 100644 --- a/main.js +++ b/main.js @@ -34881,7 +34881,7 @@ function objectWithoutProperties_objectWithoutProperties(source, excluded) { const Fetch_excluded=(/* unused pure expression or super */ null && (["execute"])),Fetch_excluded2=["execute"],Fetch_excluded3=["get"];const useAsync=()=>{const[data,setData]=(0,react.useState)(null);const[loading,setLoading]=(0,react.useState)(false);const[error,setError]=(0,react.useState)(null);const execute=(0,react.useCallback)(async function(fn){if(!fn){return;}setLoading(true);setError(null);try{for(var _len=arguments.length,args=new Array(_len>1?_len-1:0),_key=1;_key<_len;_key++){args[_key-1]=arguments[_key];}const res=await fn(...args);setData(res);setLoading(false);return res;}catch(err){setError((err===null||err===void 0?void 0:err.message)||"An unknown error occurred");setLoading(false);// throw err; }},[]);const reset=(0,react.useCallback)(()=>{setData(null);setLoading(false);setError(null);},[]);return{data,loading,error,execute,reset};};const useAsyncNow=(fn,arg)=>{const _useAsync=useAsync(),{execute}=_useAsync,asyncState=_objectWithoutProperties(_useAsync,Fetch_excluded);useEffect(()=>{if(fn){execute(fn,arg);}},[execute,fn,arg]);return _objectSpread({},asyncState);};const useFetch=()=>{const _useAsync2=useAsync(),{execute}=_useAsync2,asyncState=objectWithoutProperties_objectWithoutProperties(_useAsync2,Fetch_excluded2);const requester=(0,react.useCallback)(async(url,options)=>{var _response$headers$get;const response=await fetch(url,options);if(!response.ok){const errorInfo=await response.text();throw new Error("Request failed: ".concat(response.status," ").concat(response.statusText," - ").concat(errorInfo));}if(response.status===204){return null;}if((_response$headers$get=response.headers.get("Content-Type"))!==null&&_response$headers$get!==void 0&&_response$headers$get.includes("json")){return response.json();}return response.text();},[]);const get=(0,react.useCallback)(async function(url){let options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};try{const result=await execute(requester,url,_objectSpread2(_objectSpread2({},options),{},{method:"GET"}));return result;}catch(err){return null;}},[execute,requester]);const post=(0,react.useCallback)(async function(url,body){let options=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};try{const result=await execute(requester,url,_objectSpread2(_objectSpread2({},options),{},{method:"POST",headers:_objectSpread2({"Content-Type":"application/json"},options.headers),body:JSON.stringify(body)}));return result;}catch(err){return null;}},[execute,requester]);const put=(0,react.useCallback)(async function(url,body){let options=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};try{const result=await execute(requester,url,_objectSpread2(_objectSpread2({},options),{},{method:"PUT",headers:_objectSpread2({"Content-Type":"application/json"},options.headers),body:JSON.stringify(body)}));return result;}catch(err){return null;}},[execute,requester]);const del=(0,react.useCallback)(async function(url){let options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};try{const result=await execute(requester,url,_objectSpread2(_objectSpread2({},options),{},{method:"DELETE"}));return result;}catch(err){return null;}},[execute,requester]);return _objectSpread2(_objectSpread2({},asyncState),{},{get,post,put,del});};const useGet=url=>{const _useFetch=useFetch(),{get}=_useFetch,fetchState=objectWithoutProperties_objectWithoutProperties(_useFetch,Fetch_excluded3);(0,react.useEffect)(()=>{if(url)get(url);},[url,get]);return _objectSpread2({},fetchState);}; ;// CONCATENATED MODULE: ./src/config/app.js -const APP_NAME="KISS Translator".trim().split(/\s+/).join("-");const APP_LCNAME=APP_NAME.toLowerCase();const APP_UPNAME=APP_NAME.toUpperCase();const APP_CONSTS={fabID:"".concat(APP_LCNAME,"-fab"),boxID:"".concat(APP_LCNAME,"-box"),popupID:"".concat(APP_LCNAME,"-popup")};const APP_VERSION="2.0.10".split(".");const THEME_LIGHT="light";const THEME_DARK="dark"; +const APP_NAME="KISS Translator".trim().split(/\s+/).join("-");const APP_LCNAME=APP_NAME.toLowerCase();const APP_UPNAME=APP_NAME.toUpperCase();const APP_CONSTS={fabID:"".concat(APP_LCNAME,"-fab"),boxID:"".concat(APP_LCNAME,"-box"),popupID:"".concat(APP_LCNAME,"-popup")};const APP_VERSION="2.0.11".split(".");const THEME_LIGHT="light";const THEME_DARK="dark"; ;// CONCATENATED MODULE: ./src/config/api.js const DEFAULT_HTTP_TIMEOUT=10000;// 调用超时时间 const DEFAULT_FETCH_LIMIT=10;// 默认最大任务数量 @@ -35217,7 +35217,7 @@ const CLIENT_WEB="web";const CLIENT_CHROME="chrome";const CLIENT_EDGE="edge";con ;// CONCATENATED MODULE: ./src/config/index.js ;// CONCATENATED MODULE: ./src/index.js -function App(){var _I18N$about_md;const[lang,setLang]=(0,react.useState)("zh");const{data,loading,error}=useGet("".concat(URL_RAW_PREFIX,"/").concat(I18N===null||I18N===void 0?void 0:(_I18N$about_md=I18N["about_md"])===null||_I18N$about_md===void 0?void 0:_I18N$about_md[lang]));return/*#__PURE__*/(0,jsx_runtime.jsxs)(Paper_Paper,{sx:{padding:2,margin:2},children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Stack_Stack,{spacing:2,direction:"row",justifyContent:"flex-end",children:/*#__PURE__*/(0,jsx_runtime.jsx)(Button_Button,{variant:"text",onClick:()=>{setLang(pre=>pre==="zh"?"en":"zh");},children:lang==="zh"?"ENGLISH":"中文"})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Divider_Divider,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(Link_Link,{href:"https://github.com/fishjar/kiss-translator",children:"KISS Translator v".concat("2.0.10")})}),/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{spacing:2,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Link_Link,{href:"https://fishjar.github.io/kiss-translator/kiss-translator.user.js",children:"Install/Update Userscript for Tampermonkey/Violentmonkey"}),/*#__PURE__*/(0,jsx_runtime.jsx)(Link_Link,{href:"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js",children:"Install/Update Userscript for iOS Safari"}),/*#__PURE__*/(0,jsx_runtime.jsx)(Link_Link,{href:"https://fishjar.github.io/kiss-translator/options.html",children:"Open Options Page"})]}),loading?/*#__PURE__*/(0,jsx_runtime.jsx)("center",{children:/*#__PURE__*/(0,jsx_runtime.jsx)(CircularProgress_CircularProgress,{})}):/*#__PURE__*/(0,jsx_runtime.jsx)(ReactMarkdown,{children:error||data})]});}const src_root=client.createRoot(document.getElementById("root"));src_root.render(/*#__PURE__*/(0,jsx_runtime.jsx)(react.StrictMode,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(App,{})})); +function App(){var _I18N$about_md;const[lang,setLang]=(0,react.useState)("zh");const{data,loading,error}=useGet("".concat(URL_RAW_PREFIX,"/").concat(I18N===null||I18N===void 0?void 0:(_I18N$about_md=I18N["about_md"])===null||_I18N$about_md===void 0?void 0:_I18N$about_md[lang]));return/*#__PURE__*/(0,jsx_runtime.jsxs)(Paper_Paper,{sx:{padding:2,margin:2},children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Stack_Stack,{spacing:2,direction:"row",justifyContent:"flex-end",children:/*#__PURE__*/(0,jsx_runtime.jsx)(Button_Button,{variant:"text",onClick:()=>{setLang(pre=>pre==="zh"?"en":"zh");},children:lang==="zh"?"ENGLISH":"中文"})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Divider_Divider,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(Link_Link,{href:"https://github.com/fishjar/kiss-translator",children:"KISS Translator v".concat("2.0.11")})}),/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{spacing:2,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Link_Link,{href:"https://fishjar.github.io/kiss-translator/kiss-translator.user.js",children:"Install/Update Userscript for Tampermonkey/Violentmonkey"}),/*#__PURE__*/(0,jsx_runtime.jsx)(Link_Link,{href:"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js",children:"Install/Update Userscript for iOS Safari"}),/*#__PURE__*/(0,jsx_runtime.jsx)(Link_Link,{href:"https://fishjar.github.io/kiss-translator/options.html",children:"Open Options Page"})]}),loading?/*#__PURE__*/(0,jsx_runtime.jsx)("center",{children:/*#__PURE__*/(0,jsx_runtime.jsx)(CircularProgress_CircularProgress,{})}):/*#__PURE__*/(0,jsx_runtime.jsx)(ReactMarkdown,{children:error||data})]});}const src_root=client.createRoot(document.getElementById("root"));src_root.render(/*#__PURE__*/(0,jsx_runtime.jsx)(react.StrictMode,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(App,{})})); })(); /******/ })() diff --git a/manifest.firefox.json b/manifest.firefox.json index 3a70a64..f0bb0e9 100644 --- a/manifest.firefox.json +++ b/manifest.firefox.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "__MSG_app_name__", "description": "__MSG_app_description__", - "version": "2.0.10", + "version": "2.0.11", "default_locale": "en", "author": "Gabe", "homepage_url": "https://github.com/fishjar/kiss-translator", diff --git a/manifest.json b/manifest.json index 4b3be20..db3d670 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 3, "name": "__MSG_app_name__", "description": "__MSG_app_description__", - "version": "2.0.10", + "version": "2.0.11", "default_locale": "en", "author": "Gabe", "homepage_url": "https://github.com/fishjar/kiss-translator", diff --git a/manifest.thunderbird.json b/manifest.thunderbird.json index 76d1ab8..2e647f2 100644 --- a/manifest.thunderbird.json +++ b/manifest.thunderbird.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "__MSG_app_name__", "description": "__MSG_app_description__", - "version": "2.0.10", + "version": "2.0.11", "default_locale": "en", "author": "Gabe", "homepage_url": "https://github.com/fishjar/kiss-translator", diff --git a/options.js b/options.js index aaf2637..0d763cc 100644 --- a/options.js +++ b/options.js @@ -55599,7 +55599,7 @@ const Alert = /*#__PURE__*/react.forwardRef(function Alert(inProps, ref) { false ? 0 : void 0; /* harmony default export */ const Alert_Alert = (Alert); ;// CONCATENATED MODULE: ./src/config/app.js -const APP_NAME="KISS Translator".trim().split(/\s+/).join("-");const APP_LCNAME=APP_NAME.toLowerCase();const APP_UPNAME=APP_NAME.toUpperCase();const APP_CONSTS={fabID:"".concat(APP_LCNAME,"-fab"),boxID:"".concat(APP_LCNAME,"-box"),popupID:"".concat(APP_LCNAME,"-popup")};const APP_VERSION="2.0.10".split(".");const THEME_LIGHT="light";const THEME_DARK="dark"; +const APP_NAME="KISS Translator".trim().split(/\s+/).join("-");const APP_LCNAME=APP_NAME.toLowerCase();const APP_UPNAME=APP_NAME.toUpperCase();const APP_CONSTS={fabID:"".concat(APP_LCNAME,"-fab"),boxID:"".concat(APP_LCNAME,"-box"),popupID:"".concat(APP_LCNAME,"-popup")};const APP_VERSION="2.0.11".split(".");const THEME_LIGHT="light";const THEME_DARK="dark"; ;// CONCATENATED MODULE: ./src/config/api.js const DEFAULT_HTTP_TIMEOUT=10000;// 调用超时时间 const DEFAULT_FETCH_LIMIT=10;// 默认最大任务数量 @@ -56933,7 +56933,7 @@ keyfrom:"webdict"});const init={headers:{accept:"application/json, text/plain, * * @param {*} param0 * @returns */const apiTranslate=async _ref2=>{let{text,fromLang="auto",toLang,apiSetting=DEFAULT_API_SETTING,docInfo={},glossary,useCache=true,usePool=true}=_ref2;if(!text){throw new Error("The text cannot be empty.");}const{apiType,apiSlug,useBatchFetch}=apiSetting;const langMap=OPT_LANGS_TO_SPEC[apiType]||OPT_LANGS_SPEC_DEFAULT;const from=langMap.get(fromLang);const to=langMap.get(toLang);if(!to){throw new Error("The target lang: ".concat(toLang," not support"));}// todo: 优化缓存失效因素 -const[v1,v2]="2.0.10".split(".");const cacheOpts={apiSlug,text,fromLang,toLang,version:[v1,v2].join(".")};const cacheInput="".concat(URL_CACHE_TRAN,"?").concat(query_string.stringify(cacheOpts));// 查询缓存数据 +const[v1,v2]="2.0.11".split(".");const cacheOpts={apiSlug,text,fromLang,toLang,version:[v1,v2].join(".")};const cacheInput="".concat(URL_CACHE_TRAN,"?").concat(query_string.stringify(cacheOpts));// 查询缓存数据 if(useCache){const cache=await cache_getHttpCachePolyfill(cacheInput);if(cache!==null&&cache!==void 0&&cache.trText){return cache;}}// 请求接口数据 let tranlation=[];if(apiType===OPT_TRANS_BUILTINAI){tranlation=await apiBuiltinAITranslate({text,from,to,apiSetting});}else if(useBatchFetch&&API_SPE_TYPES.batch.has(apiType)){const{apiSlug,batchInterval,batchSize,batchLength}=apiSetting;const key="".concat(apiSlug,"_").concat(fromLang,"_").concat(toLang);const queue=getBatchQueue(key,handleTranslate,{batchInterval,batchSize,batchLength});tranlation=await queue.addTask(text,{from,to,fromLang,toLang,langMap,docInfo,glossary,apiSetting,usePool});}else{[tranlation]=await handleTranslate([text],{from,to,fromLang,toLang,langMap,docInfo,glossary,apiSetting,usePool});}let trText="";let srLang="";let srCode="";if(Array.isArray(tranlation)){[trText,srLang=""]=tranlation;if(srLang){srCode=OPT_LANGS_TO_CODE[apiType].get(srLang)||"";}}else if(typeof tranlation==="string"){trText=tranlation;}if(!trText){throw new Error("tanslate api got empty trtext");}const isSame=fromLang==="auto"&&srLang===to;// 插入缓存 if(useCache){cache_putHttpCachePolyfill(cacheInput,null,{trText,isSame,srLang,srCode});}return{trText,srLang,srCode,isSame};};// 字幕处理/翻译 @@ -59750,7 +59750,7 @@ var n = {}; return t.length === e && "." !== t && ".." !== t; }; }, - te = "object" === ("undefined" == typeof process ? "undefined" : Nt(process)) && process ? "object" === Nt(({"NODE_ENV":"production","PUBLIC_URL":"","WDS_SOCKET_HOST":undefined,"WDS_SOCKET_PATH":undefined,"WDS_SOCKET_PORT":undefined,"FAST_REFRESH":true,"REACT_APP_CLIENT":"userscript","REACT_APP_NAME":"KISS Translator","REACT_APP_NAME_CN":"简约翻译","REACT_APP_VERSION":"2.0.10","REACT_APP_HOMEPAGE":"https://github.com/fishjar/kiss-translator","REACT_APP_OPTIONSPAGE":"https://fishjar.github.io/kiss-translator/options.html","REACT_APP_OPTIONSPAGE_DEV":"http://localhost:3000/options.html","REACT_APP_LOGOURL":"https://fishjar.github.io/kiss-translator/images/logo192.png","REACT_APP_RULESURL":"https://fishjar.github.io/kiss-rules/kiss-rules_v2.json","REACT_APP_RULESURL_ON":"https://fishjar.github.io/kiss-rules/kiss-rules-on_v2.json","REACT_APP_RULESURL_OFF":"https://fishjar.github.io/kiss-rules/kiss-rules-off_v2.json","REACT_APP_USERSCRIPT_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator.user.js","REACT_APP_USERSCRIPT_IOS_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js"})) && ({"NODE_ENV":"production","PUBLIC_URL":"","WDS_SOCKET_HOST":undefined,"WDS_SOCKET_PATH":undefined,"WDS_SOCKET_PORT":undefined,"FAST_REFRESH":true,"REACT_APP_CLIENT":"userscript","REACT_APP_NAME":"KISS Translator","REACT_APP_NAME_CN":"简约翻译","REACT_APP_VERSION":"2.0.10","REACT_APP_HOMEPAGE":"https://github.com/fishjar/kiss-translator","REACT_APP_OPTIONSPAGE":"https://fishjar.github.io/kiss-translator/options.html","REACT_APP_OPTIONSPAGE_DEV":"http://localhost:3000/options.html","REACT_APP_LOGOURL":"https://fishjar.github.io/kiss-translator/images/logo192.png","REACT_APP_RULESURL":"https://fishjar.github.io/kiss-rules/kiss-rules_v2.json","REACT_APP_RULESURL_ON":"https://fishjar.github.io/kiss-rules/kiss-rules-on_v2.json","REACT_APP_RULESURL_OFF":"https://fishjar.github.io/kiss-rules/kiss-rules-off_v2.json","REACT_APP_USERSCRIPT_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator.user.js","REACT_APP_USERSCRIPT_IOS_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js"}) && ({"NODE_ENV":"production","PUBLIC_URL":"","WDS_SOCKET_HOST":undefined,"WDS_SOCKET_PATH":undefined,"WDS_SOCKET_PORT":undefined,"FAST_REFRESH":true,"REACT_APP_CLIENT":"userscript","REACT_APP_NAME":"KISS Translator","REACT_APP_NAME_CN":"简约翻译","REACT_APP_VERSION":"2.0.10","REACT_APP_HOMEPAGE":"https://github.com/fishjar/kiss-translator","REACT_APP_OPTIONSPAGE":"https://fishjar.github.io/kiss-translator/options.html","REACT_APP_OPTIONSPAGE_DEV":"http://localhost:3000/options.html","REACT_APP_LOGOURL":"https://fishjar.github.io/kiss-translator/images/logo192.png","REACT_APP_RULESURL":"https://fishjar.github.io/kiss-rules/kiss-rules_v2.json","REACT_APP_RULESURL_ON":"https://fishjar.github.io/kiss-rules/kiss-rules-on_v2.json","REACT_APP_RULESURL_OFF":"https://fishjar.github.io/kiss-rules/kiss-rules-off_v2.json","REACT_APP_USERSCRIPT_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator.user.js","REACT_APP_USERSCRIPT_IOS_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js"}).__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix"; + te = "object" === ("undefined" == typeof process ? "undefined" : Nt(process)) && process ? "object" === Nt(({"NODE_ENV":"production","PUBLIC_URL":"","WDS_SOCKET_HOST":undefined,"WDS_SOCKET_PATH":undefined,"WDS_SOCKET_PORT":undefined,"FAST_REFRESH":true,"REACT_APP_CLIENT":"userscript","REACT_APP_NAME":"KISS Translator","REACT_APP_NAME_CN":"简约翻译","REACT_APP_VERSION":"2.0.11","REACT_APP_HOMEPAGE":"https://github.com/fishjar/kiss-translator","REACT_APP_OPTIONSPAGE":"https://fishjar.github.io/kiss-translator/options.html","REACT_APP_OPTIONSPAGE_DEV":"http://localhost:3000/options.html","REACT_APP_LOGOURL":"https://fishjar.github.io/kiss-translator/images/logo192.png","REACT_APP_RULESURL":"https://fishjar.github.io/kiss-rules/kiss-rules_v2.json","REACT_APP_RULESURL_ON":"https://fishjar.github.io/kiss-rules/kiss-rules-on_v2.json","REACT_APP_RULESURL_OFF":"https://fishjar.github.io/kiss-rules/kiss-rules-off_v2.json","REACT_APP_USERSCRIPT_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator.user.js","REACT_APP_USERSCRIPT_IOS_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js"})) && ({"NODE_ENV":"production","PUBLIC_URL":"","WDS_SOCKET_HOST":undefined,"WDS_SOCKET_PATH":undefined,"WDS_SOCKET_PORT":undefined,"FAST_REFRESH":true,"REACT_APP_CLIENT":"userscript","REACT_APP_NAME":"KISS Translator","REACT_APP_NAME_CN":"简约翻译","REACT_APP_VERSION":"2.0.11","REACT_APP_HOMEPAGE":"https://github.com/fishjar/kiss-translator","REACT_APP_OPTIONSPAGE":"https://fishjar.github.io/kiss-translator/options.html","REACT_APP_OPTIONSPAGE_DEV":"http://localhost:3000/options.html","REACT_APP_LOGOURL":"https://fishjar.github.io/kiss-translator/images/logo192.png","REACT_APP_RULESURL":"https://fishjar.github.io/kiss-rules/kiss-rules_v2.json","REACT_APP_RULESURL_ON":"https://fishjar.github.io/kiss-rules/kiss-rules-on_v2.json","REACT_APP_RULESURL_OFF":"https://fishjar.github.io/kiss-rules/kiss-rules-off_v2.json","REACT_APP_USERSCRIPT_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator.user.js","REACT_APP_USERSCRIPT_IOS_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js"}) && ({"NODE_ENV":"production","PUBLIC_URL":"","WDS_SOCKET_HOST":undefined,"WDS_SOCKET_PATH":undefined,"WDS_SOCKET_PORT":undefined,"FAST_REFRESH":true,"REACT_APP_CLIENT":"userscript","REACT_APP_NAME":"KISS Translator","REACT_APP_NAME_CN":"简约翻译","REACT_APP_VERSION":"2.0.11","REACT_APP_HOMEPAGE":"https://github.com/fishjar/kiss-translator","REACT_APP_OPTIONSPAGE":"https://fishjar.github.io/kiss-translator/options.html","REACT_APP_OPTIONSPAGE_DEV":"http://localhost:3000/options.html","REACT_APP_LOGOURL":"https://fishjar.github.io/kiss-translator/images/logo192.png","REACT_APP_RULESURL":"https://fishjar.github.io/kiss-rules/kiss-rules_v2.json","REACT_APP_RULESURL_ON":"https://fishjar.github.io/kiss-rules/kiss-rules-on_v2.json","REACT_APP_RULESURL_OFF":"https://fishjar.github.io/kiss-rules/kiss-rules-off_v2.json","REACT_APP_USERSCRIPT_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator.user.js","REACT_APP_USERSCRIPT_IOS_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js"}).__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix"; It.sep = "win32" === te ? "\\" : "/"; var ee = Symbol("globstar **"); It.GLOBSTAR = ee; @@ -62135,7 +62135,7 @@ Divider.muiSkipListHighlight = true; false ? 0 : void 0; /* harmony default export */ const Divider_Divider = (Divider); ;// CONCATENATED MODULE: ./src/hooks/Loading.js -function Loading(){return/*#__PURE__*/(0,jsx_runtime.jsxs)("center",{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Divider_Divider,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(material_Link_Link,{href:"https://github.com/fishjar/kiss-translator",children:"KISS Translator v".concat("2.0.10")})}),/*#__PURE__*/(0,jsx_runtime.jsx)(CircularProgress_CircularProgress,{})]});} +function Loading(){return/*#__PURE__*/(0,jsx_runtime.jsxs)("center",{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Divider_Divider,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(material_Link_Link,{href:"https://github.com/fishjar/kiss-translator",children:"KISS Translator v".concat("2.0.11")})}),/*#__PURE__*/(0,jsx_runtime.jsx)(CircularProgress_CircularProgress,{})]});} ;// CONCATENATED MODULE: ./src/hooks/Setting.js const SettingContext=/*#__PURE__*/(0,react.createContext)({setting:setting_DEFAULT_SETTING,updateSetting:()=>{},reloadSetting:()=>{}});function SettingProvider(_ref){let{children,isSettingPage}=_ref;const{data:setting,isLoading,update,reload}=useStorage(storage_STOKEY_SETTING,setting_DEFAULT_SETTING,isSettingPage?KV_SETTING_KEY:"");(0,react.useEffect)(()=>{if(typeof(setting===null||setting===void 0?void 0:setting.darkMode)==="boolean"){update(currentSetting=>_objectSpread2(_objectSpread2({},currentSetting),{},{darkMode:currentSetting.darkMode?"dark":"light"}));}},[setting===null||setting===void 0?void 0:setting.darkMode,update]);(0,react.useEffect)(()=>{if(!isSettingPage)return;(async()=>{try{logger.setLevel(setting===null||setting===void 0?void 0:setting.logLevel);if(client_isExt){await msg_sendBgMsg(MSG_SET_LOGLEVEL,setting===null||setting===void 0?void 0:setting.logLevel);}}catch(error){logger.error("Failed to fetch log level, using default.",error);}})();},[isSettingPage,setting===null||setting===void 0?void 0:setting.logLevel]);const updateSetting=(0,react.useCallback)(objOrFn=>{update(objOrFn);debounceSyncMeta(KV_SETTING_KEY);},[update]);const updateChild=(0,react.useCallback)(key=>async obj=>{updateSetting(prev=>_objectSpread2(_objectSpread2({},prev),{},{[key]:_objectSpread2(_objectSpread2({},(prev===null||prev===void 0?void 0:prev[key])||{}),obj)}));},[updateSetting]);const value=(0,react.useMemo)(()=>({setting,updateSetting,updateChild,reloadSetting:reload}),[setting,updateSetting,updateChild,reload]);if(isLoading){return/*#__PURE__*/(0,jsx_runtime.jsx)(Loading,{});}if(!setting){/*#__PURE__*/(0,jsx_runtime.jsx)("center",{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(Alert_Alert,{severity:"error",sx:{maxWidth:600,margin:"60px auto"},children:[/*#__PURE__*/(0,jsx_runtime.jsx)("p",{children:"\u6570\u636E\u52A0\u8F7D\u51FA\u9519\uFF0C\u8BF7\u5237\u65B0\u9875\u9762\u6216\u5378\u8F7D\u540E\u91CD\u65B0\u5B89\u88C5\u3002"}),/*#__PURE__*/(0,jsx_runtime.jsx)("p",{children:"Data loading error, please refresh the page or uninstall and reinstall."})]})});}return/*#__PURE__*/(0,jsx_runtime.jsx)(SettingContext.Provider,{value:value,children:children});}/** * 设置 hook @@ -76582,7 +76582,7 @@ var BrightnessAuto = __webpack_require__(4080); ;// CONCATENATED MODULE: ./src/views/Options/DarkModeButton.js function DarkModeButton(){const{darkMode,toggleDarkMode}=useDarkMode();return/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{sx:{ml:1},onClick:toggleDarkMode,color:"inherit",children:darkMode==="dark"?/*#__PURE__*/(0,jsx_runtime.jsx)(DarkMode/* default */.Z,{}):darkMode==="light"?/*#__PURE__*/(0,jsx_runtime.jsx)(LightMode/* default */.Z,{}):/*#__PURE__*/(0,jsx_runtime.jsx)(BrightnessAuto/* default */.Z,{})});} ;// CONCATENATED MODULE: ./src/views/Options/Header.js -function Header(props){const i18n=useI18n();const{onDrawerToggle}=props;return/*#__PURE__*/(0,jsx_runtime.jsx)(AppBar_AppBar,{color:"primary",position:"sticky",sx:{zIndex:1300},children:/*#__PURE__*/(0,jsx_runtime.jsxs)(Toolbar_Toolbar,{variant:"dense",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Box_Box,{sx:{display:{sm:"none",xs:"block"}},children:/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{color:"inherit","aria-label":"open drawer",onClick:onDrawerToggle,edge:"start",children:/*#__PURE__*/(0,jsx_runtime.jsx)(icons_material_Menu/* default */.Z,{})})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{component:"div",sx:{flexGrow:1,fontWeight:"bold"},children:/*#__PURE__*/(0,jsx_runtime.jsx)(material_Link_Link,{underline:"none",color:"inherit",href:"https://github.com/fishjar/kiss-translator",target:"_blank",children:"".concat(i18n("app_name")," v").concat("2.0.10")})}),/*#__PURE__*/(0,jsx_runtime.jsx)(DarkModeButton,{})]})});}/* harmony default export */ const Options_Header = (Header); +function Header(props){const i18n=useI18n();const{onDrawerToggle}=props;return/*#__PURE__*/(0,jsx_runtime.jsx)(AppBar_AppBar,{color:"primary",position:"sticky",sx:{zIndex:1300},children:/*#__PURE__*/(0,jsx_runtime.jsxs)(Toolbar_Toolbar,{variant:"dense",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Box_Box,{sx:{display:{sm:"none",xs:"block"}},children:/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{color:"inherit","aria-label":"open drawer",onClick:onDrawerToggle,edge:"start",children:/*#__PURE__*/(0,jsx_runtime.jsx)(icons_material_Menu/* default */.Z,{})})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{component:"div",sx:{flexGrow:1,fontWeight:"bold"},children:/*#__PURE__*/(0,jsx_runtime.jsx)(material_Link_Link,{underline:"none",color:"inherit",href:"https://github.com/fishjar/kiss-translator",target:"_blank",children:"".concat(i18n("app_name")," v").concat("2.0.11")})}),/*#__PURE__*/(0,jsx_runtime.jsx)(DarkModeButton,{})]})});}/* harmony default export */ const Options_Header = (Header); ;// CONCATENATED MODULE: ./src/views/Options/Layout.js function Layout(){const navWidth=256;const location=dist_useLocation();const theme=useTheme_useTheme();const[open,setOpen]=(0,react.useState)(false);const isSm=useMediaQuery(theme.breakpoints.up("sm"));const handleDrawerToggle=()=>{setOpen(!open);};(0,react.useEffect)(()=>{setOpen(false);},[location]);return/*#__PURE__*/(0,jsx_runtime.jsxs)(Box_Box,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(CssBaseline_CssBaseline,{}),/*#__PURE__*/(0,jsx_runtime.jsx)(Options_Header,{onDrawerToggle:handleDrawerToggle}),/*#__PURE__*/(0,jsx_runtime.jsxs)(Box_Box,{sx:{display:"flex"},children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Box_Box,{component:"nav",sx:{width:{sm:navWidth},flexShrink:{sm:0}},children:/*#__PURE__*/(0,jsx_runtime.jsx)(Navigator,{PaperProps:{style:{width:navWidth}},variant:isSm?"permanent":"temporary",open:isSm?true:open,onClose:handleDrawerToggle})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Box_Box,{component:"main",sx:{flex:1,p:2,width:"100%"},children:/*#__PURE__*/(0,jsx_runtime.jsx)(Outlet,{})})]})]});} // EXTERNAL MODULE: ./node_modules/.pnpm/@mui+icons-material@5.15.15_@mui+material@5.15.15_@emotion+react@11.11.1_@types+react@18.2.79_zdo5tzcazfyjzm354hmuezm3pe/node_modules/@mui/icons-material/ContentCopy.js @@ -76759,7 +76759,7 @@ mediaQuery.addEventListener("change",handleChange);return()=>mediaQuery.removeEv const MSG_GM_xmlHttpRequest="xmlHttpRequest";const MSG_GM_setValue="setValue";const MSG_GM_getValue="getValue";const MSG_GM_deleteValue="deleteValue";const MSG_GM_info="info";/** * 注入页面的脚本,请求并接受GM接口信息 * @param {*} param0 - */const injectScript=ping=>{window.APP_INFO={name:"KISS Translator",version:"2.0.10",eventName:ping};};/** + */const injectScript=ping=>{window.APP_INFO={name:"KISS Translator",version:"2.0.11",eventName:ping};};/** * 适配GM脚本 */const adaptScript=ping=>{const promiseGM=function(action,args){let timeout=arguments.length>2&&arguments[2]!==undefined?arguments[2]:5000;return new Promise((resolve,reject)=>{const pong=genEventName();const handleEvent=e=>{window.removeEventListener(pong,handleEvent);const{data,error}=e.detail;if(error){reject(new Error(error));}else{resolve(data);}};window.addEventListener(pong,handleEvent);window.dispatchEvent(new CustomEvent(ping,{detail:{action,args,pong}}));setTimeout(()=>{window.removeEventListener(pong,handleEvent);reject(new Error("timeout"));},timeout);});};window.KISS_GM={fetch:(input,init)=>promiseGM(MSG_GM_xmlHttpRequest,{input,init}),setValue:(key,val)=>promiseGM(MSG_GM_setValue,{key,val}),getValue:key=>promiseGM(MSG_GM_getValue,{key}),deleteValue:key=>promiseGM(MSG_GM_deleteValue,{key}),getInfo:async()=>{if(!window.GM_info){window.GM_info=await promiseGM(MSG_GM_info);}return window.GM_info;}};};/** * 监听并回应页面对GM接口的请求 @@ -81322,15 +81322,15 @@ function useSubtitle(){const{setting,updateChild}=useSetting();const subtitleSet ;// CONCATENATED MODULE: ./src/views/Options/Subtitle.js function SubtitleSetting(){const i18n=useI18n();const{subtitleSetting,updateSubtitle}=useSubtitle();const{enabledApis,aiEnabledApis}=useApiList();const handleChange=e=>{e.preventDefault();let{name,value}=e.target;updateSubtitle({[name]:value});};const{enabled,apiSlug,segSlug,chunkLength,preTrans=90,throttleTrans=30,toLang,isBilingual,skipAd=false,windowStyle,originStyle,translationStyle}=subtitleSetting;return/*#__PURE__*/(0,jsx_runtime.jsx)(Box_Box,{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{spacing:3,children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(Alert_Alert,{severity:"info",children:[i18n("subtitle_helper_1"),/*#__PURE__*/(0,jsx_runtime.jsx)("br",{}),i18n("subtitle_helper_2"),/*#__PURE__*/(0,jsx_runtime.jsx)("br",{}),i18n("subtitle_helper_3")]}),/*#__PURE__*/(0,jsx_runtime.jsx)(FormControlLabel_FormControlLabel,{control:/*#__PURE__*/(0,jsx_runtime.jsx)(Switch_Switch,{size:"small",name:"enabled",checked:enabled,onChange:()=>{updateSubtitle({enabled:!enabled});}}),label:i18n("toggle_subtitle_translate"),sx:{width:"fit-content"}}),/*#__PURE__*/(0,jsx_runtime.jsx)(Box_Box,{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(Grid_Grid,{container:true,spacing:2,columns:12,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Grid_Grid,{item:true,xs:12,sm:12,md:6,lg:3,children:/*#__PURE__*/(0,jsx_runtime.jsx)(TextField_TextField,{select:true,fullWidth:true,size:"small",name:"apiSlug",value:apiSlug,label:i18n("translate_service"),onChange:handleChange,children:enabledApis.map(api=>/*#__PURE__*/(0,jsx_runtime.jsx)(MenuItem_MenuItem,{value:api.apiSlug,children:api.apiName},api.apiSlug))})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Grid_Grid,{item:true,xs:12,sm:12,md:6,lg:3,children:/*#__PURE__*/(0,jsx_runtime.jsxs)(TextField_TextField,{select:true,fullWidth:true,size:"small",name:"segSlug",value:segSlug,label:i18n("ai_segmentation"),onChange:handleChange,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(MenuItem_MenuItem,{value:"-",children:i18n("disable")}),aiEnabledApis.map(api=>/*#__PURE__*/(0,jsx_runtime.jsx)(MenuItem_MenuItem,{value:api.apiSlug,children:api.apiName},api.apiSlug))]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Grid_Grid,{item:true,xs:12,sm:12,md:6,lg:3,children:/*#__PURE__*/(0,jsx_runtime.jsx)(hooks_ValidationInput,{fullWidth:true,size:"small",label:i18n("ai_chunk_length"),type:"number",name:"chunkLength",value:chunkLength,onChange:handleChange,min:200,max:20000})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Grid_Grid,{item:true,xs:12,sm:12,md:6,lg:3,children:/*#__PURE__*/(0,jsx_runtime.jsx)(hooks_ValidationInput,{fullWidth:true,size:"small",label:i18n("pre_trans_seconds"),type:"number",name:"preTrans",value:preTrans,onChange:handleChange,min:10,max:36000})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Grid_Grid,{item:true,xs:12,sm:12,md:6,lg:3,children:/*#__PURE__*/(0,jsx_runtime.jsx)(hooks_ValidationInput,{fullWidth:true,size:"small",label:i18n("throttle_trans_interval"),type:"number",name:"throttleTrans",value:throttleTrans,onChange:handleChange,min:1,max:3600})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Grid_Grid,{item:true,xs:12,sm:12,md:6,lg:3,children:/*#__PURE__*/(0,jsx_runtime.jsx)(TextField_TextField,{fullWidth:true,select:true,size:"small",name:"toLang",value:toLang,label:i18n("to_lang"),onChange:handleChange,children:OPT_LANGS_TO.map(_ref=>{let[lang,name]=_ref;return/*#__PURE__*/(0,jsx_runtime.jsx)(MenuItem_MenuItem,{value:lang,children:name},lang);})})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Grid_Grid,{item:true,xs:12,sm:12,md:6,lg:3,children:/*#__PURE__*/(0,jsx_runtime.jsxs)(TextField_TextField,{fullWidth:true,select:true,size:"small",name:"isBilingual",value:isBilingual,label:i18n("is_bilingual_view"),onChange:handleChange,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(MenuItem_MenuItem,{value:true,children:i18n("enable")}),/*#__PURE__*/(0,jsx_runtime.jsx)(MenuItem_MenuItem,{value:false,children:i18n("disable")})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Grid_Grid,{item:true,xs:12,sm:12,md:6,lg:3,children:/*#__PURE__*/(0,jsx_runtime.jsxs)(TextField_TextField,{fullWidth:true,select:true,size:"small",name:"skipAd",value:skipAd,label:i18n("is_skip_ad"),onChange:handleChange,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(MenuItem_MenuItem,{value:true,children:i18n("enable")}),/*#__PURE__*/(0,jsx_runtime.jsx)(MenuItem_MenuItem,{value:false,children:i18n("disable")})]})})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(TextField_TextField,{size:"small",label:i18n("origin_styles"),name:"originStyle",value:originStyle,onChange:handleChange,maxRows:10,multiline:true,fullWidth:true}),/*#__PURE__*/(0,jsx_runtime.jsx)(TextField_TextField,{size:"small",label:i18n("translation_styles"),name:"translationStyle",value:translationStyle,onChange:handleChange,maxRows:10,multiline:true,fullWidth:true}),/*#__PURE__*/(0,jsx_runtime.jsx)(TextField_TextField,{size:"small",label:i18n("background_styles"),name:"windowStyle",value:windowStyle,onChange:handleChange,maxRows:10,multiline:true,fullWidth:true})]})});} ;// CONCATENATED MODULE: ./src/config/quotes.js -const quotes=[{en:"The unexamined life is not worth living.",zh:"未经审视的人生不值得过。"},{en:"I think, therefore I am.",zh:"我思故我在。"},{en:"He who has a why to live for can bear almost any how.",zh:"知道为何而活的人,几乎能忍受任何一种生活。"},{en:"Life is what happens when you're busy making other plans.",zh:"生活就是当你忙着制定其他计划时所发生的事情。"},{en:"Get busy living or get busy dying.",zh:"要么忙着活,要么忙着死。"},{en:"We are what we repeatedly do. Excellence, then, is not an act, but a habit.",zh:"我们由我们反复做的事情构成的。因此,卓越不是一种行为,而是一种习惯。"},{en:"Man is condemned to be free.",zh:"人注定是自由的。"},{en:"To be, or not to be: that is the question.",zh:"生存还是毁灭,这是一个问题。"},{en:"The purpose of life is not to be happy. It is to be useful, to be honorable, to be compassionate, to have it make some difference that you have lived and lived well.",zh:"人生的目的不是快乐,而是有用、高尚、富有同情心,让你活过并且活得好,从而使世界有所不同。"},{en:"Life is 10% what happens to us and 90% how we react to it.",zh:"生活 10% 取决于发生在我们身上的事,90% 取决于我们如何反应。"},{en:"The two most important days in your life are the day you are born and the day you find out why.",zh:"你一生中最重要的两天是:你出生的那天和你明白你为何出生的那天。"},{en:"In three words I can sum up everything I've learned about life: it goes on.",zh:"关于人生,我所学到的一切可以总结为三个词:它在继续。"},{en:"Not all those who wander are lost.",zh:"并非所有流浪者都迷失了方向。"},{en:"Life is simple, but we insist on making it complicated.",zh:"生活本简单,但我们坚持要把它弄复杂。"},{en:"Our life is what our thoughts make it.",zh:"我们的生活是由我们的思想造成的。"},{en:"Find purpose, the means will follow.",zh:"找到目标,方法自会随之而来。"},{en:"The goal of life is living in agreement with nature.",zh:"生活的目标是与自然和谐相处。"},{en:"The only true wisdom is in knowing you know nothing.",zh:"唯一的真正智慧在于知道自己一无所有。"},{en:"Knowledge is power.",zh:"知识就是力量。"},{en:"Knowing yourself is the beginning of all wisdom.",zh:"了解自己是所有智慧的开端。"},{en:"The journey of a thousand miles begins with a single step.",zh:"千里之行,始于足下。"},{en:"The only source of knowledge is experience.",zh:"知识的唯一来源是经验。"},{en:"A fool thinks himself to be wise, but a wise man knows himself to be a fool.",zh:"愚者自以为聪明,智者自知愚蠢。"},{en:"We learn from failure, not from success!",zh:"我们从失败中学习,而不是从成功中!"},{en:"The wise man is one who knows what he does not know.",zh:"智者,知其所不知。"},{en:"To know that we know what we know, and that we do not know what we do not know, that is true knowledge.",zh:"知之为知之,不知为不知,是知也。"},{en:"Curiosity is the wick in the candle of learning.",zh:"好奇心是学习这支蜡烛的灯芯。"},{en:"It is the mark of an educated mind to be able to entertain a thought without accepting it.",zh:"能够容纳一种思想而不同意它,这是一个受过教育的头脑的标志。"},{en:"Never stop questioning.",zh:"永远不要停止提问。"},{en:"The man who asks a question is a fool for a minute, the man who does not ask is a fool for life.",zh:"问问题的人,只傻一分钟;不问的人,傻一生。"},{en:"Wisdom is not a product of schooling but of the lifelong attempt to acquire it.",zh:"智慧不是学校教育的产物,而是终生努力获得的产物。"},{en:"The greatest enemy of knowledge is not ignorance, it is the illusion of knowledge.",zh:"知识最大的敌人不是无知,而是自以为拥有知识的幻觉。"},{en:"True wisdom comes to each of us when we realize how little we understand about life, ourselves, and the world around us.",zh:"当我们认识到自己对生命、对自身、对周围世界了解得多么少时,真正的智慧才会降临到我们每个人身上。"},{en:"Beware of false knowledge; it is more dangerous than ignorance.",zh:"谨防虚假的知识;它比无知更危险。"},{en:"What does not kill me makes me stronger.",zh:"杀不死我的,使我更强大。"},{en:"The only constant in life is change.",zh:"生活中唯一不变的就是变化。"},{en:"If you are going through hell, keep going.",zh:"如果你正在经历地狱,那就继续走下去。"},{en:"In the middle of difficulty lies opportunity.",zh:"机会蕴藏在困难之中。"},{en:"It is not the strongest of the species that survive, nor the most intelligent, but the one most responsive to change.",zh:"存活下来的物种不是最强壮的,也不是最聪明的,而是最能适应变化的。"},{en:"We must become the change we wish to see in the world.",zh:"我们必须成为我们希望在世界上看到的改变。"},{en:"A smooth sea never made a skilled sailor.",zh:"平静的大海练不出熟练的水手。"},{en:"Obstacles don't block the path, they are the path.",zh:"障碍不是挡住了路,障碍本身就是路。"},{en:"Fall seven times, stand up eight.",zh:"七次跌倒,八次站起。"},{en:"The art of life lies in a constant readjustment to our surroundings.",zh:"生活的艺术在于不断地调整自己以适应环境。"},{en:"Adversity introduces a man to himself.",zh:"逆境使人认识自己。"},{en:"The wound is the place where the Light enters you.",zh:"伤口是光进入你内心的入口。"},{en:"When we are no longer able to change a situation, we are challenged to change ourselves.",zh:"当我们无法改变现状时,我们就需要改变自己。"},{en:"Be the change you wish to see in the world.",zh:"成为你希望在世界上看到的改变。"},{en:"Do not pray for an easy life, pray for the strength to endure a difficult one.",zh:"不要祈祷生活安逸,要祈祷有力量去忍受艰难的生活。"},{en:"A pessimist sees the difficulty in every opportunity; an optimist sees the opportunity in every difficulty.",zh:"悲观者在每个机会中都看到困难;乐观者在每个困难中都看到机会。"},{en:"It's not what happens to you, but how you react to it that matters.",zh:"重要的不是发生在你身上的事,而是你如何应对它。"},{en:"To love oneself is the beginning of a lifelong romance.",zh:"爱自己是终身浪漫的开始。"},{en:"Love is composed of a single soul inhabiting two bodies.",zh:"爱是栖息于两个身体中的同一个灵魂。"},{en:"Man is the measure of all things.",zh:"人是万物的尺度。"},{en:"The best and most beautiful things in this world cannot be seen or even heard, but must be felt with the heart.",zh:"世界上最好最美的东西是看不见也听不见的,必须用心去感受。"},{en:"Where there is love there is life.",zh:"有爱的地方就有生命。"},{en:"If you want to be loved, be lovable.",zh:"如果你想被爱,就要变得可爱。"},{en:"We are all in the gutter, but some of us are looking at the stars.",zh:"我们都身处沟渠,但仍有人仰望星空。"},{en:"The only thing we have to fear is fear itself.",zh:"我们唯一需要恐惧的就是恐惧本身。"},{en:"Be kind, for everyone you meet is fighting a hard battle.",zh:"要友善,因为你遇到的每个人都在打一场艰苦的战斗。"},{en:"Man is born free, and everywhere he is in chains.",zh:"人生而自由,却无往不在枷锁之中。"},{en:"We love the things we love for what they are.",zh:"我们爱我们所爱之物,只因它们本来的样子。"},{en:"Darkness cannot drive out darkness; only light can do that. Hate cannot drive out hate; only love can do that.",zh:"黑暗无法驱逐黑暗,只有光明可以;仇恨无法驱逐仇恨,只有爱可以。"},{en:"An eye for an eye only ends up making the whole world blind.",zh:"以眼还眼,只会让整个世界都盲目。"},{en:"Hell is other people.",zh:"他人即地狱。"},{en:"You will not be punished for your anger, you will be punished by your anger.",zh:"你不会因为你的愤怒而受到惩罚,你会被你的愤怒所惩罚。"},{en:"To err is human, to forgive divine.",zh:"犯错是人性,宽恕是神性。"},{en:"Man is the only creature who refuses to be what he is.",zh:"人是唯一拒绝承认自己本质的生物。"},{en:"Beauty is in the eye of the beholder.",zh:"情人眼里出西施。"},{en:"All that we see or seem is but a dream within a dream.",zh:"我们所见所感,皆如梦中之梦。"},{en:"Everything you can imagine is real.",zh:"你能想象的一切都是真实的。"},{en:"The map is not the territory.",zh:"地图并非领土。"},{en:"We don't see things as they are, we see them as we are.",zh:"我们看到的不是事物的原貌,而是我们自己的样子。"},{en:"There are two ways to be fooled. One is to believe what isn't true; the other is to refuse to believe what is true.",zh:"被愚弄有两种方式。一种是相信不真实的东西;另一种是拒绝相信真实的东西。"},{en:"Simplicity is the ultimate sophistication.",zh:"简约是极致的复杂。"},{en:"The truth will set you free.",zh:"真相将使你自由。"},{en:"Reality is merely an illusion, albeit a very persistent one.",zh:"现实只是一种幻觉,尽管是一种非常持久的幻觉。"},{en:"What is rational is actual and what is actual is rational.",zh:"凡是合乎理性的东西都是现实的,凡是现实的东西都是合乎理性的。"},{en:"Truth is like the sun. You can shut it out for a time, but it ain't goin' away.",zh:"真相就像太阳。你可以暂时将它遮住,但它不会消失。"},{en:"Everything we hear is an opinion, not a fact. Everything we see is a perspective, not the truth.",zh:"我们听到的一切都只是观点,而非事实。我们看到的一切都只是视角,而非真相。"},{en:"There is no truth. There is only perception.",zh:"没有真相,只有认知。"},{en:"If you look deep enough into anything, you will find mathematics.",zh:"如果你对任何事物看得足够深入,你都会发现数学。"},{en:"The medium is the message.",zh:"媒介即信息。"},{en:"Nothing is true, everything is permitted.",zh:"没有什么是真实的,一切都被允许。"},{en:"We are what we believe we are.",zh:"我们相信自己是什么,我们就是什么。"},{en:"Yesterday is history, tomorrow is a mystery, but today is a gift. That is why it is called the present.",zh:"昨天是历史,明天是谜团,但今天是礼物。这就是为什么它被称为‘现在’(Present)。"},{en:"Time is money.",zh:"时间就是金钱。"},{en:"The only thing necessary for the triumph of evil is for good men to do nothing.",zh:"邪恶得逞的唯一条件是好人袖手旁观。"},{en:"Carpe diem.",zh:"活在当下。"},{en:"Do not dwell in the past, do not dream of the future, concentrate the mind on the present moment.",zh:"不要沉湎于过去,不要幻想未来,集中精神活在当下。"},{en:"The best time to plant a tree was 20 years ago. The second best time is now.",zh:"种树的最佳时机是20年前。其次是现在。"},{en:"Action speaks louder than words.",zh:"事实胜于雄辩。"},{en:"Honesty is the first chapter in the book of wisdom.",zh:"诚实是智慧之书的第一章。"},{en:"Two things are infinite: the universe and human stupidity; and I'm not sure about the universe.",zh:"有两样东西是无限的:宇宙和人类的愚蠢;而且我不太确定宇宙是否无限。"},{en:"You cannot step twice into the same river.",zh:"人不能两次踏进同一条河流。"},{en:"The future belongs to those who believe in the beauty of their dreams.",zh:"未来属于那些相信梦想之美的人。"},{en:"Procrastination is the thief of time.",zh:"拖延是时间的大敌。"},{en:"An investment in knowledge pays the best interest.",zh:"投资知识,收益最佳。"},{en:"I have not failed. I've just found 10,000 ways that won't work.",zh:"我没有失败。我只是找到了一万种行不通的方法。"},{en:"That which is done, is done.",zh:"木已成舟。"}];function getRandomQuote(){const randomIndex=Math.floor(Math.random()*quotes.length);return quotes[randomIndex];} +const quotes=[{en:"The unexamined life is not worth living.",zh:"未经审视的人生不值得过。",zh_TW:"未經審視的人生不值得過。",ja:"吟味されない人生は生きるに値しない。",ko:"성찰하지 않는 삶은 살 가치가 없다。"},{en:"I think, therefore I am.",zh:"我思故我在。",zh_TW:"我思故我在。",ja:"我思う、ゆえに我あり。",ko:"나는 생각한다, 고로 존재한다。"},{en:"He who has a why to live for can bear almost any how.",zh:"知道为何而活的人,几乎能忍受任何一种生活。",zh_TW:"知道為何而活的人,幾乎能忍受任何一種生活。",ja:"生きるための「なぜ」を持つ者は、ほとんどあらゆる「どのように」にも耐えることができる。",ko:"살아야 할 이유를 아는 사람은 거의 모든 상황을 견딜 수 있다。"},{en:"Life is what happens when you're busy making other plans.",zh:"生活就是当你忙着制定其他计划时所发生的事情。",zh_TW:"生活就是當你忙著制定其他計劃時所發生的事情。",ja:"人生とは、他の計画を立てるのに忙しいときに起こるものだ。",ko:"인생은 다른 계획을 세우느라 바쁠 때 일어나는 일이다。"},{en:"Get busy living or get busy dying.",zh:"要么忙着活,要么忙着死。",zh_TW:"要么忙著活,要么忙著死。",ja:"必死に生きるか、必死に死ぬかだ。",ko:"바쁘게 살거나, 바쁘게 죽거나。"},{en:"We are what we repeatedly do. Excellence, then, is not an act, but a habit.",zh:"我们由我们反复做的事情构成的。因此,卓越不是一种行为,而是一种习惯。",zh_TW:"我們由我們反覆做的事情構成的。因此,卓越不是一種行為,而是一種習慣。",ja:"我々は繰り返し行うことの集大成である。卓越とは行為ではなく、習慣なのだ。",ko:"우리는 우리가 반복적으로 하는 일의 결과물이다. 그렇다면 탁월함은 행동이 아니라 습관이다。"},{en:"Man is condemned to be free.",zh:"人注定是自由的。",zh_TW:"人註定是自由的。",ja:"人間は自由であるように呪われている。",ko:"인간은 자유롭도록 저주받았다。"},{en:"To be, or not to be: that is the question.",zh:"生存还是毁灭,这是一个问题。",zh_TW:"生存還是毀滅,這是一個問題。",ja:"生きるべきか、死ぬべきか、それが問題だ。",ko:"죽느냐 사느냐, 그것이 문제로다。"},{en:"The purpose of life is not to be happy. It is to be useful, to be honorable, to be compassionate, to have it make some difference that you have lived and lived well.",zh:"人生的目的不是快乐,而是有用、高尚、富有同情心,让你活过并且活得好,从而使世界有所不同。",zh_TW:"人生的目的不是快樂,而是有用、高尚、富有同情心,讓你活過並且活得好,從而使世界有所不同。",ja:"人生(じんせい)の目的(もくてき)は幸(しあわ)せになることではない。役(やく)に立(た)つこと、名誉(めいよ)あること、思(おも)いやりを持(も)つこと、そして自分(じぶん)が生(い)きてきたこと、よく生(い)きたことが何(なに)かの違(ちが)いをもたらすようにすることだ。",ko:"삶의 목적은 행복해지는 것이 아니다. 유용하고, 명예롭고, 자비로우며, 당신이 살았고 잘 살았다는 것이 어떤 차이를 만들도록 하는 것이다。"},{en:"Life is 10% what happens to us and 90% how we react to it.",zh:"生活 10% 取决于发生在我们身上的事,90% 取决于我们如何反应。",zh_TW:"生活 10% 取決於發生在我們身上的事,90% 取決於我們如何反應。",ja:"人生は、我々に起こることが10%で、それにどう反応するかが90%だ。",ko:"인생은 우리에게 일어나는 일이 10%이고, 그 일에 대해 우리가 어떻게 반응하느냐가 90%이다。"},{en:"The two most important days in your life are the day you are born and the day you find out why.",zh:"你一生中最重要的两天是:你出生的那天和你明白你为何出生的那天。",zh_TW:"你一生中最重要的兩天是:你出生的那天和你明白你為何出生的那天。",ja:"人生で最も重要な日は二日ある。生まれた日と、なぜ生まれたかを悟る日だ。",ko:"당신의 인생에서 가장 중요한 날은 두 번이다. 당신이 태어난 날과 그 이유를 깨닫는 날이다。"},{en:"In three words I can sum up everything I've learned about life: it goes on.",zh:"关于人生,我所学到的一切可以总结为三个词:它在继续。",zh_TW:"關於人生,我所學到的一切可以總結為三個詞:它在繼續。",ja:"人生について学んだすべてを3語でまとめることができる。それは「それでも続く」ということだ。",ko:"내가 인생에 대해 배운 모든 것을 세 단어로 요약할 수 있다: '삶은 계속된다'는 것이다。"},{en:"Not all those who wander are lost.",zh:"并非所有流浪者都迷失了方向。",zh_TW:"並非所有流浪者都迷失了方向。",ja:"さまよう者がすべて道に迷っているわけではない。",ko:"방황하는 자가 다 길을 잃은 것은 아니다。"},{en:"Life is simple, but we insist on making it complicated.",zh:"生活本简单,但我们坚持要把它弄复杂。",zh_TW:"生活本簡單,但我們堅持要把它弄複雜。",ja:"人生はシンプルだ。だが我々はそれを複雑にしようと躍起になる。",ko:"인생은 단순하지만, 우리가 복잡하게 만들기를 고집한다。"},{en:"Our life is what our thoughts make it.",zh:"我们的生活是由我们的思想造成的。",zh_TW:"我們的生活是由我們的思想造成的。",ja:"我々の人生は、我々の思考が作るものだ。",ko:"우리의 삶은 우리의 생각이 만드는 것이다。"},{en:"Find purpose, the means will follow.",zh:"找到目标,方法自会随之而来。",zh_TW:"找到目標,方法自會隨之而來。",ja:"目的を見つけよ、手段は後からついてくる。",ko:"목적을 찾으라, 수단은 따라올 것이다。"},{en:"The goal of life is living in agreement with nature.",zh:"生活的目标是与自然和谐相处。",zh_TW:"生活的目標是與自然和諧相處。",ja:"人生の目標は、自然と調和して生きることである。",ko:"삶의 목표는 자연과 조화를 이루며 사는 것이다。"},{en:"The only true wisdom is in knowing you know nothing.",zh:"唯一的真正智慧在于知道自己一无所有。",zh_TW:"唯一的真正智慧在於知道自己一無所有。",ja:"唯一真の知恵は、自分が何も知らないことを知ることにある。",ko:"유일한 참된 지혜는 자신이 아무것도 모른다는 것을 아는 것이다。"},{en:"Knowledge is power.",zh:"知识就是力量。",zh_TW:"知識就是力量。",ja:"知識は力なり。",ko:"아는 것이 힘이다。"},{en:"Knowing yourself is the beginning of all wisdom.",zh:"了解自己是所有智慧的开端。",zh_TW:"了解自己是所有智慧的開端。",ja:"自分自身を知ることが、すべての知恵の始まりである。",ko:"자신을 아는 것이 모든 지혜의 시작이다。"},{en:"The journey of a thousand miles begins with a single step.",zh:"千里之行,始于足下。",zh_TW:"千里之行,始於足下。",ja:"千里の道も一歩から。",ko:"천 리 길도 한 걸음부터。"},{en:"The only source of knowledge is experience.",zh:"知识的唯一来源是经验。",zh_TW:"知識的唯一來源是經驗。",ja:"知識の唯一の源泉は経験である。",ko:"지식의 유일한 원천은 경험이다。"},{en:"A fool thinks himself to be wise, but a wise man knows himself to be a fool.",zh:"愚者自以为聪明,智者自知愚蠢。",zh_TW:"愚者自以為聰明,智者自知愚蠢。",ja:"愚か者は自分を賢いと思うが、賢い者は自分が愚かであることを知っている。",ko:"바보는 자신이 현명하다고 생각하지만, 현명한 사람은 자신이 바보라는 것을 안다。"},{en:"We learn from failure, not from success!",zh:"我们从失败中学习,而不是从成功中!",zh_TW:"我們從失敗中學習,而不是從成功中!",ja:"我々は成功からではなく、失敗から学ぶ!",ko:"우리는 성공이 아닌, 실패로부터 배운다!"},{en:"The wise man is one who knows what he does not know.",zh:"智者,知其所不知。",zh_TW:"智者,知其所不知。",ja:"賢い者とは、自分が何を知らないかを知っている者である。",ko:"현명한 사람은 자신이 모르는 것을 아는 사람이다。"},{en:"To know that we know what we know, and that we do not know what we do not know, that is true knowledge.",zh:"知之为知之,不知为不知,是知也。",zh_TW:"知之為知之,不知為不知,是知也。",ja:"知るを知るとなし、知らざるを知らずとなす、これ知るなり。",ko:"아는 것을 안다고 하고, 모르는 것을 모른다고 하는 것, 그것이 참된 앎이다。"},{en:"Curiosity is the wick in the candle of learning.",zh:"好奇心是学习这支蜡烛的灯芯。",zh_TW:"好奇心是學習這支蠟燭的燈芯。",ja:"好奇心は、学習というロウソクの芯である。",ko:"호기심은 배움이라는 촛불의 심지이다。"},{en:"It is the mark of an educated mind to be able to entertain a thought without accepting it.",zh:"能够容纳一种思想而不同意它,这是一个受过教育的头脑的标志。",zh_TW:"能夠容納一種思想而不同意它,這是一個受過教育的頭腦的標誌。",ja:"ある考えを受け入れずに、その考えを持ち続けることができるのが、教育ある精神の証である。",ko:"어떤 생각을 받아들이지 않고도 그 생각을 해볼 수 있는 것이 교육받은 마음의 특징이다。"},{en:"Never stop questioning.",zh:"永远不要停止提问。",zh_TW:"永遠不要停止提問。",ja:"疑問を持つことを決してやめるな。",ko:"질문하는 것을 절대 멈추지 마라。"},{en:"The man who asks a question is a fool for a minute, the man who does not ask is a fool for life.",zh:"问问题的人,只傻一分钟;不问的人,傻一生。",zh_TW:"問問題的人,只傻一分鐘;不問的人,傻一生。",ja:"問う者は一時の恥、問わぬ者は一生の恥。",ko:"질문하는 사람은 1분 동안 바보가 되지만, 질문하지 않는 사람은 평생 바보가 된다。"},{en:"Wisdom is not a product of schooling but of the lifelong attempt to acquire it.",zh:"智慧不是学校教育的产物,而是终生努力获得的产物。",zh_TW:"智慧不是學校教育的產物,而是終生努力獲得的產物。",ja:"知恵とは学校教育の産物ではなく、生涯をかけて獲得しようと試みることで得られるものである。",ko:"지혜는 학교 교육의 산물이 아니라, 평생에 걸쳐 그것을 얻으려는 노력의 산물이다。"},{en:"The greatest enemy of knowledge is not ignorance, it is the illusion of knowledge.",zh:"知识最大的敌人不是无知,而是自以为拥有知识的幻觉。",zh_TW:"知識最大的敵人不是無知,而是自以為擁有知識的幻覺。",ja:"知識の最大の敵は無知ではなく、知っているという幻想である。",ko:"지식의 가장 큰 적은 무지가 아니라, 안다는 착각이다。"},{en:"True wisdom comes to each of us when we realize how little we understand about life, ourselves, and the world around us.",zh:"当我们认识到自己对生命、对自身、对周围世界了解得多么少时,真正的智慧才会降临到我们每个人身上。",zh_TW:"當我們認識到自己對生命、對自身、對周圍世界了解得多麼少時,真正的智慧才會降臨到我們每個人身上。",ja:"真の知恵は、我々が人生や自分自身、そして我々を取り巻く世界について、いかにわずかしか理解していないかを悟ったときに訪れる。",ko:"진정한 지혜는 우리가 삶과 우리 자신, 그리고 우리를 둘러싼 세계에 대해 얼마나 아는 것이 없는지를 깨달을 때 찾아온다。"},{en:"Beware of false knowledge; it is more dangerous than ignorance.",zh:"谨防虚假的知识;它比无知更危险。",zh_TW:"謹防虛假的知識;它比無知更危險。",ja:"偽りの知識に用心せよ。それは無知よりも危険である。",ko:"거짓된 지식을 경계하라. 그것은 무지보다 더 위험하다。"},{en:"What does not kill me makes me stronger.",zh:"杀不死我的,使我更强大。",zh_TW:"殺不死我的,使我更強大。",ja:"私を殺さないものは、私をより強くする。",ko:"나를 죽이지 못하는 것은 나를 더 강하게 만든다。"},{en:"The only constant in life is change.",zh:"生活中唯一不变的就是变化。",zh_TW:"生活中唯一不變的就是變化。",ja:"人生で唯一変わらないものは、変化そのものである。",ko:"삶에서 유일하게 변하지 않는 것은 변화뿐이다。"},{en:"If you are going through hell, keep going.",zh:"如果你正在经历地狱,那就继续走下去。",zh_TW:"如果你正在經歷地獄,那就繼續走下去。",ja:"地獄を経験しているなら、進み続けろ。",ko:"지옥을 겪고 있다면, 계속 나아가라。"},{en:"In the middle of difficulty lies opportunity.",zh:"机会蕴藏在困难之中。",zh_TW:"機會蘊藏在困難之中。",ja:"困難の真っ只中に、好機がある。",ko:"어려움의 한가운데에 기회가 있다。"},{en:"It is not the strongest of the species that survive, nor the most intelligent, but the one most responsive to change.",zh:"存活下来的物种不是最强壮的,也不是最聪明的,而是最能适应变化的。",zh_TW:"存活下來的物種不是最强壯的,也不是最聰明的,而是最能適應變化的。",ja:"生き残る種とは、最も強いものでも、最も知的なものでもない。最も変化に対応できるものである。",ko:"살아남는 종은 가장 강한 종도, 가장 지능이 높은 종도 아니다. 변화에 가장 잘 적응하는 종이다。"},{en:"We must become the change we wish to see in the world.",zh:"我们必须成为我们希望在世界上看到的改变。",zh_TW:"我們必須成為我們希望在世界上看到的改變。",ja:"世界に変化を望むなら、まず自らがその変化となれ。",ko:"우리는 세상에서 보고 싶은 변화가 되어야 한다。"},{en:"A smooth sea never made a skilled sailor.",zh:"平静的大海练不出熟练的水手。",zh_TW:"平靜的大海練不出熟練的水手。",ja:"穏やかな海は、熟練した船乗りを育てない。",ko:"순탄한 바다는 노련한 뱃사공을 만들지 못한다。"},{en:"Obstacles don't block the path, they are the path.",zh:"障碍不是挡住了路,障碍本身就是路。",zh_TW:"障礙不是擋住了路,障礙本身就是路。",ja:"障害は道を塞ぐものではなく、道そのものである。",ko:"장애물은 길을 막는 것이 아니라, 그 자체가 길이다。"},{en:"Fall seven times, stand up eight.",zh:"七次跌倒,八次站起。",zh_TW:"七次跌倒,八次站起。",ja:"七転び八起き。",ko:"일곱 번 넘어져도, 여덟 번 일어선다。"},{en:"The art of life lies in a constant readjustment to our surroundings.",zh:"生活的艺术在于不断地调整自己以适应环境。",zh_TW:"生活的藝術在於不斷地調整自己以適應環境。",ja:"人生(じんせい)の芸術(げいじゅつ)は、我々(われわれ)の環境(かんきょう)に対(たい)する絶(た)え間(ま)ない再調整(さいちょうせい)にある。",ko:"삶의 기술은 우리를 둘러싼 환경에 끊임없이 재적응하는 데 있다。"},{en:"Adversity introduces a man to himself.",zh:"逆境使人认识自己。",zh_TW:"逆境使人認識自己。",ja:"逆境は、人に自分自身を教えてくれる。",ko:"역경은 사람에게 자기 자신을 소개한다。"},{en:"The wound is the place where the Light enters you.",zh:"伤口是光进入你内心的入口。",zh_TW:"傷口是光進入你內心的入口。",ja:"傷口は、光があなたの中に入る場所だ。",ko:"상처는 빛이 당신에게 들어오는 곳이다。"},{en:"When we are no longer able to change a situation, we are challenged to change ourselves.",zh:"当我们无法改变现状时,我们就需要改变自己。",zh_TW:"當我們無法改變現狀時,我們就需要改變自己。",ja:"状況を変えることができなくなったとき、我々は自分自身を変えることを求められる。",ko:"상황을 더 이상 바꿀 수 없을 때, 우리는 자신을 바꿔야 하는 도전에 직면한다。"},{en:"Be the change you wish to see in the world.",zh:"成为你希望在世界上看到的改变。",zh_TW:"成為你希望在世界上看到的改變。",ja:"あなたが世界に見たいと願う変化に、あなた自身がなりなさい。",ko:"세상에서 보고 싶은 변화가 있다면, 당신 자신이 그 변화가 되어라。"},{en:"Do not pray for an easy life, pray for the strength to endure a difficult one.",zh:"不要祈祷生活安逸,要祈祷有力量去忍受艰难的生活。",zh_TW:"不要祈禱生活安逸,要祈禱有力量去忍受艱難的生活。",ja:"楽な人生を祈るな。困難な人生を耐え抜く強さを祈れ。",ko:"편안한 삶을 기도하지 말고, 어려운 삶을 견뎌낼 힘을 기도하라。"},{en:"A pessimist sees the difficulty in every opportunity; an optimist sees the opportunity in every difficulty.",zh:"悲观者在每个机会中都看到困难;乐观者在每个困难中都看到机会。",zh_TW:"悲觀者在每個機會中都看到困難;樂觀者在每個困難中都看到機會。",ja:"悲観主義者はあらゆる好機の中に困難を見る。楽観主義者はあらゆる困難の中に好機を見る。",ko:"비관론자는 모든 기회에서 어려움을 보고, 낙관론자는 모든 어려움에서 기회를 본다。"},{en:"It's not what happens to you, but how you react to it that matters.",zh:"重要的不是发生在你身上的事,而是你如何应对它。",zh_TW:"重要的不是發生在你身上的事,而是你如何應對它。",ja:"あなたに何が起こるかではなく、それにどう反応するかが重要だ。",ko:"당신에게 무슨 일이 일어났는지가 중요한 것이 아니라, 당신이 그것에 어떻게 반응하는지가 중요하다。"},{en:"To love oneself is the beginning of a lifelong romance.",zh:"爱自己是终身浪漫的开始。",zh_TW:"愛自己是終身浪漫的開始。",ja:"自分自身を愛することは、一生続くロマンスの始まりだ。",ko:"자신을 사랑하는 것은 평생 지속되는 로맨스의 시작이다。"},{en:"Love is composed of a single soul inhabiting two bodies.",zh:"爱是栖息于两个身体中的同一个灵魂。",zh_TW:"愛是棲息於兩個身體中的同一個靈魂。",ja:"愛とは、二つの体に宿る一つの魂で構成されている。",ko:"사랑은 두 개의 몸에 깃든 하나의 영혼으로 이루어져 있다。"},{en:"Man is the measure of all things.",zh:"人是万物的尺度。",zh_TW:"人是萬物的尺度。",ja:"人間は万物の尺度である。",ko:"인간은 만물의 척도이다。"},{en:"The best and most beautiful things in this world cannot be seen or even heard, but must be felt with the heart.",zh:"世界上最好最美的东西是看不见也听不见的,必须用心去感受。",zh_TW:"世界上最好最美的東西是看不見也聽不見的,必須用心去感受。",ja:"この世で最も素晴らしく、最も美しいものは、目で見たり聞いたりすることはできない。心で感じなければならない。",ko:"이 세상에서 가장 좋고 가장 아름다운 것들은 보이거나 들리지 않는다. 오직 마음으로만 느껴야 한다。"},{en:"Where there is love there is life.",zh:"有爱的地方就有生命。",zh_TW:"有愛的地方就有生命。",ja:"愛があるところに人生がある。",ko:"사랑이 있는 곳에 삶이 있다。"},{en:"If you want to be loved, be lovable.",zh:"如果你想被爱,就要变得可爱。",zh_TW:"如果你想被愛,就要變得可愛。",ja:"愛されたいなら、愛らしくあれ。",ko:"사랑받고 싶다면, 사랑스러워져라。"},{en:"We are all in the gutter, but some of us are looking at the stars.",zh:"我们都身处沟渠,但仍有人仰望星空。",zh_TW:"我們都身處溝渠,但仍有人仰望星空。",ja:"我々はみな溝の中にいる。だが、そこから星を見上げている者もいるのだ。",ko:"우리는 모두 시궁창에 있지만, 우리 중 일부는 별을 바라보고 있다。"},{en:"The only thing we have to fear is fear itself.",zh:"我们唯一需要恐惧的就是恐惧本身。",zh_TW:"我們唯一需要恐懼的就是恐懼本身。",ja:"我々が恐れるべき唯一のものは、恐れそのものである。",ko:"우리가 두려워해야 할 유일한 것은 두려움 그 자체이다。"},{en:"Be kind, for everyone you meet is fighting a hard battle.",zh:"要友善,因为你遇到的每个人都在打一场艰苦的战斗。",zh_TW:"要友善,因為你遇到的每個人都在打一場艱苦的戰鬥。",ja:"親切にしなさい。あなたが出会う誰もが、困難な戦いを戦っているのだから。",ko:"친절하라. 당신이 만나는 모든 사람은 힘겨운 싸움을 하고 있기 때문이다。"},{en:"Man is born free, and everywhere he is in chains.",zh:"人生而自由,却无往不在枷锁之中。",zh_TW:"人生而自由,卻無往不在枷鎖之中。",ja:"人は生まれながらにして自由だが、いたるところで鎖につながれている。",ko:"인간은 자유롭게 태어났으나, 어디에서나 쇠사슬에 묶여 있다。"},{en:"We love the things we love for what they are.",zh:"我们爱我们所爱之物,只因它们本来的样子。",zh_TW:"我們愛我們所愛之物,只因它們本來的樣子。",ja:"我々が愛するものを愛するのは、それがそれであるからだ。",ko:"우리는 우리가 사랑하는 것들을 그 자체로 사랑한다。"},{en:"Darkness cannot drive out darkness; only light can do that. Hate cannot drive out hate; only love can do that.",zh:"黑暗无法驱逐黑暗,只有光明可以;仇恨无法驱逐仇恨,只有爱可以。",zh_TW:"黑暗無法驅逐黑暗,只有光明可以;仇恨無法驅逐仇恨,只有愛可以。",ja:"闇は闇を追い払うことはできない。光だけがそれを可能にする。憎しみは憎しみを追い払うことはできない。愛だけがそれを可能にする。",ko:"어둠은 어둠을 몰아낼 수 없다. 오직 빛만이 할 수 있다. 증오는 증오를 몰아낼 수 없다. 오직 사랑만이 할 수 있다。"},{en:"An eye for an eye only ends up making the whole world blind.",zh:"以眼还眼,只会让整个世界都盲目。",zh_TW:"以眼還眼,只會讓整個世界都盲目。",ja:"「目には目を」は、全世界を盲目にするだけだ。",ko:"'눈에는 눈'은 결국 온 세상을 눈멀게 할 뿐이다。"},{en:"Hell is other people.",zh:"他人即地狱。",zh_TW:"他人即地獄。",ja:"地獄とは、他人である。",ko:"타인은 지옥이다。"},{en:"You will not be punished for your anger, you will be punished by your anger.",zh:"你不会因为你的愤怒而受到惩罚,你会被你的愤怒所惩罚。",zh_TW:"你不會因為你的憤怒而受到懲罰,你會被你的憤怒所懲罰。",ja:"あなたは怒りのために罰せられるのではない。怒りによって罰せられるのだ。",ko:"당신은 당신의 분노 때문에 벌을 받는 것이 아니라, 당신의 분노에 의해 벌을 받을 것이다。"},{en:"To err is human, to forgive divine.",zh:"犯错是人性,宽恕是神性。",zh_TW:"犯錯是人性,寬恕是神性。",ja:"過つは人の常、許すは神の業。",ko:"실수하는 것은 인간이고, 용서하는 것은 신이다。"},{en:"Man is the only creature who refuses to be what he is.",zh:"人是唯一拒绝承认自己本质的生物。",zh_TW:"人是唯一拒絕承認自己本質的生物。",ja:"人間は、自分が何者であるかを拒否する唯一の生き物である。",ko:"인간은 자신이 무엇인지를 거부하는 유일한 생물이다。"},{en:"Beauty is in the eye of the beholder.",zh:"情人眼里出西施。",zh_TW:"情人眼裡出西施。",ja:"美は見る人の目の中にある。",ko:"아름다움은 보는 사람의 눈에 달려 있다。"},{en:"All that we see or seem is but a dream within a dream.",zh:"我们所见所感,皆如梦中之梦。",zh_TW:"我們所見所感,皆如夢中之夢。",ja:"我々が見たり感じたりするすべては、夢の中の夢にすぎない。",ko:"우리가 보거나 보이는 모든 것은 꿈속의 꿈일 뿐이다。"},{en:"Everything you can imagine is real.",zh:"你能想象的一切都是真实的。",zh_TW:"你能想像的一切都是真實的。",ja:"想像できることは、すべて現実なのだ。",ko:"당신이 상상할 수 있는 모든 것은 현실이다。"},{en:"The map is not the territory.",zh:"地图并非领土。",zh_TW:"地圖並非領土。",ja:"地図は領土ではない。",ko:"지도는 영토가 아니다。"},{en:"We don't see things as they are, we see them as we are.",zh:"我们看到的不是事物的原貌,而是我们自己的样子。",zh_TW:"我們看到的不是事物的原貌,而是我們自己的樣子。",ja:"我々は物事をあるがままに見ているのではない。我々があるがままに見ているのだ。",ko:"우리는 사물을 있는 그대로 보지 않고, 우리 자신(의 모습)대로 본다。"},{en:"There are two ways to be fooled. One is to believe what isn't true; the other is to refuse to believe what is true.",zh:"被愚弄有两种方式。一种是相信不真实的东西;另一种是拒绝相信真实的东西。",zh_TW:"被愚弄有兩種方式。一種是相信不真實的東西;另一種是拒絕相信真實的東西。",ja:"騙される方法は二つある。一つは真実でないことを信じること。もう一つは真実であることを信じようとしないことだ。",ko:"속는 방법에는 두 가지가 있다. 하나는 사실이 아닌 것을 믿는 것이고, 다른 하나는 사실인 것을 믿기를 거부하는 것이다。"},{en:"Simplicity is the ultimate sophistication.",zh:"简约是极致的复杂。",zh_TW:"簡約是極致的複雜。",ja:"シンプルさは、究極の洗練である。",ko:"단순함은 궁극의 정교함이다。"},{en:"The truth will set you free.",zh:"真相将使你自由。",zh_TW:"真相將使你自由。",ja:"真実は、あなたを自由にする。",ko:"진리가 너희를 자유롭게 하리라。"},{en:"Reality is merely an illusion, albeit a very persistent one.",zh:"现实只是一种幻觉,尽管是一种非常持久的幻觉。",zh_TW:"現實只是一種幻覺,儘管是一種非常持久的幻覺。",ja:"現実とは、非常に根強いただの幻想にすぎない。",ko:"현실은 단지 환상일 뿐이다. 비록 매우 집요한 환상이긴 하지만。"},{en:"What is rational is actual and what is actual is rational.",zh:"凡是合乎理性的东西都是现实的,凡是现实的东西都是合乎理性的。",zh_TW:"凡是合乎理性的東西都是現實的,凡是現實的東西都是合乎理性的。",ja:"理性的なものは現実的であり、現実的なものは理性的である。",ko:"이성적인 것은 현실적이고, 현실적인 것은 이성적이다。"},{en:"Truth is like the sun. You can shut it out for a time, but it ain't goin' away.",zh:"真相就像太阳。你可以暂时将它遮住,但它不会消失。",zh_TW:"真相就像太陽。你可以暫時將它遮住,但它不會消失。",ja:"真実は太陽のようなものだ。一時的に隠すことはできても、決してなくなりはしない。",ko:"진실은 태양과 같다. 잠시 가릴 수는 있지만, 사라지게 할 수는 없다。"},{en:"Everything we hear is an opinion, not a fact. Everything we see is a perspective, not the truth.",zh:"我们听到的一切都只是观点,而非事实。我们看到的一切都只是视角,而非真相。",zh_TW:"我們聽到的一切都只是觀點,而非事實。我們看到的一切都只是視角,而非真相。",ja:"我々が聞くことすべてが意見であり、事実ではない。我々が見ることすべてが視点であり、真実ではない。",ko:"우리가 듣는 모든 것은 의견이지, 사실이 아니다. 우리가 보는 모든 것은 관점이지, 진실이 아니다。"},{en:"There is no truth. There is only perception.",zh:"没有真相,只有认知。",zh_TW:"沒有真相,只有認知。",ja:"真実などない。ただ認識があるだけだ。",ko:"진실은 없다. 오직 인식만이 있을 뿐이다。"},{en:"If you look deep enough into anything, you will find mathematics.",zh:"如果你对任何事物看得足够深入,你都会发现数学。",zh_TW:"如果你對任何事物看得足夠深入,你都會發現數學。",ja:"何事も深く見つめれば、そこには数学がある。",ko:"무엇이든 충분히 깊이 들여다보면, 수학을 발견하게 될 것이다。"},{en:"The medium is the message.",zh:"媒介即信息。",zh_TW:"媒介即訊息。",ja:"メディアはメッセージである。",ko:"미디어는 메시지다。"},{en:"Nothing is true, everything is permitted.",zh:"没有什么是真实的,一切都被允许。",zh_TW:"沒有什麼是真實的,一切都被允許。",ja:"真実などない、すべては許されている。",ko:"진실은 없으며, 모든 것이 허용된다。"},{en:"We are what we believe we are.",zh:"我们相信自己是什么,我们就是什么。",zh_TW:"我們相信自己是什麼,我們就是什麼。",ja:"我々は、我々が信じる通りの人間である。",ko:"우리는 우리가 그렇다고 믿는 존재이다。"},{en:"Yesterday is history, tomorrow is a mystery, but today is a gift. That is why it is called the present.",zh:"昨天是历史,明天是谜团,但今天是礼物。这就是为什么它被称为‘现在’(Present)。",zh_TW:"昨天是歷史,明天是謎團,但今天是禮物。這就是為什麼它被稱為‘現在’(Present)。",ja:"昨日は歴史、明日はミステリー、しかし今日は贈り物だ。だからこそ、それは『プレゼント (現在)』と呼ばれる。",ko:"어제는 역사이고, 내일은 미스터리이며, 오늘은 선물이다. 그래서 오늘을 '선물(present)'이라고 부른다。"},{en:"Time is money.",zh:"时间就是金钱。",zh_TW:"時間就是金錢。",ja:"時は金なり。",ko:"시간은 돈이다。"},{en:"The only thing necessary for the triumph of evil is for good men to do nothing.",zh:"邪恶得逞的唯一条件是好人袖手旁观。",zh_TW:"邪惡得逞的唯一條件是好人袖手旁觀。",ja:"悪が勝利するために必要なのは、善人が何もしないことだけである。",ko:"악의 승리를 위해 필요한 유일한 것은 선한 사람들이 아무것도 하지 않는 것이다。"},{en:"Carpe diem.",zh:"活在当下。",zh_TW:"活在當下。",ja:"今を生きよ(カルペ・ディエム)。",ko:"현재를 즐겨라 (카르페 디엠)。"},{en:"Do not dwell in the past, do not dream of the future, concentrate the mind on the present moment.",zh:"不要沉湎于过去,不要幻想未来,集中精神活在当下。",zh_TW:"不要沉湎於過去,不要幻想未來,集中精神活在當下。",ja:"過去に生きるな、未来を夢見るな、現在の瞬間に心を集中させよ。",ko:"과거에 머물지 말고, 미래를 꿈꾸지 말며, 현재 이 순간에 마음을 집중하라。"},{en:"The best time to plant a tree was 20 years ago. The second best time is now.",zh:"种树的最佳时机是20年前。其次是现在。",zh_TW:"種樹的最佳時機是20年前。其次是現在。",ja:"木を植えるのに最適な時期は20年前だった。二番目に最適な時期は、今だ。",ko:"나무를 심기에 가장 좋은 때는 20년 전이었다. 두 번째로 좋은 때는 바로 지금이다。"},{en:"Action speaks louder than words.",zh:"事实胜于雄辩。",zh_TW:"事實勝於雄辯。",ja:"行動は言葉よりも雄弁である。",ko:"말보다 행동이 더 중요하다。"},{en:"Honesty is the first chapter in the book of wisdom.",zh:"诚实是智慧之书的第一章。",zh_TW:"誠實是智慧之書的第一章。",ja:"誠実さは、知恵という本の第一章である。",ko:"정직은 지혜라는 책의 첫 장이다。"},{en:"Two things are infinite: the universe and human stupidity; and I'm not sure about the universe.",zh:"有两样东西是无限的:宇宙和人类的愚蠢;而且我不太确定宇宙是否无限。",zh_TW:"有兩樣東西是無限的:宇宙和人類的愚蠢;而且我不太確定宇宙是否無限。",ja:"無限なものは二つある。宇宙と人間の愚かさだ。ただ、宇宙については私にもよく分からない。",ko:"무한한 것은 두 가지뿐이다. 우주와 인간의 어리석음. 그런데 우주에 대해선 나도 확신이 없다。"},{en:"You cannot step twice into the same river.",zh:"人不能两次踏进同一条河流。",zh_TW:"人不能兩次踏進同一條河流。",ja:"同(おな)じ川(かわ)に二度(にど)入(はい)ることはできない。",ko:"같은 강물에 두 번 발을 담글 수 없다。"},{en:"The future belongs to those who believe in the beauty of their dreams.",zh:"未来属于那些相信梦想之美的人。",zh_TW:"未來屬於那些相信夢想之美的人。",ja:"未来は、自分の夢の美しさを信じる者のものである。",ko:"미래는 자신의 꿈의 아름다움을 믿는 사람들의 것이다。"},{en:"Procrastination is the thief of time.",zh:"拖延是时间的大敌。",zh_TW:"拖延是時間的大敵。",ja:"先延ばしは時間泥棒である。",ko:"미루는 습관은 시간 도둑이다。"},{en:"An investment in knowledge pays the best interest.",zh:"投资知识,收益最佳。",zh_TW:"投資知識,收益最佳。",ja:"知識への投資は、最良の利息を生む。",ko:"지식에 대한 투자는 최고의 이자를 지불한다。"},{en:"I have not failed. I've just found 10,000 ways that won't work.",zh:"我没有失败。我只是找到了一万种行不通的方法。",zh_TW:"我沒有失敗。我只是找到了一萬種行不通的方法。",ja:"私は失敗したことがない。ただ、うまくいかない1万通りの方法を見つけただけだ。",ko:"나는 실패하지 않았다. 단지 작동하지 않는 1만 가지 방법을 찾았을 뿐이다。"},{en:"That which is done, is done.",zh:"木已成舟。",zh_TW:"木已成舟。",ja:"なされたことは、なされたことだ。(覆水盆に返らず)",ko:"일어난 일은 일어난 일이다. (이미 엎질러진 물이다.)"}];function getRandomQuote(){const randomIndex=Math.floor(Math.random()*quotes.length);return quotes[randomIndex];} ;// CONCATENATED MODULE: ./src/views/Options/StylesSetting.js -var StylesSetting_templateObject;function StyleFields(_ref){let{customStyle,deleteStyle,updateStyle,isBuiltin}=_ref;const i18n=useI18n();const{setting:{uiLang}}=useSetting();const[formData,setFormData]=(0,react.useState)({});const[isModified,setIsModified]=(0,react.useState)(false);const confirm=useConfirm();(0,react.useEffect)(()=>{if(customStyle){setFormData(customStyle);}},[customStyle]);(0,react.useEffect)(()=>{if(!customStyle)return;const hasChanged=JSON.stringify(customStyle)!==JSON.stringify(formData);setIsModified(hasChanged);},[customStyle,formData]);const handleChange=e=>{e.preventDefault();let{name,value}=e.target;setFormData(prevData=>_objectSpread2(_objectSpread2({},prevData),{},{[name]:value}));};const handleSave=()=>{updateStyle(customStyle.styleSlug,formData);};const handleDelete=async()=>{const isConfirmed=await confirm({confirmText:i18n("delete"),cancelText:i18n("cancel")});if(isConfirmed){deleteStyle(customStyle.styleSlug);}};const{styleName="",styleCode=""}=formData;const textClass=(0,react.useMemo)(()=>emotion_css_esm_css(StylesSetting_templateObject||(StylesSetting_templateObject=taggedTemplateLiteral_taggedTemplateLiteral(["\n ","\n "])),styleCode),[styleCode]);const quote=(0,react.useMemo)(()=>{const q=getRandomQuote();if(uiLang==="en"){return[q.zh,q.en];}return[q.en,q.zh];},[uiLang]);return/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{spacing:3,children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(Box_Box,{children:[quote[0],/*#__PURE__*/(0,jsx_runtime.jsx)("br",{}),/*#__PURE__*/(0,jsx_runtime.jsx)("span",{className:textClass,children:quote[1]})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(TextField_TextField,{size:"small",label:i18n("style_name"),name:"styleName",value:styleName,onChange:handleChange,disabled:isBuiltin}),/*#__PURE__*/(0,jsx_runtime.jsx)(TextField_TextField,{size:"small",label:i18n("style_code"),name:"styleCode",value:styleCode,onChange:handleChange,multiline:true,maxRows:10,disabled:isBuiltin}),!isBuiltin&&/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{direction:"row",alignItems:"center",spacing:2,useFlexGap:true,flexWrap:"wrap",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Button_Button,{size:"small",variant:"contained",onClick:handleSave,disabled:!isModified,children:i18n("save")}),/*#__PURE__*/(0,jsx_runtime.jsx)(Button_Button,{size:"small",variant:"outlined",color:"error",onClick:handleDelete,children:i18n("delete")})]})]});}function StyleAccordion(_ref2){let{customStyle,deleteStyle,updateStyle,isBuiltin}=_ref2;const[expanded,setExpanded]=(0,react.useState)(false);const handleChange=e=>{setExpanded(pre=>!pre);};return/*#__PURE__*/(0,jsx_runtime.jsxs)(Accordion_Accordion,{expanded:expanded,onChange:handleChange,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(AccordionSummary_AccordionSummary,{expandIcon:/*#__PURE__*/(0,jsx_runtime.jsx)(ExpandMore/* default */.Z,{}),children:/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{sx:{overflowWrap:"anywhere"},children:"".concat(customStyle.styleName)})}),/*#__PURE__*/(0,jsx_runtime.jsx)(AccordionDetails_AccordionDetails,{children:expanded&&/*#__PURE__*/(0,jsx_runtime.jsx)(StyleFields,{customStyle:customStyle,deleteStyle:deleteStyle,updateStyle:updateStyle,isBuiltin:isBuiltin})})]});}function StylesSetting(){const i18n=useI18n();const{customStyles,addStyle,deleteStyle,updateStyle}=useStyleList();const{builtinStyles}=useAllTextStyles();const handleClick=e=>{e.preventDefault();addStyle();};return/*#__PURE__*/(0,jsx_runtime.jsx)(Box_Box,{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{spacing:3,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Box_Box,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(Button_Button,{size:"small",id:"add-style-button",variant:"contained",onClick:handleClick,startIcon:/*#__PURE__*/(0,jsx_runtime.jsx)(Add/* default */.Z,{}),children:i18n("add")})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Box_Box,{children:customStyles.map(customStyle=>/*#__PURE__*/(0,jsx_runtime.jsx)(StyleAccordion,{customStyle:customStyle,deleteStyle:deleteStyle,updateStyle:updateStyle},customStyle.styleSlug))}),/*#__PURE__*/(0,jsx_runtime.jsx)(Box_Box,{children:builtinStyles.map(customStyle=>/*#__PURE__*/(0,jsx_runtime.jsx)(StyleAccordion,{customStyle:customStyle,deleteStyle:deleteStyle,updateStyle:updateStyle,isBuiltin:true},customStyle.styleSlug))})]})});} +var StylesSetting_templateObject;function StyleFields(_ref){let{customStyle,deleteStyle,updateStyle,isBuiltin}=_ref;const i18n=useI18n();const{setting:{uiLang}}=useSetting();const[formData,setFormData]=(0,react.useState)({});const[isModified,setIsModified]=(0,react.useState)(false);const confirm=useConfirm();(0,react.useEffect)(()=>{if(customStyle){setFormData(customStyle);}},[customStyle]);(0,react.useEffect)(()=>{if(!customStyle)return;const hasChanged=JSON.stringify(customStyle)!==JSON.stringify(formData);setIsModified(hasChanged);},[customStyle,formData]);const handleChange=e=>{e.preventDefault();let{name,value}=e.target;setFormData(prevData=>_objectSpread2(_objectSpread2({},prevData),{},{[name]:value}));};const handleSave=()=>{updateStyle(customStyle.styleSlug,formData);};const handleDelete=async()=>{const isConfirmed=await confirm({confirmText:i18n("delete"),cancelText:i18n("cancel")});if(isConfirmed){deleteStyle(customStyle.styleSlug);}};const{styleName="",styleCode=""}=formData;const textClass=(0,react.useMemo)(()=>emotion_css_esm_css(StylesSetting_templateObject||(StylesSetting_templateObject=taggedTemplateLiteral_taggedTemplateLiteral(["\n ","\n "])),styleCode),[styleCode]);const quote=(0,react.useMemo)(()=>{const q=getRandomQuote();if(uiLang==="en"){return[q.zh,q.en];}return[q.en,q[uiLang]];},[uiLang]);return/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{spacing:3,children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(Box_Box,{children:[quote[0],/*#__PURE__*/(0,jsx_runtime.jsx)("br",{}),/*#__PURE__*/(0,jsx_runtime.jsx)("span",{className:textClass,children:quote[1]})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(TextField_TextField,{size:"small",label:i18n("style_name"),name:"styleName",value:styleName,onChange:handleChange,disabled:isBuiltin}),/*#__PURE__*/(0,jsx_runtime.jsx)(TextField_TextField,{size:"small",label:i18n("style_code"),name:"styleCode",value:styleCode,onChange:handleChange,multiline:true,maxRows:10,disabled:isBuiltin}),!isBuiltin&&/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{direction:"row",alignItems:"center",spacing:2,useFlexGap:true,flexWrap:"wrap",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Button_Button,{size:"small",variant:"contained",onClick:handleSave,disabled:!isModified,children:i18n("save")}),/*#__PURE__*/(0,jsx_runtime.jsx)(Button_Button,{size:"small",variant:"outlined",color:"error",onClick:handleDelete,children:i18n("delete")})]})]});}function StyleAccordion(_ref2){let{customStyle,deleteStyle,updateStyle,isBuiltin}=_ref2;const[expanded,setExpanded]=(0,react.useState)(false);const handleChange=e=>{setExpanded(pre=>!pre);};return/*#__PURE__*/(0,jsx_runtime.jsxs)(Accordion_Accordion,{expanded:expanded,onChange:handleChange,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(AccordionSummary_AccordionSummary,{expandIcon:/*#__PURE__*/(0,jsx_runtime.jsx)(ExpandMore/* default */.Z,{}),children:/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{sx:{overflowWrap:"anywhere"},children:"".concat(customStyle.styleName)})}),/*#__PURE__*/(0,jsx_runtime.jsx)(AccordionDetails_AccordionDetails,{children:expanded&&/*#__PURE__*/(0,jsx_runtime.jsx)(StyleFields,{customStyle:customStyle,deleteStyle:deleteStyle,updateStyle:updateStyle,isBuiltin:isBuiltin})})]});}function StylesSetting(){const i18n=useI18n();const{customStyles,addStyle,deleteStyle,updateStyle}=useStyleList();const{builtinStyles}=useAllTextStyles();const handleClick=e=>{e.preventDefault();addStyle();};return/*#__PURE__*/(0,jsx_runtime.jsx)(Box_Box,{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{spacing:3,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Box_Box,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(Button_Button,{size:"small",id:"add-style-button",variant:"contained",onClick:handleClick,startIcon:/*#__PURE__*/(0,jsx_runtime.jsx)(Add/* default */.Z,{}),children:i18n("add")})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Box_Box,{children:customStyles.map(customStyle=>/*#__PURE__*/(0,jsx_runtime.jsx)(StyleAccordion,{customStyle:customStyle,deleteStyle:deleteStyle,updateStyle:updateStyle},customStyle.styleSlug))}),/*#__PURE__*/(0,jsx_runtime.jsx)(Box_Box,{children:builtinStyles.map(customStyle=>/*#__PURE__*/(0,jsx_runtime.jsx)(StyleAccordion,{customStyle:customStyle,deleteStyle:deleteStyle,updateStyle:updateStyle,isBuiltin:true},customStyle.styleSlug))})]})});} ;// CONCATENATED MODULE: ./src/views/Options/index.js function Options(){const[error,setError]=(0,react.useState)("");const[ready,setReady]=(0,react.useState)(false);(0,react.useEffect)(()=>{(async()=>{if(isGm){// 等待GM注入 let i=0;for(;;){var _window,_window$APP_INFO;if(((_window=window)===null||_window===void 0?void 0:(_window$APP_INFO=_window.APP_INFO)===null||_window$APP_INFO===void 0?void 0:_window$APP_INFO.name)==="KISS Translator"){const{version,eventName}=window.APP_INFO;// 检查版本是否一致 -if(version!=="2.0.10"){setError("The version of the local script(v".concat(version,") is not the latest version(v").concat("2.0.10","). \u672C\u5730\u811A\u672C\u4E4B\u7248\u672C(v").concat(version,")\u975E\u6700\u65B0\u7248(v").concat("2.0.10",")\u3002"));return;}if(eventName){// 注入GM接口 +if(version!=="2.0.11"){setError("The version of the local script(v".concat(version,") is not the latest version(v").concat("2.0.11","). \u672C\u5730\u811A\u672C\u4E4B\u7248\u672C(v").concat(version,")\u975E\u6700\u65B0\u7248(v").concat("2.0.11",")\u3002"));return;}if(eventName){// 注入GM接口 adaptScript(eventName);}break;}if(++i>8){setError("Time out. Please confirm whether to install or enable KISS Translator GreaseMonkey script? 连接超时,请检查是否安装或启用简约翻译油猴脚本。");return;}await sleep(1000);}}// 同步数据 -await trySyncSettingAndRules();setReady(true);})();},[]);if(error){return/*#__PURE__*/(0,jsx_runtime.jsxs)("center",{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Divider_Divider,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(material_Link_Link,{href:"https://github.com/fishjar/kiss-translator",children:"KISS Translator v".concat("2.0.10")})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Alert_Alert,{severity:"error",children:error}),/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{spacing:2,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(material_Link_Link,{href:"https://fishjar.github.io/kiss-translator/kiss-translator.user.js",children:"Install/Update Userscript for Tampermonkey/Violentmonkey"}),/*#__PURE__*/(0,jsx_runtime.jsx)(material_Link_Link,{href:"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js",children:"Install/Update Userscript for iOS Safari"})]})]});}if(!ready){return/*#__PURE__*/(0,jsx_runtime.jsx)(Loading,{});}return/*#__PURE__*/(0,jsx_runtime.jsx)(SettingProvider,{isSettingPage:true,children:/*#__PURE__*/(0,jsx_runtime.jsx)(Theme,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(AlertProvider,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(ConfirmProvider,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(HashRouter,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(Routes,{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(Route,{path:"/",element:/*#__PURE__*/(0,jsx_runtime.jsx)(Layout,{}),children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{index:true,element:/*#__PURE__*/(0,jsx_runtime.jsx)(Settings,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"rules",element:/*#__PURE__*/(0,jsx_runtime.jsx)(Rules,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"styles",element:/*#__PURE__*/(0,jsx_runtime.jsx)(StylesSetting,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"input",element:/*#__PURE__*/(0,jsx_runtime.jsx)(InputSetting,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"tranbox",element:/*#__PURE__*/(0,jsx_runtime.jsx)(Tranbox,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"mousehover",element:/*#__PURE__*/(0,jsx_runtime.jsx)(MouseHoverSetting,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"subtitle",element:/*#__PURE__*/(0,jsx_runtime.jsx)(SubtitleSetting,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"apis",element:/*#__PURE__*/(0,jsx_runtime.jsx)(Apis,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"sync",element:/*#__PURE__*/(0,jsx_runtime.jsx)(SyncSetting,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"words",element:/*#__PURE__*/(0,jsx_runtime.jsx)(FavWords,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"playground",element:/*#__PURE__*/(0,jsx_runtime.jsx)(Playgound,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"about",element:/*#__PURE__*/(0,jsx_runtime.jsx)(About,{})})]})})})})})})});} +await trySyncSettingAndRules();setReady(true);})();},[]);if(error){return/*#__PURE__*/(0,jsx_runtime.jsxs)("center",{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Divider_Divider,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(material_Link_Link,{href:"https://github.com/fishjar/kiss-translator",children:"KISS Translator v".concat("2.0.11")})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Alert_Alert,{severity:"error",children:error}),/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{spacing:2,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(material_Link_Link,{href:"https://fishjar.github.io/kiss-translator/kiss-translator.user.js",children:"Install/Update Userscript for Tampermonkey/Violentmonkey"}),/*#__PURE__*/(0,jsx_runtime.jsx)(material_Link_Link,{href:"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js",children:"Install/Update Userscript for iOS Safari"})]})]});}if(!ready){return/*#__PURE__*/(0,jsx_runtime.jsx)(Loading,{});}return/*#__PURE__*/(0,jsx_runtime.jsx)(SettingProvider,{isSettingPage:true,children:/*#__PURE__*/(0,jsx_runtime.jsx)(Theme,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(AlertProvider,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(ConfirmProvider,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(HashRouter,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(Routes,{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(Route,{path:"/",element:/*#__PURE__*/(0,jsx_runtime.jsx)(Layout,{}),children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{index:true,element:/*#__PURE__*/(0,jsx_runtime.jsx)(Settings,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"rules",element:/*#__PURE__*/(0,jsx_runtime.jsx)(Rules,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"styles",element:/*#__PURE__*/(0,jsx_runtime.jsx)(StylesSetting,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"input",element:/*#__PURE__*/(0,jsx_runtime.jsx)(InputSetting,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"tranbox",element:/*#__PURE__*/(0,jsx_runtime.jsx)(Tranbox,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"mousehover",element:/*#__PURE__*/(0,jsx_runtime.jsx)(MouseHoverSetting,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"subtitle",element:/*#__PURE__*/(0,jsx_runtime.jsx)(SubtitleSetting,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"apis",element:/*#__PURE__*/(0,jsx_runtime.jsx)(Apis,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"sync",element:/*#__PURE__*/(0,jsx_runtime.jsx)(SyncSetting,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"words",element:/*#__PURE__*/(0,jsx_runtime.jsx)(FavWords,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"playground",element:/*#__PURE__*/(0,jsx_runtime.jsx)(Playgound,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"about",element:/*#__PURE__*/(0,jsx_runtime.jsx)(About,{})})]})})})})})})});} ;// CONCATENATED MODULE: ./src/options.js const options_root=client.createRoot(document.getElementById("root"));options_root.render(/*#__PURE__*/(0,jsx_runtime.jsx)(react.StrictMode,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(Options,{})})); })(); diff --git a/version.txt b/version.txt index fee3c92..da37822 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -2.0.10 \ No newline at end of file +2.0.11 \ No newline at end of file