diff --git a/CHANGELOG.md b/CHANGELOG.md index 54bac72..2d903c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,12 +6,14 @@ * Settings page looks ugly af right now. Maybe fix it some time later -### v4.2.4 +### v4.2.4 / 4.2.4.x -* Improvements to player detection. More details in the [blog post](https://stuff.tamius.net/sacred-texts/2019/08/31/ultrawidify-and-the-improper-cropping/). +* Improvements to player detection. More details in the [blog post](https://stuff.tamius.net/sacred-texts/2019/08/31/ultrawidify-and-the-improper-cropping/). +* **[4.2.4.1]** Fixed default video settings for reddit +* **[4.2.4.1]** Manually specified query selectors will also be checked for compliance with player detection rules. -### v4.2.3 / 4.2.3.1 +### v4.2.3 / 4.2.3.x * 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. * Cropping now uses user styles (as opposed to modifying element's style attribute) diff --git a/src/ext/conf/ExtensionConf.js b/src/ext/conf/ExtensionConf.js index 9a4d4ec..bf481c1 100644 --- a/src/ext/conf/ExtensionConf.js +++ b/src/ext/conf/ExtensionConf.js @@ -975,7 +975,7 @@ whatsNewChecked: true, player: { manual: true, useRelativeAncestor: false, - querySelectors: '.media-preview-content' + querySelectors: '.reddit-video-player-root, .media-preview-content' } }, css: '', @@ -992,7 +992,7 @@ whatsNewChecked: true, player: { manual: true, useRelativeAncestor: false, - querySelectors: '.media-preview-content' + querySelectors: '.reddit-video-player-root, .media-preview-content' } }, css: '', diff --git a/src/ext/lib/video-data/PlayerData.js b/src/ext/lib/video-data/PlayerData.js index acbda74..bd3538c 100644 --- a/src/ext/lib/video-data/PlayerData.js +++ b/src/ext/lib/video-data/PlayerData.js @@ -237,6 +237,9 @@ class PlayerData { const host = window.location.host; let element = this.video.parentNode; const videoWidth = this.video.offsetWidth, videoHeight = this.video.offsetHeight; + const elementQ = []; + let scorePenalty = 0; + let score; if(! element ){ if(Debug.debug) { @@ -266,18 +269,41 @@ class PlayerData { } } else if (this.settings.active.sites[host].DOM.player.querySelectors) { const allSelectors = document.querySelectorAll(this.settings.active.sites[host].DOM.player.querySelectors); - while (element && !this.collectionHas(allSelectors, element)) { + + // actually we'll also score this branch in a similar way we score the regular, auto branch + while (element !== undefined) { + + // Let's see how this works + if (this.collectionHas(allSelectors, element)) { + score = 100; // every matching element gets a baseline 100 points + + // elements that match the size get a hefty bonus + if ( (element.offsetWidth >= videoWidth && this.equalish(element.offsetHeight, videoHeight, 2)) + || (element.offsetHeight >= videoHeight && this.equalish(element.offsetWidth, videoHeight, 2))) { + score += 75; + } + + // elements farther away from the video get a penalty + score -= (scorePenalty++) * 20; + + // push the element on the queue/stack: + elementQ.push({ + score: score, + element: element, + }); + } + element = element.parentNode; } - if (element) { - return element; + if (elementQ.length) { + // return element with biggest score + // if video player has not been found, proceed to automatic detection + return elementQ.sort( (a,b) => b.score - a.score)[0].element; } } } - const elementQ = []; - let scorePenalty = 0; - let score; + while (element != undefined){ // odstranimo Ĩudne elemente, ti bi pokvarili zadeve diff --git a/src/manifest.json b/src/manifest.json index 0869dd4..b7c9529 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "Ultrawidify", "description": "Removes black bars on ultrawide videos and offers advanced options to fix aspect ratio.", - "version": "4.2.4", + "version": "4.2.4.1", "applications": { "gecko": { "id": "{cf02b1a7-a01a-4e37-a609-516a283f1ed3}" diff --git a/src/popup/panels/WhatsNewPanel.vue b/src/popup/panels/WhatsNewPanel.vue index fe12d09..7617692 100644 --- a/src/popup/panels/WhatsNewPanel.vue +++ b/src/popup/panels/WhatsNewPanel.vue @@ -5,6 +5,8 @@
4.2.4
Chrome users: as a result of Chrome's shortcomings, there now exists one potential performance issue. If you notice any performance issues, please contact me via github, email or reddit (see: 'report a problem' tab