fix for youtube screwy that happened this week

This commit is contained in:
Tamius Han 2018-02-22 22:10:13 +01:00
parent 4daa054169
commit 3896bff39b
5 changed files with 21 additions and 33 deletions

View File

@ -9,7 +9,8 @@ Debug = {
debugArDetect: true, debugArDetect: true,
debugStorage: true, debugStorage: true,
showArDetectCanvas: false, showArDetectCanvas: false,
flushStoredSettings: false flushStoredSettings: false,
playerDetectDebug: false
} }
if(_prod){ if(_prod){

View File

@ -14,6 +14,8 @@ var _se_init = async function(neverFlushStored){
var newSettings = await StorageManager.getopt_async("uw-settings"); var newSettings = await StorageManager.getopt_async("uw-settings");
var uwVersion = browser.runtime.getManifest().version;
if (Debug.debug) if (Debug.debug)
console.log("[Settings::_se_init()] settings saved in localstorage are:", newSettings, " - if that's empty, it's gonna be replaced by this:", JSON.stringify(this), ")"); console.log("[Settings::_se_init()] settings saved in localstorage are:", newSettings, " - if that's empty, it's gonna be replaced by this:", JSON.stringify(this), ")");
@ -23,6 +25,10 @@ var _se_init = async function(neverFlushStored){
} }
else{ else{
var actualSettings = JSON.parse(newSettings["uw-settings"]); var actualSettings = JSON.parse(newSettings["uw-settings"]);
if(actualSettings.version === undefined || actualSettings.version != uwVersion){
console.log("[Settings::_se_init()] extension was updated, replacing settings");
StorageManager.setopt({"uw-settings": JSON.stringify(this)});
}
if(Debug.debug) if(Debug.debug)
console.log("[Settings::_se_init()] parsed settings:", actualSettings); console.log("[Settings::_se_init()] parsed settings:", actualSettings);

View File

@ -47,7 +47,8 @@ var _pd_getPlayerDimensions = function(element){
return; return;
} }
var playerCandidateNode = element; var playerCandidateNode = element;
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 <video> is bigger than player in one dimension but smaller in the other // in case our <video> is bigger than player in one dimension but smaller in the other
// if site is coded properly, player can't be wider than that // if site is coded properly, player can't be wider than that
var candidate_width = Math.max(element.offsetWidth, screen.width); var candidate_width = Math.max(element.offsetWidth, screen.width);
@ -64,15 +65,22 @@ var _pd_getPlayerDimensions = function(element){
continue; continue;
} }
if ( element.offsetHeight <= candidate_height && if ( element.offsetHeight <= candidate_height &&
element.offsetWidth <= candidate_width ){ element.offsetWidth <= candidate_width ){
playerCandidateNode = element; playerCandidateNode = element;
candidate_width = element.offsetWidth; candidate_width = element.offsetWidth;
candidate_height = element.offsetHeight; candidate_height = element.offsetHeight;
// if(Debug.debug){ if(Debug.debug){
// console.log("Found new candidate for player. Dimensions: w:", candidate_width, "h:",candidate_height); console.log("Found new candidate for player. Dimensions: w:", candidate_width, "h:",candidate_height, "node:", playerCandidateNode);
// } }
}
else if(trustCandidateAfterGrows --<= 0){
if(Debug.debug && Debug.playerDetect){
console.log("Current element grew in comparrison to the child. We probably found the player. breaking loop, returning current result");
}
break;
} }
element = element.parentNode; element = element.parentNode;

View File

@ -6,33 +6,6 @@ if(Debug.debug)
// calling _res_restore() for some weird reason. // calling _res_restore() for some weird reason.
var _res_restore_wd = false; var _res_restore_wd = false;
var _res_manual_autoar = function(siteProps){
if(! siteProps.autoar_imdb.enabled)
return;
if(siteProps.autoar_imdb.isClass)
var ntitle = document.querySelector("."+ siteProps.autoar_imdb.title); // NOTE: needs to be tested
else
var ntitle = document.querySelector("#"+ siteProps.autoar_imdb.title); // NOTE: needs to be tested
//querySelector lahko vrne null, zato moramo preveriti, kaj smo dobili — drugače se .textContent pritožuje.
//querySelector can return null, in which case .textContent will complain.
if(!ntitle)
return;
var title = ntitle.textContent;
char_got_ar = false;
last_whatdo = {type: "autoar", what_do:"autoar"};
var sending = browser.runtime.sendMessage({
type: "gibAspectRatio",
title: title
});
// sending.then( function(){}, function(err1, err2){console.log("uw::periodic: there was an error while sending a message", err1, err2)} );
}
var _res_char = function(newAr, video, player){ var _res_char = function(newAr, video, player){
// Kot vhodni argument dobimo razmerje stranic. Problem je, ker pri nekaterih ločljivostih lahko razmerje stranic // Kot vhodni argument dobimo razmerje stranic. Problem je, ker pri nekaterih ločljivostih lahko razmerje stranic

View File

@ -1,7 +1,7 @@
{ {
"manifest_version": 2, "manifest_version": 2,
"name": "Ultrawidify", "name": "Ultrawidify",
"version": "2.1.2", "version": "2.1.3",
"icons": { "icons": {
"32":"res/icons/uw-32.png", "32":"res/icons/uw-32.png",