From 7eca642da3c9b712987dd1b26837023323c34cc8 Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Fri, 14 Feb 2020 20:29:38 +0100 Subject: [PATCH 01/15] Let's take away 'tabs' permission, since activeTab seems to do the job just fine --- src/manifest.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/manifest.json b/src/manifest.json index e7cab81..82efb71 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -57,7 +57,10 @@ "res/img/settings/about-bg.png" ], "permissions": [ - "tabs", "storage", "activeTab", "", "webNavigation" + "storage", + "activeTab", + "", + "webNavigation" ], "optional_permissions": [ "downloads" From 72b28918e9e5974812e1508b12a32a30fe974c07 Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Fri, 14 Feb 2020 20:55:20 +0100 Subject: [PATCH 02/15] Try disabling minimization --- webpack.config.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/webpack.config.js b/webpack.config.js index fed7bd0..aae9571 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -139,6 +139,9 @@ const config = { 'process.env.CHANNEL': JSON.stringify(process.env.CHANNEL) }) ], + optimization: { + minimize: false, + } }; if (config.mode === 'production') { From 66169ddeb18c07a9758c61762528b806478644e2 Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Fri, 14 Feb 2020 21:45:31 +0100 Subject: [PATCH 03/15] Remove scheduleGc to avoid webNavigation --- src/ext/uw-bg.js | 41 ----------------------------------------- src/manifest.json | 3 +-- 2 files changed, 1 insertion(+), 43 deletions(-) diff --git a/src/ext/uw-bg.js b/src/ext/uw-bg.js index 550e5ee..42cd0ce 100644 --- a/src/ext/uw-bg.js +++ b/src/ext/uw-bg.js @@ -56,8 +56,6 @@ class UWServer { } else if (BrowserDetect.chrome) { chrome.tabs.onActivated.addListener(function(m) {ths.onTabSwitched(m)}); } - - this.scheduleGc(); } async _promisifyTabsGet(browserObj, tabId){ @@ -97,23 +95,6 @@ class UWServer { } } - scheduleGc(timeout) { - if (this._gctimeout) { - return; - } - if (!timeout) { - timeout = 0; - } - - const ths = this; - setTimeout( () => { - clearTimeout(ths._gctimeout); - ths.gcFrames(); - - ths._gctimeoutgcTimeout = ths.scheduleGc(5000); - }, timeout); - } - extractHostname(url){ var hostname; @@ -157,28 +138,6 @@ class UWServer { //TODO: change extension icon based on whether there's any videos on current page } - async gcFrames() { - // does "garbage collection" on frames - - let frames; - - if (BrowserDetect.firefox) { - frames = await browser.webNavigation.getAllFrames({tabId: this.currentTabId}); - } else if (BrowserDetect.chrome) { - frames = await new Promise( (resolve, reject) => { - chrome.webNavigation.getAllFrames({tabId: this.currentTabId}, (data) => {resolve(data); return true}); - }); - } - - if (this.videoTabs[this.currentTabId]) { - for (let key in this.videoTabs[this.currentTabId].frames) { - if (! frames.find(x => x.frameId == key)) { - delete this.videoTabs[this.currentTabId].frames[key]; - } - } - } - } - registerVideo(sender) { this.logger.log('info', 'comms', '[UWServer::registerVideo] Registering video.\nsender:', sender); diff --git a/src/manifest.json b/src/manifest.json index 82efb71..6ffb2c9 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -59,8 +59,7 @@ "permissions": [ "storage", "activeTab", - "", - "webNavigation" + "" ], "optional_permissions": [ "downloads" From 4c0aca48fd9515f6923c4ce073b30e6baa461356 Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Wed, 26 Feb 2020 00:42:41 +0100 Subject: [PATCH 04/15] Add "first time" and "updated" pages templates. --- src/install/first-time/App.vue | 214 ++++++++++++++++++++++++ src/install/first-time/first-time.html | 18 +++ src/install/first-time/first-time.js | 11 ++ src/install/updated/App.vue | 215 +++++++++++++++++++++++++ src/install/updated/first-time.html | 18 +++ src/install/updated/first-time.js | 11 ++ 6 files changed, 487 insertions(+) create mode 100644 src/install/first-time/App.vue create mode 100644 src/install/first-time/first-time.html create mode 100644 src/install/first-time/first-time.js create mode 100644 src/install/updated/App.vue create mode 100644 src/install/updated/first-time.html create mode 100644 src/install/updated/first-time.js diff --git a/src/install/first-time/App.vue b/src/install/first-time/App.vue new file mode 100644 index 0000000..68cf9cf --- /dev/null +++ b/src/install/first-time/App.vue @@ -0,0 +1,214 @@ + + + + + + + + + + diff --git a/src/install/first-time/first-time.html b/src/install/first-time/first-time.html new file mode 100644 index 0000000..c66736c --- /dev/null +++ b/src/install/first-time/first-time.html @@ -0,0 +1,18 @@ + + + + + Title + + + <% if (NODE_ENV === 'development') { %> + + <% } %> + + +
+ +
+ + + diff --git a/src/install/first-time/first-time.js b/src/install/first-time/first-time.js new file mode 100644 index 0000000..b3688db --- /dev/null +++ b/src/install/first-time/first-time.js @@ -0,0 +1,11 @@ +import Vue from 'vue' +import App from './App' + +// global.browser = require('webextension-polyfill') +// Vue.prototype.$browser = global.browser + +/* eslint-disable no-new */ +new Vue({ + el: '#app', + render: h => h(App) +}) diff --git a/src/install/updated/App.vue b/src/install/updated/App.vue new file mode 100644 index 0000000..fc71851 --- /dev/null +++ b/src/install/updated/App.vue @@ -0,0 +1,215 @@ + + + + + + + + + + diff --git a/src/install/updated/first-time.html b/src/install/updated/first-time.html new file mode 100644 index 0000000..c66736c --- /dev/null +++ b/src/install/updated/first-time.html @@ -0,0 +1,18 @@ + + + + + Title + + + <% if (NODE_ENV === 'development') { %> + + <% } %> + + +
+ +
+ + + diff --git a/src/install/updated/first-time.js b/src/install/updated/first-time.js new file mode 100644 index 0000000..b3688db --- /dev/null +++ b/src/install/updated/first-time.js @@ -0,0 +1,11 @@ +import Vue from 'vue' +import App from './App' + +// global.browser = require('webextension-polyfill') +// Vue.prototype.$browser = global.browser + +/* eslint-disable no-new */ +new Vue({ + el: '#app', + render: h => h(App) +}) From acfa8332032e7b2f4ea76039fa256b8f120e7b51 Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Wed, 26 Feb 2020 00:43:01 +0100 Subject: [PATCH 05/15] Some stuff for easier logging configuration - wip --- src/common/components/JsonExplorer.vue | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/common/components/JsonExplorer.vue diff --git a/src/common/components/JsonExplorer.vue b/src/common/components/JsonExplorer.vue new file mode 100644 index 0000000..5850dcd --- /dev/null +++ b/src/common/components/JsonExplorer.vue @@ -0,0 +1,28 @@ + + \ No newline at end of file From d009b53dba822296ae0388945828309bdf259a56 Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Wed, 26 Feb 2020 00:44:28 +0100 Subject: [PATCH 06/15] update webpack to include new install/update pages --- webpack.config.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/webpack.config.js b/webpack.config.js index aae9571..4540616 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -15,6 +15,7 @@ const config = { 'ext/uw-bg': './ext/uw-bg.js', 'popup/popup': './popup/popup.js', 'options/options': './options/options.js', + 'install/first-time/first-time':'./install/first-time/first-time.js', }, output: { path: __dirname + `/dist-${process.env.BROWSER == 'firefox' ? 'ff' : process.env.BROWSER}`, @@ -78,6 +79,7 @@ const config = { { from: 'icons', to: 'icons', ignore: ['icon.xcf'] }, { from: 'popup/popup.html', to: 'popup/popup.html', transform: transformHtml }, { from: 'options/options.html', to: 'options/options.html', transform: transformHtml }, + { from: 'install/first-time/first-time.html', to: 'install/first-time/first-time.html', transform: transformHtml}, { from: 'manifest.json', to: 'manifest.json', From 9a2261faed9a8d9c809eda97017b77755a8e2cb5 Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Wed, 26 Feb 2020 00:45:06 +0100 Subject: [PATCH 07/15] whitespace --- src/ext/uw.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/ext/uw.js b/src/ext/uw.js index 7a80d6e..d1ab769 100644 --- a/src/ext/uw.js +++ b/src/ext/uw.js @@ -13,7 +13,6 @@ import Vuex from 'vuex'; import VuexWebExtensions from 'vuex-webextensions'; global.browser = require('webextension-polyfill'); - import LoggerUi from '../csui/LoggerUi'; if(Debug.debug){ @@ -215,7 +214,6 @@ class UW { rootDiv.setAttribute("id", uwid); document.body.appendChild(rootDiv); - new Vue({ el: `#${uwid}`, From 4b177a9724798c2a22a76fee0576b6445e4c7c71 Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Wed, 26 Feb 2020 00:45:35 +0100 Subject: [PATCH 08/15] initialize content script vue/ui only if there's a need --- src/ext/lib/Logger.js | 18 ++++++++++++++++-- src/ext/uw.js | 26 ++++++++++++++++++++++---- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/src/ext/lib/Logger.js b/src/ext/lib/Logger.js index 587cac8..82de7ed 100644 --- a/src/ext/lib/Logger.js +++ b/src/ext/lib/Logger.js @@ -10,6 +10,7 @@ class Logger { this.isBackgroundScript = true; this.vuexStore = options?.vuexStore; + this.uwInstance = options?.uwInstance; } static saveConfig(conf) { @@ -120,6 +121,10 @@ class Logger { }); } + setVuexStore(store) { + this.vuexStore = store; + } + clear() { this.log = []; this.startTime = performance.now(); @@ -295,6 +300,10 @@ class Logger { return false; } + isLoggingAllowed() { + return this.conf.allowLogging; + } + isLoggingToFile() { return this.conf.allowLogging && this.conf.fileOptions?.enabled; } @@ -470,8 +479,13 @@ class Logger { } if (!this.vuexStore) { - console.error("[info] No vue store. Log will not be exported."); - return; + console.error("[info] No vue store."); + if (!this.uwInstance) { + console.error('[info] no vue instance either. Not logging.'); + return; + } + console.info("[info] Initializing vue and vuex instance ..."); + this.uwInstance.initVue(); } console.info('[info] vuex store present. Parsing logs.'); diff --git a/src/ext/uw.js b/src/ext/uw.js index d1ab769..03b608b 100644 --- a/src/ext/uw.js +++ b/src/ext/uw.js @@ -41,6 +41,8 @@ class UW { this.actionHandler = undefined; this.logger = undefined; this.vuexStore = {}; + this.uiInitiated = false; + this.vueInitiated = false; } reloadSettings() { @@ -87,9 +89,16 @@ class UW { 'handleMouseMove': false } }; - this.logger = new Logger({vuexStore: this.vuexStore}); + this.logger = new Logger(); await this.logger.init(loggingOptions); + if (this.logger.isLoggingAllowed()) { + console.info("[uw::init] Logging is allowed! Initalizing vue and UI!"); + this.initVue(); + this.initUi(); + this.logger.setVuexStore(this.vuexStore); + } + // show popup if logging to file is enabled if (this.logger.isLoggingToFile()) { console.info('[uw::init] Logging to file is enabled. Will show popup!'); @@ -228,14 +237,23 @@ class UW { } showLogger() { + if (! this.vueInitiated) { + this.initVue(); + } + if (!this.uiInitiated) { + this.initUi(); + } + this.vuexStore.dispatch('uw-show-logger'); } hideLogger() { - this.vuexStore.dispatch('uw-hide-logger'); + // if either of these two is false, then we know that UI doesn't exist + // since UI doesn't exist, we don't need to dispatch uw-hide-logger + if (this.vueInitiated && this.uiInitiated) { + this.vuexStore.dispatch('uw-hide-logger'); + } } } var main = new UW(); -main.initVue(); -main.initUi(); main.init(); From c5f6868a637b7a9fd69f160cad92f1878e3089a3 Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Sun, 1 Mar 2020 16:55:52 +0100 Subject: [PATCH 09/15] Make sure aspect ratio makes sense before setting it. Don't set NaN for aspect ratio, that tends to break things --- src/ext/lib/ar-detect/ArDetector.js | 6 +++++- src/ext/lib/video-transform/Resizer.js | 13 +++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/ext/lib/ar-detect/ArDetector.js b/src/ext/lib/ar-detect/ArDetector.js index 1f95469..6bd4e36 100644 --- a/src/ext/lib/ar-detect/ArDetector.js +++ b/src/ext/lib/ar-detect/ArDetector.js @@ -391,7 +391,11 @@ class ArDetector { //#endregion getDefaultAr() { - return this.video.videoWidth / this.video.videoHeight; + const ratio = this.video.videoWidth / this.video.videoHeight; + if (isNaN(ratio)) { + return undefined; + } + return ratio; } calculateArFromEdges(edges) { diff --git a/src/ext/lib/video-transform/Resizer.js b/src/ext/lib/video-transform/Resizer.js index f268ddb..849d4cb 100644 --- a/src/ext/lib/video-transform/Resizer.js +++ b/src/ext/lib/video-transform/Resizer.js @@ -121,6 +121,19 @@ class Resizer { updateAr(ar) { + if (!ar) { + return; + } + + // Some options require a bit more testing re: whether they make sense + // if they don't, we refuse to update aspect ratio until they do + if (ar.type === AspectRatio.Automatic || ar.type === AspectRatio.Fixed) { + if (!ar.ratio || isNaN(ar.ratio)) { + return; + } + } + + // Only update aspect ratio if there's a difference between the old and the new state if (!this.lastAr || ar.type !== this.lastAr.type || ar.ratio !== this.lastAr.ratio) { this.setAr(ar); } From 33e05014fdf35d88ae715dd7cf036586afb62bc1 Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Sun, 1 Mar 2020 20:24:08 +0100 Subject: [PATCH 10/15] flex.css -> flex.scss for dat scoping --- src/csui/LoggerUi.vue | 3 ++- src/install/first-time/App.vue | 2 +- src/install/updated/App.vue | 2 +- src/options/App.vue | 2 +- src/popup/App.vue | 2 +- src/res/css/common.scss | 2 +- src/res/css/{flex.css => flex.scss} | 0 7 files changed, 7 insertions(+), 6 deletions(-) rename src/res/css/{flex.css => flex.scss} (100%) diff --git a/src/csui/LoggerUi.vue b/src/csui/LoggerUi.vue index bcb5daa..61c1cb2 100644 --- a/src/csui/LoggerUi.vue +++ b/src/csui/LoggerUi.vue @@ -235,12 +235,13 @@ export default { } + + - + - + - + diff --git a/src/popup/App.vue b/src/popup/App.vue index db5af83..af02676 100644 --- a/src/popup/App.vue +++ b/src/popup/App.vue @@ -471,7 +471,7 @@ export default { - +