diff options
author | Ajay <[email protected]> | 2023-09-23 15:40:11 -0400 |
---|---|---|
committer | Ajay <[email protected]> | 2023-09-23 15:40:11 -0400 |
commit | ee3ce8aa4624ed7f3d8a1f27332a3fe97685c825 (patch) | |
tree | b63c123f6ef15aeba066b50f312cf25475695da6 | |
parent | 1557af5d2abc97cffaa2f1b4c703ba26f0b8e94d (diff) | |
download | SponsorBlock-ee3ce8aa4624ed7f3d8a1f27332a3fe97685c825.tar.gz SponsorBlock-ee3ce8aa4624ed7f3d8a1f27332a3fe97685c825.zip |
Add seperate keybind for skip to highlight
Fixes #1187
m--------- | maze-utils | 0 | ||||
m--------- | public/_locales | 0 | ||||
-rw-r--r-- | public/options/options.html | 5 | ||||
-rw-r--r-- | src/config.ts | 2 | ||||
-rw-r--r-- | src/content.ts | 11 | ||||
-rw-r--r-- | src/js-components/skipButtonControlBar.ts | 8 |
6 files changed, 22 insertions, 4 deletions
diff --git a/maze-utils b/maze-utils -Subproject 2eb140ad3200e58aa6b2a8e73bc8ca951a4cefb +Subproject a984d114839441953d5d4ecf5005cac9f19caaa diff --git a/public/_locales b/public/_locales -Subproject d1edc0e7e3533fd47a2c4d7aae79770c3a0b82f +Subproject f85b7b926e33a41a47c91a5ae1d5e1415fc1ef6 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 @@ <div class="inline"></div> </div> + <div data-type="keybind-change" data-sync="skipToHighlightKeybind"> + <label class="optionLabel">__MSG_setSkipToHighlightShortcut__:</label> + <div class="inline"></div> + </div> + <div data-type="keybind-change" data-sync="startSponsorKeybind"> <label class="optionLabel">__MSG_setStartSponsorShortcut__:</label> <div class="inline"></div> 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 { |