diff --git a/src/csui/PlayerUiComponent.vue b/src/csui/PlayerUiComponent.vue index 0d4e56c..9e8eb02 100644 --- a/src/csui/PlayerUiComponent.vue +++ b/src/csui/PlayerUiComponent.vue @@ -138,7 +138,7 @@ export default { }, methods: { getUrl(url) { - return BrowserDetect.firefox ? browser.runtime.getURL(url) : chrome.runtime.getURL(url); + return BrowserDetect.getURL(url); }, async hidePopupForever() { const settings = new Settings(); diff --git a/src/ext/conf/BrowserDetect.js b/src/ext/conf/BrowserDetect.js index 0fa5ad4..a552e7d 100644 --- a/src/ext/conf/BrowserDetect.js +++ b/src/ext/conf/BrowserDetect.js @@ -4,6 +4,17 @@ if (process.env.CHANNEL !== 'stable') { 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 = { firefox: process.env.BROWSER === 'firefox', @@ -12,9 +23,9 @@ const BrowserDetect = { edge: process.env.BROWSER === 'edge', processEnvBrowser: process.env.BROWSER, processEnvChannel: process.env.CHANNEL, - isEdgeUA: () => /Edg\/(\.?[0-9]*)*$/.test(window.navigator.userAgent), - getBrowserObj: () => { return process.env.BROWSER === 'firefox' ? browser : chrome; }, - 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); }, + isEdgeUA: detectEdgeUA(), + browserObj: getBrowserObj(), + getURL: (url) => getURL(url), } if (process.env.CHANNEL !== 'stable') { diff --git a/src/ext/lib/video-data/PlayerData.js b/src/ext/lib/video-data/PlayerData.js index 21caaa9..d721146 100644 --- a/src/ext/lib/video-data/PlayerData.js +++ b/src/ext/lib/video-data/PlayerData.js @@ -485,7 +485,7 @@ class PlayerData { * NOTE: this method needs to be deleted once Edge gets its shit together. */ 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); } }