make skip notice countdown customisable

This commit is contained in:
Ajay Ramachandran
2021-06-25 12:32:27 -04:00
parent 31855f7501
commit 38bc6e2b1c
5 changed files with 30 additions and 7 deletions

View File

@@ -389,7 +389,13 @@
}, },
"minDurationDescription": { "minDurationDescription": {
"message": "Segments shorter than the set value will not be skipped or show in the player." "message": "Segments shorter than the set value will not be skipped or show in the player."
}, },
"skipNoticeDuration": {
"message": "Skip notice duration (seconds):"
},
"skipNoticeDurationDescription": {
"message": "The skip notice will stay on screen for at least this long. For manual skipping, it may be visible for longer."
},
"shortCheck": { "shortCheck": {
"message": "The following submission is shorter than your minimum duration option. This could mean that this is already submitted, and just being ignored due to this option. Are you sure you would like to submit?" "message": "The following submission is shorter than your minimum duration option. This could mean that this is already submitted, and just being ignored due to this option. Are you sure you would like to submit?"
}, },

View File

@@ -152,6 +152,20 @@
</div> </div>
</div> </div>
<br/>
<br/>
<div option-type="number-change" sync-option="skipNoticeDuration">
<label class="number-container">
<input type="number" step="0.1" min="1">
</label>
<br/>
<br/>
<div class="small-description">__MSG_skipNoticeDurationDescription__</div>
</div>
<br/> <br/>
<br/> <br/>

View File

@@ -1,4 +1,5 @@
import * as React from "react"; import * as React from "react";
import Config from "../config";
export interface NoticeProps { export interface NoticeProps {
noticeTitle: string, noticeTitle: string,
@@ -42,7 +43,7 @@ class NoticeComponent extends React.Component<NoticeProps, NoticeState> {
const maxCountdownTime = () => { const maxCountdownTime = () => {
if (this.props.maxCountdownTime) return this.props.maxCountdownTime(); if (this.props.maxCountdownTime) return this.props.maxCountdownTime();
else return 4; else return Config.config.skipNoticeDuration;
}; };
//the id for the setInterval running the countdown //the id for the setInterval running the countdown

View File

@@ -98,8 +98,8 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
messageOnClick: null, messageOnClick: null,
//the countdown until this notice closes //the countdown until this notice closes
maxCountdownTime: () => 4, maxCountdownTime: () => Config.config.skipNoticeDuration,
countdownTime: 4, countdownTime: Config.config.skipNoticeDuration,
countdownText: null, countdownText: null,
unskipText: chrome.i18n.getMessage("unskip"), unskipText: chrome.i18n.getMessage("unskip"),
@@ -418,7 +418,7 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
const sponsorTime = this.segments[index]; const sponsorTime = this.segments[index];
const duration = Math.round((sponsorTime.segment[1] - this.contentContainer().v.currentTime) * (1 / this.contentContainer().v.playbackRate)); const duration = Math.round((sponsorTime.segment[1] - this.contentContainer().v.currentTime) * (1 / this.contentContainer().v.playbackRate));
return Math.max(duration, 4); return Math.max(duration, Config.config.skipNoticeDuration);
}; };
return { return {
@@ -437,8 +437,8 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
unskipText: chrome.i18n.getMessage("unskip"), unskipText: chrome.i18n.getMessage("unskip"),
unskipCallback: this.unskip.bind(this), unskipCallback: this.unskip.bind(this),
maxCountdownTime: () => 4, maxCountdownTime: () => Config.config.skipNoticeDuration,
countdownTime: 4 countdownTime: Config.config.skipNoticeDuration
}; };
// See if the title should be changed // See if the title should be changed

View File

@@ -33,6 +33,7 @@ interface SBConfig {
supportInvidious: boolean, supportInvidious: boolean,
serverAddress: string, serverAddress: string,
minDuration: number, minDuration: number,
skipNoticeDuration: number,
audioNotificationOnSkip, audioNotificationOnSkip,
checkForUnlistedVideos: boolean, checkForUnlistedVideos: boolean,
testingServer: boolean, testingServer: boolean,
@@ -171,6 +172,7 @@ const Config: SBObject = {
supportInvidious: false, supportInvidious: false,
serverAddress: CompileConfig.serverAddress, serverAddress: CompileConfig.serverAddress,
minDuration: 0, minDuration: 0,
skipNoticeDuration: 4,
audioNotificationOnSkip: false, audioNotificationOnSkip: false,
checkForUnlistedVideos: false, checkForUnlistedVideos: false,
testingServer: false, testingServer: false,