From a6d286e905caffc001596306039c592912391677 Mon Sep 17 00:00:00 2001 From: xkeyC <3334969096@qq.com> Date: Fri, 9 May 2025 00:01:01 +0800 Subject: [PATCH] feat: image lazy load --- dist/chrome/action/default_popup.html | 6 +++--- dist/firefox/action/default_popup.html | 6 +++--- dist/firefox/content_scripts/content-0.js | 2 +- popup.html | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/dist/chrome/action/default_popup.html b/dist/chrome/action/default_popup.html index 8017a43..769d9ff 100644 --- a/dist/chrome/action/default_popup.html +++ b/dist/chrome/action/default_popup.html @@ -66,7 +66,7 @@
- +

UEX

采矿、精炼、贸易计算器、价格、船信息

@@ -74,7 +74,7 @@
- +

DPS 计算器

在线改船,查询伤害数值和配件购买地点

@@ -82,7 +82,7 @@
- +

CCUGame(官方汉化)

资产管理和舰队规划,一定要理性消费.jpg

diff --git a/dist/firefox/action/default_popup.html b/dist/firefox/action/default_popup.html index 8017a43..769d9ff 100644 --- a/dist/firefox/action/default_popup.html +++ b/dist/firefox/action/default_popup.html @@ -66,7 +66,7 @@
- +

UEX

采矿、精炼、贸易计算器、价格、船信息

@@ -74,7 +74,7 @@
- +

DPS 计算器

在线改船,查询伤害数值和配件购买地点

@@ -82,7 +82,7 @@
- +

CCUGame(官方汉化)

资产管理和舰队规划,一定要理性消费.jpg

