Skip to content

Commit 1514fd3

Browse files
committed
fix: enhance hotkey handling and add new event dispatches for PowerLink Skeleton
1 parent bfb3c1f commit 1514fd3

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

userscript/source/index.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,9 @@ export function RunNamuLinkUserscript(BrowserWindow: typeof window, UserscriptNa
293293
}, {
294294
Key: 'StartWith',
295295
String: '!/jump/'
296+
}, {
297+
Key: 'StartWith',
298+
String: '//i.namu.wiki/i/'
296299
}]
297300
return HotkeyArray.some(Hotkey => {
298301
switch (Hotkey.Key) {
@@ -350,9 +353,11 @@ export function RunNamuLinkUserscript(BrowserWindow: typeof window, UserscriptNa
350353

351354
if (Array.isArray(Schema)) {
352355
if (!Array.isArray(Target)) return false
353-
if (Schema.length === 0) return true
356+
if (Schema.length !== Target.length) return false
354357

355-
return Target.every(Item => MatchesShape(Schema[0], Item))
358+
return Schema.every((SchemaItem, Index) =>
359+
MatchesShape(SchemaItem, Target[Index])
360+
)
356361
}
357362

358363
if (typeof Schema === 'object') {
@@ -423,26 +428,22 @@ export function RunNamuLinkUserscript(BrowserWindow: typeof window, UserscriptNa
423428
}
424429
if (ProxySetHandlerTargetCheck(SetArgs[0]) && MatchesShape({
425430
Dummy: [],
426-
PowerLinkTracking: [
427-
{
428-
Url: '',
429-
UrlObj: {
430-
Url: ''
431-
}
432-
}
433-
],
431+
Dummy2: [],
434432
LayoutFormat: '',
435433
NumberKey: [0, 0, 0],
436434
PowerLinkText: [
437435
{
438436
Url: '',
439437
Title: '',
440-
No: 0
438+
No: 0,
439+
VSkip: true
441440
}
442441
]
443442
}, SetArgs[0])) {
444443
console.debug(`[${UserscriptName}]: Proxy set called for PowerLink Skeleton (target check):`, SetArgs)
445444
BrowserWindow.document.dispatchEvent(new CustomEvent('PL2PlaceHolderProxy'))
445+
BrowserWindow.document.dispatchEvent(new CustomEvent('PL2PlaceHolderMobile'))
446+
BrowserWindow.document.dispatchEvent(new CustomEvent('PL2PlaceHolder'))
446447
return
447448
}
448449
return OriginalReflectApply(OriginalSet, this, SetArgs)

0 commit comments

Comments
 (0)