@@ -285,50 +285,31 @@ export function RunNamuLinkUserscript(BrowserWindow: typeof window, UserscriptNa
285285 return Stringified . includes ( 'https://ader.naver.com/' )
286286 }
287287
288- function ProxySetHandlerTargetCheck ( Target : object ) : boolean {
289- for ( const PropertyName of Object . keys ( Target ) ) {
290- const Value = ( Target as Record < string , unknown > ) [ PropertyName ]
291- const Descriptor = OriginalObjectGetOwnPropertyDescriptor ( Target , PropertyName )
292-
293- if (
294- typeof Value === 'object' &&
295- Value !== null &&
296- typeof Descriptor ?. get !== 'function'
297- ) {
298- if ( ProxySetHandlerTargetCheck ( Value ) ) {
299- return true
300- }
301- } else if (
302- typeof Value === 'string' &&
303- Value . includes ( 'ader.naver.com' )
304- ) {
305- return true
306- }
288+ function ProxySetHandlerTargetCheck (
289+ Target : object ,
290+ Visited = new WeakSet < object > ( )
291+ ) : boolean {
292+ if ( Visited . has ( Target ) ) {
293+ return false
307294 }
295+ Visited . add ( Target )
308296
309- return false
310- }
311-
312- function ProxySetHandlerTargetCheckAndReplace ( Target : object , NewValue : string ) : boolean {
313- const Record = Target as Record < string , unknown >
314-
315- for ( const PropertyName of Object . keys ( Record ) ) {
316- const Value = Record [ PropertyName ]
297+ for ( const PropertyName of Object . keys ( Target ) ) {
298+ const Value = ( Target as Record < string , unknown > ) [ PropertyName ]
317299 const Descriptor = OriginalObjectGetOwnPropertyDescriptor ( Target , PropertyName )
318300
319301 if (
320302 typeof Value === 'object' &&
321303 Value !== null &&
322304 typeof Descriptor ?. get !== 'function'
323305 ) {
324- if ( ProxySetHandlerTargetCheckAndReplace ( Value , NewValue ) ) {
306+ if ( ProxySetHandlerTargetCheck ( Value , Visited ) ) {
325307 return true
326308 }
327309 } else if (
328310 typeof Value === 'string' &&
329311 Value . includes ( 'ader.naver.com' )
330312 ) {
331- Record [ PropertyName ] = NewValue
332313 return true
333314 }
334315 }
@@ -438,9 +419,6 @@ export function RunNamuLinkUserscript(BrowserWindow: typeof window, UserscriptNa
438419 BrowserWindow . document . dispatchEvent ( new CustomEvent ( 'PL2PlaceHolderProxy' ) )
439420 return
440421 }
441- else if ( ProxySetHandlerTargetCheckAndReplace ( SetArgs [ 0 ] , '' ) ) {
442- console . debug ( `[${ UserscriptName } ]: Proxy set called for PowerLink Skeleton (target check and replace):` , SetArgs )
443- }
444422 return OriginalReflectApply ( OriginalSet , this , SetArgs )
445423 }
446424 }
0 commit comments