diff --git a/js/lib/Comms.js b/js/lib/Comms.js index bb3c652..52965e4 100644 --- a/js/lib/Comms.js +++ b/js/lib/Comms.js @@ -16,6 +16,7 @@ class CommsClient { this.port.onMessage.addListener(m => ths.processReceivedMessage(m)); this.settings = settings; + this.pageInfo = undefined; } setPageInfo(pageInfo){ @@ -27,6 +28,13 @@ class CommsClient { console.log("[CommsClient.js::processMessage] Received message from background script!", message); } + if (! this.pageInfo) { + if(Debug.debug && Debug.comms){ + console.log("[CommsClient.js::processMessage] this.pageInfo not defined. Extension is probably disabled for this site."); + } + return; + } + if (message.cmd === "set-ar") { this.pageInfo.setAr(message.ratio); } else if (message.cmd === 'set-video-float') { @@ -282,6 +290,7 @@ class CommsServer { } else if (message.cmd === "set-autoar-for-site") { if (this.settings.active.sites[this.server.currentSite]) { this.settings.active.sites[this.server.currentSite].arStatus = message.mode; + console.log("SAVING AUTOAR MODE FOR SITE", this.server.currentSite, "\nnew site obj",this.settings.active.sites[this.server.currentSite] ) this.settings.save(); } else { this.settings.active.sites[this.server.currentSite] = { diff --git a/js/modules/PageInfo.js b/js/modules/PageInfo.js index a9336de..48db0f0 100644 --- a/js/modules/PageInfo.js +++ b/js/modules/PageInfo.js @@ -17,6 +17,7 @@ class PageInfo { if(comms){ this.comms = comms; + this.comms.setPageInfo(this); if(this.videos.length > 0){ comms.registerVideo(); } @@ -24,7 +25,7 @@ class PageInfo { } - reset(){ + reset() { for(video of this.videos) { video.destroy(); } diff --git a/js/uw.js b/js/uw.js index 98054c9..f747f2a 100644 --- a/js/uw.js +++ b/js/uw.js @@ -57,7 +57,6 @@ async function init(){ } pageInfo = new PageInfo(comms, settings); - comms.setPageInfo(pageInfo); if(Debug.debug){ console.log("[uw.js::setup] pageInfo initialized. Here's the object:", pageInfo);