diff --git a/NamuLink.user.js b/NamuLink.user.js index 7720da2..9eaec8f 100644 --- a/NamuLink.user.js +++ b/NamuLink.user.js @@ -8,7 +8,7 @@ // @downloadURL https://cdn.jsdelivr.net/gh/List-KR/NamuLink@latest/NamuLink.user.js // @license MIT // -// @version 3.13.0 +// @version 3.13.1 // @author PiQuark6046 and contributors // // @match https://namu.wiki/* @@ -21,4 +21,4 @@ // @inject-into page // ==/UserScript== // Used libraries: -(()=>{var f=class{value;next;constructor(e){this.value=e}},m=class{#e;#t;#n;constructor(){this.clear()}enqueue(e){let r=new f(e);this.#e?(this.#t.next=r,this.#t=r):(this.#e=r,this.#t=r),this.#n++}dequeue(){let e=this.#e;if(e)return this.#e=this.#e.next,this.#n--,e.value}clear(){this.#e=void 0,this.#t=void 0,this.#n=0}get size(){return this.#n}*[Symbol.iterator](){let e=this.#e;for(;e;)yield e.value,e=e.next}};var y={bind(n,e,r){return n.bind(r)}};function h(n){if(!((Number.isInteger(n)||n===Number.POSITIVE_INFINITY)&&n>0))throw new TypeError("Expected `concurrency` to be a number from 1 and up");let e=new m,r=0,t=()=>{r--,e.size>0&&e.dequeue()()},i=async(a,s,d)=>{r++;let E=(async()=>a(...d))();s(E);try{await E}catch{}t()},u=(a,s,d)=>{e.enqueue(y.bind(i.bind(void 0,a,s,d))),(async()=>(await Promise.resolve(),r0&&e.dequeue()()))()},l=(a,...s)=>new Promise(d=>{u(a,d,s)});return Object.defineProperties(l,{activeCount:{get:()=>r},pendingCount:{get:()=>e.size},clearQueue:{value(){e.clear()}}}),l}function v(n){if(!Number.isInteger(n.Count))throw new Error("MultithreadArrayOptions.Count should be an integer");if(n.Count<=0)throw new Error("MultithreadArrayOptions.Count should be greater than 0")}function g(n,e){v(e);let r=new Array(Math.ceil(n.length/e.Count));for(var t=0;tn.length?n.length:(t+1)*e.Count);return r}var o=typeof unsafeWindow<"u"?unsafeWindow:window,L=new Event("namuwikiunloadedadvert"),w=new Event("namuwikinavigation");o.Object.getOwnPropertyDescriptor=new Proxy(o.Object.getOwnPropertyDescriptor,{apply(n,e,r){if(!(typeof r[1]=="string"&&(r[1]==="enable_ads"||r[1]==="to_duration")))return Reflect.apply(n,e,r)}});var C=["substring","substr"];for(let n of C)o.String.prototype[n]=new Proxy(o.String.prototype[n],{apply(e,r,t){return typeof r=="string"&&/^\[+.{0,10}#.{10,50}\/\/\/.{0,20}==/.test(r)?(console.debug(`[NamuLink:index]: String.prototype.${n}:`,r),o.dispatchEvent(L),""):Reflect.apply(e,r,t)}});o.setInterval=new Proxy(o.setInterval,{apply(n,e,r){if(!(typeof r[0]=="function"&&/\(function {0,}\( {0,}\) {0,}{.+else {0,}return/.test(r[0].toString())))return Reflect.apply(n,e,r)}});o.Array.prototype.join=new Proxy(o.Array.prototype.join,{apply(n,e,r){let t=Reflect.apply(n,e,r);return t.startsWith('noscript[data-n-head="]')&&o.dispatchEvent(w),t}});var c=[],M=n=>{c.push(...n),n.forEach(e=>{e.remove()})},S=()=>{console.debug("[NamuLink:index]: ShowElements:",c),c=c.filter(n=>n.parentElement!==null),c.forEach(n=>{n.style.removeProperty("display")}),c=[]},b=n=>{var e=n.filter(t=>t instanceof HTMLElement);let r=[];return e=e.filter(t=>t.innerText.length<25),e=e.filter(t=>Array.from(t.querySelectorAll("*")).filter(l=>l instanceof HTMLElement).some(l=>Number(getComputedStyle(l).getPropertyValue("margin-bottom").replace(/px$/,""))>=4)),e=e.filter(t=>Array.from(t.querySelectorAll("*")).filter(u=>u instanceof HTMLIFrameElement).length===0),e=e.filter(t=>t.querySelectorAll('span[id^="fn-"] + a[href^="#rfn-"]').length===0),e=e.filter(t=>!Array.from(t.querySelectorAll('a[rel="noopener"][target="_blank"][class] > span ~ span')).some(i=>i.innerHTML.includes("\uB098\uBB34\uB274\uC2A4"))),e=e.filter(t=>!Array.from(t.querySelectorAll("*")).some(i=>i.innerHTML.includes("\uC2E4\uC2DC\uAC04 \uAC80\uC0C9\uC5B4"))),r.push(...e.filter(t=>Array.from(t.querySelectorAll("*")).filter(l=>l instanceof HTMLElement).filter(l=>getComputedStyle(l).getPropertyValue("animation-iteration-count")==="infinite").length>=6)),e=e.filter(t=>{let u=Array.from(t.querySelectorAll("*")).filter(l=>l instanceof HTMLElement);return u.some(l=>Number(getComputedStyle(l).getPropertyValue("margin-bottom").replace(/px$/,""))>=10)&&u.every(l=>Number(getComputedStyle(l).getPropertyValue("margin-left").replace(/px$/,""))<=10)}),r.push(...e.filter(t=>{let u=Array.from(t.querySelectorAll("*")).filter(s=>s instanceof HTMLElement),a=Array.from(t.parentElement?.querySelectorAll("*")??[]).filter(s=>s instanceof HTMLElement);return u.every(s=>!s.innerText.includes("alt='external/"))&&a.filter(s=>s.nextElementSibling===t&&!(s instanceof HTMLHeadingElement)).length>0})),r},p=async()=>{let n=[];n.push(...Array.from(o.document.querySelectorAll('div[class] div[class*=" "]:has(span ~ ul li) ~ div div[class] > div[class] div[class] ~ div[class]'))),n.push(...Array.from(o.document.querySelectorAll('div:not([class*=" "]) div[class] div[class*=" "]')));let e=[],r=h((navigator.hardwareConcurrency??4)<4?4:navigator.hardwareConcurrency),t=[];for(let i of g(n,{Count:2}))t.push(r(()=>b(i)));e=await Promise.all(t).then(i=>i.flat()),console.debug("[NamuLink:index]: HideLeftoverElement:",e),M(e)};o.addEventListener("namuwikiloadedadvert",p);o.addEventListener("namuwikiunloadedadvert",p);o.addEventListener("namuwikifristvisit",p);o.addEventListener("namuwikinavigation",S);})(); +(()=>{var f=class{value;next;constructor(e){this.value=e}},d=class{#e;#t;#n;constructor(){this.clear()}enqueue(e){let r=new f(e);this.#e?(this.#t.next=r,this.#t=r):(this.#e=r,this.#t=r),this.#n++}dequeue(){let e=this.#e;if(e)return this.#e=this.#e.next,this.#n--,e.value}clear(){this.#e=void 0,this.#t=void 0,this.#n=0}get size(){return this.#n}*[Symbol.iterator](){let e=this.#e;for(;e;)yield e.value,e=e.next}};var y={bind(n,e,r){return n.bind(r)}};function h(n){if(!((Number.isInteger(n)||n===Number.POSITIVE_INFINITY)&&n>0))throw new TypeError("Expected `concurrency` to be a number from 1 and up");let e=new d,r=0,t=()=>{r--,e.size>0&&e.dequeue()()},i=async(a,s,m)=>{r++;let E=(async()=>a(...m))();s(E);try{await E}catch{}t()},u=(a,s,m)=>{e.enqueue(y.bind(i.bind(void 0,a,s,m))),(async()=>(await Promise.resolve(),r0&&e.dequeue()()))()},l=(a,...s)=>new Promise(m=>{u(a,m,s)});return Object.defineProperties(l,{activeCount:{get:()=>r},pendingCount:{get:()=>e.size},clearQueue:{value(){e.clear()}}}),l}function v(n){if(!Number.isInteger(n.Count))throw new Error("MultithreadArrayOptions.Count should be an integer");if(n.Count<=0)throw new Error("MultithreadArrayOptions.Count should be greater than 0")}function g(n,e){v(e);let r=new Array(Math.ceil(n.length/e.Count));for(var t=0;tn.length?n.length:(t+1)*e.Count);return r}var o=typeof unsafeWindow<"u"?unsafeWindow:window,L=new Event("namuwikiunloadedadvert"),w=new Event("namuwikinavigation");o.Object.getOwnPropertyDescriptor=new Proxy(o.Object.getOwnPropertyDescriptor,{apply(n,e,r){if(!(typeof r[1]=="string"&&(r[1]==="enable_ads"||r[1]==="to_duration")))return Reflect.apply(n,e,r)}});var C=["substring","substr"];for(let n of C)o.String.prototype[n]=new Proxy(o.String.prototype[n],{apply(e,r,t){return typeof r=="string"&&/^\[+.{0,10}#.{10,50}\/\/\/.{0,20}==/.test(r)?(console.debug(`[NamuLink:index]: String.prototype.${n}:`,r),o.dispatchEvent(L),""):Reflect.apply(e,r,t)}});var M=["setTimeout","setInterval"];for(let n of M)o[n]=new Proxy(o[n],{apply(e,r,t){if(!(typeof t[0]=="function"&&(/return {0,}new {0,}Promise.+\.apply {0,}\(.+function.+next.+throw.+void/.test(t[0].toString())||/AM('|") {0,}: {0,}('|")PM.+('|")\$refs('|").+('|")style('|")/.test(t[0].toString()))))return console.debug(`[NamuLink:index]: ${n}:`,t),Reflect.apply(e,r,t)}});o.Array.prototype.join=new Proxy(o.Array.prototype.join,{apply(n,e,r){let t=Reflect.apply(n,e,r);return t.startsWith('noscript[data-n-head="]')&&o.dispatchEvent(w),t}});var c=[],S=n=>{c.push(...n),n.forEach(e=>{e.remove()})},b=()=>{console.debug("[NamuLink:index]: ShowElements:",c),c=c.filter(n=>n.parentElement!==null),c.forEach(n=>{n.style.removeProperty("display")}),c=[]},H=n=>{var e=n.filter(t=>t instanceof HTMLElement);let r=[];return e=e.filter(t=>t.innerText.length<25),e=e.filter(t=>Array.from(t.querySelectorAll("*")).filter(l=>l instanceof HTMLElement).some(l=>Number(getComputedStyle(l).getPropertyValue("margin-bottom").replace(/px$/,""))>=4)),e=e.filter(t=>Array.from(t.querySelectorAll("*")).filter(u=>u instanceof HTMLIFrameElement).length===0),e=e.filter(t=>t.querySelectorAll('span[id^="fn-"] + a[href^="#rfn-"]').length===0),e=e.filter(t=>!Array.from(t.querySelectorAll('a[rel="noopener"][target="_blank"][class] > span ~ span')).some(i=>i.innerHTML.includes("\uB098\uBB34\uB274\uC2A4"))),e=e.filter(t=>!Array.from(t.querySelectorAll("*")).some(i=>i.innerHTML.includes("\uC2E4\uC2DC\uAC04 \uAC80\uC0C9\uC5B4"))),r.push(...e.filter(t=>Array.from(t.querySelectorAll("*")).filter(l=>l instanceof HTMLElement).filter(l=>getComputedStyle(l).getPropertyValue("animation-iteration-count")==="infinite").length>=6)),e=e.filter(t=>{let u=Array.from(t.querySelectorAll("*")).filter(l=>l instanceof HTMLElement);return u.some(l=>Number(getComputedStyle(l).getPropertyValue("margin-bottom").replace(/px$/,""))>=10)&&u.every(l=>Number(getComputedStyle(l).getPropertyValue("margin-left").replace(/px$/,""))<=10)}),r.push(...e.filter(t=>{let u=Array.from(t.querySelectorAll("*")).filter(s=>s instanceof HTMLElement),a=Array.from(t.parentElement?.querySelectorAll("*")??[]).filter(s=>s instanceof HTMLElement);return u.every(s=>!s.innerText.includes("alt='external/"))&&a.filter(s=>s.nextElementSibling===t&&!(s instanceof HTMLHeadingElement)).length>0})),r},p=async()=>{let n=[];n.push(...Array.from(o.document.querySelectorAll('div[class] div[class*=" "]:has(span ~ ul li) ~ div div[class] > div[class] div[class] ~ div[class]'))),n.push(...Array.from(o.document.querySelectorAll('div:not([class*=" "]) div[class] div[class*=" "]')));let e=[],r=h((navigator.hardwareConcurrency??4)<4?4:navigator.hardwareConcurrency),t=[];for(let i of g(n,{Count:2}))t.push(r(()=>H(i)));e=await Promise.all(t).then(i=>i.flat()),console.debug("[NamuLink:index]: HideLeftoverElement:",e),S(e)};o.addEventListener("namuwikiloadedadvert",p);o.addEventListener("namuwikiunloadedadvert",p);o.addEventListener("namuwikifristvisit",p);o.addEventListener("namuwikinavigation",b);})();