From 4d88ab44529319b7a72dde53de8ea60586945bf9 Mon Sep 17 00:00:00 2001 From: Justin Cherniak Date: Tue, 4 Oct 2022 11:09:29 +0100 Subject: [PATCH] Allow setting of Zoom factor for webview to fix small sites --- MMM-WebView.js | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/MMM-WebView.js b/MMM-WebView.js index 709419a..a824b50 100644 --- a/MMM-WebView.js +++ b/MMM-WebView.js @@ -15,6 +15,7 @@ Module.register('MMM-WebView', { autoRefresh: false, autoRefreshInterval: 10 * 60 * 1000, loadedJS: undefined, + zoomfactor: undefined, }, start: function () { if (this.config.autoRefresh) { @@ -33,17 +34,23 @@ Module.register('MMM-WebView', { return wrapper; }, notificationReceived: function (notification, payload, sender) { - if (notification == 'MODULE_DOM_CREATED') { + if (notification != 'MODULE_DOM_CREATED') { + return; + } + + const webview = document.getElementById(WEBVIEW_ID); + if (!webview) { + return; + } + + webview.addEventListener('did-finish-load', () => { if (this.config.loadedJS && this.config.loadedJS.length > 0) { - const webview = document.getElementById(WEBVIEW_ID); - if (webview) { - webview.addEventListener('did-finish-load', () => { - webview.executeJavaScript(this.config.loadedJS); - }); - } else { - // TODO: Show Error - } + webview.executeJavaScript(this.config.loadedJS); } - } + + if (this.config.zoomfactor) { + webview.setZoomFactor(this.config.zoomfactor); + } + }); }, });