From 0266bb49ca0260bdc9e92d8044deea8abbbb58df Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Wed, 19 Feb 2020 12:35:10 -0500 Subject: [PATCH 1/9] Fixed typo --- src/content.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/content.ts b/src/content.ts index 6433c905..c9e2f6e0 100644 --- a/src/content.ts +++ b/src/content.ts @@ -43,8 +43,6 @@ var lastPreviewBarUpdate; //whether the duration listener listening for the duration changes of the video has been setup yet var durationListenerSetUp = false; -// Timestamp of the last duration change -var lastDurationChange = 0; //the channel this video is about var channelURL; @@ -430,8 +428,6 @@ function createPreviewBar(): void { * This happens when the resolution changes or at random time to clear memory. */ function durationChangeListener() { - lastDurationChange = Date.now(); - updatePreviewBar(); } @@ -802,7 +798,7 @@ function getStartTimes(sponsorTimes: number[][], minimum?: number, hideHiddenSpo return startTimes; } -//skip from fhe start time to the end time for a certain index sponsor time +//skip from the start time to the end time for a certain index sponsor time function skipToTime(v, index, sponsorTimes, openNotice) { if (!Config.config.disableAutoSkip || previewResetter !== null) { v.currentTime = sponsorTimes[index][1]; From e75e58875512bf0ca05426b4632836165cc7cfb8 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Wed, 19 Feb 2020 12:37:17 -0500 Subject: [PATCH 2/9] Sped up direct links a tiny bit. --- src/content.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content.ts b/src/content.ts index c9e2f6e0..0427abdd 100644 --- a/src/content.ts +++ b/src/content.ts @@ -64,7 +64,7 @@ var previewResetter: NodeJS.Timeout = null; var controls = null; // Direct Links after the config is loaded -utils.wait(() => Config.config !== null).then(() => videoIDChange(getYouTubeVideoID(document.URL))); +utils.wait(() => Config.config !== null, 1000, 1).then(() => videoIDChange(getYouTubeVideoID(document.URL))); //the last time looked at (used to see if this time is in the interval) var lastTime = -1; From bfc771bd99b47251c343c3020d4f4d663357a2e4 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Wed, 19 Feb 2020 12:37:39 -0500 Subject: [PATCH 3/9] Removed unused variables --- src/content.ts | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/content.ts b/src/content.ts index 0427abdd..555ea68f 100644 --- a/src/content.ts +++ b/src/content.ts @@ -66,19 +66,10 @@ var controls = null; // Direct Links after the config is loaded utils.wait(() => Config.config !== null, 1000, 1).then(() => videoIDChange(getYouTubeVideoID(document.URL))); -//the last time looked at (used to see if this time is in the interval) -var lastTime = -1; - //the amount of times the sponsor lookup has retried //this only happens if there is an error var sponsorLookupRetries = 0; -//the last time in the video a sponsor was skipped -//used for the go back button -var lastSponsorTimeSkipped = null; -//used for ratings -var lastSponsorTimeSkippedUUID = null; - //if showing the start sponsor button or the end sponsor button on the player var showingStartSponsor = true; From ab2a9530e9bd295fa860ae1409c5325eda0a87fa Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Wed, 19 Feb 2020 12:41:22 -0500 Subject: [PATCH 4/9] Sped up zero second sponsors a tiny bit --- src/content.ts | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/content.ts b/src/content.ts index 555ea68f..3a4d0623 100644 --- a/src/content.ts +++ b/src/content.ts @@ -70,6 +70,12 @@ utils.wait(() => Config.config !== null, 1000, 1).then(() => videoIDChange(getYo //this only happens if there is an error var sponsorLookupRetries = 0; +//the last time in the video a sponsor was skipped +//used for the go back button +var lastSponsorTimeSkipped = null; +//used for ratings +var lastSponsorTimeSkippedUUID = null; + //if showing the start sponsor button or the end sponsor button on the player var showingStartSponsor = true; @@ -229,9 +235,6 @@ document.onkeydown = function(e: KeyboardEvent){ } function resetValues() { - //reset last sponsor times - lastTime = -1; - //reset sponsor times sponsorTimes = null; UUIDs = []; @@ -425,6 +428,8 @@ function durationChangeListener() { function cancelSponsorSchedule(): void { if (currentSkipSchedule !== null) { clearTimeout(currentSkipSchedule); + + currentSkipSchedule = null; } } @@ -446,7 +451,7 @@ function startSponsorSchedule(currentTime?: number): void { let skipTime = skipInfo.array[skipInfo.index]; let timeUntilSponsor = skipTime[0] - currentTime; - currentSkipSchedule = setTimeout(() => { + let skippingFunction = () => { if (video.currentTime >= skipTime[0] && video.currentTime < skipTime[1]) { skipToTime(video, skipInfo.index, skipInfo.array, skipInfo.openNotice); @@ -454,7 +459,13 @@ function startSponsorSchedule(currentTime?: number): void { } else { startSponsorSchedule(); } - }, timeUntilSponsor * 1000 * (1 / video.playbackRate)); + }; + + if (timeUntilSponsor <= 0) { + skippingFunction(); + } else { + currentSkipSchedule = setTimeout(skippingFunction, timeUntilSponsor * 1000 * (1 / video.playbackRate)); + } } function sponsorsLookup(id: string, channelIDPromise?) { From c6107057d9ea5a04f4166719b8a2a845eaa6b9a9 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Wed, 19 Feb 2020 12:54:58 -0500 Subject: [PATCH 5/9] Firefox dev environment now loads Firefox uBlock Origin --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 078bb0b7..72f20cd5 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ }, "scripts": { "web-run": "npm run web-run:chrome", - "web-run:firefox": "cd dist && web-ext run --start-url https://chrome.google.com/webstore/detail/ublock-origin/cjpalhdlnbpafiamejdnhcphjbkeiagm", + "web-run:firefox": "cd dist && web-ext run --start-url https://addons.mozilla.org/firefox/addon/ublock-origin/", "web-run:chrome": "cd dist && web-ext run --start-url https://chrome.google.com/webstore/detail/ublock-origin/cjpalhdlnbpafiamejdnhcphjbkeiagm -t chromium", "build": "npm run build:chrome", "build:chrome": "webpack --env.browser=chrome --config webpack/webpack.prod.js", From 8b28bccfd72f6544673c46fa5016bd52b311c5da Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Wed, 19 Feb 2020 12:57:22 -0500 Subject: [PATCH 6/9] Run dev now uses dev build. --- package.json | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 72f20cd5..f68cda87 100644 --- a/package.json +++ b/package.json @@ -29,11 +29,14 @@ "build": "npm run build:chrome", "build:chrome": "webpack --env.browser=chrome --config webpack/webpack.prod.js", "build:firefox": "webpack --env.browser=firefox --config webpack/webpack.prod.js", + "build:dev": "npm run build:dev:chrome", + "build:dev:chrome": "webpack --env.browser=chrome --config webpack/webpack.dev.js", + "build:dev:firefox": "webpack --env.browser=firefox --config webpack/webpack.dev.js", "build:watch": "npm run build:watch:chrome", "build:watch:chrome": "webpack --env.browser=chrome --config webpack/webpack.dev.js --watch", "build:watch:firefox": "webpack --env.browser=firefox --config webpack/webpack.dev.js --watch", - "dev": "npm run build && concurrently \"npm run web-run\" \"npm run build:watch\"", - "dev:firefox": "npm run build:firefox && concurrently \"npm run web-run:firefox\" \"npm run build:watch:firefox\"", + "dev": "npm run build:dev && concurrently \"npm run web-run\" \"npm run build:watch\"", + "dev:firefox": "npm run build:dev:firefox && concurrently \"npm run web-run:firefox\" \"npm run build:watch:firefox\"", "clean": "rimraf dist", "test": "npx jest" }, From 397bcc94c5cd4388b2179344ef67fa1e48bf509f Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Wed, 19 Feb 2020 13:35:05 -0500 Subject: [PATCH 7/9] Remove redundant code --- src/content.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/content.ts b/src/content.ts index 3a4d0623..b7f764c6 100644 --- a/src/content.ts +++ b/src/content.ts @@ -454,11 +454,9 @@ function startSponsorSchedule(currentTime?: number): void { let skippingFunction = () => { if (video.currentTime >= skipTime[0] && video.currentTime < skipTime[1]) { skipToTime(video, skipInfo.index, skipInfo.array, skipInfo.openNotice); - - startSponsorSchedule(); - } else { - startSponsorSchedule(); } + + startSponsorSchedule(); }; if (timeUntilSponsor <= 0) { From 4ca57cc0257d25764714d2c1296016abf84ccceb Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Wed, 19 Feb 2020 13:45:00 -0500 Subject: [PATCH 8/9] Fixed preview sponsors not skipping when only they are there. --- src/content.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/content.ts b/src/content.ts index b7f764c6..d00f55bd 100644 --- a/src/content.ts +++ b/src/content.ts @@ -440,7 +440,7 @@ function cancelSponsorSchedule(): void { function startSponsorSchedule(currentTime?: number): void { cancelSponsorSchedule(); - if (sponsorTimes === null || Config.config.disableSkipping || channelWhitelisted){ + if (Config.config.disableSkipping || channelWhitelisted){ return; } @@ -448,6 +448,8 @@ function startSponsorSchedule(currentTime?: number): void { let skipInfo = getNextSkipIndex(currentTime); + if (skipInfo.index === -1) return; + let skipTime = skipInfo.array[skipInfo.index]; let timeUntilSponsor = skipTime[0] - currentTime; @@ -489,6 +491,8 @@ function sponsorsLookup(id: string, channelIDPromise?) { video.addEventListener('ratechange', () => startSponsorSchedule()); video.addEventListener('seeking', cancelSponsorSchedule); video.addEventListener('pause', cancelSponsorSchedule); + + startSponsorSchedule(); } if (channelIDPromise !== undefined) { @@ -763,7 +767,8 @@ function getNextSkipIndex(currentTime: number): {array: number[][], index: numbe let minPreviewSponsorTimeIndex = previewSponsorStartTimes.indexOf(Math.min(...previewSponsorStartTimesAfterCurrentTime)); - if (minPreviewSponsorTimeIndex == -1 || sponsorStartTimes[minSponsorTimeIndex] < previewSponsorStartTimes[minPreviewSponsorTimeIndex]) { + if ((minPreviewSponsorTimeIndex === -1 && minSponsorTimeIndex !== -1) || + sponsorStartTimes[minSponsorTimeIndex] < previewSponsorStartTimes[minPreviewSponsorTimeIndex]) { return { array: sponsorTimes, index: minSponsorTimeIndex, @@ -787,6 +792,8 @@ function getNextSkipIndex(currentTime: number): {array: number[][], index: numbe * @param hideHiddenSponsors */ function getStartTimes(sponsorTimes: number[][], minimum?: number, hideHiddenSponsors: boolean = false): number[] { + if (sponsorTimes === null) return []; + let startTimes: number[] = []; for (let i = 0; i < sponsorTimes.length; i++) { From 8be3cb157a1c62ab6495b98d1f26337e32e5b5e7 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Thu, 20 Feb 2020 11:23:44 -0500 Subject: [PATCH 9/9] Increased version number --- manifest/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest/manifest.json b/manifest/manifest.json index 2645d1c0..880e6d52 100644 --- a/manifest/manifest.json +++ b/manifest/manifest.json @@ -1,7 +1,7 @@ { "name": "__MSG_fullName__", "short_name": "__MSG_Name__", - "version": "1.2.14", + "version": "1.2.15", "default_locale": "en", "description": "__MSG_Description__", "content_scripts": [{