Distinction between chrome build and edge build, and "doesn't matter which of the two" build.

This commit is contained in:
Tamius Han 2020-12-30 15:35:08 +01:00
parent 4c359675b6
commit f4ff7e7ed6
5 changed files with 10 additions and 9 deletions

View File

@ -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,

View File

@ -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});
}

View File

@ -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])));
}
}

View File

@ -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(

View File

@ -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,