diff --git a/js/lib/Comms.js b/js/lib/Comms.js index 2e3d727..bb3c652 100644 --- a/js/lib/Comms.js +++ b/js/lib/Comms.js @@ -3,7 +3,7 @@ if(Debug.debug){ } class CommsClient { - constructor(name) { + constructor(name, settings) { if (BrowserDetect.firefox) { this.port = browser.runtime.connect({name: name}); } else if (BrowserDetect.chrome) { @@ -12,13 +12,10 @@ class CommsClient { this.port = browser.runtime.connect({name: name}) } - console.log("BrowserDetect", BrowserDetect) - console.log("!! port", this.port) var ths = this; this.port.onMessage.addListener(m => ths.processReceivedMessage(m)); - this.hasSettings = false; - this.settings = new Settings(); + this.settings = settings; } setPageInfo(pageInfo){ @@ -33,7 +30,7 @@ class CommsClient { if (message.cmd === "set-ar") { this.pageInfo.setAr(message.ratio); } else if (message.cmd === 'set-video-float') { - this.settings.active.miscFullscreenthis.settings.videoFloat = message.newFloat; + this.settings.active.miscFullscreenSettings.videoFloat = message.newFloat; this.pageInfo.restoreAr(); } else if (message.cmd === "has-videos") { diff --git a/js/uw-bg.js b/js/uw-bg.js index 35a02ea..ce40531 100644 --- a/js/uw-bg.js +++ b/js/uw-bg.js @@ -23,9 +23,9 @@ class UWServer { var ths = this; if(BrowserDetect.firefox) { - browser.tabs.onActivated.addListener((m) => ths.onTabSwitched(m)); + browser.tabs.onActivated.addListener(function(m) {ths.onTabSwitched(m)}); } else if (BrowserDetect.chrome) { - chrome.tabs.onActivated.addListener((m) => ths.onTabSwitched(m)); + chrome.tabs.onActivated.addListener(function(m) {ths.onTabSwitched(m)}); } } diff --git a/js/uw.js b/js/uw.js index 06e580d..98054c9 100644 --- a/js/uw.js +++ b/js/uw.js @@ -21,7 +21,11 @@ async function init(){ if(Debug.debug) console.log("[uw::main] loading configuration ..."); - comms = new CommsClient('content-client-port'); + + settings = new Settings(); + await settings.init(); + + comms = new CommsClient('content-client-port', settings); // load settings // var settingsLoaded = await comms.requestSettings(); @@ -39,8 +43,7 @@ async function init(){ // if(Debug.debug) // console.log("[uw::main] configuration should be loaded now"); - settings = new Settings(); - await settings.init(); + console.log("SETTINGS SHOULD BE LOADED NOW!", settings)