mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-07 12:07:11 +03:00
Add keybind for previewing a segment
This commit is contained in:
Submodule public/_locales updated: 7f2d4e63dc...baf39106e0
@@ -448,6 +448,11 @@
|
|||||||
<div class="inline"></div>
|
<div class="inline"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div data-type="keybind-change" data-sync="previewKeybind">
|
||||||
|
<label class="optionLabel">__MSG_setPreviewKeybind__:</label>
|
||||||
|
<div class="inline"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div data-type="keybind-change" data-sync="actuallySubmitKeybind">
|
<div data-type="keybind-change" data-sync="actuallySubmitKeybind">
|
||||||
<label class="optionLabel">__MSG_setSubmitKeybind__:</label>
|
<label class="optionLabel">__MSG_setSubmitKeybind__:</label>
|
||||||
<div class="inline"></div>
|
<div class="inline"></div>
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import SelectorComponent, { SelectorOption } from "./SelectorComponent";
|
|||||||
import { DEFAULT_CATEGORY } from "../utils/categoryUtils";
|
import { DEFAULT_CATEGORY } from "../utils/categoryUtils";
|
||||||
import { getFormattedTime, getFormattedTimeToSeconds } from "../../maze-utils/src/formating";
|
import { getFormattedTime, getFormattedTimeToSeconds } from "../../maze-utils/src/formating";
|
||||||
import { asyncRequestToServer } from "../utils/requests";
|
import { asyncRequestToServer } from "../utils/requests";
|
||||||
|
import { defaultPreviewTime } from "../utils/constants";
|
||||||
|
|
||||||
export interface SponsorTimeEditProps {
|
export interface SponsorTimeEditProps {
|
||||||
index: number;
|
index: number;
|
||||||
@@ -671,7 +672,7 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
|
|||||||
previewTime(ctrlPressed = false, shiftPressed = false, skipToEndTime = false): void {
|
previewTime(ctrlPressed = false, shiftPressed = false, skipToEndTime = false): void {
|
||||||
const sponsorTimes = this.props.contentContainer().sponsorTimesSubmitting;
|
const sponsorTimes = this.props.contentContainer().sponsorTimesSubmitting;
|
||||||
const index = this.props.index;
|
const index = this.props.index;
|
||||||
let seekTime = 2;
|
let seekTime = defaultPreviewTime;
|
||||||
if (ctrlPressed) seekTime = 0.5;
|
if (ctrlPressed) seekTime = 0.5;
|
||||||
if (shiftPressed) seekTime = 0.25;
|
if (shiftPressed) seekTime = 0.25;
|
||||||
|
|
||||||
|
|||||||
@@ -82,13 +82,17 @@ class SubmissionNoticeComponent extends React.Component<SubmissionNoticeProps, S
|
|||||||
if (currentSegmentCount > this.lastSegmentCount) {
|
if (currentSegmentCount > this.lastSegmentCount) {
|
||||||
this.lastSegmentCount = currentSegmentCount;
|
this.lastSegmentCount = currentSegmentCount;
|
||||||
|
|
||||||
const scrollElement = this.noticeRef.current.getElement().current.querySelector("#sponsorSkipNoticeMiddleRowSubmissionNotice");
|
this.scrollToBottom();
|
||||||
scrollElement.scrollTo({
|
|
||||||
top: scrollElement.scrollHeight + 1000
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scrollToBottom() {
|
||||||
|
const scrollElement = this.noticeRef.current.getElement().current.querySelector("#sponsorSkipNoticeMiddleRowSubmissionNotice");
|
||||||
|
scrollElement.scrollTo({
|
||||||
|
top: scrollElement.scrollHeight + 1000
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
render(): React.ReactElement {
|
render(): React.ReactElement {
|
||||||
const sortButton =
|
const sortButton =
|
||||||
<img id={"sponsorSkipSortButton" + this.state.idSuffix}
|
<img id={"sponsorSkipSortButton" + this.state.idSuffix}
|
||||||
|
|||||||
@@ -144,6 +144,7 @@ class KeybindDialogComponent extends React.Component<KeybindDialogProps, Keybind
|
|||||||
if (this.props.option !== "skipKeybind" && this.equals(Config.config['skipKeybind']) ||
|
if (this.props.option !== "skipKeybind" && this.equals(Config.config['skipKeybind']) ||
|
||||||
this.props.option !== "submitKeybind" && this.equals(Config.config['submitKeybind']) ||
|
this.props.option !== "submitKeybind" && this.equals(Config.config['submitKeybind']) ||
|
||||||
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 !== "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']))
|
||||||
return {message: chrome.i18n.getMessage("keyAlreadyUsed"), blocking: true};
|
return {message: chrome.i18n.getMessage("keyAlreadyUsed"), blocking: true};
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ interface SBConfig {
|
|||||||
startSponsorKeybind: Keybind;
|
startSponsorKeybind: Keybind;
|
||||||
submitKeybind: Keybind;
|
submitKeybind: Keybind;
|
||||||
actuallySubmitKeybind: Keybind;
|
actuallySubmitKeybind: Keybind;
|
||||||
|
previewKeybind: Keybind;
|
||||||
nextChapterKeybind: Keybind;
|
nextChapterKeybind: Keybind;
|
||||||
previousChapterKeybind: Keybind;
|
previousChapterKeybind: Keybind;
|
||||||
closeSkipNoticeKeybind: Keybind;
|
closeSkipNoticeKeybind: Keybind;
|
||||||
@@ -347,6 +348,7 @@ const syncDefaults = {
|
|||||||
startSponsorKeybind: { key: ";" },
|
startSponsorKeybind: { key: ";" },
|
||||||
submitKeybind: { key: "'" },
|
submitKeybind: { key: "'" },
|
||||||
actuallySubmitKeybind: { key: "'", ctrl: true },
|
actuallySubmitKeybind: { key: "'", ctrl: true },
|
||||||
|
previewKeybind: { key: ";", ctrl: true },
|
||||||
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" },
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ import { addCleanupListener } from "../maze-utils/src/cleanup";
|
|||||||
import { hideDeArrowPromotion, tryShowingDeArrowPromotion } from "./dearrowPromotion";
|
import { hideDeArrowPromotion, tryShowingDeArrowPromotion } from "./dearrowPromotion";
|
||||||
import { asyncRequestToServer } from "./utils/requests";
|
import { asyncRequestToServer } from "./utils/requests";
|
||||||
import { isMobileControlsOpen } from "./utils/mobileUtils";
|
import { isMobileControlsOpen } from "./utils/mobileUtils";
|
||||||
|
import { defaultPreviewTime } from "./utils/constants";
|
||||||
|
|
||||||
cleanPage();
|
cleanPage();
|
||||||
|
|
||||||
@@ -2230,7 +2231,16 @@ function openSubmissionMenu() {
|
|||||||
if (sponsorTimesSubmitting !== undefined && sponsorTimesSubmitting.length > 0) {
|
if (sponsorTimesSubmitting !== undefined && sponsorTimesSubmitting.length > 0) {
|
||||||
submissionNotice = new SubmissionNotice(skipNoticeContentContainer, sendSubmitMessage);
|
submissionNotice = new SubmissionNotice(skipNoticeContentContainer, sendSubmitMessage);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function previewRecentSegment() {
|
||||||
|
if (sponsorTimesSubmitting !== undefined && sponsorTimesSubmitting.length > 0) {
|
||||||
|
previewTime(sponsorTimesSubmitting[sponsorTimesSubmitting.length - 1].segment[0] - defaultPreviewTime);
|
||||||
|
|
||||||
|
if (submissionNotice) {
|
||||||
|
submissionNotice.scrollToBottom();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function submitSegments() {
|
function submitSegments() {
|
||||||
@@ -2444,6 +2454,7 @@ function hotkeyListener(e: KeyboardEvent): void {
|
|||||||
const closeSkipNoticeKey = Config.config.closeSkipNoticeKeybind;
|
const closeSkipNoticeKey = Config.config.closeSkipNoticeKeybind;
|
||||||
const startSponsorKey = Config.config.startSponsorKeybind;
|
const startSponsorKey = Config.config.startSponsorKeybind;
|
||||||
const submitKey = Config.config.actuallySubmitKeybind;
|
const submitKey = Config.config.actuallySubmitKeybind;
|
||||||
|
const previewKey = Config.config.previewKeybind;
|
||||||
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;
|
||||||
@@ -2475,6 +2486,9 @@ function hotkeyListener(e: KeyboardEvent): void {
|
|||||||
} else if (keybindEquals(key, openSubmissionMenuKey)) {
|
} else if (keybindEquals(key, openSubmissionMenuKey)) {
|
||||||
openSubmissionMenu();
|
openSubmissionMenu();
|
||||||
return;
|
return;
|
||||||
|
} else if (keybindEquals(key, previewKey)) {
|
||||||
|
previewRecentSegment();
|
||||||
|
return;
|
||||||
} else if (keybindEquals(key, nextChapterKey)) {
|
} else if (keybindEquals(key, nextChapterKey)) {
|
||||||
if (sponsorTimes.length > 0) e.stopPropagation();
|
if (sponsorTimes.length > 0) e.stopPropagation();
|
||||||
nextChapter();
|
nextChapter();
|
||||||
|
|||||||
@@ -56,6 +56,10 @@ class SubmissionNotice {
|
|||||||
submit(): void {
|
submit(): void {
|
||||||
this.noticeRef.current?.submit?.();
|
this.noticeRef.current?.submit?.();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scrollToBottom(): void {
|
||||||
|
this.noticeRef.current?.scrollToBottom?.();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default SubmissionNotice;
|
export default SubmissionNotice;
|
||||||
@@ -157,4 +157,6 @@ export function getGuidelineInfo(category: Category): TextBox[] {
|
|||||||
text: chrome.i18n.getMessage(`generic_guideline2`)
|
text: chrome.i18n.getMessage(`generic_guideline2`)
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const defaultPreviewTime = 2;
|
||||||
Reference in New Issue
Block a user