diff --git a/js/lib/Comms.js b/js/lib/Comms.js index 1b66e96..f24fc24 100644 --- a/js/lib/Comms.js +++ b/js/lib/Comms.js @@ -20,8 +20,11 @@ class CommsClient { console.log("[CommsClient.js::processMessage] Received message from background script!", message); } - if(message.cmd === "set-ar"){ + if (message.cmd === "set-ar") { this.pageInfo.setAr(message.ratio); + } else if (message.cmd === 'set-video-float') { + ExtensionConf.miscFullscreenSettings.videoFloat = message.newFloat; + this.pageInfo.restoreAr(); } else if (message.cmd === "has-videos") { } else if (message.cmd === "set-config") { @@ -239,6 +242,12 @@ class CommsServer { ExtensionConf.keyboard.shortcuts.q.arg = message.ratio; Settings.save(ExtensionConf); this.sendToAll({cmd: 'reload-settings', newConf: ExtensionConf}); + } else if (message.cmd === 'set-video-float') { + this.sendToActive(message); + ExtensionConf.miscFullscreenSettings.videoFloat = message.newFloat; + Settings.save(ExtensionConf); + this.sendToAll({cmd: 'reload-settings', newConf: ExtensionConf}); + } else if (message.cmd === 'autoar-start') { this.sendToActive(message); } else if (message.cmd === "autoar-enable") { // LEGACY - can be removed prolly? diff --git a/js/lib/GuardLine.js b/js/lib/GuardLine.js index c0a0873..7183ca5 100644 --- a/js/lib/GuardLine.js +++ b/js/lib/GuardLine.js @@ -90,7 +90,7 @@ class GuardLine { // should succeed by default. Also need to check bottom, for cases where only one edge is known if(! fallbackMode && (! this.blackbar.top || ! this.blackbar.bottom)) { - console.log("NO EDGE WAS DETECTED. THIS TEST IS POINTLESS. btw guardline") + // console.log("NO EDGE WAS DETECTED. THIS TEST IS POINTLESS. btw guardline") return { success: true }; } diff --git a/js/lib/VideoData.js b/js/lib/VideoData.js index b985681..41c0fc5 100644 --- a/js/lib/VideoData.js +++ b/js/lib/VideoData.js @@ -95,6 +95,10 @@ class VideoData { this.resizer.setAr(ar, lastAr); } + restoreAr(){ + this.resizer.restore(); + } + setStretchMode(stretchMode){ this.resizer.setStretchMode(stretchMode); } diff --git a/js/modules/ArDetect.js b/js/modules/ArDetect.js index 1c365f1..240b818 100644 --- a/js/modules/ArDetect.js +++ b/js/modules/ArDetect.js @@ -348,7 +348,9 @@ class ArDetector { if(this.fallbackMode){ if(edges.top > 1 && edges.top <= ExtensionConf.arDetect.fallbackMode.noTriggerZonePx ){ - console.log("Edge is in the no-trigger zone. Aspect ratio change is not triggered.") + if(Debug.debug && Debug.debugArDetect) { + console.log("Edge is in the no-trigger zone. Aspect ratio change is not triggered.") + } return; } @@ -450,9 +452,10 @@ class ArDetector { this.context.drawImage(this.video, 0,0, this.canvas.width, this.canvas.height); } catch(ex){ - if(Debug.debug) + if(Debug.debug) { console.log("%c[ArDetect::_ard_vdraw] can't draw image on canvas. Trying canvas.drawWindow instead", "color:#000; backgroud:#f51;", ex); - + } + try{ if(! ExtensionConf.arDetect.fallbackMode.enabled) throw "fallbackMode is disabled."; diff --git a/js/modules/PageInfo.js b/js/modules/PageInfo.js index a79a967..7cd183c 100644 --- a/js/modules/PageInfo.js +++ b/js/modules/PageInfo.js @@ -215,6 +215,12 @@ class PageInfo { } } + restoreAr() { + for(var vd of this.videos){ + vd.restoreAr() + } + } + setStretchMode(sm){ // TODO: find a way to only change aspect ratio for one video diff --git a/js/modules/Resizer.js b/js/modules/Resizer.js index 6bf484f..313033d 100644 --- a/js/modules/Resizer.js +++ b/js/modules/Resizer.js @@ -67,11 +67,12 @@ class Resizer { } // pause AR on basic stretch, unpause when using other mdoes - if (this.stretcher.mode === StretchMode.BASIC) { - this.conf.arDetector.pause(); - } else { - this.conf.arDetector.unpause(); - } + // fir sine reason unpause doesn't unpause. investigate that later + // if (this.stretcher.mode === StretchMode.BASIC) { + // this.conf.arDetector.pause(); + // } else { + // this.conf.arDetector.unpause(); + // } // do stretch thingy if (this.stretcher.mode === StretchMode.NO_STRETCH || this.stretcher.mode === StretchMode.CONDITIONAL){ @@ -205,14 +206,14 @@ class Resizer { var translate = {x: 0, y: 0}; - if(this.pan){ + if (this.pan) { // todo: calculate translate } else { - if( ExtensionConf.miscFullscreenSettings.videoFloat == "left" ){ - translate.x = (this.conf.player.dimensions.width - actualWidth ) * -0.5; + if (ExtensionConf.miscFullscreenSettings.videoFloat == "left") { + translate.x = (this.conf.player.dimensions.width - actualWidth) * -0.5; } - else if( ExtensionConf.miscFullscreenSettings.videoFloat == "right" ){ - translate.x = (this.conf.player.dimensions.width - actualWidth ) * 0.5; + else if (ExtensionConf.miscFullscreenSettings.videoFloat == "right") { + translate.x = (this.conf.player.dimensions.width - actualWidth) * 0.5; } } @@ -221,7 +222,7 @@ class Resizer { applyCss(stretchFactors, translate){ - if (! this.video ){ + if (! this.video) { if(Debug.debug) console.log("[Resizer::_res_applyCss] Video went missing, doing nothing."); this.conf.destroy(); @@ -266,9 +267,6 @@ class Resizer { styleString += styleArray[i] + "; "; this.setStyleString(styleString); - - - } setStyleString (styleString, count = 0) { diff --git a/res/popup/js/popup.js b/res/popup/js/popup.js index 64e0770..6625f40 100644 --- a/res/popup/js/popup.js +++ b/res/popup/js/popup.js @@ -587,7 +587,7 @@ document.addEventListener("click", (e) => { command.global = true; if(e.target.classList.contains("_align_left")){ - command.cmd = "force-video-float", + command.cmd = "set-video-float", command.newFloat = "left" // console.log(".................\n\n\n..........\n\n >>command<< \n\n\n\n ",command,"\n\n\n.........\n\n\n................................"); @@ -595,12 +595,12 @@ document.addEventListener("click", (e) => { return command; } if(e.target.classList.contains("_align_center")){ - command.cmd = "force-video-float" + command.cmd = "set-video-float" command.newFloat = "center" return command; } if(e.target.classList.contains("_align_right")){ - command.cmd = "force-video-float"; + command.cmd = "set-video-float"; command.newFloat = "right"; return command; }