diff options
-rw-r--r-- | .github/workflows/release.yml | 2 | ||||
-rw-r--r-- | manifest/manifest.json | 2 | ||||
-rw-r--r-- | src/background.ts | 4 | ||||
-rw-r--r-- | src/content.ts | 57 |
4 files changed, 43 insertions, 22 deletions
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 21a2fe2a..48365c37 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -67,10 +67,12 @@ jobs: uses: Shopify/upload-to-release@master with: args: builds/ChromeExtension.zip + name: ChromeExtension.zip repo-token: ${{ secrets.GITHUB_TOKEN }} - name: Upload to release uses: Shopify/upload-to-release@master with: args: builds/FirefoxExtension.zip + name: FirefoxExtension.zip repo-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/manifest/manifest.json b/manifest/manifest.json index 4ae39362..fcfd4bc0 100644 --- a/manifest/manifest.json +++ b/manifest/manifest.json @@ -1,7 +1,7 @@ { "name": "__MSG_fullName__", "short_name": "__MSG_Name__", - "version": "1.2.23", + "version": "1.2.24", "default_locale": "en", "description": "__MSG_Description__", "content_scripts": [{ diff --git a/src/background.ts b/src/background.ts index 330481e7..5b49c7d2 100644 --- a/src/background.ts +++ b/src/background.ts @@ -88,10 +88,6 @@ chrome.runtime.onInstalled.addListener(function (object) { const newUserID = utils.generateUserID(); //save this UUID Config.config.userID = newUserID; - - //TODO: Remove when mobile support is old - // Don't show this to new users - // Config.config.mobileUpdateShowCount = 1; } }, 1500); }); diff --git a/src/content.ts b/src/content.ts index 410b1989..36137809 100644 --- a/src/content.ts +++ b/src/content.ts @@ -21,7 +21,7 @@ var UUIDs = []; var sponsorVideoID = null; // Skips are scheduled to ensure precision. -// Skips are rescheduled every seeked event. +// Skips are rescheduled every seeking event. // Skips are canceled every seeking event var currentSkipSchedule: NodeJS.Timeout = null; var seekListenerSetUp = false @@ -35,6 +35,9 @@ var sponsorSkipped = []; //the video var video: HTMLVideoElement; +/** The last time this video was seeking to */ +var lastVideoTime: number = null; + var onInvidious; var onMobileYouTube; @@ -476,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); - - if (Config.config.disableAutoSkip) { - forcedSkipTime = skipTime[0] + 0.001; + // 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; + } 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); } } @@ -533,12 +548,27 @@ function sponsorsLookup(id: string, channelIDPromise?) { startSponsorSchedule(); } }); - video.addEventListener('seeked', () => { - if (!video.paused) startSponsorSchedule(); + video.addEventListener('seeking', () => { + // Reset lastCheckVideoTime + lastCheckVideoTime = -1 + lastCheckTime = 0; + + lastVideoTime = video.currentTime; + + if (!video.paused){ + startSponsorSchedule(); + } }); video.addEventListener('ratechange', () => startSponsorSchedule()); - video.addEventListener('seeking', cancelSponsorSchedule); - video.addEventListener('pause', cancelSponsorSchedule); + video.addEventListener('pause', () => { + // Reset lastCheckVideoTime + lastCheckVideoTime = -1; + lastCheckTime = 0; + + lastVideoTime = video.currentTime; + + cancelSponsorSchedule(); + }); startSponsorSchedule(); } @@ -872,13 +902,6 @@ function skipToTime(v, index, sponsorTimes, openNotice) { let skipNotice = new SkipNotice(this, currentUUID, Config.config.disableAutoSkip, skipNoticeContentContainer); - //TODO: Remove this when Mobile support is old - if (Config.config.mobileUpdateShowCount < 1) { - skipNotice.addNoticeInfoMessage(chrome.i18n.getMessage("mobileUpdateInfo")); - - Config.config.mobileUpdateShowCount += 1; - } - //auto-upvote this sponsor if (Config.config.trackViewCount && !Config.config.disableAutoSkip && Config.config.autoUpvote) { vote(1, currentUUID, null); |