mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
1 line
609 B
JavaScript
1 line
609 B
JavaScript
(()=>{return(e,t)=>{(async()=>{const{map:n}=await t.importAsync(`i18n.${e.i18nLanguage}`);const o=e=>{const t=[];const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null,false);let o=n.nextNode();while(o){t.push(o);o=n.nextNode()}return t};const r=e=>{const t=n.get(e.nodeValue.trim());if(t!==undefined){if(typeof t==="string"){e.nodeValue=t}else{const{text:n,selector:o}=t;if(e.parentElement.matches(o)){e.nodeValue=n}}}};o(document.body).forEach(r);Observer.childListSubtree("body",e=>{e.forEach(e=>[...e.addedNodes].forEach(e=>{if(e.nodeType===Node.TEXT_NODE){r(e)}else{o(e).forEach(r)}}))})})()}})(); |