Merge branch '4.2.4' into stable

This commit is contained in:
Tamius Han 2019-09-01 01:52:34 +02:00
commit 8e21bb8f92
5 changed files with 42 additions and 12 deletions

View File

@ -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/).</li>
* 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)

View File

@ -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: '',

View File

@ -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

View File

@ -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}"

View File

@ -5,6 +5,8 @@
<p class="label">4.2.4</p>
<ul>
<li>Improvements to player detection. More details in the <a href="https://stuff.tamius.net/sacred-texts/2019/08/31/ultrawidify-and-the-improper-cropping/" target="_blank">blog post</a>.</li>
<li><b>[4.2.4.1]</b> Fixed default settings for reddit</li>
<li><b>[4.2.4.1]</b> Manually specified query selectors are now also checked for compliance with player detection rules.</li>
</ul>
<p v-if="BrowserDetect.chrome"><b>Chrome users:</b> 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