Skip to content

Commit

Permalink
Merge pull request #84 from etherfun/master
Browse files Browse the repository at this point in the history
Add Feature  : Advance notice skip
  • Loading branch information
hanydd authored Dec 2, 2024
2 parents 1b1acfc + 493bd70 commit 0b8fb76
Show file tree
Hide file tree
Showing 10 changed files with 268 additions and 73 deletions.
23 changes: 20 additions & 3 deletions public/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@
"message": "重新显示空降提醒"
},
"showSkipNotice": {
"message": "在跳过片段后显示提醒弹窗"
"message": "跳过片段时显示提醒弹窗"
},
"showCategoryGuidelines": {
"message": "显示类别说明"
Expand Down Expand Up @@ -367,6 +367,14 @@
"message": "要跳到 {0} 吗?",
"description": "Used for skipping to things (Skip to Highlight)"
},
"autoSkipped": {
"message": "{0} 准备跳过",
"description": "Example: Ready Sponsor Skipped"
},
"autoMuted": {
"message": "{0} 准备静音",
"description": "Example: Ready Sponsor Muted"
},
"skipped": {
"message": "{0} 已跳过",
"description": "Example: Sponsor Skipped"
Expand Down Expand Up @@ -471,11 +479,20 @@
"optionSectionExtensionRelated": {
"message": "插件相关选项"
},
"advanceSkipNotice": {
"message": "提前显示“空降提醒弹窗”"
},
"skipNoticeDurationBefore": {
"message": "“空降提醒弹窗”提前显示时间(秒):"
},
"skipNoticeDurationBeforeDescription": {
"message": "提前提醒您跳过片段的弹窗的提前时间。"
},
"skipNoticeDuration": {
"message": "“空降提醒弹窗”显示持续时间(秒):"
"message": "“空降提醒弹窗”跳过后或跳过提醒显示时间(秒):"
},
"skipNoticeDurationDescription": {
"message": "提醒您跳过片段的弹窗的显示时长。手动跳过片段的提醒弹窗可能会显示更久"
"message": "您跳过片段或者提醒您跳过片段的弹窗的显示时长。用于您对片段投票或跳过/取消跳过。\n手动跳过片段的提醒弹窗可能会显示更久"
},
"shortCheck": {
"message": "以下的提交短于您的最小持续时间选项。这代表它们可能已经被提交,只是由于该选项被忽略了。您确定要提交吗?"
Expand Down
25 changes: 21 additions & 4 deletions public/_locales/zh_CN/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@
"message": "重新显示空降提醒"
},
"showSkipNotice": {
"message": "在跳过片段后显示提醒弹窗"
"message": "跳过片段时显示提醒弹窗"
},
"showCategoryGuidelines": {
"message": "显示类别说明"
Expand Down Expand Up @@ -367,6 +367,14 @@
"message": "要跳到 {0} 吗?",
"description": "Used for skipping to things (Skip to Highlight)"
},
"autoSkipped": {
"message": "{0} 准备跳过",
"description": "Example: Ready Sponsor Skipped"
},
"autoMuted": {
"message": "{0} 准备静音",
"description": "Example: Ready Sponsor Muted"
},
"skipped": {
"message": "{0} 已跳过",
"description": "Example: Sponsor Skipped"
Expand Down Expand Up @@ -471,11 +479,20 @@
"optionSectionExtensionRelated": {
"message": "插件相关选项"
},
"advanceSkipNotice": {
"message": "提前显示“空降提醒弹窗”"
},
"skipNoticeDurationBefore": {
"message": "“空降提醒弹窗”提前显示时间(秒):"
},
"skipNoticeDurationBeforeDescription": {
"message": "提前提醒您跳过片段的弹窗的提前时间。"
},
"skipNoticeDuration": {
"message": "“空降提醒弹窗”显示持续时间(秒):"
"message": "“空降提醒弹窗”跳过后或跳过提醒显示时间(秒):"
},
"skipNoticeDurationDescription": {
"message": "提醒您跳过片段的弹窗的显示时长。手动跳过片段的提醒弹窗可能会显示更久"
"message": "您跳过片段或者提醒您跳过片段的弹窗的显示时长。用于您对片段投票或跳过/取消跳过。\n手动跳过片段的提醒弹窗可能会显示更久"
},
"shortCheck": {
"message": "以下的提交短于您的最小持续时间选项。这代表它们可能已经被提交,只是由于该选项被忽略了。您确定要提交吗?"
Expand Down Expand Up @@ -1175,7 +1192,7 @@
"description": "This is used on the popup to show how much time left. It will look like \"5s\". The word {seconds} will be replaced, so keep it here. Translations should only change the \"s\""
},
"FillerWarning": {
"message": "Warning: This is an incredibly aggressive category. You most likely will have to unskip stuff, or disable it sometimes. Be warned that many videos have over 50% or more of the video skipped! However, remember that there are still specific guidelines to follow when submitting.",
"message": "警告:这是一个非常激进的分类。 您很可能会需要取消跳过某些内容,或者有时候需要禁用它。 请注意,许多视频的跳过率超过50%甚至更多! 但是请记住,在提交时仍需遵守特定的指导原则。",
"description": "Warning that appears when enabling the filler tangent category"
},
"cleanPopup": {
Expand Down
23 changes: 20 additions & 3 deletions public/_locales/zh_TW/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@
"message": "重新顯示跳過提醒"
},
"showSkipNotice": {
"message": "在跳過片段後顯示提醒跳出視窗"
"message": "跳過片段時顯示提醒跳出視窗"
},
"showCategoryGuidelines": {
"message": "顯示類別說明"
Expand Down Expand Up @@ -367,6 +367,14 @@
"message": "要跳到 {0} 嗎?",
"description": "Used for skipping to things (Skip to Highlight)"
},
"autoSkipped": {
"message": "{0} 準備跳過",
"description": "Example: Ready Sponsor Skipped"
},
"autoMuted": {
"message": "{0} 準備靜音",
"description": "Example: Ready Sponsor Muted"
},
"skipped": {
"message": "{0} 已跳過",
"description": "Example: Sponsor Skipped"
Expand Down Expand Up @@ -471,11 +479,20 @@
"optionSectionExtensionRelated": {
"message": "插件相關選項"
},
"advanceSkipNotice": {
"message": "提前顯示跳過提醒視窗"
},
"skipNoticeDurationBefore": {
"message": "跳過提醒提前跳出視窗時間(秒):"
},
"skipNoticeDurationBeforeDescription": {
"message": "跳過提醒提前跳出視窗的提前時常。"
},
"skipNoticeDuration": {
"message": "跳過提醒跳出視窗持續時間(秒):"
"message": "跳過后或跳過提醒顯示時間(秒):"
},
"skipNoticeDurationDescription": {
"message": "跳過提醒跳出視窗的顯示時常。手動跳過的提醒可能會顯示更久"
"message": "您跳過片段或者跳過提醒跳出視窗的顯示時常。用於您對片段進行投票或者跳過/取消跳過。\n手動跳過的提醒可能會顯示更久"
},
"shortCheck": {
"message": "以下的提交短於您的最小持續時間選項。這代表它們可能已經被提交,只是由於該選項被忽略了。您確定要提交嗎?"
Expand Down
25 changes: 24 additions & 1 deletion public/options/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,33 @@ <h3>__MSG_optionSectionSkipNotice__</h3>
<span class="optionLabel">__MSG_skipNoticeDuration__</span>
<input type="number" step="1" min="1">
</label>

<div class="small-description">__MSG_skipNoticeDurationDescription__</div>
</div>

<div data-type="toggle" data-toggle-type="switch" data-sync="advanceSkipNotice">
<div class="switch-container">
<label class="switch">
<input id="advanceSkipNotice" type="checkbox" checked>
<span class="slider round"></span>
</label>
<label class="switch-label" for="advanceSkipNotice">
__MSG_advanceSkipNotice__
</label>
</div>

<div data-type="number-change" data-sync="skipNoticeDurationBefore" data-dependent-on="advanceSkipNotice">
<br />

<label class="number-container">
<span class="optionLabel">__MSG_skipNoticeDurationBefore__</span>
<input type="number" step="1" min="1">
</label>

<div class="small-description">__MSG_skipNoticeDurationBeforeDescription__</div>
</div>
</div>

<div data-type="toggle" data-toggle-type="reverse" data-sync="dontShowNotice">
<div class="switch-container">
<label class="switch">
Expand Down
2 changes: 1 addition & 1 deletion public/shared.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
}

.sponsorSkipNoticeParent {
min-width: 390px;
min-width: 410px;
max-width: 50%;
}

Expand Down
30 changes: 25 additions & 5 deletions src/components/SkipNoticeComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,16 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
this.unselectedColor = Config.config.colorPalette.white;
this.lockedColor = Config.config.colorPalette.locked;

let countDown: number = 0;
if (Config.config.advanceSkipNotice && Config.config.skipNoticeDurationBefore > 0) {
countDown = Number(Config.config.skipNoticeDurationBefore) + Number(Config.config.skipNoticeDuration);
} else {
countDown = Number(Config.config.skipNoticeDuration);
}
const isMuteSegment = this.segments[0].actionType === ActionType.Mute;
const maxCountdownTime = isMuteSegment
? this.getFullDurationCountdown(0)
: () => Config.config.skipNoticeDuration;
: () => countDown;

const defaultSkipButtonState = this.props.startReskip ? SkipButtonState.Redo : SkipButtonState.Undo;
const skipButtonStates = [
Expand Down Expand Up @@ -678,7 +684,7 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
}

unskip(buttonIndex: number, index: number, forceSeek: boolean): void {
this.contentContainer().unskipSponsorTime(this.segments[index], this.props.unskipTime, forceSeek);
(this.contentContainer().unskipSponsorTime(this.segments[index], this.props.unskipTime, forceSeek));

this.unskippedMode(buttonIndex, index, SkipButtonState.Redo);
}
Expand All @@ -692,12 +698,26 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
const skipButtonCallbacks = this.state.skipButtonCallbacks;
skipButtonCallbacks[buttonIndex] = this.unskip.bind(this);

let countDown: number;
if (Config.config.advanceSkipNotice && Config.config.skipNoticeDurationBefore > 0) {
if (this.props.segments[0].segment[0] > getVideo().currentTime) {
countDown = Number(Config.config.skipNoticeDurationBefore) + Number(Config.config.skipNoticeDuration);
} else {
if (Config.config.skipNoticeDuration < 1) {
countDown = Config.config.skipNoticeDurationBefore;
} else {
countDown = Config.config.skipNoticeDuration;
}
}
} else {
countDown = Config.config.skipNoticeDuration;
}
const newState: SkipNoticeState = {
skipButtonStates,
skipButtonCallbacks,

maxCountdownTime: () => Config.config.skipNoticeDuration,
countdownTime: Config.config.skipNoticeDuration,
maxCountdownTime: () => countDown,
countdownTime: countDown,
};

//reset countdown
Expand Down Expand Up @@ -754,7 +774,7 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
(sponsorTime.segment[1] - getVideo().currentTime) * (1 / getVideo().playbackRate)
);

return Math.max(duration, Config.config.skipNoticeDuration);
return Math.max(duration, Config.config.skipNoticeDurationBefore);
};
}

Expand Down
4 changes: 4 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ interface SBConfig {
serverAddress: string;
minDuration: number;
skipNoticeDuration: number;
skipNoticeDurationBefore: number;
advanceSkipNotice:boolean;
audioNotificationOnSkip: boolean;
checkForUnlistedVideos: boolean;
testingServer: boolean;
Expand Down Expand Up @@ -241,6 +243,8 @@ const syncDefaults = {
serverAddress: CompileConfig.serverAddress,
minDuration: 0,
skipNoticeDuration: 4,
skipNoticeDurationBefore: 4,
advanceSkipNotice:false,
audioNotificationOnSkip: false,
checkForUnlistedVideos: false,
testingServer: false,
Expand Down
Loading

0 comments on commit 0b8fb76

Please sign in to comment.