Added keybinds to vote on the last segment

Added keybinds to vote on the last segment

fixed Upvote/Downvote keybind message variable names to match others in that options section
This commit is contained in:
gosha305
2025-02-10 01:28:22 +01:00
parent 19efcb5a98
commit c9c02e91ff
4 changed files with 27 additions and 1 deletions

View File

@@ -472,6 +472,16 @@
<div class="inline"></div> <div class="inline"></div>
</div> </div>
<div data-type="keybind-change" data-sync="upvoteKeybind">
<label class="optionLabel">__MSG_setUpvoteKeybind__:</label>
<div class="inline"></div>
</div>
<div data-type="keybind-change" data-sync="downvoteKeybind">
<label class="optionLabel">__MSG_setDownvoteKeybind__:</label>
<div class="inline"></div>
</div>
</div> </div>
<div id="import" class="option-group hidden"> <div id="import" class="option-group hidden">

View File

@@ -146,7 +146,9 @@ class KeybindDialogComponent extends React.Component<KeybindDialogProps, Keybind
this.props.option !== "actuallySubmitKeybind" && this.equals(Config.config['actuallySubmitKeybind']) || this.props.option !== "actuallySubmitKeybind" && this.equals(Config.config['actuallySubmitKeybind']) ||
this.props.option !== "previewKeybind" && this.equals(Config.config['previewKeybind']) || this.props.option !== "previewKeybind" && this.equals(Config.config['previewKeybind']) ||
this.props.option !== "closeSkipNoticeKeybind" && this.equals(Config.config['closeSkipNoticeKeybind']) || this.props.option !== "closeSkipNoticeKeybind" && this.equals(Config.config['closeSkipNoticeKeybind']) ||
this.props.option !== "startSponsorKeybind" && this.equals(Config.config['startSponsorKeybind'])) this.props.option !== "startSponsorKeybind" && this.equals(Config.config['startSponsorKeybind']) ||
this.props.option !== "downvoteKeybind" && this.equals(Config.config['downvoteKeybind']) ||
this.props.option !== "upvoteKeybind" && this.equals(Config.config['upvoteKeybind']))
return {message: chrome.i18n.getMessage("keyAlreadyUsed"), blocking: true}; return {message: chrome.i18n.getMessage("keyAlreadyUsed"), blocking: true};
return null; return null;

View File

@@ -97,6 +97,8 @@ interface SBConfig {
nextChapterKeybind: Keybind; nextChapterKeybind: Keybind;
previousChapterKeybind: Keybind; previousChapterKeybind: Keybind;
closeSkipNoticeKeybind: Keybind; closeSkipNoticeKeybind: Keybind;
upvoteKeybind: Keybind;
downvoteKeybind: Keybind;
// What categories should be skipped // What categories should be skipped
categorySelections: CategorySelection[]; categorySelections: CategorySelection[];
@@ -356,6 +358,8 @@ const syncDefaults = {
nextChapterKeybind: { key: "ArrowRight", ctrl: true }, nextChapterKeybind: { key: "ArrowRight", ctrl: true },
previousChapterKeybind: { key: "ArrowLeft", ctrl: true }, previousChapterKeybind: { key: "ArrowLeft", ctrl: true },
closeSkipNoticeKeybind: { key: "Backspace" }, closeSkipNoticeKeybind: { key: "Backspace" },
downvoteKeybind: { key: "h" },
upvoteKeybind: { key: "g" },
categorySelections: [{ categorySelections: [{
name: "sponsor" as Category, name: "sponsor" as Category,

View File

@@ -2575,6 +2575,8 @@ function hotkeyListener(e: KeyboardEvent): void {
const openSubmissionMenuKey = Config.config.submitKeybind; const openSubmissionMenuKey = Config.config.submitKeybind;
const nextChapterKey = Config.config.nextChapterKeybind; const nextChapterKey = Config.config.nextChapterKeybind;
const previousChapterKey = Config.config.previousChapterKeybind; const previousChapterKey = Config.config.previousChapterKeybind;
const upvoteKey = Config.config.upvoteKeybind;
const downvoteKey = Config.config.downvoteKeybind;
if (keybindEquals(key, skipKey)) { if (keybindEquals(key, skipKey)) {
if (activeSkipKeybindElement) { if (activeSkipKeybindElement) {
@@ -2618,6 +2620,14 @@ function hotkeyListener(e: KeyboardEvent): void {
if (sponsorTimes.length > 0) e.stopPropagation(); if (sponsorTimes.length > 0) e.stopPropagation();
previousChapter(); previousChapter();
return; return;
} else if (keybindEquals(key, upvoteKey)) {
const lastSegment = [...sponsorTimes].reverse()?.find((s) => s.segment[0]<=getCurrentTime());
if (lastSegment) vote(1,lastSegment.UUID, undefined, skipNotices?.find((skipNotice) => skipNotice.segments.some((segment) => segment.UUID === lastSegment.UUID))?.skipNoticeRef.current);
return;
} else if (keybindEquals(key, downvoteKey)) {
const lastSegment = [...sponsorTimes].reverse()?.find((s) => s.segment[0]<=getCurrentTime());
if (lastSegment) vote(0,lastSegment.UUID, undefined, skipNotices?.find((skipNotice) => skipNotice.segments.some((segment) => segment.UUID === lastSegment.UUID))?.skipNoticeRef.current);
return;
} }
} }