From a5c3f660aa202ecd1d1e1f555b2ebd1d4a6ecf15 Mon Sep 17 00:00:00 2001 From: piquark6046 Date: Mon, 23 Mar 2026 06:27:23 +0000 Subject: [PATCH 1/2] fix: enhance ProxySetHandlerTargetCheck to prevent infinite recursion with WeakSet --- userscript/source/index.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/userscript/source/index.ts b/userscript/source/index.ts index 1ea1e53..1d631d8 100644 --- a/userscript/source/index.ts +++ b/userscript/source/index.ts @@ -285,7 +285,15 @@ export function RunNamuLinkUserscript(BrowserWindow: typeof window, UserscriptNa return Stringified.includes('https://ader.naver.com/') } - function ProxySetHandlerTargetCheck(Target: object): boolean { + function ProxySetHandlerTargetCheck( + Target: object, + Visited = new WeakSet() + ): boolean { + if (Visited.has(Target)) { + return false + } + Visited.add(Target) + for (const PropertyName of Object.keys(Target)) { const Value = (Target as Record)[PropertyName] const Descriptor = OriginalObjectGetOwnPropertyDescriptor(Target, PropertyName) @@ -295,7 +303,7 @@ export function RunNamuLinkUserscript(BrowserWindow: typeof window, UserscriptNa Value !== null && typeof Descriptor?.get !== 'function' ) { - if (ProxySetHandlerTargetCheck(Value)) { + if (ProxySetHandlerTargetCheck(Value, Visited)) { return true } } else if ( From 7016584c14f07e9d2cf3fb89d71c4913136e20b1 Mon Sep 17 00:00:00 2001 From: piquark6046 Date: Mon, 23 Mar 2026 06:46:28 +0000 Subject: [PATCH 2/2] fix: remove `ProxySetHandlerTargetCheckAndReplace` --- userscript/source/index.ts | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/userscript/source/index.ts b/userscript/source/index.ts index 1d631d8..14ae5b4 100644 --- a/userscript/source/index.ts +++ b/userscript/source/index.ts @@ -317,33 +317,6 @@ export function RunNamuLinkUserscript(BrowserWindow: typeof window, UserscriptNa return false } - function ProxySetHandlerTargetCheckAndReplace(Target: object, NewValue: string): boolean { - const Record = Target as Record - - for (const PropertyName of Object.keys(Record)) { - const Value = Record[PropertyName] - const Descriptor = OriginalObjectGetOwnPropertyDescriptor(Target, PropertyName) - - if ( - typeof Value === 'object' && - Value !== null && - typeof Descriptor?.get !== 'function' - ) { - if (ProxySetHandlerTargetCheckAndReplace(Value, NewValue)) { - return true - } - } else if ( - typeof Value === 'string' && - Value.includes('ader.naver.com') - ) { - Record[PropertyName] = NewValue - return true - } - } - - return false - } - function MatchesShape(Schema: unknown, Target: unknown): boolean { if (Schema === null || Target === null) { return Schema === Target @@ -446,9 +419,6 @@ export function RunNamuLinkUserscript(BrowserWindow: typeof window, UserscriptNa BrowserWindow.document.dispatchEvent(new CustomEvent('PL2PlaceHolderProxy')) return } - else if (ProxySetHandlerTargetCheckAndReplace(SetArgs[0], '')) { - console.debug(`[${UserscriptName}]: Proxy set called for PowerLink Skeleton (target check and replace):`, SetArgs) - } return OriginalReflectApply(OriginalSet, this, SetArgs) } }