From bf26961aaaae67cc6036c921d7c00d8c7ac3bce7 Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Sun, 10 Jan 2021 18:07:58 +0100 Subject: [PATCH 001/176] Fix formatting in what's new panel --- src/popup/panels/WhatsNewPanel.vue | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/popup/panels/WhatsNewPanel.vue b/src/popup/panels/WhatsNewPanel.vue index fd9918e..f299d25 100644 --- a/src/popup/panels/WhatsNewPanel.vue +++ b/src/popup/panels/WhatsNewPanel.vue @@ -20,8 +20,14 @@
  • [4.5.1.1] Streamable fix broke old.reddit + RES on embeds from v.redd.it and streamable.com. We're now using an alternative implementation. (#128) +
  • +
  • [4.5.1.2] Fixed the issue where videos would sometimes get misaligned while using hybrid stretch. (#125) +
  • +
  • [4.5.1.3] Added a potential fix for disney plus +
  • +
  • [4.5.1.3] Microsoft Edge has fixed the bugs that prevented the extension from working properly. Popup should no longer be shown.
  • From aec87e7681a11ab682585f29e449f92a6613e7a9 Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Sun, 10 Jan 2021 20:46:41 +0100 Subject: [PATCH 002/176] Don't assume jenkins build number is always there, cos it's not on local builds --- webpack.config.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index 8cb6897..447d6d9 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -121,7 +121,7 @@ const config = { .substr(2) // YYYY -> YY .replace('-', '') // YY-MM-DD -> YYMM-DD .replace('-', '.') // YYMM-DD -> YYMM.DD - }.${process.env.BUILD_NUMBER}`; + }.${process.env.BUILD_NUMBER ?? 0}`; jsonContent.browser_action.default_title = "Ultrawidify Nightly"; // because we don't want web-ext to submit this as proper release @@ -137,7 +137,7 @@ const config = { .substr(2) // YYYY -> YY .replace('-', '') // YY-MM-DD -> YYMM-DD .replace('-', '.') // YYMM-DD -> YYMM.DD - }.${process.env.BUILD_NUMBER}`; + }.${process.env.BUILD_NUMBER ?? 0}`; jsonContent.browser_action.default_title = "Ultrawidify Testing"; // because we don't want web-ext to submit this as proper release From df2b0f56145d588c44ffd693152a2df2e3aadc63 Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Tue, 12 Jan 2021 23:18:14 +0100 Subject: [PATCH 003/176] Add toString method to aspect ratio enum --- src/common/enums/aspect-ratio.enum.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/common/enums/aspect-ratio.enum.js b/src/common/enums/aspect-ratio.enum.js index 95c92f1..46c1f7d 100644 --- a/src/common/enums/aspect-ratio.enum.js +++ b/src/common/enums/aspect-ratio.enum.js @@ -6,6 +6,19 @@ var AspectRatio = Object.freeze({ FitHeight: 3, // legacy/dynamic: fit to height Fixed: 4, // pre-determined aspect ratio Manual: 5, // ratio achieved by zooming in/zooming out + + toString: (ar) => { + switch (ar) { + case -1: return 'Initial'; + case 0: return 'Reset'; + case 1: return 'Automatic'; + case 2: return 'FitWidth'; + case 3: return 'FitHeight'; + case 4: return 'Fixed'; + case 5: return 'Manual'; + default: return '' + } + } }); export default AspectRatio; From aa1ccedad5cf43568832eb517896b1978c3b2fd0 Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Tue, 12 Jan 2021 23:19:04 +0100 Subject: [PATCH 004/176] Cosmetic changes --- src/ext/lib/ar-detect/ArDetector.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ext/lib/ar-detect/ArDetector.js b/src/ext/lib/ar-detect/ArDetector.js index 48b5fe8..b6997c6 100644 --- a/src/ext/lib/ar-detect/ArDetector.js +++ b/src/ext/lib/ar-detect/ArDetector.js @@ -474,19 +474,19 @@ class ArDetector { // poglejmo, če se je razmerje stranic spremenilo // check if aspect ratio is changed: - var lastAr = this.conf.resizer.getLastAr(); + let lastAr = this.conf.resizer.getLastAr(); if (lastAr.type === AspectRatio.Automatic && lastAr.ratio !== null && lastAr.ratio !== undefined){ // spremembo lahko zavrnemo samo, če uporabljamo avtomatski način delovanja in če smo razmerje stranic // že nastavili. // // we can only deny aspect ratio changes if we use automatic mode and if aspect ratio was set from here. - var arDiff = trueAr - lastAr.ar; + let arDiff = trueAr - lastAr.ar; if (arDiff < 0) arDiff = -arDiff; - var arDiff_percent = arDiff / trueAr; + const arDiff_percent = arDiff / trueAr; // ali je sprememba v mejah dovoljenega? Če da -> fertik // is ar variance within acceptable levels? If yes -> we done From 884db1c5e3ccfd043dfe11fda4fc48216dae153d Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Tue, 12 Jan 2021 23:24:20 +0100 Subject: [PATCH 005/176] Do event listeners properly --- src/ext/lib/video-data/VideoData.js | 83 ++++++++++++++++------------- 1 file changed, 47 insertions(+), 36 deletions(-) diff --git a/src/ext/lib/video-data/VideoData.js b/src/ext/lib/video-data/VideoData.js index 9e62f8f..19f6e40 100644 --- a/src/ext/lib/video-data/VideoData.js +++ b/src/ext/lib/video-data/VideoData.js @@ -71,21 +71,29 @@ class VideoData { this.video.classList.remove('uw-ultrawidify-base-wide-screen'); } + onLoadedData() { + this.logger.log('info', 'init', '[VideoData::ctor->video.onloadeddata] Video fired event "loaded data!"'); + this.onVideoLoaded(); + } + onLoadedMetadata() { + this.logger.log('info', 'init', '[VideoData::ctor->video.onloadedmetadata] Video fired event "loaded metadata!"'); + this.onVideoLoaded(); + } + onTimeUpdate() { + console.info('received timeupdate event!', this); + this.onVideoLoaded(); + } async setupStageOne() { this.logger.log('info', 'init', '%c[VideoData::setupStageOne] ——————————— Starting setup stage one! ———————————', 'color: #0f9'); // ensure base css is loaded before doing anything this.injectBaseCss(); // this is in case extension loads before the video - this.video.addEventListener('loadeddata', () => { - this.logger.log('info', 'init', '[VideoData::ctor->video.onloadeddata] Video fired event "loaded data!"'); - this.onVideoLoaded(); - }); + this.video.addEventListener('loadeddata', this.onLoadedData.bind(this)); + this.video.addEventListener('loadedmetadata', this.onLoadedMetadata.bind(this)); // this one is in case extension loads after the video is loaded - this.video.addEventListener('timeupdate', () => { - this.onVideoLoaded(); - }); + this.video.addEventListener('timeupdate', this.onTimeUpdate.bind(this)); this.logger.log('info', 'init', '%c[VideoData::setupStageOne] ——————————— Setup stage one complete! ———————————', 'color: #0f9'); } @@ -158,6 +166,38 @@ class VideoData { } } + destroy() { + this.logger.log('info', ['debug', 'init'], `[VideoData::destroy] received destroy command`); + + if (this.video) { + this.video.classList.remove(this.userCssClassName); + this.video.classList.remove('uw-ultrawidify-base-wide-screen'); + + this.video.removeEventListener('onloadeddata', this.onLoadedData); + this.video.removeEventListener('onloadedmetadata', this.onLoadedMetadata); + this.video.removeEventListener('ontimeupdate', this.onTimeUpdate); + } + + this.pause(); + this.destroyed = true; + try { + this.arDetector.stop(); + this.arDetector.destroy(); + } catch (e) {} + this.arDetector = undefined; + try { + this.resizer.destroy(); + } catch (e) {} + this.resizer = undefined; + try { + this.player.destroy(); + } catch (e) {} + try { + this.observer.disconnect(); + } catch (e) {} + this.player = undefined; + this.video = undefined; + } restoreCrop() { this.logger.log('info', 'debug', '[VideoData::restoreCrop] Attempting to reset aspect ratio.') @@ -378,35 +418,6 @@ class VideoData { } } - destroy() { - this.logger.log('info', ['debug', 'init'], `[VideoData::destroy] received destroy command`); - - if (this.video) { - this.video.classList.remove(this.userCssClassName); - this.video.classList.remove('uw-ultrawidify-base-wide-screen'); - } - - this.pause(); - this.destroyed = true; - try { - this.arDetector.stop(); - this.arDetector.destroy(); - } catch (e) {} - this.arDetector = undefined; - try { - this.resizer.destroy(); - } catch (e) {} - this.resizer = undefined; - try { - this.player.destroy(); - } catch (e) {} - try { - this.observer.disconnect(); - } catch (e) {} - this.player = undefined; - this.video = undefined; - } - pause(){ this.paused = true; if(this.arDetector){ From 2025547d3375d964da487ddf45b55901b4a8c62d Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Tue, 12 Jan 2021 23:28:17 +0100 Subject: [PATCH 006/176] Un-initalize videoData on illegal video dimensions ($ When youtube changes between two videos, video dimensions briefly become 0x0. This is super duper illegal and sometimes causes the behaviour described in issue #125. Setting VideoData.videoLoaded to false fixes this. --- src/ext/lib/video-data/VideoData.js | 7 +++++++ src/ext/lib/video-transform/Resizer.js | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/ext/lib/video-data/VideoData.js b/src/ext/lib/video-data/VideoData.js index 19f6e40..f0252c9 100644 --- a/src/ext/lib/video-data/VideoData.js +++ b/src/ext/lib/video-data/VideoData.js @@ -33,6 +33,9 @@ class VideoData { async onVideoLoaded() { if (!this.videoLoaded) { + if (this.video.videoWidth && this.video.videoHeight) { + return; // onVideoLoaded is a lie in this case + } this.logger.log('info', 'init', '%c[VideoData::onVideoLoaded] ——————————— Initiating phase two of videoData setup ———————————', 'color: #0f9'); this.videoLoaded = true; @@ -52,6 +55,10 @@ class VideoData { } } + videoUnloaded() { + this.videoLoaded = false; + } + async injectBaseCss() { try { await this.pageInfo.injectCss(` diff --git a/src/ext/lib/video-transform/Resizer.js b/src/ext/lib/video-transform/Resizer.js index 7a5ec8f..6b056eb 100644 --- a/src/ext/lib/video-transform/Resizer.js +++ b/src/ext/lib/video-transform/Resizer.js @@ -146,7 +146,8 @@ class Resizer { } if (!this.video.videoWidth || !this.video.videoHeight) { - this.logger.log('warning', 'debug', '[Resizer::setAr] Video has no width or no height. This is not allowed. Aspect ratio will not be set.'); + this.logger.log('warning', 'debug', '[Resizer::setAr] Video has no width or no height. This is not allowed. Aspect ratio will not be set, and videoData will be uninitialized.'); + this.conf.videoUnloaded(); } this.logger.log('info', 'debug', '[Resizer::setAr] trying to set ar. New ar:', ar) From 437890a609ea073b20ad5901c7ab3a3c1880a65e Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Tue, 12 Jan 2021 23:28:27 +0100 Subject: [PATCH 007/176] Documentation & comments --- src/ext/lib/video-data/VideoData.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/ext/lib/video-data/VideoData.js b/src/ext/lib/video-data/VideoData.js index f0252c9..97de308 100644 --- a/src/ext/lib/video-data/VideoData.js +++ b/src/ext/lib/video-data/VideoData.js @@ -51,7 +51,6 @@ class VideoData { this.restoreCrop(); this.videoDimensionsLoaded = true; - } } @@ -78,6 +77,7 @@ class VideoData { this.video.classList.remove('uw-ultrawidify-base-wide-screen'); } + //#region