Distinction between chrome build and edge build, and "doesn't matter which of the two" build.
This commit is contained in:
parent
4c359675b6
commit
f4ff7e7ed6
@ -7,6 +7,7 @@ if (process.env.CHANNEL !== 'stable') {
|
|||||||
|
|
||||||
const BrowserDetect = {
|
const BrowserDetect = {
|
||||||
firefox: process.env.BROWSER === 'firefox',
|
firefox: process.env.BROWSER === 'firefox',
|
||||||
|
anyChromium: process.env.BROWSER !== 'firefox',
|
||||||
chrome: process.env.BROWSER === 'chrome',
|
chrome: process.env.BROWSER === 'chrome',
|
||||||
edge: process.env.BROWSER === 'edge',
|
edge: process.env.BROWSER === 'edge',
|
||||||
processEnvBrowser: process.env.BROWSER,
|
processEnvBrowser: process.env.BROWSER,
|
||||||
|
@ -11,7 +11,7 @@ class CommsClient {
|
|||||||
|
|
||||||
if (BrowserDetect.firefox) {
|
if (BrowserDetect.firefox) {
|
||||||
this.port = browser.runtime.connect({name: name});
|
this.port = browser.runtime.connect({name: name});
|
||||||
} else if (BrowserDetect.chrome) {
|
} else if (BrowserDetect.anyChromium) {
|
||||||
this.port = chrome.runtime.connect({name: name});
|
this.port = chrome.runtime.connect({name: name});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ class UWServer {
|
|||||||
|
|
||||||
if(BrowserDetect.firefox) {
|
if(BrowserDetect.firefox) {
|
||||||
browser.tabs.onActivated.addListener((m) => {this.onTabSwitched(m)});
|
browser.tabs.onActivated.addListener((m) => {this.onTabSwitched(m)});
|
||||||
} else if (BrowserDetect.chrome) {
|
} else if (BrowserDetect.anyChromium) {
|
||||||
chrome.tabs.onActivated.addListener((m) => {this.onTabSwitched(m)});
|
chrome.tabs.onActivated.addListener((m) => {this.onTabSwitched(m)});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -84,7 +84,7 @@ class UWServer {
|
|||||||
try {
|
try {
|
||||||
if (BrowserDetect.firefox || BrowserDetect.edge) {
|
if (BrowserDetect.firefox || BrowserDetect.edge) {
|
||||||
browser.tabs.insertCSS(sender.tab.id, {code: css, cssOrigin: 'user', frameId: sender.frameId});
|
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});
|
chrome.tabs.insertCSS(sender.tab.id, {code: css, cssOrigin: 'user', frameId: sender.frameId});
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -95,7 +95,7 @@ class UWServer {
|
|||||||
try {
|
try {
|
||||||
if (BrowserDetect.firefox || BrowserDetect.edge) {
|
if (BrowserDetect.firefox || BrowserDetect.edge) {
|
||||||
browser.tabs.removeCSS(sender.tab.id, {code: css, cssOrigin: 'user', frameId: sender.frameId});
|
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
|
// 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});
|
chrome.tabs.removeCSS(sender.tab.id, {code: css, cssOrigin: 'user', frameId: sender.frameId});
|
||||||
}
|
}
|
||||||
@ -141,7 +141,7 @@ class UWServer {
|
|||||||
let tab;
|
let tab;
|
||||||
if (BrowserDetect.firefox) {
|
if (BrowserDetect.firefox) {
|
||||||
tab = await browser.tabs.get(this.currentTabId);
|
tab = await browser.tabs.get(this.currentTabId);
|
||||||
} else if (BrowserDetect.chrome) {
|
} else if (BrowserDetect.anyChromium) {
|
||||||
tab = await this._promisifyTabsGet(chrome, this.currentTabId);
|
tab = await this._promisifyTabsGet(chrome, this.currentTabId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,7 +223,7 @@ class UWServer {
|
|||||||
file: '/ext/uw-ui.js',
|
file: '/ext/uw-ui.js',
|
||||||
allFrames: true,
|
allFrames: true,
|
||||||
});
|
});
|
||||||
} else if (BrowserDetect.chrome) {
|
} else if (BrowserDetect.anyChromium) {
|
||||||
await new Promise( resolve =>
|
await new Promise( resolve =>
|
||||||
chrome.tabs.executeScript({
|
chrome.tabs.executeScript({
|
||||||
file: '/ext/uw-ui.js',
|
file: '/ext/uw-ui.js',
|
||||||
@ -269,7 +269,7 @@ class UWServer {
|
|||||||
async getCurrentTab() {
|
async getCurrentTab() {
|
||||||
if (BrowserDetect.firefox) {
|
if (BrowserDetect.firefox) {
|
||||||
return (await browser.tabs.query({active: true, currentWindow: true}))[0];
|
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])));
|
return new Promise((resolve, reject) => chrome.tabs.query({active: true, currentWindow: true}, (x) => resolve(x[0])));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -216,7 +216,7 @@ export default {
|
|||||||
// reminder — webextension-polyfill doesn't seem to work in vue!
|
// reminder — webextension-polyfill doesn't seem to work in vue!
|
||||||
await browser.permissions.request({permissions: ['downloads']});
|
await browser.permissions.request({permissions: ['downloads']});
|
||||||
browser.downloads.download({saveAs: true, filename: 'ultrawidify-settings.json', url: fileUrl});
|
browser.downloads.download({saveAs: true, filename: 'ultrawidify-settings.json', url: fileUrl});
|
||||||
} else if (BrowserDetect.chrome) {
|
} else if (BrowserDetect.anyChromium) {
|
||||||
const ths = this;
|
const ths = this;
|
||||||
|
|
||||||
chrome.permissions.request(
|
chrome.permissions.request(
|
||||||
|
@ -261,7 +261,7 @@ export default {
|
|||||||
cmd: 'unmark-player',
|
cmd: 'unmark-player',
|
||||||
forwardToAll: true,
|
forwardToAll: true,
|
||||||
});
|
});
|
||||||
if (BrowserDetect.chrome) {
|
if (BrowserDetect.anyChromium) {
|
||||||
chrome.extension.getBackgroundPage().sendUnmarkPlayer({
|
chrome.extension.getBackgroundPage().sendUnmarkPlayer({
|
||||||
cmd: 'unmark-player',
|
cmd: 'unmark-player',
|
||||||
forwardToAll: true,
|
forwardToAll: true,
|
||||||
|
Loading…
Reference in New Issue
Block a user