From ee3ce8aa4624ed7f3d8a1f27332a3fe97685c825 Mon Sep 17 00:00:00 2001 From: Ajay Date: Sat, 23 Sep 2023 15:40:11 -0400 Subject: [PATCH] Add seperate keybind for skip to highlight Fixes #1187 --- maze-utils | 2 +- public/_locales | 2 +- public/options/options.html | 5 +++++ src/config.ts | 2 ++ src/content.ts | 11 ++++++++++- src/js-components/skipButtonControlBar.ts | 8 +++++--- 6 files changed, 24 insertions(+), 6 deletions(-) diff --git a/maze-utils b/maze-utils index 2eb140ad..a984d114 160000 --- a/maze-utils +++ b/maze-utils @@ -1 +1 @@ -Subproject commit 2eb140ad3200e58aa6b2a8e73bc8ca951a4cefb4 +Subproject commit a984d114839441953d5d4ecf5005cac9f19caaa7 diff --git a/public/_locales b/public/_locales index d1edc0e7..f85b7b92 160000 --- a/public/_locales +++ b/public/_locales @@ -1 +1 @@ -Subproject commit d1edc0e7e3533fd47a2c4d7aae79770c3a0b82fc +Subproject commit f85b7b926e33a41a47c91a5ae1d5e1415fc1ef6c diff --git a/public/options/options.html b/public/options/options.html index cc112195..e99ad571 100644 --- a/public/options/options.html +++ b/public/options/options.html @@ -414,6 +414,11 @@
+
+ +
+
+
diff --git a/src/config.ts b/src/config.ts index 61b32937..4dab0dab 100644 --- a/src/config.ts +++ b/src/config.ts @@ -86,6 +86,7 @@ interface SBConfig { }; skipKeybind: Keybind; + skipToHighlightKeybind: Keybind; startSponsorKeybind: Keybind; submitKeybind: Keybind; nextChapterKeybind: Keybind; @@ -328,6 +329,7 @@ const syncDefaults = { * TODO: Find a way to skip having to update these checks. Maybe storing keybinds in a Map? */ skipKeybind: { key: "Enter" }, + skipToHighlightKeybind: { key: "Enter", ctrl: true }, startSponsorKeybind: { key: ";" }, submitKeybind: { key: "'" }, nextChapterKeybind: { key: "ArrowRight", ctrl: true }, diff --git a/src/content.ts b/src/content.ts index 7b1c757b..6de4a9e5 100644 --- a/src/content.ts +++ b/src/content.ts @@ -2432,14 +2432,23 @@ function hotkeyListener(e: KeyboardEvent): void { }; const skipKey = Config.config.skipKeybind; + const skipToHighlightKey = Config.config.skipToHighlightKeybind; const startSponsorKey = Config.config.startSponsorKeybind; const submitKey = Config.config.submitKeybind; const nextChapterKey = Config.config.nextChapterKeybind; const previousChapterKey = Config.config.previousChapterKeybind; if (keybindEquals(key, skipKey)) { - if (activeSkipKeybindElement) + if (activeSkipKeybindElement) { activeSkipKeybindElement.toggleSkip.call(activeSkipKeybindElement); + } + + return; + } else if (keybindEquals(key, skipToHighlightKey)) { + if (skipButtonControlBar) { + skipButtonControlBar.toggleSkip.call(skipButtonControlBar); + } + return; } else if (keybindEquals(key, startSponsorKey)) { startOrEndTimingNewSegment(); diff --git a/src/js-components/skipButtonControlBar.ts b/src/js-components/skipButtonControlBar.ts index f8b2439f..2a93c49c 100644 --- a/src/js-components/skipButtonControlBar.ts +++ b/src/js-components/skipButtonControlBar.ts @@ -147,8 +147,10 @@ export class SkipButtonControlBar { } toggleSkip(): void { - this.skip(this.segment); - this.disableText(); + if (this.segment && this.enabled) { + this.skip(this.segment); + this.disableText(); + } } disableText(): void { @@ -182,7 +184,7 @@ export class SkipButtonControlBar { } private getTitle(): string { - return getSkippingText([this.segment], false) + (this.showKeybindHint ? " (" + keybindToString(Config.config.skipKeybind) + ")" : ""); + return getSkippingText([this.segment], false) + (this.showKeybindHint ? " (" + keybindToString(Config.config.skipToHighlightKeybind) + ")" : ""); } private getChapterPrefix(): HTMLElement {