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 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; - 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( this.close()}