diff --git a/CHANGELOG.md b/CHANGELOG.md index 6516863..54bac72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ * Settings page looks ugly af right now. Maybe fix it some time later +### v4.2.4 + +* Improvements to player detection. More details in the [blog post](https://stuff.tamius.net/sacred-texts/2019/08/31/ultrawidify-and-the-improper-cropping/). + + ### v4.2.3 / 4.2.3.1 * Fixed twitchy behaviour on Twitch, Facebook and Twatter. Here's a [blog post](https://stuff.tamius.net/sacred-texts/2019/08/24/ultrawidify-the-twitchy-twitch-problem/) that covers the issue in more detail. diff --git a/package.json b/package.json index 2725202..784df83 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ultravidify", - "version": "4.2.3", + "version": "4.2.4", "description": "Aspect ratio fixer for youtube that works around some people's disability to properly encode 21:9 (and sometimes, 16:9) videos.", "author": "Tamius Han ", "scripts": { diff --git a/src/ext/conf/Debug.js b/src/ext/conf/Debug.js index 9c3e9bf..d1b8387 100644 --- a/src/ext/conf/Debug.js +++ b/src/ext/conf/Debug.js @@ -10,16 +10,14 @@ var Debug = { // resizer: true, // debugArDetect: true, // scaler: true, - // debugStorage: false, // debugStorage: true, // comms: false, // comms: true, // showArDetectCanvas: true, // flushStoredSettings: true, - // flushStoredSettings: false, // playerDetect: true, // periodic: true, - // // videoRescan: true, + // videoRescan: true, // mousemove: true, // arDetect: { // edgeDetect: true diff --git a/src/ext/conf/ExtConfPatches.js b/src/ext/conf/ExtConfPatches.js index 83e36f1..9a1c841 100644 --- a/src/ext/conf/ExtConfPatches.js +++ b/src/ext/conf/ExtConfPatches.js @@ -10,7 +10,7 @@ const ExtensionConfPatch = { player: { manual: true, useRelativeAncestor: false, - querySelectors: '.media-preview-content, .reddit-video-player-root' + querySelectors: '.reddit-video-player-root, .media-preview-content' } }, css: '', @@ -21,7 +21,7 @@ const ExtensionConfPatch = { player: { manual: true, useRelativeAncestor: false, - querySelectors: '.media-preview-content, .reddit-video-player-root' + querySelectors: '.reddit-video-player-root, .media-preview-content' } }, css: '', diff --git a/src/ext/lib/Settings.js b/src/ext/lib/Settings.js index bcca4db..c2190f6 100644 --- a/src/ext/lib/Settings.js +++ b/src/ext/lib/Settings.js @@ -78,7 +78,9 @@ class Settings { const settings = await this.get(); // |—> on first setup, settings is undefined & settings.version is haram - const oldVersion = (settings && settings.version) || '0.0.0'; + // | since new installs ship with updates by default, no patching is + // | needed. In this case, we assume we're on the current version + const oldVersion = (settings && settings.version) || this.getExtensionVersion(); const currentVersion = this.getExtensionVersion(); if(Debug.debug) { @@ -90,43 +92,43 @@ class Settings { if (Debug.flushStoredSettings) { console.log("%c[Settings::init] Debug.flushStoredSettings is true. Using default settings", "background: #d00; color: #ffd"); Debug.flushStoredSettings = false; // don't do it again this session - this.setDefaultSettings(); this.active = this.getDefaultSettings(); + this.active.version = currentVersion; + this.set(this.active); return this.active; } } // if there's no settings saved, return default settings. if(! settings || (Object.keys(settings).length === 0 && settings.constructor === Object)) { - this.setDefaultSettings(); this.active = this.getDefaultSettings(); + this.active.version = currentVersion; + this.set(this.active); return this.active; } // if last saved settings was for version prior to 4.x, we reset settings to default // it's not like people will notice cos that version didn't preserve settings at all if (settings.version && !settings.version.startsWith('4')) { - this.setDefaultSettings(); this.active = this.getDefaultSettings(); + this.active.version = currentVersion; + this.set(this.active); return this.active; } + // in every case, we'll update the version number: + settings.version = currentVersion; + // if there's settings, set saved object as active settings this.active = settings; - // from some point to 4.2.3.1, settings version wasn't saved. Fix that. - if (!settings.version) { - this.active.version = currentVersion; - } - // check if extension has been updated. If not, return settings as they were retreived - if(oldVersion === currentVersion) { + if (oldVersion == currentVersion) { if(Debug.debug) { console.log("[Settings::init] extension was saved with current version of ultrawidify. Returning object as-is."); } - return this.active; } @@ -223,6 +225,7 @@ class Settings { } setDefaultSettings() { + this.default.version = this.getExtensionVersion(); this.set(this.default); } diff --git a/src/ext/lib/video-data/PlayerData.js b/src/ext/lib/video-data/PlayerData.js index 1b654bf..acbda74 100644 --- a/src/ext/lib/video-data/PlayerData.js +++ b/src/ext/lib/video-data/PlayerData.js @@ -236,6 +236,7 @@ class PlayerData { getPlayer(isFullScreen) { const host = window.location.host; let element = this.video.parentNode; + const videoWidth = this.video.offsetWidth, videoHeight = this.video.offsetHeight; if(! element ){ if(Debug.debug) { @@ -274,18 +275,11 @@ class PlayerData { } } + const elementQ = []; + let scorePenalty = 0; + let score; - var trustCandidateAfterGrows = 2; // if candidate_width or candidate_height increases in either dimensions this many - // times, we say we found our player. (This number ignores weird elements) - // in case our