@@ -19,6 +19,48 @@ const Win = typeof unsafeWindow !== 'undefined' ? unsafeWindow : window
1919export function RunNamuLinkUserscript ( BrowserWindow : typeof window , UserscriptName : string = 'NamuLink' ) : void {
2020 const ProtectedFunctionPrototypeToString = BrowserWindow . Function . prototype . toString
2121
22+ let PowerLinkGenerationPositiveRegExps : RegExp [ ] [ ] = [ [
23+ / f o r * \( * ; * ; * \) * s w i t c h * \( * _ [ a - z 0 - 9 ] + \[ _ [ a - z 0 - 9 ] + \( [ a - z 0 - 9 ] + \) \] * = _ [ a - z 0 - 9 ] + / ,
24+ / _ [ a - z 0 - 9 ] + \[ ( ' | " ) [ A - Z ] + ( ' | " ) \] \) \( \[ * \] \) / ,
25+ / 0 x [ a - z 0 - 9 ] + * \) * ; * c a s e /
26+ ] , [
27+ / ; * r e t u r n * t h i s \[ _ 0 x [ a - z 0 - 9 ] + \( * 0 x [ 0 - 9 a - z ] + * \) / ,
28+ / ; * i f * \( * _ 0 x [ a - z 0 - 9 ] + * & & * \( * _ 0 x [ a - z 0 - 9 ] + * = * _ 0 x [ a - z 0 - 9 ] + / ,
29+ / \) * , * v o i d * \( * t h i s * \[ * _ 0 x [ a - z 0 - 9 ] + \( * 0 x [ 0 - 9 a - z ] + * \) * \] * = * _ 0 x [ a - z 0 - 9 ] + * \[ /
30+ ] ]
31+
32+ BrowserWindow . Function . prototype . bind = new Proxy ( BrowserWindow . Function . prototype . bind , {
33+ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
34+ apply ( Target : typeof Function . prototype . bind , ThisArg : Function , Args : Parameters < typeof Function . prototype . bind > ) {
35+ let StringifiedFunc = Reflect . apply ( ProtectedFunctionPrototypeToString , ThisArg , Args ) as string
36+ if ( PowerLinkGenerationPositiveRegExps . filter ( PowerLinkGenerationPositiveRegExp => PowerLinkGenerationPositiveRegExp . filter ( Index => Index . test ( StringifiedFunc ) ) . length >= 3 ) . length === 1 ) {
37+ console . debug ( `[${ UserscriptName } ]: Function.prototype.bind:` , ThisArg )
38+ return Reflect . apply ( Target , ( ) => { } , [ ] )
39+ }
40+ return Reflect . apply ( Target , ThisArg , Args )
41+ }
42+ } )
43+
44+ let PowerLinkGenerationSkeletionPositiveRegExps : RegExp [ ] [ ] = [ [
45+ / \( * \) * = > * { * 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 ] + * \) * \] \( \) ; * } / ,
46+ / \( * \) * = > * { * 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 ] + * \) * \] \( \) ; * } /
47+ ] , [
48+ / \( * \) * = > * { * 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 / ,
49+ / \( * 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 ] + * \) * \] * \( \) * ; /
50+ ] ]
51+
52+ BrowserWindow . setTimeout = new Proxy ( BrowserWindow . setTimeout , {
53+ apply ( Target : typeof setTimeout , ThisArg : undefined , Args : Parameters < typeof setTimeout > ) {
54+ let StringifiedFunc = Reflect . apply ( ProtectedFunctionPrototypeToString , Args [ 0 ] , Args ) as string
55+ if ( PowerLinkGenerationSkeletionPositiveRegExps . filter ( PowerLinkGenerationSkeletionPositiveRegExp => PowerLinkGenerationSkeletionPositiveRegExp . filter ( Index => Index . test ( StringifiedFunc ) ) . length >= 1 ) . length === 1 ) {
56+ console . debug ( `[${ UserscriptName } ]: setTimeout:` , Args [ 0 ] )
57+ return
58+ }
59+
60+ return Reflect . apply ( Target , ThisArg , Args )
61+ }
62+ } )
63+
2264 if ( document . readyState === 'loading' ) {
2365 window . addEventListener ( 'DOMContentLoaded' , ( ) => {
2466 SPA . InstallSpaNavigationBridge ( {
0 commit comments