mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-08 20:47:11 +03:00
Add keybind for submitting instead of just using the submission menu
This commit is contained in:
Submodule public/_locales updated: b5f7f0089b...01bf91daef
@@ -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>
|
||||
|
||||
@@ -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};
|
||||
|
||||
|
||||
@@ -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 },
|
||||
|
||||
|
||||
@@ -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() {
|
||||
if (submissionNotice !== null){
|
||||
submissionNotice.close();
|
||||
function closeSubmissionMenu() {
|
||||
submissionNotice?.close();
|
||||
submissionNotice = null;
|
||||
}
|
||||
|
||||
function openSubmissionMenu() {
|
||||
if (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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,6 +52,10 @@ class SubmissionNotice {
|
||||
|
||||
this.noticeElement.remove();
|
||||
}
|
||||
|
||||
submit(): void {
|
||||
this.noticeRef.current?.submit?.();
|
||||
}
|
||||
}
|
||||
|
||||
export default SubmissionNotice;
|
||||
Reference in New Issue
Block a user