diff options
author | Ajay <[email protected]> | 2023-12-22 11:41:35 -0500 |
---|---|---|
committer | Ajay <[email protected]> | 2023-12-22 11:41:35 -0500 |
commit | 157216148c4d57a8dd19c3556f4343741b7f5534 (patch) | |
tree | 8aee6f55c0911660ae1b4eb18a7a1bef8612519c | |
parent | 5ac19eecd4f13a08e7064d781f83cbdb7a53d3d5 (diff) | |
download | SponsorBlock-157216148c4d57a8dd19c3556f4343741b7f5534.tar.gz SponsorBlock-157216148c4d57a8dd19c3556f4343741b7f5534.zip |
Add keybind for submitting instead of just using the submission menu
m--------- | public/_locales | 0 | ||||
-rw-r--r-- | public/options/options.html | 5 | ||||
-rw-r--r-- | src/components/options/KeybindDialogComponent.tsx | 1 | ||||
-rw-r--r-- | src/config.ts | 2 | ||||
-rw-r--r-- | src/content.ts | 35 | ||||
-rw-r--r-- | src/render/SubmissionNotice.tsx | 4 |
6 files changed, 38 insertions, 9 deletions
diff --git a/public/_locales b/public/_locales -Subproject b5f7f0089b0971d7f226edf0044d3cb85840789 +Subproject 01bf91daef4ed4d3f9ed02096b8186799dc7373 diff --git a/public/options/options.html b/public/options/options.html index 52a58123..5a9c78e1 100644 --- a/public/options/options.html +++ b/public/options/options.html @@ -439,6 +439,11 @@ </div> <div data-type="keybind-change" data-sync="submitKeybind"> + <label class="optionLabel">__MSG_setOpenSubmissionMenuKeybind__:</label> + <div class="inline"></div> + </div> + + <div data-type="keybind-change" data-sync="actuallySubmitKeybind"> <label class="optionLabel">__MSG_setSubmitKeybind__:</label> <div class="inline"></div> </div> diff --git a/src/components/options/KeybindDialogComponent.tsx b/src/components/options/KeybindDialogComponent.tsx index 057a3b05..f67c82b5 100644 --- a/src/components/options/KeybindDialogComponent.tsx +++ b/src/components/options/KeybindDialogComponent.tsx @@ -143,6 +143,7 @@ class KeybindDialogComponent extends React.Component<KeybindDialogProps, Keybind if (this.props.option != "skipKeybind" && this.equals(Config.config['skipKeybind']) || this.props.option != "submitKeybind" && this.equals(Config.config['submitKeybind']) || + this.props.option !== "actuallySubmitKeybind" && this.equals(Config.config['actuallySubmitKeybind']) || this.props.option != "startSponsorKeybind" && this.equals(Config.config['startSponsorKeybind'])) return {message: chrome.i18n.getMessage("keyAlreadyUsed"), blocking: true}; diff --git a/src/config.ts b/src/config.ts index 09a3ebfb..69b3382a 100644 --- a/src/config.ts +++ b/src/config.ts @@ -92,6 +92,7 @@ interface SBConfig { skipToHighlightKeybind: Keybind; startSponsorKeybind: Keybind; submitKeybind: Keybind; + actuallySubmitKeybind: Keybind; nextChapterKeybind: Keybind; previousChapterKeybind: Keybind; @@ -341,6 +342,7 @@ const syncDefaults = { skipToHighlightKeybind: { key: "Enter", ctrl: true }, startSponsorKeybind: { key: ";" }, submitKeybind: { key: "'" }, + actuallySubmitKeybind: { key: "'", ctrl: true }, nextChapterKeybind: { key: "ArrowRight", ctrl: true }, previousChapterKeybind: { key: "ArrowLeft", ctrl: true }, diff --git a/src/content.ts b/src/content.ts index 8323b833..1c6fbb88 100644 --- a/src/content.ts +++ b/src/content.ts @@ -251,7 +251,7 @@ function messageListener(request: Message, sender: unknown, sendResponse: (respo break; case "submitTimes": - submitSponsorTimes(); + openSubmissionMenu(); break; case "refreshSegments": // update video on refresh if videoID invalid @@ -312,7 +312,7 @@ function messageListener(request: Message, sender: unknown, sendResponse: (respo updateEditButtonsOnPlayer(); updateSponsorTimesSubmitting(false); - submitSponsorTimes(); + openSubmissionMenu(); } sendResponse({ @@ -1816,7 +1816,7 @@ async function createButtons(): Promise<void> { createButton("startSegment", "sponsorStart", () => startOrEndTimingNewSegment(), "PlayerStartIconSponsorBlocker.svg"); createButton("cancelSegment", "sponsorCancel", () => cancelCreatingSegment(), "PlayerCancelSegmentIconSponsorBlocker.svg"); createButton("delete", "clearTimes", () => clearSponsorTimes(), "PlayerDeleteIconSponsorBlocker.svg"); - createButton("submit", "OpenSubmissionMenu", () => submitSponsorTimes(), "PlayerUploadIconSponsorBlocker.svg"); + createButton("submit", "OpenSubmissionMenu", () => openSubmissionMenu(), "PlayerUploadIconSponsorBlocker.svg"); createButton("info", "openPopup", () => openInfoMenu(), "PlayerInfoIconSponsorBlocker.svg"); const controlsContainer = getControls(); @@ -2227,10 +2227,14 @@ function resetSponsorSubmissionNotice(callRef = true) { submissionNotice = null; } -function submitSponsorTimes() { +function closeSubmissionMenu() { + submissionNotice?.close(); + submissionNotice = null; +} + +function openSubmissionMenu() { if (submissionNotice !== null){ - submissionNotice.close(); - submissionNotice = null; + closeSubmissionMenu(); return; } @@ -2240,6 +2244,15 @@ function submitSponsorTimes() { } +function submitSegments() { + if (sponsorTimesSubmitting !== undefined + && sponsorTimesSubmitting.length > 0 + && submissionNotice !== null) { + submissionNotice.submit(); + } + +} + //send the message to the background js //called after all the checks have been made that it's okay to do so async function sendSubmitMessage() { @@ -2446,7 +2459,8 @@ 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 submitKey = Config.config.actuallySubmitKeybind; + const openSubmissionMenuKey = Config.config.submitKeybind; const nextChapterKey = Config.config.nextChapterKeybind; const previousChapterKey = Config.config.previousChapterKeybind; @@ -2466,7 +2480,10 @@ function hotkeyListener(e: KeyboardEvent): void { startOrEndTimingNewSegment(); return; } else if (keybindEquals(key, submitKey)) { - submitSponsorTimes(); + submitSegments(); + return; + } else if (keybindEquals(key, openSubmissionMenuKey)) { + openSubmissionMenu(); return; } else if (keybindEquals(key, nextChapterKey)) { if (sponsorTimes.length > 0) e.stopPropagation(); @@ -2485,7 +2502,7 @@ function hotkeyListener(e: KeyboardEvent): void { } else if (key.key == startSponsorKey?.key && startSponsorKey.code == null && !keybindEquals(Config.syncDefaults.startSponsorKeybind, startSponsorKey)) { startOrEndTimingNewSegment(); } else if (key.key == submitKey?.key && submitKey.code == null && !keybindEquals(Config.syncDefaults.submitKeybind, submitKey)) { - submitSponsorTimes(); + openSubmissionMenu(); } } diff --git a/src/render/SubmissionNotice.tsx b/src/render/SubmissionNotice.tsx index 295d8e2b..671dde6b 100644 --- a/src/render/SubmissionNotice.tsx +++ b/src/render/SubmissionNotice.tsx @@ -52,6 +52,10 @@ class SubmissionNotice { this.noticeElement.remove(); } + + submit(): void { + this.noticeRef.current?.submit?.(); + } } export default SubmissionNotice;
\ No newline at end of file |