fixed #24 and prolly #23

This commit is contained in:
Tamius Han 2018-02-22 22:14:52 +01:00
commit 728fa0a0b3
5 changed files with 24 additions and 32 deletions

View File

@ -81,6 +81,10 @@ Manually triggering aspect ratio change will suspend automatic aspect ratio dete
## Changelog
### v2.1.3
* Youtube pushed an update that broke this extension on Firefox (but not on Chrome?). This update fixes it.
### v2.1.2
* Fixed some bugs with autodetection sometimes not working properly on Youtube.
@ -162,7 +166,7 @@ Furthermore, triggering UI re-initialisation on onUpdated events turned out to n
This is why Netflix uses another function that manually checks whether the player bar is present. Ideally that check happens every tenth of a second, but Firefox may be limiting that to one per second.
###v1.0.2
### v1.0.2
The 'extension sometimes not working' bug was fixed (by having extension try to setup every time a page got updated), but the fix had some problems. Namely, the extension would re-initiate (complete with re-adding the entire UI) itself very _very_ often.

View File

@ -10,6 +10,7 @@ Debug = {
debugStorage: true,
showArDetectCanvas: true,
flushStoredSettings: false,
playerDetectDebug: false
arDetect: {
edgeDetect: true
}

View File

@ -14,6 +14,8 @@ var _se_init = async function(neverFlushStored){
var newSettings = await StorageManager.getopt_async("uw-settings");
var uwVersion = browser.runtime.getManifest().version;
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), ")");
@ -23,6 +25,10 @@ var _se_init = async function(neverFlushStored){
}
else{
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)
console.log("[Settings::_se_init()] parsed settings:", actualSettings);

View File

@ -47,7 +47,8 @@ var _pd_getPlayerDimensions = function(element){
return;
}
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
// if site is coded properly, player can't be wider than that
var candidate_width = Math.max(element.offsetWidth, screen.width);
@ -64,15 +65,22 @@ var _pd_getPlayerDimensions = function(element){
continue;
}
if ( element.offsetHeight <= candidate_height &&
element.offsetWidth <= candidate_width ){
playerCandidateNode = element;
candidate_width = element.offsetWidth;
candidate_height = element.offsetHeight;
// if(Debug.debug){
// console.log("Found new candidate for player. Dimensions: w:", candidate_width, "h:",candidate_height);
// }
if(Debug.debug){
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;

View File

@ -6,33 +6,6 @@ if(Debug.debug)
// calling _res_restore() for some weird reason.
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){
// Kot vhodni argument dobimo razmerje stranic. Problem je, ker pri nekaterih ločljivostih lahko razmerje stranic