diff --git a/src/components/SkipNoticeComponent.tsx b/src/components/SkipNoticeComponent.tsx index 5bd92966..a11cdcc1 100644 --- a/src/components/SkipNoticeComponent.tsx +++ b/src/components/SkipNoticeComponent.tsx @@ -26,6 +26,8 @@ export interface SkipNoticeProps { closeListener: () => void; showKeybindHint?: boolean; smaller: boolean; + + unskipTime?: number; } export interface SkipNoticeState { @@ -455,7 +457,7 @@ class SkipNoticeComponent extends React.Component= skipTime[0] && video.currentTime < skipTime[1]) { - skipToTime(video, skipTime, skippingSegments, skipInfo.openNotice); + skipToTime({ + v: video, + skipTime, + skippingSegments, + openNotice: skipInfo.openNotice + }); if (utils.getCategorySelection(currentSkip.category)?.option === CategorySkipOption.ManualSkip) { forcedSkipTime = skipTime[0] + 0.001; @@ -568,7 +573,13 @@ function setupVideoListeners() { video.currentTime - segment.segment[0] > 0 && video.currentTime - segment.segment[0] < video.duration * 0.006); // Approximate size on preview bar if (currentPoiSegment) { - skipToTime(video, currentPoiSegment.segment, [currentPoiSegment], true, true); + skipToTime({ + v: video, + skipTime: currentPoiSegment.segment, + skippingSegments: [currentPoiSegment], + openNotice: true, + forceAutoSkip: true + }); } } }); @@ -744,7 +755,13 @@ function startSkipScheduleCheckingForStartSponsors() { for (const time of poiSegments) { const skipOption = utils.getCategorySelection(time.category)?.option; if (skipOption !== CategorySkipOption.ShowOverlay) { - skipToTime(video, time.segment, [time], true); + skipToTime({ + v: video, + skipTime: time.segment, + skippingSegments: [time], + openNotice: true, + unskipTime: video.currentTime + }); if (skipOption === CategorySkipOption.AutoSkip) break; } } @@ -1049,7 +1066,7 @@ function sendTelemetryAndCount(skippingSegments: SponsorTime[], secondsSkipped: } //skip from the start time to the end time for a certain index sponsor time -function skipToTime(v: HTMLVideoElement, skipTime: number[], skippingSegments: SponsorTime[], openNotice: boolean, forceAutoSkip = false) { +function skipToTime({v, skipTime, skippingSegments, openNotice, forceAutoSkip, unskipTime}: SkipToTimeParams): void { // There will only be one submission if it is manual skip const autoSkip: boolean = forceAutoSkip || shouldAutoSkip(skippingSegments[0]); @@ -1067,7 +1084,7 @@ function skipToTime(v: HTMLVideoElement, skipTime: number[], skippingSegments: S //send out the message saying that a sponsor message was skipped if (!Config.config.dontShowNotice || !autoSkip) { skipNotices.forEach((notice) => notice.setShowKeybindHint(false)); - skipNotices.push(new SkipNotice(skippingSegments, autoSkip, skipNoticeContentContainer)); + skipNotices.push(new SkipNotice(skippingSegments, autoSkip, skipNoticeContentContainer, unskipTime)); } } @@ -1075,9 +1092,10 @@ function skipToTime(v: HTMLVideoElement, skipTime: number[], skippingSegments: S if (autoSkip) sendTelemetryAndCount(skippingSegments, skipTime[1] - skipTime[0], true); } -function unskipSponsorTime(segment: SponsorTime) { +function unskipSponsorTime(segment: SponsorTime, unskipTime: number = null) { //add a tiny bit of time to make sure it is not skipped again - video.currentTime = segment.segment[0] + 0.001; + console.log(unskipTime) + video.currentTime = unskipTime ?? segment.segment[0] + 0.001; } function reskipSponsorTime(segment: SponsorTime) { diff --git a/src/render/SkipNotice.tsx b/src/render/SkipNotice.tsx index 2fd73a8b..ae1b4f67 100644 --- a/src/render/SkipNotice.tsx +++ b/src/render/SkipNotice.tsx @@ -17,7 +17,7 @@ class SkipNotice { skipNoticeRef: React.MutableRefObject; - constructor(segments: SponsorTime[], autoSkip = false, contentContainer: ContentContainer) { + constructor(segments: SponsorTime[], autoSkip = false, contentContainer: ContentContainer, unskipTime: number = null) { this.skipNoticeRef = React.createRef(); this.segments = segments; @@ -45,7 +45,8 @@ class SkipNotice { contentContainer={contentContainer} ref={this.skipNoticeRef} closeListener={() => this.close()} - smaller={true} />, + smaller={true} + unskipTime={unskipTime} />, this.noticeElement ); } diff --git a/src/types.ts b/src/types.ts index 7f13f396..8d478a1a 100644 --- a/src/types.ts +++ b/src/types.ts @@ -6,7 +6,7 @@ export interface ContentContainer { (): { vote: (type: number, UUID: SegmentUUID, category?: Category, skipNotice?: SkipNoticeComponent) => void, dontShowNoticeAgain: () => void, - unskipSponsorTime: (segment: SponsorTime) => void, + unskipSponsorTime: (segment: SponsorTime, unskipTime: number) => void, sponsorTimes: SponsorTime[], sponsorTimesSubmitting: SponsorTime[], skipNotices: SkipNotice[], @@ -185,4 +185,13 @@ export enum ChannelIDStatus { export interface ChannelIDInfo { id: string, status: ChannelIDStatus +} + +export interface SkipToTimeParams { + v: HTMLVideoElement, + skipTime: number[], + skippingSegments: SponsorTime[], + openNotice: boolean, + forceAutoSkip?: boolean, + unskipTime?: number } \ No newline at end of file