diff --git a/dist/chrome/content_scripts/content-0.js b/dist/chrome/content_scripts/content-0.js index b9f618c..03d6980 100644 --- a/dist/chrome/content_scripts/content-0.js +++ b/dist/chrome/content_scripts/content-0.js @@ -1 +1 @@ -(()=>{var s={242:function(){let s={},e=!1,n=!1;function a(e){e.sort(function(s,e){return e.word.length-s.word.length}).forEach(({word:e,replacement:n})=>{s[e]=n}),window.location.hostname.startsWith("issue-council.robertsspaceindustries.com")&&(s.save="保存"),t().then(s=>{})}async function t(){async function s(e,n){if(e.nodeType===Node.TEXT_NODE){let s=e.nodeValue||"",a=u(s);if(s!==a&&n){let t=n.getAttribute("data-original-value")||"";n.setAttribute("data-original-value",t+s),e.nodeValue=a}}else for(let n=0;n{s.innerText=s.getAttribute("data-original-value")||"",s.removeAttribute("data-original-value")}),document.querySelectorAll('input[type="button"], input[type="submit"], input[type="text"], input[type="password"]').forEach(s=>{s.hasAttribute("data-original-value")&&("button"===s.type||"submit"===s.type?s.value=s.getAttribute("data-original-value")||"":s.placeholder=s.getAttribute("data-original-value")||"",s.removeAttribute("data-original-value"))}),Promise.resolve({success:!0})}function i(s,e){let n,a;if("INPUT"===s.tagName){if(n="button"===s.type||"submit"===s.type?"value":"placeholder",a=u(s[n]),s[n]===a)return;let t=e.getAttribute("data-original-value")||"";s.setAttribute("data-original-value",t+s[n])}else{if(a=u(s[n="data"]),s[n]===a)return;let t=e.getAttribute("data-original-value")||"";e.setAttribute("data-original-value",t+s[n])}s[n]=a}function u(n){let a=n.toLowerCase().replace(/\xa0/g," ").replace(/\s{2,}/g," ").trim(),t=n.replace(/\xa0/g," ").replace(/\s{2,}/g," ").trim(),r=a.replace("the ",""),i=a.replace("- ","");if(s[a])n=s[a];else if(e)if(t.includes(" - ")){let e=n,r=t.split(" - ");if("upgrade"===r[0].toLowerCase()&&a.includes("to")&&a.endsWith("edition")){let s=a.replace("standard edition","").replace("upgrade","").replace("warbond edition","").split(" to "),e="升级包 "+u(s[0])+" 到 "+u(s[1]);a.endsWith("warbond edition")?e+=" 战争债券版":e+=" 标准版",n=e}else r.forEach(function(n){e=s[n.toLowerCase()]?e.replace(n,s[n.toLowerCase()]):e.replace(n,u(n))}),n=e}else if(a.endsWith("starter pack")||a.endsWith("starter package")){let e=a.replace("starter package","").replace("starter pack","").trim();s[e.toLowerCase()]&&(e=s[e.toLowerCase()]),n=e+" 新手包"}else a.startsWith("the ")&&s[r]?n=s[r]:a.startsWith("- ")&&s[i]&&(n="- "+s[i]);return n}new(window.MutationObserver||window.WebKitMutationObserver)(function(s,e){for(let e of s)for(let s of e.addedNodes)!function s(e){if(n&&function(s){if(["IMG","svg","mat-icon"].includes(s.tagName)||s.id&&[].includes(s.id))return!1;if(s.classList){for(let e of["css-truncate"])if(s.classList.contains(e))return!1}return!0}(e))for(let n of e.childNodes){if(["RELATIVE-TIME","TIME-AGO"].includes(e.tagName))return void function(s){let e=navigator.language||navigator.language,n=$(s).attr("datetime");$(s).text(timeago.format(n,e.replace("-","_")))}(e);n.nodeType===Node.TEXT_NODE?i(n,e):n.nodeType===Node.ELEMENT_NODE&&("INPUT"===n.tagName?i(n,e):s(n))}}(s)}).observe(document.body,{subtree:!0,characterData:!0,childList:!0}),window.location.href.includes("robertsspaceindustries.com")&&(e=!0),window.location.hostname.includes("www.erkul.games")&&document.body.addEventListener("click",function(s){setTimeout(function(){t().then(s=>{})},200)}),chrome.runtime.sendMessage({action:"_loadLocalizationData",url:window.location.href},function(s){console.log("response ==="+JSON.stringify(s)),s.result.length>0&&(n=!0,a(s.result))}),chrome.runtime.onMessage.addListener((s,t,i)=>{if("_toggleTranslation"===s.action){if(n){n=!1,r();return}n=!0,e=!0,a(s.data)}}),window.addEventListener("message",async s=>{if(s.source!==window||!s.data||"SC_TRANSLATE_REQUEST"!==s.data.type)return;let{action:t}=s.data;if("translate"===t)try{e=!0,chrome.runtime.sendMessage({action:"_loadLocalizationData",url:"manual"},function(s){n=!0,a(s.result)})}catch(s){s.message}else if("undoTranslate"===t)try{await r()}catch(s){s.message}}),window.postMessage({type:"SC-BOX-TRANSLATE-API-AVAILABLE"},"*")},148:function(s,e){(function(s){"use strict";var e=["second","minute","hour","day","week","month","year"];function n(s,n){if(0===n)return["just now","right now"];var a=e[Math.floor(n/2)];return 1=u[t]&&t=u[n]&&n"1.3.8",n.ruid="bundler=rspack@1.3.8",n(242),n(148)})(); \ No newline at end of file +(()=>{var s={242:function(){let s={},e=!1,n=!1;function a(e){e.sort(function(s,e){return e.word.length-s.word.length}).forEach(({word:e,replacement:n})=>{s[e]=n}),window.location.hostname.startsWith("issue-council.robertsspaceindustries.com")&&(s.save="保存"),t().then(s=>{})}async function t(){async function s(e,n){if(e.nodeType===Node.TEXT_NODE){let s=e.nodeValue||"",a=u(s);if(s!==a&&n){let t=n.getAttribute("data-original-value")||"";n.setAttribute("data-original-value",t+s),e.nodeValue=a}}else for(let n=0;n{s.innerText=s.getAttribute("data-original-value")||"",s.removeAttribute("data-original-value")}),document.querySelectorAll('input[type="button"], input[type="submit"], input[type="text"], input[type="password"]').forEach(s=>{s.hasAttribute("data-original-value")&&("button"===s.type||"submit"===s.type?s.value=s.getAttribute("data-original-value")||"":s.placeholder=s.getAttribute("data-original-value")||"",s.removeAttribute("data-original-value"))}),Promise.resolve({success:!0})}function i(s,e){let n,a;if("INPUT"===s.tagName){if(n="button"===s.type||"submit"===s.type?"value":"placeholder",a=u(s[n]),s[n]===a)return;let t=e.getAttribute("data-original-value")||"";s.setAttribute("data-original-value",t+s[n])}else{if(a=u(s[n="data"]),s[n]===a)return;let t=e.getAttribute("data-original-value")||"";e.setAttribute("data-original-value",t+s[n])}s[n]=a}function u(n){let a=n.toLowerCase().replace(/\xa0/g," ").replace(/\s{2,}/g," ").trim(),t=n.replace(/\xa0/g," ").replace(/\s{2,}/g," ").trim(),r=a.replace("the ",""),i=a.replace("- ","");if(s[a])n=s[a];else if(e)if(t.includes(" - ")){let e=n,r=t.split(" - ");if("upgrade"===r[0].toLowerCase()&&a.includes("to")&&a.endsWith("edition")){let s=a.replace("standard edition","").replace("upgrade","").replace("warbond edition","").split(" to "),e="升级包 "+u(s[0])+" 到 "+u(s[1]);a.endsWith("warbond edition")?e+=" 战争债券版":e+=" 标准版",n=e}else r.forEach(function(n){e=s[n.toLowerCase()]?e.replace(n,s[n.toLowerCase()]):e.replace(n,u(n))}),n=e}else if(a.endsWith("starter pack")||a.endsWith("starter package")){let e=a.replace("starter package","").replace("starter pack","").trim();s[e.toLowerCase()]&&(e=s[e.toLowerCase()]),n=e+" 新手包"}else a.startsWith("the ")&&s[r]?n=s[r]:a.startsWith("- ")&&s[i]&&(n="- "+s[i]);return n}new(window.MutationObserver||window.WebKitMutationObserver)(function(s,e){for(let e of s)for(let s of e.addedNodes)!function s(e){if(n&&function(s){if(["IMG","svg","mat-icon"].includes(s.tagName)||s.id&&[].includes(s.id))return!1;if(s.classList){for(let e of["css-truncate"])if(s.classList.contains(e))return!1}return!0}(e))for(let n of e.childNodes){if(["RELATIVE-TIME","TIME-AGO"].includes(e.tagName))return void function(s){let e=navigator.language||navigator.language,n=$(s).attr("datetime");$(s).text(timeago.format(n,e.replace("-","_")))}(e);n.nodeType===Node.TEXT_NODE?i(n,e):n.nodeType===Node.ELEMENT_NODE&&("INPUT"===n.tagName?i(n,e):s(n))}}(s)}).observe(document.body,{subtree:!0,characterData:!0,childList:!0}),window.location.href.includes("robertsspaceindustries.com")&&(e=!0),window.location.hostname.includes("www.erkul.games")&&document.body.addEventListener("click",function(s){setTimeout(function(){t().then(s=>{})},200)}),chrome.runtime.sendMessage({action:"_loadLocalizationData",url:window.location.href},function(s){console.log("response ==="+JSON.stringify(s)),s.result.length>0&&(n=!0,a(s.result))}),chrome.runtime.onMessage.addListener((s,t,i)=>{if("_toggleTranslation"===s.action){if(n){n=!1,r(),window.postMessage({type:"TOGGLED-SC-BOX-TRANSLATE",action:"off"},"*");return}n=!0,e=!0,a(s.data),window.postMessage({type:"TOGGLED-SC-BOX-TRANSLATE",action:"on"},"*")}}),window.addEventListener("message",async s=>{if(s.source!==window||!s.data||"SC_TRANSLATE_REQUEST"!==s.data.type)return;let{action:t}=s.data;if("translate"===t)try{e=!0,chrome.runtime.sendMessage({action:"_loadLocalizationData",url:"manual"},function(s){n=!0,a(s.result)})}catch(s){s.message}else if("undoTranslate"===t)try{await r()}catch(s){s.message}}),window.postMessage({type:"SC-BOX-TRANSLATE-API-AVAILABLE"},"*")},148:function(s,e){(function(s){"use strict";var e=["second","minute","hour","day","week","month","year"];function n(s,n){if(0===n)return["just now","right now"];var a=e[Math.floor(n/2)];return 1=u[t]&&t=u[n]&&n"1.3.8",n.ruid="bundler=rspack@1.3.8",n(242),n(148)})(); \ No newline at end of file