diff --git a/background.js b/background.js index 370efaf..545ba67 100644 --- a/background.js +++ b/background.js @@ -155,7 +155,7 @@ function setLocalData(key, data) { chrome.runtime.onInstalled.addListener(function () { chrome.contextMenus.create({ id: "translate", - title: "翻译本页面", + title: "切换翻译", contexts: ["page"] }); }); @@ -163,6 +163,6 @@ chrome.runtime.onInstalled.addListener(function () { chrome.contextMenus.onClicked.addListener((info, tab) => { console.log("contextMenus", info, tab); _initLocalization("manual").then(data => { - chrome.tabs.sendMessage(tab.id, {action: "_initTranslation", data}); + chrome.tabs.sendMessage(tab.id, {action: "_toggleTranslation", data}); }); }); diff --git a/core.js b/core.js index 3ce781b..c6c2ee0 100644 --- a/core.js +++ b/core.js @@ -1,5 +1,6 @@ let SCLocalizationReplaceLocalesMap = {}; let SCLocalizationEnableSplitMode = false; +let SCLocalizationTranslating = false; function InitWebLocalization() { // init script @@ -25,7 +26,6 @@ function LocalizationWatchUpdate() { }); if (window.location.href.includes("robertsspaceindustries.com")) { - console.log("SCLocalizationEnableSplitMode = true"); SCLocalizationEnableSplitMode = true; } @@ -51,16 +51,25 @@ function WebLocalizationUpdateReplaceWords(w) { } allTranslate().then(_ => { }); - // console.log("WebLocalizationUpdateReplaceWords ==" + w) } async function allTranslate() { - async function replaceTextNode(node1) { - if (node1.nodeType === Node.TEXT_NODE) { - node1.nodeValue = GetSCLocalizationTranslateString(node1.nodeValue); + SCLocalizationTranslating = true; + + async function replaceTextNode(node, parentNode) { + if (node.nodeType === Node.TEXT_NODE) { + // 保存原始文本内容 + const originalText = node.nodeValue; + const translatedText = GetSCLocalizationTranslateString(originalText); + + // 只有当文本发生变化时才保存原始文本 + if (originalText !== translatedText) { + parentNode.setAttribute('data-original-value', originalText); + node.nodeValue = translatedText; + } } else { - for (let i = 0; i < node1.childNodes.length; i++) { - await replaceTextNode(node1.childNodes[i]); + for (let i = 0; i < node.childNodes.length; i++) { + await replaceTextNode(node.childNodes[i], node); } } } @@ -68,7 +77,36 @@ async function allTranslate() { await replaceTextNode(document.body); } +async function undoTranslate() { + SCLocalizationTranslating = false; + + document.querySelectorAll('*[data-original-value]').forEach(element => { + element.innerText = element.getAttribute('data-original-value'); + element.removeAttribute('data-original-value'); + }); + + // 处理输入元素 + const inputElements = document.querySelectorAll('input[type="button"], input[type="submit"], input[type="text"], input[type="password"]'); + inputElements.forEach(el => { + // 尝试从 data-original-value 属性恢复原始值 + if (el.hasAttribute('data-original-value')) { + if (el.type === 'button' || el.type === 'submit') { + el.value = el.getAttribute('data-original-value'); + } else { + el.placeholder = el.getAttribute('data-original-value'); + } + el.removeAttribute('data-original-value'); + } + }); + + return { success: true }; +} + function traverseElement(el) { + if (!SCLocalizationTranslating) { + return; + } + if (!shouldTranslateEl(el)) { return } @@ -80,12 +118,12 @@ function traverseElement(el) { } if (child.nodeType === Node.TEXT_NODE) { - translateElement(child); + translateElement(child, el); } else if (child.nodeType === Node.ELEMENT_NODE) { if (child.tagName === "INPUT") { - translateElement(child); + translateElement(child, el); } else { - traverseElement(child); + traverseElement(child, el); } } else { // pass @@ -93,7 +131,7 @@ function traverseElement(el) { } } -function translateElement(el) { +function translateElement(el, parentNode) { // Get the text field name let k; if (el.tagName === "INPUT") { @@ -102,8 +140,11 @@ function translateElement(el) { } else { k = 'placeholder'; } + + el.setAttribute('data-original-value', el[k]); } else { k = 'data'; + parentNode.setAttribute('data-original-value', el[k]); } el[k] = GetSCLocalizationTranslateString(el[k]); } @@ -189,23 +230,26 @@ InitWebLocalization(); function _loadLocalizationData() { chrome.runtime.sendMessage({ action: "_loadLocalizationData", url: window.location.href }, function (response) { - console.log("response ==" + JSON.stringify(response)); WebLocalizationUpdateReplaceWords(response.result); }); } chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { - if (request.action === "_initTranslation") { + if (request.action === "_toggleTranslation") { + if (SCLocalizationTranslating) { + SCLocalizationTranslating = false; + undoTranslate(); + return; + } SCLocalizationEnableSplitMode = true; WebLocalizationUpdateReplaceWords(request.data); } }); window.addEventListener('message', async (event) => { - console.log(event) if (event.source !== window || !event.data || event.data.type !== 'SC_TRANSLATE_REQUEST') return; - const { action, payload } = event.data; + const { action } = event.data; let response = { success: false }; @@ -215,17 +259,13 @@ window.addEventListener('message', async (event) => { chrome.runtime.sendMessage({ action: "_loadLocalizationData", url: "manual" }, function (response) { WebLocalizationUpdateReplaceWords(response.result); }); + response = { success: true }; } catch (error) { response = { success: false, error: error.message }; } - } else if (action === 'updateReplaceWords') { + } else if (action === 'undoTranslate') { try { - if (payload && payload.words && Array.isArray(payload.words)) { - WebLocalizationUpdateReplaceWords(payload.words); - response = { success: true }; - } else { - response = { success: false, error: 'Invalid words format' }; - } + response = await undoTranslate(); } catch (error) { response = { success: false, error: error.message }; } diff --git a/dist/chrome/background/service_worker.js b/dist/chrome/background/service_worker.js index a939898..3c4ff15 100644 --- a/dist/chrome/background/service_worker.js +++ b/dist/chrome/background/service_worker.js @@ -1 +1 @@ -(()=>{var e={},t={};function s(r){var n=t[r];if(void 0!==n)return n.exports;var o=t[r]={exports:{}};return e[r](o,o.exports,s),o.exports}s.rv=()=>"1.3.8",s.ruid="bundler=rspack@1.3.8";let r=null;async function n(){r=await a("versions.json"),console.log("Localization Version ==="),console.log(r)}async function o(e){if(console.log("url ==="+e),null==r)return await n(),o(e);let t=r,s={};e.includes("robertsspaceindustries.com")||e.includes("manual")?(s["zh-CN"]=await a("zh-CN-rsi.json",{cacheKey:"zh-CN",version:t.rsi}),s.concierge=await a("concierge.json",{cacheKey:"concierge",version:t.concierge}),s.orgs=await a("orgs.json",t.orgs),s.address=await a("addresses.json",{cacheKey:"orgs",version:t.addresses}),s.hangar=await a("hangar.json",{cacheKey:"hangar",version:t.hangar})):e.includes("uexcorp.space")?s.UEX=await a("zh-CN-uex.json",{cacheKey:"uex",version:t.uex}):e.includes("erkul.games")&&(s.DPS=await a("zh-CN-dps.json",{cacheKey:"dps",version:t.dps}));let c=[];function i(e){c.push(...function(e,t){let s=[],r=e[t];if("object"==typeof r)for(let[e,t]of Object.entries(r)){let r=e.toString().trim().toLowerCase().replace(/\xa0/g," ").replace(/\s{2,}/g," ");s.push({word:r,replacement:t.toString()})}return s}(s,e))}if(e.includes("robertsspaceindustries.com")||e.includes("manual")){if(e.startsWith("https://robertsspaceindustries.com/spectrum/community/"))return;i("zh-CN"),(e.startsWith("https://robertsspaceindustries.com/orgs")||e.startsWith("https://robertsspaceindustries.com/citizens")||e.startsWith("https://robertsspaceindustries.com/account/organization"))&&(c.push({word:"members",replacement:"名成员"}),i("orgs")),e.startsWith("https://robertsspaceindustries.com/account/addresses")&&i("address"),e.startsWith("https://robertsspaceindustries.com/account/referral-program")&&c.push({word:"Total recruits: ",replacement:"总邀请数:"},{word:"Prospects ",replacement:"未完成的邀请"},{word:"Recruits",replacement:"已完成的邀请"}),e.startsWith("https://robertsspaceindustries.com/account/concierge")&&(c=[],i("concierge")),e.startsWith("https://robertsspaceindustries.com/account/pledges")&&i("hangar")}else e.includes("uexcorp.space")?i("UEX"):e.includes("erkul.games")&&i("DPS");return c}async function a(e,{cacheKey:t="",version:s=null}={}){if(url="https://git.scbox.xkeyc.cn/SCToolBox/ScWeb_Chinese_Translate/raw/branch/main/json/locales/"+e,t&&""!==t){let e=await c(`${t}_version`),r=await c(t);if(r&&"object"==typeof r&&Object.keys(r).length>0&&e===s)return r}let r=new Date,n=await fetch(url,{method:"GET",mode:"cors"}),o=new Date,u=await n.json();return t&&""!==t&&(console.log(`update ${t} v == ${s} time == ${(o-r)/1e3}s`),await i(t,u),await i(`${t}_version`,s)),u}function c(e){return new Promise(t=>{chrome.storage.local.get([e],s=>{t(s[e]||null)})})}function i(e,t){return new Promise(s=>{let r={};r[e]=t,chrome.storage.local.set(r,()=>{s()})})}chrome.runtime.onInstalled.addListener(function(){n().then(e=>{}),console.log("SWTT init")}),chrome.runtime.onMessage.addListener(function(e,t,s){if("_loadLocalizationData"===e.action)return o(e.url).then(e=>{s({result:e})}),!0}),chrome.runtime.onInstalled.addListener(function(){chrome.contextMenus.create({id:"translate",title:"翻译本页面",contexts:["page"]})}),chrome.contextMenus.onClicked.addListener((e,t)=>{console.log("contextMenus",e,t),o("manual").then(e=>{chrome.tabs.sendMessage(t.id,{action:"_initTranslation",data:e})})})})(); \ No newline at end of file +(()=>{var e={},t={};function s(r){var n=t[r];if(void 0!==n)return n.exports;var o=t[r]={exports:{}};return e[r](o,o.exports,s),o.exports}s.rv=()=>"1.3.8",s.ruid="bundler=rspack@1.3.8";let r=null;async function n(){r=await a("versions.json"),console.log("Localization Version ==="),console.log(r)}async function o(e){if(console.log("url ==="+e),null==r)return await n(),o(e);let t=r,s={};e.includes("robertsspaceindustries.com")||e.includes("manual")?(s["zh-CN"]=await a("zh-CN-rsi.json",{cacheKey:"zh-CN",version:t.rsi}),s.concierge=await a("concierge.json",{cacheKey:"concierge",version:t.concierge}),s.orgs=await a("orgs.json",t.orgs),s.address=await a("addresses.json",{cacheKey:"orgs",version:t.addresses}),s.hangar=await a("hangar.json",{cacheKey:"hangar",version:t.hangar})):e.includes("uexcorp.space")?s.UEX=await a("zh-CN-uex.json",{cacheKey:"uex",version:t.uex}):e.includes("erkul.games")&&(s.DPS=await a("zh-CN-dps.json",{cacheKey:"dps",version:t.dps}));let c=[];function i(e){c.push(...function(e,t){let s=[],r=e[t];if("object"==typeof r)for(let[e,t]of Object.entries(r)){let r=e.toString().trim().toLowerCase().replace(/\xa0/g," ").replace(/\s{2,}/g," ");s.push({word:r,replacement:t.toString()})}return s}(s,e))}if(e.includes("robertsspaceindustries.com")||e.includes("manual")){if(e.startsWith("https://robertsspaceindustries.com/spectrum/community/"))return;i("zh-CN"),(e.startsWith("https://robertsspaceindustries.com/orgs")||e.startsWith("https://robertsspaceindustries.com/citizens")||e.startsWith("https://robertsspaceindustries.com/account/organization"))&&(c.push({word:"members",replacement:"名成员"}),i("orgs")),e.startsWith("https://robertsspaceindustries.com/account/addresses")&&i("address"),e.startsWith("https://robertsspaceindustries.com/account/referral-program")&&c.push({word:"Total recruits: ",replacement:"总邀请数:"},{word:"Prospects ",replacement:"未完成的邀请"},{word:"Recruits",replacement:"已完成的邀请"}),e.startsWith("https://robertsspaceindustries.com/account/concierge")&&(c=[],i("concierge")),e.startsWith("https://robertsspaceindustries.com/account/pledges")&&i("hangar")}else e.includes("uexcorp.space")?i("UEX"):e.includes("erkul.games")&&i("DPS");return c}async function a(e,{cacheKey:t="",version:s=null}={}){if(url="https://git.scbox.xkeyc.cn/SCToolBox/ScWeb_Chinese_Translate/raw/branch/main/json/locales/"+e,t&&""!==t){let e=await c(`${t}_version`),r=await c(t);if(r&&"object"==typeof r&&Object.keys(r).length>0&&e===s)return r}let r=new Date,n=await fetch(url,{method:"GET",mode:"cors"}),o=new Date,u=await n.json();return t&&""!==t&&(console.log(`update ${t} v == ${s} time == ${(o-r)/1e3}s`),await i(t,u),await i(`${t}_version`,s)),u}function c(e){return new Promise(t=>{chrome.storage.local.get([e],s=>{t(s[e]||null)})})}function i(e,t){return new Promise(s=>{let r={};r[e]=t,chrome.storage.local.set(r,()=>{s()})})}chrome.runtime.onInstalled.addListener(function(){n().then(e=>{}),console.log("SWTT init")}),chrome.runtime.onMessage.addListener(function(e,t,s){if("_loadLocalizationData"===e.action)return o(e.url).then(e=>{s({result:e})}),!0}),chrome.runtime.onInstalled.addListener(function(){chrome.contextMenus.create({id:"translate",title:"切换翻译",contexts:["page"]})}),chrome.contextMenus.onClicked.addListener((e,t)=>{console.log("contextMenus",e,t),o("manual").then(e=>{chrome.tabs.sendMessage(t.id,{action:"_toggleTranslation",data:e})})})})(); \ No newline at end of file diff --git a/dist/chrome/content_scripts/content-0.js b/dist/chrome/content_scripts/content-0.js index 3da736b..352d182 100644 --- a/dist/chrome/content_scripts/content-0.js +++ b/dist/chrome/content_scripts/content-0.js @@ -1 +1 @@ -(()=>{var s={756:function(){let s={},n=!1;function e(n){n.sort(function(s,n){return n.word.length-s.word.length}).forEach(({word:n,replacement:e})=>{s[n]=e}),window.location.hostname.startsWith("issue-council.robertsspaceindustries.com")&&(s.save="保存"),a().then(s=>{})}async function a(){async function s(n){if(n.nodeType===Node.TEXT_NODE)n.nodeValue=r(n.nodeValue);else for(let e=0;e{})},200)}),chrome.runtime.sendMessage({action:"_loadLocalizationData",url:window.location.href},function(s){console.log("response =="+JSON.stringify(s)),e(s.result)}),chrome.runtime.onMessage.addListener((s,a,t)=>{"_initTranslation"===s.action&&(n=!0,e(s.data))}),window.addEventListener("message",async s=>{if(console.log(s),s.source!==window||!s.data||"SC_TRANSLATE_REQUEST"!==s.data.type)return;let{action:a,payload:t}=s.data;if("translate"===a)try{n=!0,chrome.runtime.sendMessage({action:"_loadLocalizationData",url:"manual"},function(s){e(s.result)})}catch(s){s.message}else if("updateReplaceWords"===a)try{t&&t.words&&Array.isArray(t.words)&&e(t.words)}catch(s){s.message}}),window.postMessage({type:"SC-BOX-TRANSLATE-API-AVAILABLE"},"*")},928:function(s,n){(function(s){"use strict";var n=["second","minute","hour","day","week","month","year"];function e(s,e){if(0===e)return["just now","right now"];var a=n[Math.floor(e/2)];return 1=u[t]&&t=u[e]&&e"1.3.8",e.ruid="bundler=rspack@1.3.8",e(756),e(928)})(); \ No newline at end of file +(()=>{var s={756:function(){let s={},n=!1,e=!1;function a(n){n.sort(function(s,n){return n.word.length-s.word.length}).forEach(({word:n,replacement:e})=>{s[n]=e}),window.location.hostname.startsWith("issue-council.robertsspaceindustries.com")&&(s.save="保存"),t().then(s=>{})}async function t(){async function s(n,e){if(n.nodeType===Node.TEXT_NODE){let s=n.nodeValue,a=u(s);s!==a&&(e.setAttribute("data-original-value",s),n.nodeValue=a)}else for(let e=0;e{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"))}),{success:!0}}function i(s,n){let e;"INPUT"===s.tagName?(e="button"===s.type||"submit"===s.type?"value":"placeholder",s.setAttribute("data-original-value",s[e])):(e="data",n.setAttribute("data-original-value",s[e])),s[e]=u(s[e])}function u(e){let a=e.toLowerCase().replace(/\xa0/g," ").replace(/\s{2,}/g," ").trim(),t=e.replace(/\xa0/g," ").replace(/\s{2,}/g," ").trim(),r=a.replace("the ",""),i=a.replace("- ","");if(s[a])e=s[a];else if(n)if(t.includes(" - ")){let n=e,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 "),n="升级包 "+u(s[0])+" 到 "+u(s[1]);a.endsWith("warbond edition")?n+=" 战争债券版":n+=" 标准版",e=n}else r.forEach(function(e){n=s[e.toLowerCase()]?n.replace(e,s[e.toLowerCase()]):n.replace(e,u(e))}),e=n}else if(a.endsWith("starter pack")||a.endsWith("starter package")){let n=a.replace("starter package","").replace("starter pack","").trim();s[n.toLowerCase()]&&(n=s[n.toLowerCase()]),e=n+" 新手包"}else a.startsWith("the ")&&s[r]?e=s[r]:a.startsWith("- ")&&s[i]&&(e="- "+s[i]);return e}new(window.MutationObserver||window.WebKitMutationObserver)(function(s,n){for(let n of s)for(let s of n.addedNodes)!function s(n){if(e&&function(s){if(["IMG","svg","mat-icon"].includes(s.tagName)||s.id&&[].includes(s.id))return!1;if(s.classList){for(let n of["css-truncate"])if(s.classList.contains(n))return!1}return!0}(n))for(let e of n.childNodes){if(["RELATIVE-TIME","TIME-AGO"].includes(n.tagName))return void function(s){let n=navigator.language||navigator.userLanguage,e=$(s).attr("datetime");$(s).text(timeago.format(e,n.replace("-","_")))}(n);e.nodeType===Node.TEXT_NODE?i(e,n):e.nodeType===Node.ELEMENT_NODE&&("INPUT"===e.tagName?i(e,n):s(e,n))}}(s)}).observe(document.body,{subtree:!0,characterData:!0,childList:!0}),window.location.href.includes("robertsspaceindustries.com")&&(n=!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){a(s.result)}),chrome.runtime.onMessage.addListener((s,t,i)=>{if("_toggleTranslation"===s.action){if(e){e=!1,r();return}n=!0,a(s.data)}}),window.addEventListener("message",async s=>{if(s.source!==window||!s.data||"SC_TRANSLATE_REQUEST"!==s.data.type)return;let{action:e}=s.data;if("translate"===e)try{n=!0,chrome.runtime.sendMessage({action:"_loadLocalizationData",url:"manual"},function(s){a(s.result)})}catch(s){s.message}else if("undoTranslate"===e)try{await r()}catch(s){s.message}}),window.postMessage({type:"SC-BOX-TRANSLATE-API-AVAILABLE"},"*")},928:function(s,n){(function(s){"use strict";var n=["second","minute","hour","day","week","month","year"];function e(s,e){if(0===e)return["just now","right now"];var a=n[Math.floor(e/2)];return 1=u[t]&&t=u[e]&&e"1.3.8",e.ruid="bundler=rspack@1.3.8",e(756),e(928)})(); \ No newline at end of file diff --git a/dist/firefox/action/default_popup.html b/dist/firefox/action/default_popup.html deleted file mode 100644 index 8017a43..0000000 --- a/dist/firefox/action/default_popup.html +++ /dev/null @@ -1,93 +0,0 @@ - - - 星际公民盒子浏览器拓展 - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/dist/firefox/background/scripts.js b/dist/firefox/background/scripts.js deleted file mode 100644 index a939898..0000000 --- a/dist/firefox/background/scripts.js +++ /dev/null @@ -1 +0,0 @@ -(()=>{var e={},t={};function s(r){var n=t[r];if(void 0!==n)return n.exports;var o=t[r]={exports:{}};return e[r](o,o.exports,s),o.exports}s.rv=()=>"1.3.8",s.ruid="bundler=rspack@1.3.8";let r=null;async function n(){r=await a("versions.json"),console.log("Localization Version ==="),console.log(r)}async function o(e){if(console.log("url ==="+e),null==r)return await n(),o(e);let t=r,s={};e.includes("robertsspaceindustries.com")||e.includes("manual")?(s["zh-CN"]=await a("zh-CN-rsi.json",{cacheKey:"zh-CN",version:t.rsi}),s.concierge=await a("concierge.json",{cacheKey:"concierge",version:t.concierge}),s.orgs=await a("orgs.json",t.orgs),s.address=await a("addresses.json",{cacheKey:"orgs",version:t.addresses}),s.hangar=await a("hangar.json",{cacheKey:"hangar",version:t.hangar})):e.includes("uexcorp.space")?s.UEX=await a("zh-CN-uex.json",{cacheKey:"uex",version:t.uex}):e.includes("erkul.games")&&(s.DPS=await a("zh-CN-dps.json",{cacheKey:"dps",version:t.dps}));let c=[];function i(e){c.push(...function(e,t){let s=[],r=e[t];if("object"==typeof r)for(let[e,t]of Object.entries(r)){let r=e.toString().trim().toLowerCase().replace(/\xa0/g," ").replace(/\s{2,}/g," ");s.push({word:r,replacement:t.toString()})}return s}(s,e))}if(e.includes("robertsspaceindustries.com")||e.includes("manual")){if(e.startsWith("https://robertsspaceindustries.com/spectrum/community/"))return;i("zh-CN"),(e.startsWith("https://robertsspaceindustries.com/orgs")||e.startsWith("https://robertsspaceindustries.com/citizens")||e.startsWith("https://robertsspaceindustries.com/account/organization"))&&(c.push({word:"members",replacement:"名成员"}),i("orgs")),e.startsWith("https://robertsspaceindustries.com/account/addresses")&&i("address"),e.startsWith("https://robertsspaceindustries.com/account/referral-program")&&c.push({word:"Total recruits: ",replacement:"总邀请数:"},{word:"Prospects ",replacement:"未完成的邀请"},{word:"Recruits",replacement:"已完成的邀请"}),e.startsWith("https://robertsspaceindustries.com/account/concierge")&&(c=[],i("concierge")),e.startsWith("https://robertsspaceindustries.com/account/pledges")&&i("hangar")}else e.includes("uexcorp.space")?i("UEX"):e.includes("erkul.games")&&i("DPS");return c}async function a(e,{cacheKey:t="",version:s=null}={}){if(url="https://git.scbox.xkeyc.cn/SCToolBox/ScWeb_Chinese_Translate/raw/branch/main/json/locales/"+e,t&&""!==t){let e=await c(`${t}_version`),r=await c(t);if(r&&"object"==typeof r&&Object.keys(r).length>0&&e===s)return r}let r=new Date,n=await fetch(url,{method:"GET",mode:"cors"}),o=new Date,u=await n.json();return t&&""!==t&&(console.log(`update ${t} v == ${s} time == ${(o-r)/1e3}s`),await i(t,u),await i(`${t}_version`,s)),u}function c(e){return new Promise(t=>{chrome.storage.local.get([e],s=>{t(s[e]||null)})})}function i(e,t){return new Promise(s=>{let r={};r[e]=t,chrome.storage.local.set(r,()=>{s()})})}chrome.runtime.onInstalled.addListener(function(){n().then(e=>{}),console.log("SWTT init")}),chrome.runtime.onMessage.addListener(function(e,t,s){if("_loadLocalizationData"===e.action)return o(e.url).then(e=>{s({result:e})}),!0}),chrome.runtime.onInstalled.addListener(function(){chrome.contextMenus.create({id:"translate",title:"翻译本页面",contexts:["page"]})}),chrome.contextMenus.onClicked.addListener((e,t)=>{console.log("contextMenus",e,t),o("manual").then(e=>{chrome.tabs.sendMessage(t.id,{action:"_initTranslation",data:e})})})})(); \ No newline at end of file diff --git a/dist/firefox/content_scripts/content-0.js b/dist/firefox/content_scripts/content-0.js deleted file mode 100644 index 3da736b..0000000 --- a/dist/firefox/content_scripts/content-0.js +++ /dev/null @@ -1 +0,0 @@ -(()=>{var s={756:function(){let s={},n=!1;function e(n){n.sort(function(s,n){return n.word.length-s.word.length}).forEach(({word:n,replacement:e})=>{s[n]=e}),window.location.hostname.startsWith("issue-council.robertsspaceindustries.com")&&(s.save="保存"),a().then(s=>{})}async function a(){async function s(n){if(n.nodeType===Node.TEXT_NODE)n.nodeValue=r(n.nodeValue);else for(let e=0;e{})},200)}),chrome.runtime.sendMessage({action:"_loadLocalizationData",url:window.location.href},function(s){console.log("response =="+JSON.stringify(s)),e(s.result)}),chrome.runtime.onMessage.addListener((s,a,t)=>{"_initTranslation"===s.action&&(n=!0,e(s.data))}),window.addEventListener("message",async s=>{if(console.log(s),s.source!==window||!s.data||"SC_TRANSLATE_REQUEST"!==s.data.type)return;let{action:a,payload:t}=s.data;if("translate"===a)try{n=!0,chrome.runtime.sendMessage({action:"_loadLocalizationData",url:"manual"},function(s){e(s.result)})}catch(s){s.message}else if("updateReplaceWords"===a)try{t&&t.words&&Array.isArray(t.words)&&e(t.words)}catch(s){s.message}}),window.postMessage({type:"SC-BOX-TRANSLATE-API-AVAILABLE"},"*")},928:function(s,n){(function(s){"use strict";var n=["second","minute","hour","day","week","month","year"];function e(s,e){if(0===e)return["just now","right now"];var a=n[Math.floor(e/2)];return 1=u[t]&&t=u[e]&&e"1.3.8",e.ruid="bundler=rspack@1.3.8",e(756),e(928)})(); \ No newline at end of file diff --git a/dist/firefox/content_scripts/content-1.js b/dist/firefox/content_scripts/content-1.js deleted file mode 100644 index 60004cc..0000000 --- a/dist/firefox/content_scripts/content-1.js +++ /dev/null @@ -1 +0,0 @@ -(()=>{var e={282:function(e){!function(t,n){"use strict";"object"==typeof e.exports?e.exports=t.document?n(t,!0):function(e){if(!e.document)throw Error("jQuery requires a window with a document");return n(e)}:n(t)}("undefined"!=typeof window?window:this,function(e,t){"use strict";var n=[],r=Object.getPrototypeOf,i=n.slice,o=n.flat?function(e){return n.flat.call(e)}:function(e){return n.concat.apply([],e)},a=n.push,s=n.indexOf,u={},l=u.toString,c=u.hasOwnProperty,f=c.toString,p=f.call(Object),d={},h=function(e){return"function"==typeof e&&"number"!=typeof e.nodeType},g=function(e){return null!=e&&e===e.window},v=e.document,y={type:!0,src:!0,nonce:!0,noModule:!0};function m(e,t,n){var r,i,o=(n=n||v).createElement("script");if(o.text=e,t)for(r in y)(i=t[r]||t.getAttribute&&t.getAttribute(r))&&o.setAttribute(r,i);n.head.appendChild(o).parentNode.removeChild(o)}function x(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?u[l.call(e)]||"object":typeof e}var b="3.5.1",w=function(e,t){return new w.fn.init(e,t)};function T(e){var t=!!e&&"length"in e&&e.length,n=x(e);return!h(e)&&!g(e)&&("array"===n||0===t||"number"==typeof t&&0+~]|"+M+")"+M+"*"),U=RegExp(M+"|>"),X=new RegExp(F),V=RegExp("^"+I+"$"),G={ID:RegExp("^#("+I+")"),CLASS:RegExp("^\\.("+I+")"),TAG:RegExp("^("+I+"|[*])"),ATTR:RegExp("^"+W),PSEUDO:RegExp("^"+F),CHILD:RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:RegExp("^(?:"+R+")$","i"),needsContext:RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},Y=/HTML$/i,Q=/^(?:input|select|textarea|button)$/i,J=/^h\d$/i,K=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ee=/[+~]/,et=RegExp("\\\\[\\da-fA-F]{1,6}"+M+"?|\\\\([^\\r\\n\\f])","g"),en=function(e,t){var n="0x"+e.slice(1)-65536;return t||(n<0?String.fromCharCode(n+65536):String.fromCharCode(n>>10|55296,1023&n|56320))},er=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ei=function(e,t){return t?"\0"===e?"�":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},eo=function(){p()},ea=em(function(e){return!0===e.disabled&&"fieldset"===e.nodeName.toLowerCase()},{dir:"parentNode",next:"legend"});try{H.apply(j=O.call(w.childNodes),w.childNodes),j[w.childNodes.length].nodeType}catch(e){H={apply:j.length?function(e,t){L.apply(e,O.call(t))}:function(e,t){for(var n=e.length,r=0;e[n++]=t[r++];);e.length=n-1}}}function es(e,t,r,i){var o,s,l,c,f,h,y,m=t&&t.ownerDocument,w=t?t.nodeType:9;if(r=r||[],"string"!=typeof e||!e||1!==w&&9!==w&&11!==w)return r;if(!i&&(p(t),t=t||d,g)){if(11!==w&&(f=Z.exec(e)))if(o=f[1]){if(9===w){if(!(l=t.getElementById(o)))return r;if(l.id===o)return r.push(l),r}else if(m&&(l=m.getElementById(o))&&x(t,l)&&l.id===o)return r.push(l),r}else{if(f[2])return H.apply(r,t.getElementsByTagName(e)),r;if((o=f[3])&&n.getElementsByClassName&&t.getElementsByClassName)return H.apply(r,t.getElementsByClassName(o)),r}if(n.qsa&&!A[e+" "]&&(!v||!v.test(e))&&(1!==w||"object"!==t.nodeName.toLowerCase())){if(y=e,m=t,1===w&&(U.test(e)||z.test(e))){for((m=ee.test(e)&&eg(t.parentNode)||t)===t&&n.scope||((c=t.getAttribute("id"))?c=c.replace(er,ei):t.setAttribute("id",c=b)),s=(h=a(e)).length;s--;)h[s]=(c?"#"+c:":scope")+" "+ey(h[s]);y=h.join(",")}try{return H.apply(r,m.querySelectorAll(y)),r}catch(t){A(e,!0)}finally{c===b&&t.removeAttribute("id")}}}return u(e.replace($,"$1"),t,r,i)}function eu(){var e=[];return function t(n,i){return e.push(n+" ")>r.cacheLength&&delete t[e.shift()],t[n+" "]=i}}function el(e){return e[b]=!0,e}function ec(e){var t=d.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function ef(e,t){for(var n=e.split("|"),i=n.length;i--;)r.attrHandle[n[i]]=t}function ep(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(r)return r;if(n){for(;n=n.nextSibling;)if(n===t)return -1}return e?1:-1}function ed(e){return function(t){return"form"in t?t.parentNode&&!1===t.disabled?"label"in t?"label"in t.parentNode?t.parentNode.disabled===e:t.disabled===e:t.isDisabled===e||!e!==t.isDisabled&&ea(t)===e:t.disabled===e:"label"in t&&t.disabled===e}}function eh(e){return el(function(t){return t*=1,el(function(n,r){for(var i,o=e([],n.length,t),a=o.length;a--;)n[i=o[a]]&&(n[i]=!(r[i]=n[i]))})})}function eg(e){return e&&void 0!==e.getElementsByTagName&&e}for(t in n=es.support={},o=es.isXML=function(e){var t=e.namespaceURI,n=(e.ownerDocument||e).documentElement;return!Y.test(t||n&&n.nodeName||"HTML")},p=es.setDocument=function(e){var t,i,a=e?e.ownerDocument||e:w;return a!=d&&9===a.nodeType&&a.documentElement&&(h=(d=a).documentElement,g=!o(d),w!=d&&(i=d.defaultView)&&i.top!==i&&(i.addEventListener?i.addEventListener("unload",eo,!1):i.attachEvent&&i.attachEvent("onunload",eo)),n.scope=ec(function(e){return h.appendChild(e).appendChild(d.createElement("div")),void 0!==e.querySelectorAll&&!e.querySelectorAll(":scope fieldset div").length}),n.attributes=ec(function(e){return e.className="i",!e.getAttribute("className")}),n.getElementsByTagName=ec(function(e){return e.appendChild(d.createComment("")),!e.getElementsByTagName("*").length}),n.getElementsByClassName=K.test(d.getElementsByClassName),n.getById=ec(function(e){return h.appendChild(e).id=b,!d.getElementsByName||!d.getElementsByName(b).length}),n.getById?(r.filter.ID=function(e){var t=e.replace(et,en);return function(e){return e.getAttribute("id")===t}},r.find.ID=function(e,t){if(void 0!==t.getElementById&&g){var n=t.getElementById(e);return n?[n]:[]}}):(r.filter.ID=function(e){var t=e.replace(et,en);return function(e){var n=void 0!==e.getAttributeNode&&e.getAttributeNode("id");return n&&n.value===t}},r.find.ID=function(e,t){if(void 0!==t.getElementById&&g){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];for(i=t.getElementsByName(e),r=0;o=i[r++];)if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),r.find.TAG=n.getElementsByTagName?function(e,t){return void 0!==t.getElementsByTagName?t.getElementsByTagName(e):n.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){for(;n=o[i++];)1===n.nodeType&&r.push(n);return r}return o},r.find.CLASS=n.getElementsByClassName&&function(e,t){if(void 0!==t.getElementsByClassName&&g)return t.getElementsByClassName(e)},y=[],v=[],(n.qsa=K.test(d.querySelectorAll))&&(ec(function(e){var t;h.appendChild(e).innerHTML="",e.querySelectorAll("[msallowcapture^='']").length&&v.push("[*^$]="+M+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||v.push("\\["+M+"*(?:value|"+R+")"),e.querySelectorAll("[id~="+b+"-]").length||v.push("~="),(t=d.createElement("input")).setAttribute("name",""),e.appendChild(t),e.querySelectorAll("[name='']").length||v.push("\\["+M+"*name"+M+"*="+M+"*(?:''|\"\")"),e.querySelectorAll(":checked").length||v.push(":checked"),e.querySelectorAll("a#"+b+"+*").length||v.push(".#.+[+~]"),e.querySelectorAll("\\\f"),v.push("[\\r\\n\\f]")}),ec(function(e){e.innerHTML="";var t=d.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&v.push("name"+M+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&v.push(":enabled",":disabled"),h.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&v.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),v.push(",.*:")})),(n.matchesSelector=K.test(m=h.matches||h.webkitMatchesSelector||h.mozMatchesSelector||h.oMatchesSelector||h.msMatchesSelector))&&ec(function(e){n.disconnectedMatch=m.call(e,"*"),m.call(e,"[s!='']:x"),y.push("!=",F)}),v=v.length&&new RegExp(v.join("|")),y=y.length&&new RegExp(y.join("|")),x=(t=K.test(h.compareDocumentPosition))||K.test(h.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t){for(;t=t.parentNode;)if(t===e)return!0}return!1},N=t?function(e,t){if(e===t)return f=!0,0;var r=!e.compareDocumentPosition-!t.compareDocumentPosition;return r||(1&(r=(e.ownerDocument||e)==(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!n.sortDetached&&t.compareDocumentPosition(e)===r?e==d||e.ownerDocument==w&&x(w,e)?-1:t==d||t.ownerDocument==w&&x(w,t)?1:c?P(c,e)-P(c,t):0:4&r?-1:1)}:function(e,t){if(e===t)return f=!0,0;var n,r=0,i=e.parentNode,o=t.parentNode,a=[e],s=[t];if(!i||!o)return e==d?-1:t==d?1:i?-1:o?1:c?P(c,e)-P(c,t):0;if(i===o)return ep(e,t);for(n=e;n=n.parentNode;)a.unshift(n);for(n=t;n=n.parentNode;)s.unshift(n);for(;a[r]===s[r];)r++;return r?ep(a[r],s[r]):a[r]==w?-1:+(s[r]==w)}),d},es.matches=function(e,t){return es(e,null,null,t)},es.matchesSelector=function(e,t){if(p(e),n.matchesSelector&&g&&!A[t+" "]&&(!y||!y.test(t))&&(!v||!v.test(t)))try{var r=m.call(e,t);if(r||n.disconnectedMatch||e.document&&11!==e.document.nodeType)return r}catch(e){A(t,!0)}return 0":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(et,en),e[3]=(e[3]||e[4]||e[5]||"").replace(et,en),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||es.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&es.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return G.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&X.test(n)&&(t=a(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(et,en).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=E[e+" "];return t||(t=RegExp("(^|"+M+")"+e+"("+M+"|$)"))&&E(e,function(e){return t.test("string"==typeof e.className&&e.className||void 0!==e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(e,t,n){return function(r){var i=es.attr(r,e);return null==i?"!="===t:!t||(i+="","="===t?i===n:"!="===t?i!==n:"^="===t?n&&0===i.indexOf(n):"*="===t?n&&-1:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function D(e,t,n){return h(t)?w.grep(e,function(e,r){return!!t.call(e,r,e)!==n}):t.nodeType?w.grep(e,function(e){return e===t!==n}):"string"!=typeof t?w.grep(e,function(e){return -1)[^>]*|#([\w-]+))$/;(w.fn.init=function(e,t,n){var r,i;if(!e)return this;if(n=n||j,"string"==typeof e){if(!(r="<"===e[0]&&">"===e[e.length-1]&&3<=e.length?[null,e,null]:q.exec(e))||!r[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(r[1]){if(t=t instanceof w?t[0]:t,w.merge(this,w.parseHTML(r[1],t&&t.nodeType?t.ownerDocument||t:v,!0)),N.test(r[1])&&w.isPlainObject(t))for(r in t)h(this[r])?this[r](t[r]):this.attr(r,t[r]);return this}return(i=v.getElementById(r[2]))&&(this[0]=i,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):h(e)?void 0!==n.ready?n.ready(e):e(w):w.makeArray(e,this)}).prototype=w.fn,j=w(v);var L=/^(?:parents|prev(?:Until|All))/,H={children:!0,contents:!0,next:!0,prev:!0};function O(e,t){for(;(e=e[t])&&1!==e.nodeType;);return e}w.fn.extend({has:function(e){var t=w(e,this),n=t.length;return this.filter(function(){for(var e=0;e\x20\t\r\n\f]*)/i,eh=/^$|^module$|\/(?:java|ecma)script/i;ec=v.createDocumentFragment().appendChild(v.createElement("div")),(ef=v.createElement("input")).setAttribute("type","radio"),ef.setAttribute("checked","checked"),ef.setAttribute("name","t"),ec.appendChild(ef),d.checkClone=ec.cloneNode(!0).cloneNode(!0).lastChild.checked,ec.innerHTML="",d.noCloneChecked=!!ec.cloneNode(!0).lastChild.defaultValue,ec.innerHTML="",d.option=!!ec.lastChild;var eg={thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};function ev(e,t){var n;return n=void 0!==e.getElementsByTagName?e.getElementsByTagName(t||"*"):void 0!==e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&A(e,t)?w.merge([e],n):n}function ey(e,t){for(var n=0,r=e.length;n",""]);var em=/<|&#?\w+;/;function ex(e,t,n,r,i){for(var o,a,s,u,l,c=t.createDocumentFragment(),f=[],p=0,d=e.length;p\s*$/g;function eq(e,t){return A(e,"table")&&A(11!==t.nodeType?t:t.firstChild,"tr")&&w(e).children("tbody")[0]||e}function eL(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function eH(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function eO(e,t){var n,r,i,o,a,s;if(1===t.nodeType){if(Y.hasData(e)&&(s=Y.get(e).events))for(i in Y.remove(t,"handle events"),s)for(n=0,r=s[i].length;nw.inArray(this,e)&&(w.cleanData(ev(this)),n&&n.replaceChild(t,this))},e)}}),w.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,t){w.fn[e]=function(e){for(var n,r=[],i=w(e),o=i.length-1,s=0;s<=o;s++)n=s===o?this:this.clone(!0),w(i[s])[t](n),a.apply(r,n.get());return this.pushStack(r)}});var eM=RegExp("^("+ee+")(?!px)[a-z%]+$","i"),eI=function(t){var n=t.ownerDocument.defaultView;return n&&n.opener||(n=e),n.getComputedStyle(t)},eW=function(e,t,n){var r,i,o={};for(i in t)o[i]=e.style[i],e.style[i]=t[i];for(i in r=n.call(e),t)e.style[i]=o[i];return r},eF=RegExp(en.join("|"),"i");function eB(e,t,n){var r,i,o,a,s=e.style;return(n=n||eI(e))&&(""!==(a=n.getPropertyValue(t)||n[t])||ei(e)||(a=w.style(e,t)),!d.pixelBoxStyles()&&eM.test(a)&&eF.test(t)&&(r=s.width,i=s.minWidth,o=s.maxWidth,s.minWidth=s.maxWidth=s.width=a,a=n.width,s.width=r,s.minWidth=i,s.maxWidth=o)),void 0!==a?a+"":a}function e$(e,t){return{get:function(){if(!e())return(this.get=t).apply(this,arguments);delete this.get}}}!function(){function t(){if(c){l.style.cssText="position:absolute;left:-11111px;width:60px;margin-top:1px;padding:0;border:0",c.style.cssText="position:relative;display:block;box-sizing:border-box;overflow:scroll;margin:auto;border:1px;padding:1px;width:60%;top:1%",er.appendChild(l).appendChild(c);var t=e.getComputedStyle(c);r="1%"!==t.top,u=12===n(t.marginLeft),c.style.right="60%",a=36===n(t.right),i=36===n(t.width),c.style.position="absolute",o=12===n(c.offsetWidth/3),er.removeChild(l),c=null}}function n(e){return Math.round(parseFloat(e))}var r,i,o,a,s,u,l=v.createElement("div"),c=v.createElement("div");c.style&&(c.style.backgroundClip="content-box",c.cloneNode(!0).style.backgroundClip="",d.clearCloneStyle="content-box"===c.style.backgroundClip,w.extend(d,{boxSizingReliable:function(){return t(),i},pixelBoxStyles:function(){return t(),a},pixelPosition:function(){return t(),r},reliableMarginLeft:function(){return t(),u},scrollboxSize:function(){return t(),o},reliableTrDimensions:function(){var t,n,r;return null==s&&(t=v.createElement("table"),n=v.createElement("tr"),r=v.createElement("div"),t.style.cssText="position:absolute;left:-11111px",n.style.height="1px",r.style.height="9px",er.appendChild(t).appendChild(n).appendChild(r),s=3r.indexOf(" "+o+" ")&&(r+=o+" ");i!==(s=to(r))&&n.setAttribute("class",s)}}return this},removeClass:function(e){var t,n,r,i,o,a,s,u=0;if(h(e))return this.each(function(t){w(this).removeClass(e.call(this,t,ta(this)))});if(!arguments.length)return this.attr("class","");if((t=ts(e)).length){for(;n=this[u++];)if(i=ta(n),r=1===n.nodeType&&" "+to(i)+" "){for(a=0;o=t[a++];)for(;-1m.indexOf(":")&&"on"+m,(t=t[w.expando]?t:new w.Event(m,"object"==typeof t&&t)).isTrigger=i?2:3,t.namespace=x.join("."),t.rnamespace=t.namespace?RegExp("(^|\\.)"+x.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,t.result=void 0,t.target||(t.target=r),n=null==n?[t]:w.makeArray(n,[t]),p=w.event.special[m]||{},i||!p.trigger||!1!==p.trigger.apply(r,n))){if(!i&&!p.noBubble&&!g(r)){for(u=p.delegateType||m,tl.test(u+m)||(a=a.parentNode);a;a=a.parentNode)y.push(a),s=a;s===(r.ownerDocument||v)&&y.push(s.defaultView||s.parentWindow||e)}for(o=0;(a=y[o++])&&!t.isPropagationStopped();)d=a,t.type=1").attr(e.scriptAttrs||{}).prop({charset:e.scriptCharset,src:e.url}).on("load error",n=function(e){t.remove(),n=null,e&&i("error"===e.type?404:200,e.type)}),v.head.appendChild(t[0])},abort:function(){n&&n()}}});var tH,tO=[],tP=/(=)\?(?=&|$)|\?\?/;w.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=tO.pop()||w.expando+"_"+tp.guid++;return this[e]=!0,e}}),w.ajaxPrefilter("json jsonp",function(t,n,r){var i,o,a,s=!1!==t.jsonp&&(tP.test(t.url)?"url":"string"==typeof t.data&&0===(t.contentType||"").indexOf("application/x-www-form-urlencoded")&&tP.test(t.data)&&"data");if(s||"jsonp"===t.dataTypes[0])return i=t.jsonpCallback=h(t.jsonpCallback)?t.jsonpCallback():t.jsonpCallback,s?t[s]=t[s].replace(tP,"$1"+i):!1!==t.jsonp&&(t.url+=(td.test(t.url)?"&":"?")+t.jsonp+"="+i),t.converters["script json"]=function(){return a||w.error(i+" was not called"),a[0]},t.dataTypes[0]="json",o=e[i],e[i]=function(){a=arguments},r.always(function(){void 0===o?w(e).removeProp(i):e[i]=o,t[i]&&(t.jsonpCallback=n.jsonpCallback,tO.push(i)),a&&h(o)&&o(a[0]),a=o=void 0}),"script"}),(tH=v.implementation.createHTMLDocument("").body).innerHTML="
",d.createHTMLDocument=2===tH.childNodes.length,w.parseHTML=function(e,t,n){var r,i,o;return"string"!=typeof e?[]:("boolean"==typeof t&&(n=t,t=!1),t||(d.createHTMLDocument?((r=(t=v.implementation.createHTMLDocument("")).createElement("base")).href=v.location.href,t.head.appendChild(r)):t=v),o=!n&&[],(i=N.exec(e))?[t.createElement(i[1])]:(i=ex([e],t,o),o&&o.length&&w(o).remove(),w.merge([],i.childNodes)))},w.fn.load=function(e,t,n){var r,i,o,a=this,s=e.indexOf(" ");return -1").append(w.parseHTML(e)).find(r):e)}).always(n&&function(e,t){a.each(function(){n.apply(this,o||[e.responseText,t,e])})}),this},w.expr.pseudos.animated=function(e){return w.grep(w.timers,function(t){return e===t.elem}).length},w.offset={setOffset:function(e,t,n){var r,i,o,a,s,u,l=w.css(e,"position"),c=w(e),f={};"static"===l&&(e.style.position="relative"),s=c.offset(),o=w.css(e,"top"),u=w.css(e,"left"),("absolute"===l||"fixed"===l)&&-1<(o+u).indexOf("auto")?(a=(r=c.position()).top,i=r.left):(a=parseFloat(o)||0,i=parseFloat(u)||0),h(t)&&(t=t.call(e,n,w.extend({},s))),null!=t.top&&(f.top=t.top-s.top+a),null!=t.left&&(f.left=t.left-s.left+i),"using"in t?t.using.call(e,f):("number"==typeof f.top&&(f.top+="px"),"number"==typeof f.left&&(f.left+="px"),c.css(f))}},w.fn.extend({offset:function(e){if(arguments.length)return void 0===e?this:this.each(function(t){w.offset.setOffset(this,e,t)});var t,n,r=this[0];return r?r.getClientRects().length?(t=r.getBoundingClientRect(),n=r.ownerDocument.defaultView,{top:t.top+n.pageYOffset,left:t.left+n.pageXOffset}):{top:0,left:0}:void 0},position:function(){if(this[0]){var e,t,n,r=this[0],i={top:0,left:0};if("fixed"===w.css(r,"position"))t=r.getBoundingClientRect();else{for(t=this.offset(),n=r.ownerDocument,e=r.offsetParent||n.documentElement;e&&(e===n.body||e===n.documentElement)&&"static"===w.css(e,"position");)e=e.parentNode;e&&e!==r&&1===e.nodeType&&((i=w(e).offset()).top+=w.css(e,"borderTopWidth",!0),i.left+=w.css(e,"borderLeftWidth",!0))}return{top:t.top-i.top-w.css(r,"marginTop",!0),left:t.left-i.left-w.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){for(var e=this.offsetParent;e&&"static"===w.css(e,"position");)e=e.offsetParent;return e||er})}}),w.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,t){var n="pageYOffset"===t;w.fn[e]=function(r){return $(this,function(e,r,i){var o;if(g(e)?o=e:9===e.nodeType&&(o=e.defaultView),void 0===i)return o?o[t]:e[r];o?o.scrollTo(n?o.pageXOffset:i,n?i:o.pageYOffset):e[r]=i},e,r,arguments.length)}}),w.each(["top","left"],function(e,t){w.cssHooks[t]=e$(d.pixelPosition,function(e,n){if(n)return n=eB(e,t),eM.test(n)?w(e).position()[t]+"px":n})}),w.each({Height:"height",Width:"width"},function(e,t){w.each({padding:"inner"+e,content:t,"":"outer"+e},function(n,r){w.fn[r]=function(i,o){var a=arguments.length&&(n||"boolean"!=typeof i),s=n||(!0===i||!0===o?"margin":"border");return $(this,function(t,n,i){var o;return g(t)?0===r.indexOf("outer")?t["inner"+e]:t.document.documentElement["client"+e]:9===t.nodeType?(o=t.documentElement,Math.max(t.body["scroll"+e],o["scroll"+e],t.body["offset"+e],o["offset"+e],o["client"+e])):void 0===i?w.css(t,n,s):w.style(t,n,i,s)},t,a?i:void 0,a)}})}),w.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){w.fn[t]=function(e){return this.on(t,e)}}),w.fn.extend({bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1==arguments.length?this.off(e,"**"):this.off(t,e||"**",n)},hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)}}),w.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(e,t){w.fn[t]=function(e,n){return 0"1.3.8",n.ruid="bundler=rspack@1.3.8",n(282)})(); \ No newline at end of file diff --git a/dist/firefox/content_scripts/content-2.js b/dist/firefox/content_scripts/content-2.js deleted file mode 100644 index 495a033..0000000 --- a/dist/firefox/content_scripts/content-2.js +++ /dev/null @@ -1 +0,0 @@ -(()=>{var e={},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var a=t[n]={exports:{}};return e[n](a,a.exports,r),a.exports}r.rv=()=>"1.3.8",r.ruid="bundler=rspack@1.3.8",function(){function e(t,r,n,o=100){let a=setInterval(()=>{let e=t.querySelector(r);e&&(clearInterval(a),n(e))},o)}function t(e){if(!e||e.parentNode.querySelector('a[data-cy-id="button"][href="/account/pledges"]'))return;let t=e.cloneNode(!0);t.href="/account/pledges";let r=t.querySelector('span[data-cy-id="button__text"]');r&&(r.innerText="My Hangar");let n=t.querySelector('i[data-cy-id="button__icon"]');n&&(n.className="a-button__icon a-icon -gridView"),e.parentNode.insertBefore(t,e)}e(document,"#sidePanel",r=>{new MutationObserver(r=>{for(let n of r)"childList"===n.type&&n.addedNodes.length>0&&n.addedNodes.forEach(r=>{1===r.nodeType&&e(r,'a[data-cy-id="button"][href="/account/settings"]',e=>{t(e)})})}).observe(r,{childList:!0,subtree:!0});let n=sidePanel.querySelector('a[data-cy-id="button"][href="/account/settings"]');n&&t(n)})}()})(); \ No newline at end of file diff --git a/dist/firefox/icons/icon.png b/dist/firefox/icons/icon.png deleted file mode 100644 index 3ceb859..0000000 Binary files a/dist/firefox/icons/icon.png and /dev/null differ diff --git a/dist/firefox/manifest.json b/dist/firefox/manifest.json deleted file mode 100644 index 86df0b0..0000000 --- a/dist/firefox/manifest.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "manifest_version": 3, - "name": "星际公民盒子浏览器拓展", - "version": "0.0.11", - "description": "为星际公民网站及工具站提供汉化", - "author": "xkeyC", - "icons": { - "16": "icons/icon.png", - "48": "icons/icon.png", - "192": "icons/icon.png" - }, - "host_permissions": [ - "https://git.scbox.xkeyc.cn/*" - ], - "permissions": [ - "storage", - "contextMenus" - ], - "action": { - "default_popup": "action/default_popup.html" - }, - "background": { - "scripts": [ - "background/scripts.js" - ] - }, - "content_scripts": [ - { - "matches": [ - "*://*/*" - ], - "exclude_matches": [ - "https://robertsspaceindustries.com/spectrum/*" - ], - "js": [ - "content_scripts/content-0.js" - ], - "run_at": "document_end", - "css": [] - }, - { - "matches": [ - "https://www.erkul.games/*" - ], - "js": [ - "content_scripts/content-1.js" - ], - "run_at": "document_end", - "css": [] - }, - { - "matches": [ - "https://robertsspaceindustries.com/*" - ], - "js": [ - "content_scripts/content-2.js" - ], - "run_at": "document_idle", - "css": [] - } - ] -} \ No newline at end of file