bitwarden-estensione-browser/src/services/utilsService.js

45 lines
1.2 KiB
JavaScript
Raw Normal View History

function UtilsService() {
initUtilsService();
2016-09-21 17:11:36 +02:00
this.browserCache = null;
};
function initUtilsService() {
UtilsService.prototype.getBrowser = function () {
2016-09-21 17:11:36 +02:00
if (this.browserCache) {
return this.browserCache;
}
if (navigator.userAgent.indexOf("Firefox") !== -1 || navigator.userAgent.indexOf("Gecko/") !== -1) {
2016-09-21 17:11:36 +02:00
this.browserCache = 'firefox';
}
2016-09-21 17:11:36 +02:00
else if ((!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0) {
this.browserCache = 'opera';
}
2016-09-21 17:11:36 +02:00
else if (navigator.userAgent.indexOf(" Edge/") !== -1) {
this.browserCache = 'edge';
}
2016-09-21 17:11:36 +02:00
else if (window.chrome) {
this.browserCache = 'chrome';
}
2016-09-21 17:11:36 +02:00
return this.browserCache;
};
2016-09-21 17:11:36 +02:00
UtilsService.prototype.isFirefox = function () {
return this.getBrowser() === 'firefox';
}
UtilsService.prototype.isChrome = function () {
return this.getBrowser() === 'chrome';
}
UtilsService.prototype.isEdge = function () {
return this.getBrowser() === 'edge';
}
UtilsService.prototype.isOpera = function () {
return this.getBrowser() === 'opera';
}
};