From f4ff7e7ed614a954c32711093a31a760e3374809 Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Wed, 30 Dec 2020 15:35:08 +0100 Subject: [PATCH] Distinction between chrome build and edge build, and "doesn't matter which of the two" build. --- src/ext/conf/BrowserDetect.js | 1 + src/ext/lib/comms/CommsClient.js | 2 +- src/ext/uw-bg.js | 12 ++++++------ src/options/GeneralSettings.vue | 2 +- src/popup/App.vue | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/ext/conf/BrowserDetect.js b/src/ext/conf/BrowserDetect.js index d2d58e5..0fa5ad4 100644 --- a/src/ext/conf/BrowserDetect.js +++ b/src/ext/conf/BrowserDetect.js @@ -7,6 +7,7 @@ if (process.env.CHANNEL !== 'stable') { const BrowserDetect = { firefox: process.env.BROWSER === 'firefox', + anyChromium: process.env.BROWSER !== 'firefox', chrome: process.env.BROWSER === 'chrome', edge: process.env.BROWSER === 'edge', processEnvBrowser: process.env.BROWSER, diff --git a/src/ext/lib/comms/CommsClient.js b/src/ext/lib/comms/CommsClient.js index 8f6ef89..e6e0c30 100644 --- a/src/ext/lib/comms/CommsClient.js +++ b/src/ext/lib/comms/CommsClient.js @@ -11,7 +11,7 @@ class CommsClient { if (BrowserDetect.firefox) { this.port = browser.runtime.connect({name: name}); - } else if (BrowserDetect.chrome) { + } else if (BrowserDetect.anyChromium) { this.port = chrome.runtime.connect({name: name}); } diff --git a/src/ext/uw-bg.js b/src/ext/uw-bg.js index 89c6351..df74b25 100644 --- a/src/ext/uw-bg.js +++ b/src/ext/uw-bg.js @@ -69,7 +69,7 @@ class UWServer { if(BrowserDetect.firefox) { browser.tabs.onActivated.addListener((m) => {this.onTabSwitched(m)}); - } else if (BrowserDetect.chrome) { + } else if (BrowserDetect.anyChromium) { chrome.tabs.onActivated.addListener((m) => {this.onTabSwitched(m)}); } } @@ -84,7 +84,7 @@ class UWServer { try { if (BrowserDetect.firefox || BrowserDetect.edge) { browser.tabs.insertCSS(sender.tab.id, {code: css, cssOrigin: 'user', frameId: sender.frameId}); - } else if (BrowserDetect.chrome) { + } else if (BrowserDetect.anyChromium) { chrome.tabs.insertCSS(sender.tab.id, {code: css, cssOrigin: 'user', frameId: sender.frameId}); } } catch (e) { @@ -95,7 +95,7 @@ class UWServer { try { if (BrowserDetect.firefox || BrowserDetect.edge) { browser.tabs.removeCSS(sender.tab.id, {code: css, cssOrigin: 'user', frameId: sender.frameId}); - } else if (BrowserDetect.chrome) { + } else if (BrowserDetect.anyChromium) { // this doesn't work currently, but hopefully chrome will get this feature in the future chrome.tabs.removeCSS(sender.tab.id, {code: css, cssOrigin: 'user', frameId: sender.frameId}); } @@ -141,7 +141,7 @@ class UWServer { let tab; if (BrowserDetect.firefox) { tab = await browser.tabs.get(this.currentTabId); - } else if (BrowserDetect.chrome) { + } else if (BrowserDetect.anyChromium) { tab = await this._promisifyTabsGet(chrome, this.currentTabId); } @@ -223,7 +223,7 @@ class UWServer { file: '/ext/uw-ui.js', allFrames: true, }); - } else if (BrowserDetect.chrome) { + } else if (BrowserDetect.anyChromium) { await new Promise( resolve => chrome.tabs.executeScript({ file: '/ext/uw-ui.js', @@ -269,7 +269,7 @@ class UWServer { async getCurrentTab() { if (BrowserDetect.firefox) { return (await browser.tabs.query({active: true, currentWindow: true}))[0]; - } else if (BrowserDetect.chrome) { + } else if (BrowserDetect.anyChromium) { return new Promise((resolve, reject) => chrome.tabs.query({active: true, currentWindow: true}, (x) => resolve(x[0]))); } } diff --git a/src/options/GeneralSettings.vue b/src/options/GeneralSettings.vue index 3aa2242..ce42e2f 100644 --- a/src/options/GeneralSettings.vue +++ b/src/options/GeneralSettings.vue @@ -216,7 +216,7 @@ export default { // reminder — webextension-polyfill doesn't seem to work in vue! await browser.permissions.request({permissions: ['downloads']}); browser.downloads.download({saveAs: true, filename: 'ultrawidify-settings.json', url: fileUrl}); - } else if (BrowserDetect.chrome) { + } else if (BrowserDetect.anyChromium) { const ths = this; chrome.permissions.request( diff --git a/src/popup/App.vue b/src/popup/App.vue index 5a67bbd..2192d5b 100644 --- a/src/popup/App.vue +++ b/src/popup/App.vue @@ -261,7 +261,7 @@ export default { cmd: 'unmark-player', forwardToAll: true, }); - if (BrowserDetect.chrome) { + if (BrowserDetect.anyChromium) { chrome.extension.getBackgroundPage().sendUnmarkPlayer({ cmd: 'unmark-player', forwardToAll: true,