From 5b0fcef15cf658701d510b8346936c6abf9a0919 Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Sun, 14 Mar 2021 00:34:47 +0100 Subject: [PATCH] Move popup to vue --- src/popup/App.vue | 39 +++++++++++------------ src/popup/panels/AboutPanel.vue | 13 ++++---- src/popup/panels/DefaultSettingsPanel.vue | 11 ++++--- src/popup/panels/PerformancePanel.vue | 9 +++--- src/popup/panels/SiteDetailsPanel.vue | 9 +++--- src/popup/panels/WhatsNewPanel.vue | 8 +++-- 6 files changed, 45 insertions(+), 44 deletions(-) diff --git a/src/popup/App.vue b/src/popup/App.vue index cb591e7..b9b5dd9 100644 --- a/src/popup/App.vue +++ b/src/popup/App.vue @@ -213,16 +213,18 @@ import Donate from '../common/misc/Donate.vue'; import Debug from '../ext/conf/Debug'; import BrowserDetect from '../ext/conf/BrowserDetect'; import Comms from '../ext/lib/comms/Comms'; -import VideoPanel from './panels/VideoPanel'; -import PerformancePanel from './panels/PerformancePanel'; +import VideoPanel from './panels/VideoPanel.vue'; +import PerformancePanel from './panels/PerformancePanel.vue'; import Settings from '../ext/lib/Settings'; import PopupExec from './js/PopupExec'; -import DefaultSettingsPanel from './panels/DefaultSettingsPanel'; -import AboutPanel from './panels/AboutPanel'; +import DefaultSettingsPanel from './panels/DefaultSettingsPanel.vue'; +import AboutPanel from './panels/AboutPanel.vue'; import ExtensionMode from '../common/enums/ExtensionMode.enum'; import Logger from '../ext/lib/Logger'; import {ChromeShittinessMitigations as CSM} from '../common/js/ChromeShittinessMitigations'; +import { browser } from 'webextension-polyfill-ts'; +import Vue from '*.vue'; export default Vue.extend({ data () { return { @@ -260,7 +262,7 @@ export default Vue.extend({ await this.settings.init(); this.settingsInitialized = true; - const port = BrowserDetect.firefox ? browser.runtime.connect({name: 'popup-port'}) : chrome.runtime.connect({name: 'popup-port'}); + const port = browser.runtime.connect(null, {name: 'popup-port'}); port.onMessage.addListener( (m,p) => this.processReceivedMessage(m,p)); CSM.setProperty('port', port); @@ -272,12 +274,12 @@ export default Vue.extend({ cmd: 'unmark-player', forwardToAll: true, }); - if (BrowserDetect.anyChromium) { - chrome.extension.getBackgroundPage().sendUnmarkPlayer({ - cmd: 'unmark-player', - forwardToAll: true, - }); - } + // if (BrowserDetect.anyChromium) { + // chrome.extension.getBackgroundPage().sendUnmarkPlayer({ + // cmd: 'unmark-player', + // forwardToAll: true, + // }); + // } }); // get info about current site from background script @@ -318,7 +320,7 @@ export default Vue.extend({ }, methods: { async sleep(t) { - return new Promise( (resolve,reject) => { + return new Promise( (resolve,reject) => { setTimeout(() => resolve(), t); }); }, @@ -333,9 +335,7 @@ export default Vue.extend({ this.logger.log('error','popup','[popup::getSite] sending get-current-site failed for some reason. Reason:', e); } }, - getRandomColor() { - return `rgb(${Math.floor(Math.random() * 128)}, ${Math.floor(Math.random() * 128)}, ${Math.floor(Math.random() * 128)})`; - }, + selectTab(tab) { this.selectedTab = tab; if (tab === 'whats-new') { @@ -344,9 +344,6 @@ export default Vue.extend({ } this.toggleSideMenu(false); }, - selectFrame(frame) { - this.selectedFrame = frame; - }, async updateConfig() { // when this runs, a site could have been enabled or disabled // this means we must update canShowVideoTab @@ -387,7 +384,7 @@ export default Vue.extend({ if (this.site) { if (!this.site.host) { // dunno why this fix is needed, but sometimes it is - this.site.host = site.tabHostname; + this.site.host = message.site.tabHostname; } } if (!this.site || this.site.host !== message.site.host) { @@ -538,8 +535,8 @@ export default Vue.extend({ updateZoom(nz){ this.currentZoom = nz; }, - selectFrame(id){ - this.selectedFrame = id; + selectFrame(frame) { + this.selectedFrame = frame; }, selectSite(host) { this.selectedSite = host; diff --git a/src/popup/panels/AboutPanel.vue b/src/popup/panels/AboutPanel.vue index 3a1a088..c53b95f 100644 --- a/src/popup/panels/AboutPanel.vue +++ b/src/popup/panels/AboutPanel.vue @@ -36,19 +36,21 @@ - - diff --git a/src/popup/panels/DefaultSettingsPanel.vue b/src/popup/panels/DefaultSettingsPanel.vue index 282c953..9642d08 100644 --- a/src/popup/panels/DefaultSettingsPanel.vue +++ b/src/popup/panels/DefaultSettingsPanel.vue @@ -122,13 +122,14 @@ -