diff --git a/src/content/autofill.js b/src/content/autofill.js index af7d2a3a3b..f38715c857 100644 --- a/src/content/autofill.js +++ b/src/content/autofill.js @@ -994,7 +994,8 @@ End 1Password Extension */ - if ((typeof safari !== 'undefined')) { + if ((typeof safari !== 'undefined') && navigator.userAgent.indexOf(' Safari/') !== -1 && + navigator.userAgent.indexOf('Chrome') === -1) { safari.self.addEventListener('message', function (msgEvent) { var msg = msgEvent.message; if (msg.command === 'collectPageDetails') { diff --git a/src/content/autofiller.js b/src/content/autofiller.js index 3c8a9f05b8..d7711b5d37 100644 --- a/src/content/autofiller.js +++ b/src/content/autofiller.js @@ -1,7 +1,8 @@ document.addEventListener('DOMContentLoaded', (event) => { let pageHref = null; - if ((typeof safari !== 'undefined')) { + if ((typeof safari !== 'undefined') && navigator.userAgent.indexOf(' Safari/') !== -1 && + navigator.userAgent.indexOf('Chrome') === -1) { const responseCommand = 'autofillerAutofillOnPageLoadEnabledResponse'; safari.self.tab.dispatchMessage('bitwarden', { command: 'bgGetDataForTab', diff --git a/src/content/notificationBar.js b/src/content/notificationBar.js index 83d01e56bf..85bb994c90 100644 --- a/src/content/notificationBar.js +++ b/src/content/notificationBar.js @@ -14,9 +14,10 @@ document.addEventListener('DOMContentLoaded', function (event) { iframed = isIframed(), submitButtonNames = ['log in', 'sign in', 'login', 'go', 'submit', 'continue', 'next'], notificationBarData = null, - isSafariApi = (typeof safari !== 'undefined'); + isSafari = (typeof safari !== 'undefined') && navigator.userAgent.indexOf(' Safari/') !== -1 && + navigator.userAgent.indexOf('Chrome') === -1; - if (isSafariApi) { + if (isSafari) { const responseCommand = 'notificationBarDataResponse'; safari.self.tab.dispatchMessage('bitwarden', { command: 'bgGetDataForTab', @@ -385,7 +386,7 @@ document.addEventListener('DOMContentLoaded', function (event) { return; } - var barPageUrl = isSafariApi ? (safari.extension.baseURI + barPage) : chrome.extension.getURL(barPage); + var barPageUrl = isSafari ? (safari.extension.baseURI + barPage) : chrome.extension.getURL(barPage); var iframe = document.createElement('iframe'); iframe.src = barPageUrl; @@ -447,7 +448,7 @@ document.addEventListener('DOMContentLoaded', function (event) { } function sendPlatformMessage(msg) { - if (isSafariApi) { + if (isSafari) { safari.self.tab.dispatchMessage('bitwarden', msg); } else { diff --git a/src/services/browserPlatformUtils.service.ts b/src/services/browserPlatformUtils.service.ts index 26a2626484..98493bdacd 100644 --- a/src/services/browserPlatformUtils.service.ts +++ b/src/services/browserPlatformUtils.service.ts @@ -61,7 +61,7 @@ export default class BrowserPlatformUtilsService implements PlatformUtilsService return this.deviceCache; } - if (navigator.userAgent.indexOf('Firefox') !== -1 || navigator.userAgent.indexOf('Gecko/') !== -1) { + if (navigator.userAgent.indexOf(' Firefox/') !== -1 || navigator.userAgent.indexOf(' Gecko/') !== -1) { this.deviceCache = DeviceType.Firefox; } else if ((!!(window as any).opr && !!opr.addons) || !!(window as any).opera || navigator.userAgent.indexOf(' OPR/') >= 0) { @@ -70,9 +70,10 @@ export default class BrowserPlatformUtilsService implements PlatformUtilsService this.deviceCache = DeviceType.Edge; } else if (navigator.userAgent.indexOf(' Vivaldi/') !== -1) { this.deviceCache = DeviceType.Vivaldi; - } else if (navigator.userAgent.indexOf('Safari') !== -1 && navigator.userAgent.indexOf('Chrome') === -1) { + } else if ((window as any).safari && navigator.userAgent.indexOf(' Safari/') !== -1 && + navigator.userAgent.indexOf('Chrome') === -1) { this.deviceCache = DeviceType.Safari; - } else if ((window as any).chrome) { + } else if ((window as any).chrome && navigator.userAgent.indexOf(' Chrome/') !== -1) { this.deviceCache = DeviceType.Chrome; }