From 3896bff39bb326d130348f42299241605a19e7cd Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Thu, 22 Feb 2018 22:10:13 +0100 Subject: [PATCH] fix for youtube screwy that happened this week --- js/conf/Debug.js | 3 ++- js/conf/Settings.js | 6 ++++++ js/lib/PlayerDetect.js | 16 ++++++++++++---- js/modules/Resizer.js | 27 --------------------------- manifest.json | 2 +- 5 files changed, 21 insertions(+), 33 deletions(-) diff --git a/js/conf/Debug.js b/js/conf/Debug.js index 27ae3d4..f06b599 100644 --- a/js/conf/Debug.js +++ b/js/conf/Debug.js @@ -9,7 +9,8 @@ Debug = { debugArDetect: true, debugStorage: true, showArDetectCanvas: false, - flushStoredSettings: false + flushStoredSettings: false, + playerDetectDebug: false } if(_prod){ diff --git a/js/conf/Settings.js b/js/conf/Settings.js index acb4bed..5aa2423 100644 --- a/js/conf/Settings.js +++ b/js/conf/Settings.js @@ -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); diff --git a/js/lib/PlayerDetect.js b/js/lib/PlayerDetect.js index 13e4b74..a451211 100644 --- a/js/lib/PlayerDetect.js +++ b/js/lib/PlayerDetect.js @@ -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