From a9993d5d807b35bbf3515c1f2213d7295001f8d7 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Mon, 30 Mar 2020 20:08:00 -0400 Subject: [PATCH] Added check for videoID change not being called --- src/content.ts | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/content.ts b/src/content.ts index 2ab873e0..36137809 100644 --- a/src/content.ts +++ b/src/content.ts @@ -479,12 +479,24 @@ function startSponsorSchedule(currentTime?: number): void { let forcedSkipTime: number = null; if (video.currentTime >= skipTime[0] && video.currentTime < skipTime[1]) { - skipToTime(video, skipInfo.index, skipInfo.array, skipInfo.openNotice); + // Double check that the videoID is correct + // TODO: Remove this bug catching if statement when the bug is found + let currentVideoID = getYouTubeVideoID(document.URL); + if (currentVideoID == sponsorVideoID) { + skipToTime(video, skipInfo.index, skipInfo.array, skipInfo.openNotice); - if (Config.config.disableAutoSkip) { - forcedSkipTime = skipTime[0] + 0.001; + if (Config.config.disableAutoSkip) { + forcedSkipTime = skipTime[0] + 0.001; + } else { + forcedSkipTime = skipTime[1]; + } } else { - forcedSkipTime = skipTime[1]; + // Something has really gone wrong + console.error("[SponsorBlock] The videoID recorded when trying to skip is different than what it should be."); + console.error("[SponsorBlock] VideoID recorded: " + sponsorVideoID + ". Actual VideoID: " + currentVideoID); + + // Video ID change occured + videoIDChange(currentVideoID); } }