diff options
author | Ajay <[email protected]> | 2022-04-21 21:28:25 -0400 |
---|---|---|
committer | Ajay <[email protected]> | 2022-04-21 21:28:25 -0400 |
commit | c773b4ecd103925eb56bd5b42931e29469367682 (patch) | |
tree | 49d6f8a8582136b9a4d04a66b6731ce9e757f1a8 | |
parent | 9bad5ed324d2fe7718821c53664eacfc37940d8b (diff) | |
download | SponsorBlock-c773b4ecd103925eb56bd5b42931e29469367682.tar.gz SponsorBlock-c773b4ecd103925eb56bd5b42931e29469367682.zip |
Enter unskip with skip notice hidden
-rw-r--r-- | src/components/SkipNoticeComponent.tsx | 7 | ||||
-rw-r--r-- | src/content.ts | 24 | ||||
-rw-r--r-- | src/render/SkipNotice.tsx | 3 |
3 files changed, 26 insertions, 8 deletions
diff --git a/src/components/SkipNoticeComponent.tsx b/src/components/SkipNoticeComponent.tsx index 6b3246d3..2216fbc5 100644 --- a/src/components/SkipNoticeComponent.tsx +++ b/src/components/SkipNoticeComponent.tsx @@ -18,6 +18,7 @@ export interface SkipNoticeProps { segments: SponsorTime[]; autoSkip: boolean; + startReskip?: boolean; // Contains functions and variables from the content script needed by the skip notice contentContainer: ContentContainer; @@ -120,8 +121,10 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta countdownTime: Config.config.skipNoticeDuration, countdownText: null, - skipButtonText: this.getUnskipText(), - skipButtonCallback: (index) => this.unskip(index), + skipButtonText: this.props.startReskip + ? this.getReskipText() : this.getUnskipText(), + skipButtonCallback: this.props.startReskip + ? (index) => this.reskip(index) : (index) => this.unskip(index), showSkipButton: true, editing: false, diff --git a/src/content.ts b/src/content.ts index c5fc7dbc..1dfb9216 100644 --- a/src/content.ts +++ b/src/content.ts @@ -1357,12 +1357,17 @@ function skipToTime({v, skipTime, skippingSegments, openNotice, forceAutoSkip, u if (openNotice) { //send out the message saying that a sponsor message was skipped if (!Config.config.dontShowNotice || !autoSkip) { - const newSkipNotice = new SkipNotice(skippingSegments, autoSkip, skipNoticeContentContainer, unskipTime); - if (onMobileYouTube || Config.config.skipKeybind == null) newSkipNotice.setShowKeybindHint(false); - skipNotices.push(newSkipNotice); - + createSkipNotice(skippingSegments, autoSkip, unskipTime, false); + } else if (autoSkip) { activeSkipKeybindElement?.setShowKeybindHint(false); - activeSkipKeybindElement = newSkipNotice; + activeSkipKeybindElement = { + setShowKeybindHint: () => {}, //eslint-disable-line @typescript-eslint/no-empty-function + toggleSkip: () => { + unskipSponsorTime(skippingSegments[0], unskipTime); + + createSkipNotice(skippingSegments, autoSkip, unskipTime, true); + } + }; } } } @@ -1371,6 +1376,15 @@ function skipToTime({v, skipTime, skippingSegments, openNotice, forceAutoSkip, u if (autoSkip) sendTelemetryAndCount(skippingSegments, skipTime[1] - skipTime[0], true); } +function createSkipNotice(skippingSegments: SponsorTime[], autoSkip: boolean, unskipTime: number, startReskip: boolean) { + const newSkipNotice = new SkipNotice(skippingSegments, autoSkip, skipNoticeContentContainer, unskipTime, startReskip); + if (onMobileYouTube || Config.config.skipKeybind == null) newSkipNotice.setShowKeybindHint(false); + skipNotices.push(newSkipNotice); + + activeSkipKeybindElement?.setShowKeybindHint(false); + activeSkipKeybindElement = newSkipNotice; +} + function unskipSponsorTime(segment: SponsorTime, unskipTime: number = null) { if (segment.actionType === ActionType.Mute) { video.muted = false; diff --git a/src/render/SkipNotice.tsx b/src/render/SkipNotice.tsx index b3ea571c..38b190e1 100644 --- a/src/render/SkipNotice.tsx +++ b/src/render/SkipNotice.tsx @@ -19,7 +19,7 @@ class SkipNotice { skipNoticeRef: React.MutableRefObject<SkipNoticeComponent>; - constructor(segments: SponsorTime[], autoSkip = false, contentContainer: ContentContainer, unskipTime: number = null) { + constructor(segments: SponsorTime[], autoSkip = false, contentContainer: ContentContainer, unskipTime: number = null, startReskip = false) { this.skipNoticeRef = React.createRef(); this.segments = segments; @@ -44,6 +44,7 @@ class SkipNotice { ReactDOM.render( <SkipNoticeComponent segments={segments} autoSkip={autoSkip} + startReskip={startReskip} contentContainer={contentContainer} ref={this.skipNoticeRef} closeListener={() => this.close()} |