@@ -24,22 +24,35 @@ declare const __OCR_WORKER_CODE__: string
2424export async function RunNamuLinkUserscript ( BrowserWindow : typeof window , UserscriptName : string = 'NamuLink' ) : Promise < void > {
2525 const OriginalReflectApply = BrowserWindow . Reflect . apply
2626
27- let PL2AfterLoadInitTimerPatterns : RegExp [ ] [ ] = [ [
28- / \( * \) * = > * { * v a r * _ 0 x [ 0 - 9 a - z ] + * = * a 0 _ 0 x [ 0 - 9 a - f ] + * ; * t h i s \[ * _ 0 x [ a - z 0 - 9 ] + \( * 0 x [ 0 - 9 a - f ] + * \) * \] \( \) ; * } / ,
29- / \( * \) * = > * { * v a r * _ 0 x [ 0 - 9 a - z ] + * = * a 0 _ 0 x [ 0 - 9 a - f ] + * ; * t h i s \[ * _ 0 x [ a - z 0 - 9 ] + \( * 0 x [ 0 - 9 a - f ] + * \) * \] \( \) ; * } /
30- ] , [
31- / \( * \) * = > * { * v a r _ 0 x [ a - z 0 - 9 ] + * = * _ 0 x [ a - z 0 - 9 ] + * ; * i f * \( * t h i s \[ * _ 0 x [ a - z 0 - 9 ] + * \( * 0 x [ 0 - 9 a - f ] + * \) * \] * \) * r e t u r n * c l e a r T i m e o u t / ,
32- / \( * 0 x [ 0 - 9 a - f ] + * \) * \] * \) * , * v o i d * \( * t h i s \[ * _ 0 x [ a - z 0 - 9 ] + \( * 0 x [ 0 - 9 a - f ] + * \) * \] * = * v o i d * \( [ x 0 - 9 a - f * + - ] + * \) * \) * ; * t h i s \[ _ 0 x [ a - z 0 - 9 ] + \( * 0 x [ 0 - 9 a - f ] + * \) * \] * \( \) * ; /
27+ const PL2PromiseThenRegexs : RegExp [ ] [ ] = [ [
28+ / f u n c t i o n * [ A - Z a - z 0 - 9 ] + * \( [ A - Z a - z 0 - 9 ] + * * \) * { * f u n c t i o n * [ A - Z a - z 0 - 9 ] + * \( * [ a - z A - Z ] + * , * [ A - Z a - z ] + * \) * { * r e t u r n * [ A - Z a - z 0 - 9 ] + * \( * / ,
29+ / { * r e t u r n * [ A - Z a - z 0 - 9 ] + * \( * [ a - z A - Z ] + * - * 0 x [ a - f 0 - 9 ] + * , * [ a - z A - Z ] + * \) * ; * \} * [ A - Z a - z 0 - 9 ] + * \( * [ A - Z a - z 0 - 9 ] + * , * [ A - Z a - z 0 - 9 ] + * , * [ A - Z a - z 0 - 9 ] + / ,
30+ / \( * [ A - Z a - z 0 - 9 ] + * , * [ A - Z a - z 0 - 9 ] + * , * [ A - Z a - z 0 - 9 ] + * , * [ A - Z a - z 0 - 9 ] + * , * [ A - Z a - z 0 - 9 ] + * , * [ A - Z a - z 0 - 9 ] + * \( * 0 x [ a - f 0 - 9 ] + * , * 0 x [ a - f 0 - 9 ] + * \) * , * [ A - Z a - z 0 - 9 ] + * \) * ; /
3331 ] ]
3432
35- BrowserWindow . setTimeout = new Proxy ( BrowserWindow . setTimeout , {
36- apply ( Target : typeof setTimeout , ThisArg : undefined , Args : Parameters < typeof setTimeout > ) {
37- let StringifiedFunc = String ( Args [ 0 ] )
38- if ( PL2AfterLoadInitTimerPatterns . filter ( PowerLinkGenerationSkeletionPositiveRegExp => PowerLinkGenerationSkeletionPositiveRegExp . filter ( Index => Index . test ( StringifiedFunc ) ) . length >= 1 ) . length === 1 ) {
39- console . debug ( `[${ UserscriptName } ]: setTimeout called for PowerLink Skeleton:` , Args [ 0 ] )
40- return OriginalReflectApply ( Target , ThisArg , [ ( ) => { } , 0 ] )
33+ BrowserWindow . Promise . prototype . then = new Proxy ( BrowserWindow . Promise . prototype . then , {
34+ apply ( Target : typeof Promise . prototype . then , ThisArg : Promise < unknown > , Args : Parameters < typeof Promise . prototype . then > ) {
35+ if ( typeof Args [ 0 ] !== 'function' || typeof Args [ 1 ] !== 'function' ) {
36+ return OriginalReflectApply ( Target , ThisArg , Args )
37+ }
38+ const Stringified : [ string , string ] = [ String ( Args [ 0 ] ) , String ( Args [ 1 ] ) ]
39+ if ( Stringified . every ( Str => PL2PromiseThenRegexs . filter ( Regexs => Regexs . filter ( Regex => Regex . test ( Str ) ) . length === Regexs . length ) . length === 1 ) ) {
40+ console . debug ( `[${ UserscriptName } ] Detected PL2 Promise.then` , Stringified , Args )
41+ setTimeout ( ( ) => {
42+ let Targeted = [ ...document . querySelectorAll ( '#app div[class] div[class] ~ div[class]' ) ] . filter ( Ele => Ele instanceof HTMLElement )
43+ Targeted = Targeted . filter ( Ele => parseFloat ( getComputedStyle ( Ele ) . getPropertyValue ( 'margin-bottom' ) ) >= 12.5 )
44+ Targeted = Targeted . filter ( Ele => Ele . innerText . trim ( ) . length === 0 )
45+ Targeted = Targeted . filter ( Ele => [ ...Ele . querySelectorAll ( '*' ) ] . filter ( Child => Child instanceof HTMLElement ) . some ( Child => {
46+ const Height = Child . getBoundingClientRect ( ) . height
47+ return Height > 0 && Height <= 5
48+ } ) )
49+ console . debug ( `[${ UserscriptName } ] Detected PL2 Promise.then Targeted` , Targeted )
50+ Targeted . forEach ( Ele => {
51+ Ele . style . setProperty ( 'display' , 'none' , 'important' )
52+ } )
53+ } , 250 )
54+ return
4155 }
42-
4356 return OriginalReflectApply ( Target , ThisArg , Args )
4457 }
4558 } )
0 commit comments