diff --git a/dist/firefox/content_scripts/content-0.js b/dist/firefox/content_scripts/content-0.js index f28b7c8..34b6caf 100644 --- a/dist/firefox/content_scripts/content-0.js +++ b/dist/firefox/content_scripts/content-0.js @@ -1 +1 @@ -(()=>{var s={242:function(){let s={},e=!1,n=!1;function a(s){chrome.runtime.sendMessage({action:"_setTranslateSwitch",url:window.location.href,enableManual:s},function(e){console.log("SET translate switch ===",window.location.href,"enableManual === ",s)})}function t(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="保存"),i().then(s=>{})}async function i(){async function s(e,n){if(e.nodeType===Node.TEXT_NODE){let s=e.nodeValue||"",a=o(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"))}),window.postMessage({type:"TOGGLED-SC-BOX-TRANSLATE",action:"off"},"*"),Promise.resolve({success:!0})}function u(s,e){let n,a;if("INPUT"===s.tagName){if(n="button"===s.type||"submit"===s.type?"value":"placeholder",a=o(s[n]),s[n]===a)return;let t=e.getAttribute("data-original-value")||"";s.setAttribute("data-original-value",t+s[n])}else{if(a=o(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 o(n){let a=n.toLowerCase().replace(/\xa0/g," ").replace(/\s{2,}/g," ").trim(),t=n.replace(/\xa0/g," ").replace(/\s{2,}/g," ").trim(),i=a.replace("the ",""),r=a.replace("- ","");if(s[a])n=s[a];else if(e)if(t.includes(" - ")){let e=n,i=t.split(" - ");if("upgrade"===i[0].toLowerCase()&&a.includes("to")&&a.endsWith("edition")){let s=a.replace("standard edition","").replace("upgrade","").replace("warbond edition","").split(" to "),e="升级包 "+o(s[0])+" 到 "+o(s[1]);a.endsWith("warbond edition")?e+=" 战争债券版":e+=" 标准版",n=e}else i.forEach(function(n){e=s[n.toLowerCase()]?e.replace(n,s[n.toLowerCase()]):e.replace(n,o(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[i]?n=s[i]:a.startsWith("- ")&&s[r]&&(n="- "+s[r]);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?u(n,e):n.nodeType===Node.ELEMENT_NODE&&("INPUT"===n.tagName?u(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(){i().then(s=>{})},200)}),chrome.runtime.sendMessage({action:"_loadLocalizationData",url:window.location.href},function(s){s.result.length>0&&(n=!0,t(s.result))}),chrome.runtime.onMessage.addListener((s,i,u)=>{if("_toggleTranslation"===s.action){if(n){n=!1,r(),a(!1);return}n=!0,e=!0,window.postMessage({type:"TOGGLED-SC-BOX-TRANSLATE",action:"on"},"*"),t(s.data),a(!0)}}),window.addEventListener("message",async s=>{if(s.source!==window||!s.data||"SC_TRANSLATE_REQUEST"!==s.data.type)return;let{action:a}=s.data;if("translate"===a)try{e=!0,chrome.runtime.sendMessage({action:"_loadLocalizationData",url:"manual"},function(s){n=!0,window.postMessage({type:"TOGGLED-SC-BOX-TRANSLATE",action:"on"},"*"),t(s.result)})}catch(s){s.message}else if("undoTranslate"===a)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.9",n.ruid="bundler=rspack@1.3.9",n(242),n(148)})(); \ No newline at end of file +(()=>{var s={242:function(){let s={},e=!1,n=!1;function a(s){chrome.runtime.sendMessage({action:"_setTranslateSwitch",url:window.location.href,enableManual:s},function(e){console.log("SET translate switch ===",window.location.href,"enableManual === ",s)})}function t(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="保存"),i().then(s=>{})}async function i(){async function s(e,n){if(e.nodeType===Node.TEXT_NODE){let s=e.nodeValue||"",a=o(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"))}),window.postMessage({type:"TOGGLED-SC-BOX-TRANSLATE",action:"off"},"*"),Promise.resolve({success:!0})}function u(s,e){let n,a;if("INPUT"===s.tagName){if(n="button"===s.type||"submit"===s.type?"value":"placeholder",a=o(s[n]),s[n]===a)return;let t=e.getAttribute("data-original-value")||"";s.setAttribute("data-original-value",t+s[n])}else{if(a=o(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 o(n){let a=n.toLowerCase().replace(/\xa0/g," ").replace(/\s{2,}/g," ").trim(),t=n.replace(/\xa0/g," ").replace(/\s{2,}/g," ").trim(),i=a.replace("the ",""),r=a.replace("- ","");if(s[a])n=s[a];else if(e)if(t.includes(" - ")){let e=n,i=t.split(" - ");if("upgrade"===i[0].toLowerCase()&&a.includes("to")&&a.endsWith("edition")){let s=a.replace("standard edition","").replace("upgrade","").replace("warbond edition","").split(" to "),e="升级包 "+o(s[0])+" 到 "+o(s[1]);a.endsWith("warbond edition")?e+=" 战争债券版":e+=" 标准版",n=e}else i.forEach(function(n){e=s[n.toLowerCase()]?e.replace(n,s[n.toLowerCase()]):e.replace(n,o(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[i]?n=s[i]:a.startsWith("- ")&&s[r]&&(n="- "+s[r]);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?u(n,e):n.nodeType===Node.ELEMENT_NODE&&("INPUT"===n.tagName?u(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(){i().then(s=>{})},200)}),chrome.runtime.sendMessage({action:"_loadLocalizationData",url:window.location.href},function(s){s.result.length>0&&(n=!0,t(s.result),window.postMessage({type:"TOGGLED-SC-BOX-TRANSLATE",action:"on"},"*"))}),chrome.runtime.onMessage.addListener((s,i,u)=>{if("_toggleTranslation"===s.action){if(n){n=!1,r(),a(!1);return}n=!0,e=!0,window.postMessage({type:"TOGGLED-SC-BOX-TRANSLATE",action:"on"},"*"),t(s.data),a(!0)}}),window.addEventListener("message",async s=>{if(s.source!==window||!s.data||"SC_TRANSLATE_REQUEST"!==s.data.type)return;let{action:i}=s.data;if("translate"===i)try{a(!0),await new Promise(s=>setTimeout(s,100)),e=!0,chrome.runtime.sendMessage({action:"_loadLocalizationData",url:window.location.href},function(s){n=!0,window.postMessage({type:"TOGGLED-SC-BOX-TRANSLATE",action:"on"},"*"),t(s.result)})}catch(s){s.message}else if("undoTranslate"===i)try{a(!1),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.9",n.ruid="bundler=rspack@1.3.9",n(242),n(148)})(); \ No newline at end of file diff --git a/popup.html b/popup.html index 4b32c06..0716da1 100644 --- a/popup.html +++ b/popup.html @@ -73,7 +73,7 @@