@filteringdev/namulink 19.4.0 → 19.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/NamuLink.user.js +2 -3
- package/dist/index.js +84 -7
- package/package.json +1 -1
package/dist/NamuLink.user.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
// @downloadURL https://cdn.jsdelivr.net/npm/@filteringdev/namulink@latest/dist/NamuLink.user.js
|
|
9
9
|
// @license MPL-2.0
|
|
10
10
|
//
|
|
11
|
-
// @version 19.
|
|
11
|
+
// @version 19.5.0
|
|
12
12
|
// @author PiQuark6046 and contributors
|
|
13
13
|
//
|
|
14
14
|
// @grant unsafeWindow
|
|
@@ -18,11 +18,10 @@
|
|
|
18
18
|
// @description:ko NamuLink는 나무위키에 있는 파워링크 광고를 차단합니다.
|
|
19
19
|
//
|
|
20
20
|
// @match *://namu.wiki/*
|
|
21
|
-
// @match *://*.namu.wiki/*
|
|
22
21
|
// ==/UserScript==
|
|
23
22
|
|
|
24
23
|
|
|
25
|
-
(()=>{var z=typeof unsafeWindow<"u"?unsafeWindow:window;function R(u,c="NamuLink"){let L=u.Function.prototype.call,f=u.Reflect.apply,h=u.Object.defineProperty,k=u.Proxy,s=[[/function *\( *[A-Za-z0-9]+ *, *[A-Za-z0-9]+ *, *[A-Za-z0-9]+ *, *[A-Za-z0-9]+ *, *[A-Za-z0-9]+ *, *[A-Za-z0-9]+ *\) *{ *return *[A-Za-z.-9]+/,/, *[A-Za-z0-9]+ *, *[A-Za-z0-9]+ *\) *{ *return *[A-Za-z.-9]+ *\( *[0-9a-fx *+-]+ *, *[A-Za-z.-9]+ *, *[A-Za-z.-9]+ *, *[0-9a-fx *+-]+/,/return *[A-Za-z.-9]+ *\( *[0-9a-fx *+-]+ *, *[A-Za-z.-9]+ *, *[A-Za-z.-9]+ *, *[0-9a-fx *+-]+ *,[A-Za-z.-9]+ *, *[A-Za-z.-9]+ * *\) *; *}/],[/function *[A-Za-z0-9]+ *\( *[A-Za-z0-9]+ *, *[A-Za-z0-9]+ *, *[A-Za-z0-9]+ *, *[A-Za-z0-9]+ *, *[A-Za-z0-9]+ *, *[A-Za-z0-9]+ *\) *{ *return *[A-Za-z.-9]+/,/, *[A-Za-z0-9]+ *, *[A-Za-z0-9]+ *\) *{ *return *[A-Za-z.-9]+ *\( *[0-9a-fx *+-]+ *, *[A-Za-z.-9]+ *, *[A-Za-z.-9]+ *, *[0-9a-fx *+-]+/,/return *[A-Za-z.-9]+ *\( *[0-9a-fx *+-]+ *, *[A-Za-z.-9]+ *, *[A-Za-z.-9]+ *, *[0-9a-fx *+-]+ *,[A-Za-z.-9]+ *, *[A-Za-z.-9]+ * *\) *; *}/]];function V(t){if(typeof t!="object"||t===null)return null;let e=new Set,n=t._;for(;typeof n=="object"&&n!==null&&!e.has(n);){e.add(n);let o=n.vnode;if(typeof o=="object"&&o!==null){let r=o.el;if(r instanceof HTMLElement)return r}n=n.parent}return null}function S(t){if(typeof t!="object"||t===null)return null;let e=new Set,n=t._;for(;typeof n=="object"&&n!==null&&!e.has(n);){e.add(n);let o=n.render;if(typeof o=="function")return o;n=n.parent}return null}function y(t){if(typeof t!="object"||t===null)return null;let e=new Set,n=t._;for(;typeof n=="object"&&n!==null&&!e.has(n);){e.add(n);let o=n.parent;if(typeof o=="object"&&o!==null){let i=o.vnode;if(typeof i=="object"&&i!==null){let a=i.el;if(a instanceof HTMLElement)return a}}let r=n.vnode;if(typeof r=="object"&&r!==null){let i=r.el;if(i instanceof HTMLElement)return i}n=o}return null}let m=.35,P=.75,p=.04;function l(t){return Number.parseFloat(t)||0}let b=null,g=!1;u.Function.prototype.call=new Proxy(L,{apply(t,e,n){if(g)return f(t,e,n);g=!0;let o=String(e);if(o.length<500&&s.filter(r=>r.filter(i=>i.test(o)).length===r.length).length===1){let r=y(n[6]);if(r!==null&&[...r.querySelectorAll("*")].filter(i=>{if(!(i instanceof HTMLElement))return!1;let a=i.getClientRects()[0]?.height??0,d=Math.max(l(getComputedStyle(i).getPropertyValue("padding-bottom")),l(getComputedStyle(i).getPropertyValue("margin-bottom")));return a>0&&d>=a*(m-p)&&d<=a*(P+p)}).length>=1)return console.debug(`[${c}]: Function.prototype.call called for PowerLink Skeleton:`,e),b=r,u.document.dispatchEvent(new CustomEvent("PL2PlaceHolder")),u.document.dispatchEvent(new CustomEvent("PL2PlaceHolderMobile")),g=!1,f(t,()=>{},[]);console.debug(`[${c}]: Matched Function.prototype.call called, but not for PowerLink Skeleton:`,e)}return g=!1,f(t,e,n)}}),u.Object.defineProperty=new Proxy(h,{apply(t,e,n){let o=S(n[0]),r=y(n[0]),i=String(o??"");if(o!==null&&r!==null&&i.length<500&&s.filter(a=>a.filter(d=>d.test(i)).length===a.length).length===1&&[...r.querySelectorAll("*")].filter(a=>{if(!(a instanceof HTMLElement))return!1;let d=a.getClientRects()[0]?.height??0,w=Math.max(l(getComputedStyle(a).getPropertyValue("padding-bottom")),l(getComputedStyle(a).getPropertyValue("margin-bottom")));return d>0&&w>=d*(m-p)&&w<=d*(P+p)}).length>=1){console.debug(`[${c}]: Restoring renderer.call for detected PowerLink skeleton:`,n[0]),o.call=Function.prototype.call;return}return f(t,e,n)}});let E=[[/\( *\) *=> *{ *var *_0x[0-9a-z]+ *= *a0_0x[0-9a-f]+ *; *this\[ *_0x[a-z0-9]+\( *0x[0-9a-f]+ *\) *\]\(\); *}/,/\( *\) *=> *{ *var *_0x[0-9a-z]+ *= *a0_0x[0-9a-f]+ *; *this\[ *_0x[a-z0-9]+\( *0x[0-9a-f]+ *\) *\]\(\); *}/],[/\( *\) *=> *{ *var _0x[a-z0-9]+ *= *_0x[a-z0-9]+ *; *if *\( *this\[ *_0x[a-z0-9]+ *\( *0x[0-9a-f]+ *\) *\] *\) *return *clearTimeout/,/\( *0x[0-9a-f]+ *\) *\] *\) *, *void *\( *this\[ *_0x[a-z0-9]+\( *0x[0-9a-f]+ *\) *\] *= *void *\([x0-9a-f*+-]+ *\) *\) *; *this\[_0x[a-z0-9]+\( *0x[0-9a-f]+ *\) *\] *\(\) *;/]];u.setTimeout=new Proxy(u.setTimeout,{apply(t,e,n){let o=String(n[0]);return E.filter(r=>r.filter(i=>i.test(o)).length>=1).length===1?(console.debug(`[${c}]: setTimeout called for PowerLink Skeleton:`,n[0]),f(t,e,[()=>{},0])):f(t,e,n)}});function x(t,e){if(typeof t!="object"||t===null)return 1;let n=new Set,o=t._;for(;typeof o=="object"&&o!==null;){if(n.has(o))return 2;n.add(o);let r=o;if(typeof r.render=="function")return r.render=e,0;o=r.parent}return 3}u.Proxy=new Proxy(k,{construct(t,e){let n=S(e[0]),o=y(e[0]),r=String(n??"");return n!==null&&o!==null&&r.length<500&&s.filter(i=>i.filter(a=>a.test(r)).length===i.length).length===1&&[...o.querySelectorAll("*")].filter(i=>{if(!(i instanceof HTMLElement))return!1;let a=i.getClientRects()[0]?.height??0,d=Math.max(l(getComputedStyle(i).getPropertyValue("padding-bottom")),l(getComputedStyle(i).getPropertyValue("margin-bottom")));return a>0&&d>=a*(m-p)&&d<=a*(P+p)}).length>=1&&(console.debug(`[${c}]: Prevented declaring render function in Vue.js 3 for detected PowerLink skeleton:`,e[0],o),x(e[0],()=>null),u.document.dispatchEvent(new CustomEvent("PL2PlaceHolderProxy"))),Reflect.construct(t,e)}}),u.document.addEventListener("PL2AdvertContainer",()=>{setTimeout(()=>{let t=new Set([b]);t=new Set([...t,...[...t].flatMap(e=>[...e.querySelectorAll("*")])]),t=new Set([...t].filter(e=>l(getComputedStyle(e).getPropertyValue("border-bottom-width"))>=.5)),t=new Set([...t].filter(e=>l(getComputedStyle(e).getPropertyValue("border-left-width"))>=.5)),t=new Set([...t].filter(e=>l(getComputedStyle(e).getPropertyValue("border-right-width"))>=.5)),t=new Set([...t].filter(e=>l(getComputedStyle(e).getPropertyValue("border-top-width"))>=.5)),t=new Set([...t].filter(e=>[...e.querySelectorAll("*")].some(n=>{if(!(n instanceof HTMLElement))return!1;let o=n.getClientRects()[0]?.height??0,r=l(getComputedStyle(n).getPropertyValue("margin-bottom"));return o===0?!1:r>=o*.65&&r<=o*1.25}))),console.debug(`[${c}]: Removing PowerLink Skeleton Containers (PL2AdvertContainer):`,t),t.forEach(e=>{e.setAttribute("style","display: none !important;")})},2500)}),u.document.addEventListener("PL2PlaceHolderMobile",()=>{setTimeout(()=>{let t=new Set([...u.document.querySelectorAll("div[class] div[class] div[class] ~ div[class]")]);t=new Set([...t].filter(e=>e instanceof HTMLElement)),t=new Set([...t].filter(e=>l(getComputedStyle(e).getPropertyValue("margin-bottom"))>15||l(getComputedStyle(e).getPropertyValue("padding-top"))>20)),t=new Set([...t].filter(e=>e instanceof HTMLElement&&e.innerText.trim().length===0)),t=new Set([...t].filter(e=>[...e.querySelectorAll("*")].some(n=>n instanceof HTMLElement&&l(getComputedStyle(n).getPropertyValue("padding-top"))>=5&&l(getComputedStyle(n).getPropertyValue("padding-bottom"))>=5&&l(getComputedStyle(n).getPropertyValue("padding-left"))>=5&&l(getComputedStyle(n).getPropertyValue("padding-right"))>=5))),console.debug(`[${c}]: Removing PowerLink Skeleton Containers (PL2PlaceHolderMobile):`,t),t.forEach(e=>{e.setAttribute("style","display: none !important;")})},2500)}),u.document.addEventListener("PL2PlaceHolder",()=>{setTimeout(()=>{let t=new Set([...u.document.querySelectorAll("div[class] div[class] div[class] ~ div[class]")]);t=new Set([...t].filter(e=>e instanceof HTMLElement)),t=new Set([...t].filter(e=>l(getComputedStyle(e).getPropertyValue("padding-top"))>10||l(getComputedStyle(e).getPropertyValue("margin-top"))>10)),t=new Set([...t,...[...t].flatMap(e=>[...e.querySelectorAll("*:not(button)")])]),t=new Set([...t].filter(e=>e instanceof HTMLElement&&e.innerText.trim().length===0)),t=new Set([...t].filter(e=>l(getComputedStyle(e).getPropertyValue("border-bottom-width"))>=.5)),t=new Set([...t].filter(e=>l(getComputedStyle(e).getPropertyValue("border-left-width"))>=.5)),t=new Set([...t].filter(e=>l(getComputedStyle(e).getPropertyValue("border-right-width"))>=.5)),t=new Set([...t].filter(e=>l(getComputedStyle(e).getPropertyValue("border-top-width"))>=.5)),t=new Set([...t].filter(e=>l(getComputedStyle(e).getPropertyValue("transition-duration"))>=.01)),console.debug(`[${c}]: Removing PowerLink Skeleton Containers (PL2PlaceHolder):`,t),t.forEach(e=>{e.setAttribute("style","display: none !important;")})},2500)}),u.document.addEventListener("PL2PlaceHolderProxy",()=>{setTimeout(()=>{let t=new Set([...u.document.querySelectorAll("div[class] div[class] div[class] ~ div[class]")]);t=new Set([...t].filter(e=>e instanceof HTMLElement)),t=new Set([...t].filter(e=>l(getComputedStyle(e).getPropertyValue("padding-top"))>=5&&l(getComputedStyle(e).getPropertyValue("padding-bottom"))>=5&&l(getComputedStyle(e).getPropertyValue("padding-left"))>=5&&l(getComputedStyle(e).getPropertyValue("padding-right"))>=5&&l(getComputedStyle(e).getPropertyValue("border-top-width"))>=.35&&l(getComputedStyle(e).getPropertyValue("border-bottom-width"))>=.35&&l(getComputedStyle(e).getPropertyValue("border-left-width"))>=.35&&l(getComputedStyle(e).getPropertyValue("border-right-width"))>=.35&&e.getClientRects()[0]?.height<=20&&e.getClientRects()[0]?.height>0)),t=new Set([...t].filter(e=>e instanceof HTMLElement&&e.innerText.trim().length===0)),console.debug(`[${c}]: Removing PowerLink Skeleton Containers (PL2PlaceHolderProxy):`,t),t.forEach(e=>{e.setAttribute("style","display: none !important;")})},2500)})}R(z);})();
|
|
24
|
+
(()=>{var z=typeof unsafeWindow<"u"?unsafeWindow:window;function C(a,f="NamuLink"){let h=a.Function.prototype.call,d=a.Reflect.apply,R=a.Object.defineProperty,E=a.Proxy,p=a.Object.getOwnPropertyDescriptor,m=[[/function *\( *[A-Za-z0-9]+ *, *[A-Za-z0-9]+ *, *[A-Za-z0-9]+ *, *[A-Za-z0-9]+ *, *[A-Za-z0-9]+ *, *[A-Za-z0-9]+ *\) *{ *return *[A-Za-z.-9]+/,/, *[A-Za-z0-9]+ *, *[A-Za-z0-9]+ *\) *{ *return *[A-Za-z.-9]+ *\( *[0-9a-fx *+-]+ *, *[A-Za-z.-9]+ *, *[A-Za-z.-9]+ *, *[0-9a-fx *+-]+/,/return *[A-Za-z.-9]+ *\( *[0-9a-fx *+-]+ *, *[A-Za-z.-9]+ *, *[A-Za-z.-9]+ *, *[0-9a-fx *+-]+ *,[A-Za-z.-9]+ *, *[A-Za-z.-9]+ * *\) *; *}/],[/function *[A-Za-z0-9]+ *\( *[A-Za-z0-9]+ *, *[A-Za-z0-9]+ *, *[A-Za-z0-9]+ *, *[A-Za-z0-9]+ *, *[A-Za-z0-9]+ *, *[A-Za-z0-9]+ *\) *{ *return *[A-Za-z.-9]+/,/, *[A-Za-z0-9]+ *, *[A-Za-z0-9]+ *\) *{ *return *[A-Za-z.-9]+ *\( *[0-9a-fx *+-]+ *, *[A-Za-z.-9]+ *, *[A-Za-z.-9]+ *, *[0-9a-fx *+-]+/,/return *[A-Za-z.-9]+ *\( *[0-9a-fx *+-]+ *, *[A-Za-z.-9]+ *, *[A-Za-z.-9]+ *, *[0-9a-fx *+-]+ *,[A-Za-z.-9]+ *, *[A-Za-z.-9]+ * *\) *; *}/]];function T(t){if(typeof t!="object"||t===null||typeof d(p,a.Object,[t,"_"])?.get=="function")return null;let e=new Set,n=t._;for(;typeof n=="object"&&n!==null&&!e.has(n);){e.add(n);let o=n.vnode;if(typeof o=="object"&&o!==null){let l=o.el;if(l instanceof HTMLElement)return l}n=n.parent}return null}function w(t){if(typeof t!="object"||t===null||typeof d(p,a.Object,[t,"_"])?.get=="function")return null;let e=new Set,n=t._;for(;typeof n=="object"&&n!==null&&!e.has(n);){e.add(n);let o=n.render;if(typeof o=="function")return o;n=n.parent}return null}function P(t){if(typeof t!="object"||t===null||typeof d(p,a.Object,[t,"_"])?.get=="function")return null;let e=new Set,n=t._;for(;typeof n=="object"&&n!==null&&!e.has(n);){e.add(n);let o=n.parent;if(typeof o=="object"&&o!==null){let i=o.vnode;if(typeof i=="object"&&i!==null){let u=i.el;if(u instanceof HTMLElement)return u}}let l=n.vnode;if(typeof l=="object"&&l!==null){let i=l.el;if(i instanceof HTMLElement)return i}n=o}return null}let S=.35,b=.75,s=.04;function r(t){return Number.parseFloat(t)||0}let k=null,g=!1;a.Function.prototype.call=new Proxy(h,{apply(t,e,n){if(g)return d(t,e,n);g=!0;let o=String(e);if(o.length<500&&m.filter(l=>l.filter(i=>i.test(o)).length===l.length).length===1){let l=P(n[6]);if(l!==null&&[...l.querySelectorAll("*")].filter(i=>{if(!(i instanceof HTMLElement))return!1;let u=i.getClientRects()[0]?.height??0,c=Math.max(r(getComputedStyle(i).getPropertyValue("padding-bottom")),r(getComputedStyle(i).getPropertyValue("margin-bottom")));return u>0&&c>=u*(S-s)&&c<=u*(b+s)}).length>=1)return console.debug(`[${f}]: Function.prototype.call called for PowerLink Skeleton:`,e),k=l,a.document.dispatchEvent(new CustomEvent("PL2PlaceHolder")),a.document.dispatchEvent(new CustomEvent("PL2PlaceHolderMobile")),g=!1,d(t,()=>{},[]);console.debug(`[${f}]: Matched Function.prototype.call called, but not for PowerLink Skeleton:`,e)}return g=!1,d(t,e,n)}}),a.Object.defineProperty=new Proxy(R,{apply(t,e,n){let o=w(n[0]),l=P(n[0]),i=String(o??"");if(o!==null&&l!==null&&i.length<500&&m.filter(u=>u.filter(c=>c.test(i)).length===u.length).length===1&&[...l.querySelectorAll("*")].filter(u=>{if(!(u instanceof HTMLElement))return!1;let c=u.getClientRects()[0]?.height??0,y=Math.max(r(getComputedStyle(u).getPropertyValue("padding-bottom")),r(getComputedStyle(u).getPropertyValue("margin-bottom")));return c>0&&y>=c*(S-s)&&y<=c*(b+s)}).length>=1){console.debug(`[${f}]: Restoring renderer.call for detected PowerLink skeleton:`,n[0]),o.call=Function.prototype.call;return}return d(t,e,n)}});let V=[[/\( *\) *=> *{ *var *_0x[0-9a-z]+ *= *a0_0x[0-9a-f]+ *; *this\[ *_0x[a-z0-9]+\( *0x[0-9a-f]+ *\) *\]\(\); *}/,/\( *\) *=> *{ *var *_0x[0-9a-z]+ *= *a0_0x[0-9a-f]+ *; *this\[ *_0x[a-z0-9]+\( *0x[0-9a-f]+ *\) *\]\(\); *}/],[/\( *\) *=> *{ *var _0x[a-z0-9]+ *= *_0x[a-z0-9]+ *; *if *\( *this\[ *_0x[a-z0-9]+ *\( *0x[0-9a-f]+ *\) *\] *\) *return *clearTimeout/,/\( *0x[0-9a-f]+ *\) *\] *\) *, *void *\( *this\[ *_0x[a-z0-9]+\( *0x[0-9a-f]+ *\) *\] *= *void *\([x0-9a-f*+-]+ *\) *\) *; *this\[_0x[a-z0-9]+\( *0x[0-9a-f]+ *\) *\] *\(\) *;/]];a.setTimeout=new Proxy(a.setTimeout,{apply(t,e,n){let o=String(n[0]);return V.filter(l=>l.filter(i=>i.test(o)).length>=1).length===1?(console.debug(`[${f}]: setTimeout called for PowerLink Skeleton:`,n[0]),d(t,e,[()=>{},0])):d(t,e,n)}});function x(t,e){if(typeof t!="object"||t===null)return 1;if(typeof d(p,a.Object,[t,"_"])?.get=="function")return null;let n=new Set,o=t._;for(;typeof o=="object"&&o!==null;){if(n.has(o))return 2;n.add(o);let l=o;if(typeof l.render=="function")return l.render=e,0;o=l.parent}return 3}function j(t){if(typeof t!="object"||t===null||typeof d(p,a.Object,[t,"_"])?.get=="function")return null;let e=new Set,n=t._;for(;typeof n=="object"&&n!==null&&!e.has(n);){e.add(n);let o=n,l=o.render;if(typeof l=="function")return l;let i=o.vnode;if(typeof i=="object"&&i!==null){let u=i.type;if(typeof u=="object"&&u!==null){let c=u.render;if(typeof c=="function")return c}}n=o.parent}return null}function v(t,e){if(typeof t!="object"||t===null)return 1;if(typeof d(p,a.Object,[t,"_"])?.get=="function")return null;let n=new Set,o=t._;for(;typeof o=="object"&&o!==null;){if(n.has(o))return 2;n.add(o);let l=o,i=l.vnode;if(typeof i=="object"&&i!==null){let u=i.type;if(typeof u=="object"&&u!==null&&typeof u.render=="function")return u.render=e,0}o=l.parent}return 3}let L=new Set;a.Proxy=new Proxy(E,{construct(t,e){let n=w(e[0]),o=j(e[0]),l=P(e[0]),i=String(n??"");if(n!==null&&l!==null&&i.length<500&&m.filter(u=>u.filter(c=>c.test(i)).length===u.length).length===1&&[...l.querySelectorAll("*")].filter(u=>{if(!(u instanceof HTMLElement))return!1;let c=u.getClientRects()[0]?.height??0,y=Math.max(r(getComputedStyle(u).getPropertyValue("padding-bottom")),r(getComputedStyle(u).getPropertyValue("margin-bottom")));return c>0&&y>=c*(S-s)&&y<=c*(b+s)}).length>=1)console.debug(`[${f}]: Prevented declaring render function in Vue.js 3 for detected PowerLink skeleton:`,e[0],l),L.add(n),x(e[0],()=>null),a.document.dispatchEvent(new CustomEvent("PL2PlaceHolderProxy"));else if(o!==null&&L.has(o))return console.debug(`[${f}]: Prevented declaring render function in Vue.js 3 in SPA moving for detected PowerLink skeleton:`,e[0]),v(e[0],()=>null),a.document.dispatchEvent(new CustomEvent("PL2PlaceHolderProxy")),Reflect.construct(t,e);return Reflect.construct(t,e)}}),a.document.addEventListener("PL2AdvertContainer",()=>{setTimeout(()=>{let t=new Set([k]);t=new Set([...t,...[...t].flatMap(e=>[...e.querySelectorAll("*")])]),t=new Set([...t].filter(e=>r(getComputedStyle(e).getPropertyValue("border-bottom-width"))>=.5)),t=new Set([...t].filter(e=>r(getComputedStyle(e).getPropertyValue("border-left-width"))>=.5)),t=new Set([...t].filter(e=>r(getComputedStyle(e).getPropertyValue("border-right-width"))>=.5)),t=new Set([...t].filter(e=>r(getComputedStyle(e).getPropertyValue("border-top-width"))>=.5)),t=new Set([...t].filter(e=>[...e.querySelectorAll("*")].some(n=>{if(!(n instanceof HTMLElement))return!1;let o=n.getClientRects()[0]?.height??0,l=r(getComputedStyle(n).getPropertyValue("margin-bottom"));return o===0?!1:l>=o*.65&&l<=o*1.25}))),console.debug(`[${f}]: Removing PowerLink Skeleton Containers (PL2AdvertContainer):`,t),t.forEach(e=>{e.setAttribute("style","display: none !important;")})},2500)}),a.document.addEventListener("PL2PlaceHolderMobile",()=>{setTimeout(()=>{let t=new Set([...a.document.querySelectorAll("div[class] div[class] div[class] ~ div[class]")]);t=new Set([...t].filter(e=>e instanceof HTMLElement)),t=new Set([...t].filter(e=>r(getComputedStyle(e).getPropertyValue("margin-bottom"))>15||r(getComputedStyle(e).getPropertyValue("padding-top"))>20)),t=new Set([...t].filter(e=>e instanceof HTMLElement&&e.innerText.trim().length===0)),t=new Set([...t].filter(e=>[...e.querySelectorAll("*")].some(n=>n instanceof HTMLElement&&r(getComputedStyle(n).getPropertyValue("padding-top"))>=5&&r(getComputedStyle(n).getPropertyValue("padding-bottom"))>=5&&r(getComputedStyle(n).getPropertyValue("padding-left"))>=5&&r(getComputedStyle(n).getPropertyValue("padding-right"))>=5))),console.debug(`[${f}]: Removing PowerLink Skeleton Containers (PL2PlaceHolderMobile):`,t),t.forEach(e=>{e.setAttribute("style","display: none !important;")})},2500)}),a.document.addEventListener("PL2PlaceHolder",()=>{setTimeout(()=>{let t=new Set([...a.document.querySelectorAll("div[class] div[class] div[class] ~ div[class]")]);t=new Set([...t].filter(e=>e instanceof HTMLElement)),t=new Set([...t].filter(e=>r(getComputedStyle(e).getPropertyValue("padding-top"))>10||r(getComputedStyle(e).getPropertyValue("margin-top"))>10)),t=new Set([...t,...[...t].flatMap(e=>[...e.querySelectorAll("*:not(button)")])]),t=new Set([...t].filter(e=>e instanceof HTMLElement&&e.innerText.trim().length===0)),t=new Set([...t].filter(e=>r(getComputedStyle(e).getPropertyValue("border-bottom-width"))>=.5)),t=new Set([...t].filter(e=>r(getComputedStyle(e).getPropertyValue("border-left-width"))>=.5)),t=new Set([...t].filter(e=>r(getComputedStyle(e).getPropertyValue("border-right-width"))>=.5)),t=new Set([...t].filter(e=>r(getComputedStyle(e).getPropertyValue("border-top-width"))>=.5)),t=new Set([...t].filter(e=>r(getComputedStyle(e).getPropertyValue("transition-duration"))>=.01)),console.debug(`[${f}]: Removing PowerLink Skeleton Containers (PL2PlaceHolder):`,t),t.forEach(e=>{e.setAttribute("style","display: none !important;")})},2500)}),a.document.addEventListener("PL2PlaceHolderProxy",()=>{setTimeout(()=>{let t=new Set([...a.document.querySelectorAll("div[class] div[class] div[class] ~ div[class]")]);t=new Set([...t].filter(e=>e instanceof HTMLElement)),t=new Set([...t].filter(e=>r(getComputedStyle(e).getPropertyValue("padding-top"))>=5&&r(getComputedStyle(e).getPropertyValue("padding-bottom"))>=5&&r(getComputedStyle(e).getPropertyValue("padding-left"))>=5&&r(getComputedStyle(e).getPropertyValue("padding-right"))>=5&&r(getComputedStyle(e).getPropertyValue("border-top-width"))>=.35&&r(getComputedStyle(e).getPropertyValue("border-bottom-width"))>=.35&&r(getComputedStyle(e).getPropertyValue("border-left-width"))>=.35&&r(getComputedStyle(e).getPropertyValue("border-right-width"))>=.35&&e.getClientRects()[0]?.height<=20&&e.getClientRects()[0]?.height>0)),t=new Set([...t].filter(e=>e instanceof HTMLElement&&e.innerText.trim().length===0)),console.debug(`[${f}]: Removing PowerLink Skeleton Containers (PL2PlaceHolderProxy):`,t),t.forEach(e=>{e.setAttribute("style","display: none !important;")})},2500)})}C(z);})();
|
|
26
25
|
/*!
|
|
27
26
|
* @license MPL-2.0
|
|
28
27
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
package/dist/index.js
CHANGED
|
@@ -13,6 +13,7 @@ export function RunNamuLinkUserscript(BrowserWindow, UserscriptName = 'NamuLink'
|
|
|
13
13
|
const OriginalReflectApply = BrowserWindow.Reflect.apply;
|
|
14
14
|
const OriginalObjectDefineProperty = BrowserWindow.Object.defineProperty;
|
|
15
15
|
const OriginalProxy = BrowserWindow.Proxy;
|
|
16
|
+
const OriginalObjectGetOwnPropertyDescriptor = BrowserWindow.Object.getOwnPropertyDescriptor;
|
|
16
17
|
const PL2MajorFuncCallPatterns = [[
|
|
17
18
|
/function *\( *[A-Za-z0-9]+ *, *[A-Za-z0-9]+ *, *[A-Za-z0-9]+ *, *[A-Za-z0-9]+ *, *[A-Za-z0-9]+ *, *[A-Za-z0-9]+ *\) *{ *return *[A-Za-z.-9]+/,
|
|
18
19
|
/, *[A-Za-z0-9]+ *, *[A-Za-z0-9]+ *\) *{ *return *[A-Za-z.-9]+ *\( *[0-9a-fx *+-]+ *, *[A-Za-z.-9]+ *, *[A-Za-z.-9]+ *, *[0-9a-fx *+-]+/,
|
|
@@ -25,6 +26,8 @@ export function RunNamuLinkUserscript(BrowserWindow, UserscriptName = 'NamuLink'
|
|
|
25
26
|
function PowerLinkElementFromArg(Arg) {
|
|
26
27
|
if (typeof Arg !== 'object' || Arg === null)
|
|
27
28
|
return null;
|
|
29
|
+
if (typeof OriginalReflectApply(OriginalObjectGetOwnPropertyDescriptor, BrowserWindow.Object, [Arg, '_'])?.get === 'function')
|
|
30
|
+
return null;
|
|
28
31
|
const Visited = new Set();
|
|
29
32
|
let Current = Arg['_'];
|
|
30
33
|
while (typeof Current === 'object' && Current !== null) {
|
|
@@ -45,6 +48,8 @@ export function RunNamuLinkUserscript(BrowserWindow, UserscriptName = 'NamuLink'
|
|
|
45
48
|
function PowerLinkRenderFromArg(Arg) {
|
|
46
49
|
if (typeof Arg !== 'object' || Arg === null)
|
|
47
50
|
return null;
|
|
51
|
+
if (typeof OriginalReflectApply(OriginalObjectGetOwnPropertyDescriptor, BrowserWindow.Object, [Arg, '_'])?.get === 'function')
|
|
52
|
+
return null;
|
|
48
53
|
const Visited = new Set();
|
|
49
54
|
let Current = Arg['_'];
|
|
50
55
|
while (typeof Current === 'object' && Current !== null) {
|
|
@@ -61,6 +66,8 @@ export function RunNamuLinkUserscript(BrowserWindow, UserscriptName = 'NamuLink'
|
|
|
61
66
|
function PowerLinkElementFromArgParent(Arg) {
|
|
62
67
|
if (typeof Arg !== 'object' || Arg === null)
|
|
63
68
|
return null;
|
|
69
|
+
if (typeof OriginalReflectApply(OriginalObjectGetOwnPropertyDescriptor, BrowserWindow.Object, [Arg, '_'])?.get === 'function')
|
|
70
|
+
return null;
|
|
64
71
|
const Visited = new Set();
|
|
65
72
|
let Current = Arg['_'];
|
|
66
73
|
while (typeof Current === 'object' && Current !== null) {
|
|
@@ -127,10 +134,10 @@ export function RunNamuLinkUserscript(BrowserWindow, UserscriptName = 'NamuLink'
|
|
|
127
134
|
BrowserWindow.Object.defineProperty = new Proxy(OriginalObjectDefineProperty, {
|
|
128
135
|
apply(Target, ThisArg, Args) {
|
|
129
136
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
130
|
-
let
|
|
137
|
+
let VuejsRender = PowerLinkRenderFromArg(Args[0]);
|
|
131
138
|
let PL2Element = PowerLinkElementFromArgParent(Args[0]);
|
|
132
|
-
let Stringified = String(
|
|
133
|
-
if (
|
|
139
|
+
let Stringified = String(VuejsRender ?? '');
|
|
140
|
+
if (VuejsRender !== null && PL2Element !== null && Stringified.length < 500 &&
|
|
134
141
|
PL2MajorFuncCallPatterns.filter(Patterns => Patterns.filter(Pattern => Pattern.test(Stringified)).length === Patterns.length).length === 1 &&
|
|
135
142
|
[...PL2Element.querySelectorAll('*')].filter(Child => {
|
|
136
143
|
if (!(Child instanceof HTMLElement))
|
|
@@ -140,7 +147,7 @@ export function RunNamuLinkUserscript(BrowserWindow, UserscriptName = 'NamuLink'
|
|
|
140
147
|
return PL2TitleHeight > 0 && PL2TitleMarginBottom >= PL2TitleHeight * (MinRatio - EpsilonRatio) && PL2TitleMarginBottom <= PL2TitleHeight * (MaxRatio + EpsilonRatio);
|
|
141
148
|
}).length >= 1) {
|
|
142
149
|
console.debug(`[${UserscriptName}]: Restoring renderer.call for detected PowerLink skeleton:`, Args[0]);
|
|
143
|
-
|
|
150
|
+
VuejsRender.call = Function.prototype.call;
|
|
144
151
|
return;
|
|
145
152
|
}
|
|
146
153
|
return OriginalReflectApply(Target, ThisArg, Args);
|
|
@@ -167,6 +174,8 @@ export function RunNamuLinkUserscript(BrowserWindow, UserscriptName = 'NamuLink'
|
|
|
167
174
|
function PowerLinkOverrideRenderFromArg(Arg, Override) {
|
|
168
175
|
if (typeof Arg !== 'object' || Arg === null)
|
|
169
176
|
return 1;
|
|
177
|
+
if (typeof OriginalReflectApply(OriginalObjectGetOwnPropertyDescriptor, BrowserWindow.Object, [Arg, '_'])?.get === 'function')
|
|
178
|
+
return null;
|
|
170
179
|
const Visited = new Set();
|
|
171
180
|
let Current = Arg['_'];
|
|
172
181
|
while (typeof Current === 'object' && Current !== null) {
|
|
@@ -183,13 +192,74 @@ export function RunNamuLinkUserscript(BrowserWindow, UserscriptName = 'NamuLink'
|
|
|
183
192
|
}
|
|
184
193
|
return 3;
|
|
185
194
|
}
|
|
195
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
196
|
+
function PowerLinkVnodeTypeRenderFromArg(Arg) {
|
|
197
|
+
if (typeof Arg !== 'object' || Arg === null)
|
|
198
|
+
return null;
|
|
199
|
+
if (typeof OriginalReflectApply(OriginalObjectGetOwnPropertyDescriptor, BrowserWindow.Object, [Arg, '_'])?.get === 'function')
|
|
200
|
+
return null;
|
|
201
|
+
const Visited = new Set();
|
|
202
|
+
let Current = Arg['_'];
|
|
203
|
+
while (typeof Current === 'object' && Current !== null) {
|
|
204
|
+
if (Visited.has(Current))
|
|
205
|
+
break;
|
|
206
|
+
Visited.add(Current);
|
|
207
|
+
const CurrentRecord = Current;
|
|
208
|
+
const Render = CurrentRecord['render'];
|
|
209
|
+
if (typeof Render === 'function')
|
|
210
|
+
return Render;
|
|
211
|
+
const VNode = CurrentRecord['vnode'];
|
|
212
|
+
if (typeof VNode === 'object' && VNode !== null) {
|
|
213
|
+
const Type = VNode['type'];
|
|
214
|
+
if (typeof Type === 'object' && Type !== null) {
|
|
215
|
+
const TypeRender = Type['render'];
|
|
216
|
+
if (typeof TypeRender === 'function')
|
|
217
|
+
return TypeRender;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
Current = CurrentRecord['parent'];
|
|
221
|
+
}
|
|
222
|
+
return null;
|
|
223
|
+
}
|
|
224
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
225
|
+
function PowerLinkOverrideVnodeTypeRenderOnlyFromArg(Arg, Override) {
|
|
226
|
+
if (typeof Arg !== 'object' || Arg === null)
|
|
227
|
+
return 1;
|
|
228
|
+
if (typeof OriginalReflectApply(OriginalObjectGetOwnPropertyDescriptor, BrowserWindow.Object, [Arg, '_'])?.get === 'function')
|
|
229
|
+
return null;
|
|
230
|
+
const Visited = new Set();
|
|
231
|
+
let Current = Arg['_'];
|
|
232
|
+
while (typeof Current === 'object' && Current !== null) {
|
|
233
|
+
if (Visited.has(Current))
|
|
234
|
+
return 2;
|
|
235
|
+
Visited.add(Current);
|
|
236
|
+
const CurrentRecord = Current;
|
|
237
|
+
const VNode = CurrentRecord['vnode'];
|
|
238
|
+
if (typeof VNode === 'object' && VNode !== null) {
|
|
239
|
+
const Type = VNode['type'];
|
|
240
|
+
if (typeof Type === 'object' && Type !== null) {
|
|
241
|
+
const TypeRender = Type['render'];
|
|
242
|
+
if (typeof TypeRender === 'function') {
|
|
243
|
+
Type['render'] = Override;
|
|
244
|
+
return 0;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
Current = CurrentRecord['parent'];
|
|
249
|
+
}
|
|
250
|
+
return 3;
|
|
251
|
+
}
|
|
252
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
253
|
+
let VuejsPL2Render = new Set();
|
|
186
254
|
BrowserWindow.Proxy = new Proxy(OriginalProxy, {
|
|
187
255
|
construct(Target, Args) {
|
|
188
256
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
189
|
-
let
|
|
257
|
+
let VuejsRender = PowerLinkRenderFromArg(Args[0]);
|
|
258
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
259
|
+
let VuejsCtxSubtreeRender = PowerLinkVnodeTypeRenderFromArg(Args[0]);
|
|
190
260
|
let PL2Element = PowerLinkElementFromArgParent(Args[0]);
|
|
191
|
-
let Stringified = String(
|
|
192
|
-
if (
|
|
261
|
+
let Stringified = String(VuejsRender ?? '');
|
|
262
|
+
if (VuejsRender !== null && PL2Element !== null && Stringified.length < 500 &&
|
|
193
263
|
PL2MajorFuncCallPatterns.filter(Patterns => Patterns.filter(Pattern => Pattern.test(Stringified)).length === Patterns.length).length === 1 &&
|
|
194
264
|
[...PL2Element.querySelectorAll('*')].filter(Child => {
|
|
195
265
|
if (!(Child instanceof HTMLElement))
|
|
@@ -199,9 +269,16 @@ export function RunNamuLinkUserscript(BrowserWindow, UserscriptName = 'NamuLink'
|
|
|
199
269
|
return PL2TitleHeight > 0 && PL2TitleMarginBottom >= PL2TitleHeight * (MinRatio - EpsilonRatio) && PL2TitleMarginBottom <= PL2TitleHeight * (MaxRatio + EpsilonRatio);
|
|
200
270
|
}).length >= 1) {
|
|
201
271
|
console.debug(`[${UserscriptName}]: Prevented declaring render function in Vue.js 3 for detected PowerLink skeleton:`, Args[0], PL2Element);
|
|
272
|
+
VuejsPL2Render.add(VuejsRender);
|
|
202
273
|
PowerLinkOverrideRenderFromArg(Args[0], () => null);
|
|
203
274
|
BrowserWindow.document.dispatchEvent(new CustomEvent('PL2PlaceHolderProxy'));
|
|
204
275
|
}
|
|
276
|
+
else if (VuejsCtxSubtreeRender !== null && VuejsPL2Render.has(VuejsCtxSubtreeRender)) {
|
|
277
|
+
console.debug(`[${UserscriptName}]: Prevented declaring render function in Vue.js 3 in SPA moving for detected PowerLink skeleton:`, Args[0]);
|
|
278
|
+
PowerLinkOverrideVnodeTypeRenderOnlyFromArg(Args[0], () => null);
|
|
279
|
+
BrowserWindow.document.dispatchEvent(new CustomEvent('PL2PlaceHolderProxy'));
|
|
280
|
+
return Reflect.construct(Target, Args);
|
|
281
|
+
}
|
|
205
282
|
return Reflect.construct(Target, Args);
|
|
206
283
|
}
|
|
207
284
|
});
|