mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-07 20:17:05 +03:00
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:
@@ -472,6 +472,16 @@
|
||||
<div class="inline"></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 id="import" class="option-group hidden">
|
||||
|
||||
@@ -146,7 +146,9 @@ class KeybindDialogComponent extends React.Component<KeybindDialogProps, Keybind
|
||||
this.props.option !== "actuallySubmitKeybind" && this.equals(Config.config['actuallySubmitKeybind']) ||
|
||||
this.props.option !== "previewKeybind" && this.equals(Config.config['previewKeybind']) ||
|
||||
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 null;
|
||||
|
||||
@@ -97,6 +97,8 @@ interface SBConfig {
|
||||
nextChapterKeybind: Keybind;
|
||||
previousChapterKeybind: Keybind;
|
||||
closeSkipNoticeKeybind: Keybind;
|
||||
upvoteKeybind: Keybind;
|
||||
downvoteKeybind: Keybind;
|
||||
|
||||
// What categories should be skipped
|
||||
categorySelections: CategorySelection[];
|
||||
@@ -356,6 +358,8 @@ const syncDefaults = {
|
||||
nextChapterKeybind: { key: "ArrowRight", ctrl: true },
|
||||
previousChapterKeybind: { key: "ArrowLeft", ctrl: true },
|
||||
closeSkipNoticeKeybind: { key: "Backspace" },
|
||||
downvoteKeybind: { key: "h" },
|
||||
upvoteKeybind: { key: "g" },
|
||||
|
||||
categorySelections: [{
|
||||
name: "sponsor" as Category,
|
||||
|
||||
@@ -2575,6 +2575,8 @@ function hotkeyListener(e: KeyboardEvent): void {
|
||||
const openSubmissionMenuKey = Config.config.submitKeybind;
|
||||
const nextChapterKey = Config.config.nextChapterKeybind;
|
||||
const previousChapterKey = Config.config.previousChapterKeybind;
|
||||
const upvoteKey = Config.config.upvoteKeybind;
|
||||
const downvoteKey = Config.config.downvoteKeybind;
|
||||
|
||||
if (keybindEquals(key, skipKey)) {
|
||||
if (activeSkipKeybindElement) {
|
||||
@@ -2618,6 +2620,14 @@ function hotkeyListener(e: KeyboardEvent): void {
|
||||
if (sponsorTimes.length > 0) e.stopPropagation();
|
||||
previousChapter();
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user