Skip to content

Commit bfb3c1f

Browse files
committed
fix: add MatchPL2TrackingString function to enhance tracking string checks in ProxySetHandler
1 parent 0f3ecfd commit bfb3c1f

1 file changed

Lines changed: 28 additions & 2 deletions

File tree

userscript/source/index.ts

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,35 @@ export function RunNamuLinkUserscript(BrowserWindow: typeof window, UserscriptNa
280280
return 3
281281
}
282282

283+
function MatchPL2TrackingString(Value: string): boolean {
284+
const HotkeyArray: {
285+
Key: 'StartWith' | 'Includes' | 'EndsWith',
286+
String: string
287+
}[] = [{
288+
Key: 'Includes',
289+
String: '//ader.naver.com/'
290+
}, {
291+
Key: 'Includes',
292+
String: '//ader.naver.com/'
293+
}, {
294+
Key: 'StartWith',
295+
String: '!/jump/'
296+
}]
297+
return HotkeyArray.some(Hotkey => {
298+
switch (Hotkey.Key) {
299+
case 'StartWith':
300+
return Value.startsWith(Hotkey.String)
301+
case 'Includes':
302+
return Value.includes(Hotkey.String)
303+
case 'EndsWith':
304+
return Value.endsWith(Hotkey.String)
305+
}
306+
})
307+
}
308+
283309
function ProxySetHandlerNewValueCheck(NewValue: Parameters<ProxyHandler<object>['set']>[2]): boolean {
284310
let Stringified: string = String(NewValue)
285-
return Stringified.includes('https://ader.naver.com/')
311+
return MatchPL2TrackingString(Stringified)
286312
}
287313

288314
function ProxySetHandlerTargetCheck(
@@ -308,7 +334,7 @@ export function RunNamuLinkUserscript(BrowserWindow: typeof window, UserscriptNa
308334
}
309335
} else if (
310336
typeof Value === 'string' &&
311-
Value.includes('ader.naver.com')
337+
MatchPL2TrackingString(Value)
312338
) {
313339
return true
314340
}

0 commit comments

Comments
 (0)