Some cosmetic changes in BrowserDetect

This commit is contained in:
Tamius Han 2020-12-30 15:35:54 +01:00
parent f4ff7e7ed6
commit 7cb378029c
3 changed files with 16 additions and 5 deletions

View File

@ -138,7 +138,7 @@ export default {
}, },
methods: { methods: {
getUrl(url) { getUrl(url) {
return BrowserDetect.firefox ? browser.runtime.getURL(url) : chrome.runtime.getURL(url); return BrowserDetect.getURL(url);
}, },
async hidePopupForever() { async hidePopupForever() {
const settings = new Settings(); const settings = new Settings();

View File

@ -4,6 +4,17 @@ if (process.env.CHANNEL !== 'stable') {
console.info('Loaded BrowserDetect'); console.info('Loaded BrowserDetect');
} }
function detectEdgeUA() {
return /Edg\/(\.?[0-9]*)*$/.test(window.navigator.userAgent);
}
function getBrowserObj() {
return process.env.BROWSER === 'firefox' ? browser : chrome;
}
function getURL(url) {
return process.env.BROWSER === 'firefox' ? browser.runtime.getURL(url) : chrome.runtime.getURL(url);
}
const BrowserDetect = { const BrowserDetect = {
firefox: process.env.BROWSER === 'firefox', firefox: process.env.BROWSER === 'firefox',
@ -12,9 +23,9 @@ const BrowserDetect = {
edge: process.env.BROWSER === 'edge', edge: process.env.BROWSER === 'edge',
processEnvBrowser: process.env.BROWSER, processEnvBrowser: process.env.BROWSER,
processEnvChannel: process.env.CHANNEL, processEnvChannel: process.env.CHANNEL,
isEdgeUA: () => /Edg\/(\.?[0-9]*)*$/.test(window.navigator.userAgent), isEdgeUA: detectEdgeUA(),
getBrowserObj: () => { return process.env.BROWSER === 'firefox' ? browser : chrome; }, browserObj: getBrowserObj(),
getURL: (url) => { console.log('getting file:', url); console.log(process.env.BROWSER === 'firefox' ? browser.runtime.getURL(url) : chrome.runtime.getURL(url)); return process.env.BROWSER === 'firefox' ? browser.runtime.getURL(url) : chrome.runtime.getURL(url); }, getURL: (url) => getURL(url),
} }
if (process.env.CHANNEL !== 'stable') { if (process.env.CHANNEL !== 'stable') {

View File

@ -485,7 +485,7 @@ class PlayerData {
* NOTE: this method needs to be deleted once Edge gets its shit together. * NOTE: this method needs to be deleted once Edge gets its shit together.
*/ */
showEdgeNotification() { showEdgeNotification() {
if (BrowserDetect.isEdgeUA() && !this.settings.active.mutedNotifications?.browserSpecific?.edge?.brokenDrm?.[window.hostname]) { if (BrowserDetect.isEdgeUA && !this.settings.active.mutedNotifications?.browserSpecific?.edge?.brokenDrm?.[window.hostname]) {
this.ui = new PlayerUi(this.element, this.settings); this.ui = new PlayerUi(this.element, this.settings);
} }
} }