@filteringdev/namulink 19.1.2 → 19.2.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 -2
- package/dist/index.js +41 -20
- 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.2.0
|
|
12
12
|
// @author PiQuark6046 and contributors
|
|
13
13
|
//
|
|
14
14
|
// @grant unsafeWindow
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
// ==/UserScript==
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
(()=>{var
|
|
25
|
+
(()=>{var x=typeof unsafeWindow<"u"?unsafeWindow:window;function A(o,i="NamuLink"){let f=o.Function.prototype.call,u=o.Reflect.apply,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 y(e){if(typeof e!="object"||e===null)return null;let t=new Set,l=e._;for(;typeof l=="object"&&l!==null&&!t.has(l);){t.add(l);let r=l.vnode;if(typeof r=="object"&&r!==null){let n=r.el;if(n instanceof HTMLElement)return n}l=l.parent}return null}let S=.35,b=.75,d=.04,m=null,p=!1;o.Function.prototype.call=new Proxy(f,{apply(e,t,l){if(p)return u(e,t,l);p=!0;let r=String(t);if(r.length<500&&s.filter(n=>n.filter(a=>a.test(r)).length===n.length).length===1){let n=y(l[6]);if(n!==null&&[...n.querySelectorAll("*")].filter(a=>{if(!(a instanceof HTMLElement))return!1;let c=a.getClientRects()[0]?.height??0,g=Math.max(Number(getComputedStyle(a).getPropertyValue("padding-bottom").replaceAll(/px/g,"")),Number(getComputedStyle(a).getPropertyValue("margin-bottom").replaceAll(/px/g,"")));return c>0&&g>=c*(S-d)&&g<=c*(b+d)}).length>=1)return console.debug(`[${i}]: Function.prototype.call called for PowerLink Skeleton:`,t),m=n,o.document.dispatchEvent(new CustomEvent("PL2PlaceHolder")),o.document.dispatchEvent(new CustomEvent("PL2PlaceHolderMobile")),p=!1,u(e,()=>{},[]);console.debug(`[${i}]: Matched Function.prototype.call called, but not for PowerLink Skeleton:`,t)}return p=!1,u(e,t,l)}});let P=[[/\( *\) *=> *{ *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]+ *\) *\] *\(\) *;/]];o.setTimeout=new Proxy(o.setTimeout,{apply(e,t,l){let r=String(l[0]);return P.filter(n=>n.filter(a=>a.test(r)).length>=1).length===1?(console.debug(`[${i}]: setTimeout called for PowerLink Skeleton:`,l[0]),u(e,t,[()=>{},0])):u(e,t,l)}}),o.document.addEventListener("PL2AdvertContainer",()=>{setTimeout(()=>{let e=new Set([m]);e=new Set([...e,...[...e].flatMap(t=>[...t.querySelectorAll("*")])]),e=new Set([...e].filter(t=>Number(getComputedStyle(t).getPropertyValue("border-bottom-width").replaceAll(/px/g,""))>=.5)),e=new Set([...e].filter(t=>Number(getComputedStyle(t).getPropertyValue("border-left-width").replaceAll(/px/g,""))>=.5)),e=new Set([...e].filter(t=>Number(getComputedStyle(t).getPropertyValue("border-right-width").replaceAll(/px/g,""))>=.5)),e=new Set([...e].filter(t=>Number(getComputedStyle(t).getPropertyValue("border-top-width").replaceAll(/px/g,""))>=.5)),e=new Set([...e].filter(t=>[...t.querySelectorAll("*")].some(l=>{if(!(l instanceof HTMLElement))return!1;let r=l.getClientRects()[0]?.height??0,n=Number(getComputedStyle(l).getPropertyValue("margin-bottom").replaceAll(/px/g,""));return r===0?!1:n>=r*.65&&n<=r*1.25}))),console.debug(`[${i}]: Removing PowerLink Skeleton Containers (PL2AdvertContainer):`,e),e.forEach(t=>{t.setAttribute("style","display: none !important;")})},2500)}),o.document.addEventListener("PL2PlaceHolderMobile",()=>{setTimeout(()=>{let e=new Set([...o.document.querySelectorAll("div[class] div[class] div[class] ~ div[class]")]);e=new Set([...e].filter(t=>t instanceof HTMLElement)),e=new Set([...e].filter(t=>Number(getComputedStyle(t).getPropertyValue("margin-bottom").replaceAll(/px$/g,""))>15||Number(getComputedStyle(t).getPropertyValue("padding-top").replaceAll(/px$/g,""))>20)),e=new Set([...e].filter(t=>t instanceof HTMLElement&&t.innerText.trim().length===0)),e=new Set([...e].filter(t=>[...t.querySelectorAll("*")].some(l=>l instanceof HTMLElement&&Number(getComputedStyle(l).getPropertyValue("padding-top").replaceAll(/px/g,""))>=5&&Number(getComputedStyle(l).getPropertyValue("padding-bottom").replaceAll(/px/g,""))>=5&&Number(getComputedStyle(l).getPropertyValue("padding-left").replaceAll(/px/g,""))>=5&&Number(getComputedStyle(l).getPropertyValue("padding-right").replaceAll(/px/g,""))>=5))),console.debug(`[${i}]: Removing PowerLink Skeleton Containers (PL2PlaceHolderMobile):`,e),e.forEach(t=>{t.setAttribute("style","display: none !important;")})},2500),o.document.addEventListener("PL2PlaceHolder",()=>{setTimeout(()=>{let e=new Set([...o.document.querySelectorAll("div[class] div[class] div[class] ~ div[class]")]);e=new Set([...e].filter(t=>t instanceof HTMLElement)),e=new Set([...e].filter(t=>Number(getComputedStyle(t).getPropertyValue("padding-top").replaceAll(/px$/g,""))>10||Number(getComputedStyle(t).getPropertyValue("margin-top").replaceAll(/px$/g,""))>10)),e=new Set([...e,...[...e].flatMap(t=>[...t.querySelectorAll("*:not(button)")])]),e=new Set([...e].filter(t=>t instanceof HTMLElement&&t.innerText.trim().length===0)),e=new Set([...e].filter(t=>Number(getComputedStyle(t).getPropertyValue("border-bottom-width").replaceAll(/px/g,""))>=.5)),e=new Set([...e].filter(t=>Number(getComputedStyle(t).getPropertyValue("border-left-width").replaceAll(/px/g,""))>=.5)),e=new Set([...e].filter(t=>Number(getComputedStyle(t).getPropertyValue("border-right-width").replaceAll(/px/g,""))>=.5)),e=new Set([...e].filter(t=>Number(getComputedStyle(t).getPropertyValue("border-top-width").replaceAll(/px/g,""))>=.5)),e=new Set([...e].filter(t=>Number(getComputedStyle(t).getPropertyValue("transition-duration").replaceAll(/s$/g,""))>=.01)),console.debug(`[${i}]: Removing PowerLink Skeleton Containers (PL2PlaceHolder):`,e),e.forEach(t=>{t.setAttribute("style","display: none !important;")})},2500)})})}A(x);})();
|
|
26
26
|
/*!
|
|
27
27
|
* @license MPL-2.0
|
|
28
28
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
package/dist/index.js
CHANGED
|
@@ -12,16 +12,32 @@ export function RunNamuLinkUserscript(BrowserWindow, UserscriptName = 'NamuLink'
|
|
|
12
12
|
const OriginalFunctionPrototypeCall = BrowserWindow.Function.prototype.call;
|
|
13
13
|
const OriginalReflectApply = BrowserWindow.Reflect.apply;
|
|
14
14
|
const PL2MajorFuncCallPatterns = [[
|
|
15
|
-
/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]+ *\) *{ *
|
|
16
|
-
|
|
17
|
-
/
|
|
18
|
-
/[a-zA-Z0-9]+ *\[ *('|")[a-zA-Z0-9]+('|") *\] *\) *\( *[a-zA-Z0-9]+ *, *{ *\[ *[a-zA-Z0-9]+ *\] *: *[0-9xa-f*+-]+ *,(('|")[A-Za-z0-9]+('|")|[A-Za-z0-9 ()\[\]+*-]+) *: *[a-zA-Z0-9]+ *\[ *[a-zA-Z0-9]+ *\( *[0-9xa-f*+-]+ *. *[0-9xa-f*+-]+ *\) *\] *\[/
|
|
19
|
-
]];
|
|
20
|
-
const FalsePositiveSignPatterns = [[
|
|
21
|
-
/new *Map *\( *Object *\[ *_0x[a-f0-9]+ *\( *0x[a-f0-9]+ *\) *\] *\( *{ *('|")pretendard('|") *: *{ *('|")fontFamily('|") *: */,
|
|
22
|
-
/('|")fontFamily('|") *: *_0x[a-f0-9]+ *\( *0x[a-f0-9]+ *\) *, *('|")styleUrl('|") *: *_0x[a-f0-9]+ *\( *0x[a-f0-9]+ *\) *, *('|")isGoogleFonts/,
|
|
23
|
-
/('|")popper--wide('|") *: *_0x[a-f0-9]+ *\( *0x[a-f0-9]+ *\) *, *('|")popper__title('|") *: *_0x[a-f0-9]+ *\( *0x[a-f0-9]+ *\) *} *} *,/
|
|
15
|
+
/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]+/,
|
|
16
|
+
/, *[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 *+-]+/,
|
|
17
|
+
/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]+ * *\) *; *}/
|
|
24
18
|
]];
|
|
19
|
+
function GetPowerLinkElementFromArg(Arg) {
|
|
20
|
+
if (typeof Arg !== 'object' || Arg === null)
|
|
21
|
+
return null;
|
|
22
|
+
const Visited = new Set();
|
|
23
|
+
let Current = Arg['_'];
|
|
24
|
+
while (typeof Current === 'object' && Current !== null) {
|
|
25
|
+
if (Visited.has(Current))
|
|
26
|
+
break;
|
|
27
|
+
Visited.add(Current);
|
|
28
|
+
const VNode = Current['vnode'];
|
|
29
|
+
if (typeof VNode === 'object' && VNode !== null) {
|
|
30
|
+
const Element = VNode['el'];
|
|
31
|
+
if (Element instanceof HTMLElement)
|
|
32
|
+
return Element;
|
|
33
|
+
}
|
|
34
|
+
Current = Current['parent'];
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
const MinRatio = 0.35;
|
|
39
|
+
const MaxRatio = 0.75;
|
|
40
|
+
const EpsilonRatio = 0.04;
|
|
25
41
|
let CommentContainer = null;
|
|
26
42
|
let InHook = false;
|
|
27
43
|
BrowserWindow.Function.prototype.call = new Proxy(OriginalFunctionPrototypeCall, {
|
|
@@ -32,18 +48,23 @@ export function RunNamuLinkUserscript(BrowserWindow, UserscriptName = 'NamuLink'
|
|
|
32
48
|
}
|
|
33
49
|
InHook = true;
|
|
34
50
|
const Stringified = String(ThisArg);
|
|
35
|
-
if (Stringified.length <
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
51
|
+
if (Stringified.length < 500 && PL2MajorFuncCallPatterns.filter(Patterns => Patterns.filter(Pattern => Pattern.test(Stringified)).length === Patterns.length).length === 1) {
|
|
52
|
+
let PL2Element = GetPowerLinkElementFromArg(Args[6]);
|
|
53
|
+
if (PL2Element !== null && [...PL2Element.querySelectorAll('*')].filter(Child => {
|
|
54
|
+
if (!(Child instanceof HTMLElement))
|
|
55
|
+
return false;
|
|
56
|
+
let PL2TitleHeight = Child.getClientRects()[0]?.height ?? 0;
|
|
57
|
+
let PL2TitleMarginBottom = Math.max(Number(getComputedStyle(Child).getPropertyValue('padding-bottom').replaceAll(/px/g, '')), Number(getComputedStyle(Child).getPropertyValue('margin-bottom').replaceAll(/px/g, '')));
|
|
58
|
+
return PL2TitleHeight > 0 && PL2TitleMarginBottom >= PL2TitleHeight * (MinRatio - EpsilonRatio) && PL2TitleMarginBottom <= PL2TitleHeight * (MaxRatio + EpsilonRatio);
|
|
59
|
+
}).length >= 1) {
|
|
60
|
+
console.debug(`[${UserscriptName}]: Function.prototype.call called for PowerLink Skeleton:`, ThisArg);
|
|
61
|
+
CommentContainer = PL2Element;
|
|
62
|
+
BrowserWindow.document.dispatchEvent(new CustomEvent('PL2PlaceHolder'));
|
|
63
|
+
BrowserWindow.document.dispatchEvent(new CustomEvent('PL2PlaceHolderMobile'));
|
|
64
|
+
InHook = false;
|
|
65
|
+
return OriginalReflectApply(Target, () => { }, []);
|
|
42
66
|
}
|
|
43
|
-
|
|
44
|
-
BrowserWindow.document.dispatchEvent(new CustomEvent('PL2PlaceHolderMobile'));
|
|
45
|
-
InHook = false;
|
|
46
|
-
return OriginalReflectApply(Target, () => { }, []);
|
|
67
|
+
console.debug(`[${UserscriptName}]: Matched Function.prototype.call called, but not for PowerLink Skeleton:`, ThisArg);
|
|
47
68
|
}
|
|
48
69
|
InHook = false;
|
|
49
70
|
return OriginalReflectApply(Target, ThisArg, Args);
|