mirror of
https://github.com/bitwarden/desktop.git
synced 2024-10-07 05:28:19 +02:00
getBrowser cache
This commit is contained in:
parent
5b1172b8d0
commit
32d459159c
@ -1,22 +1,44 @@
|
|||||||
function UtilsService() {
|
function UtilsService() {
|
||||||
initUtilsService();
|
initUtilsService();
|
||||||
|
|
||||||
|
this.browserCache = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
function initUtilsService() {
|
function initUtilsService() {
|
||||||
UtilsService.prototype.getBrowser = function () {
|
UtilsService.prototype.getBrowser = function () {
|
||||||
if (navigator.userAgent.indexOf("Firefox") !== -1 || navigator.userAgent.indexOf("Gecko/") !== -1) {
|
if (this.browserCache) {
|
||||||
return 'firefox';
|
return this.browserCache;
|
||||||
}
|
|
||||||
if ((!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0) {
|
|
||||||
return 'opera';
|
|
||||||
}
|
|
||||||
if (navigator.userAgent.indexOf(" Edge/") !== -1) {
|
|
||||||
return 'edge';
|
|
||||||
}
|
|
||||||
if (window.chrome) {
|
|
||||||
return 'chrome';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
if (navigator.userAgent.indexOf("Firefox") !== -1 || navigator.userAgent.indexOf("Gecko/") !== -1) {
|
||||||
|
this.browserCache = 'firefox';
|
||||||
|
}
|
||||||
|
else if ((!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0) {
|
||||||
|
this.browserCache = 'opera';
|
||||||
|
}
|
||||||
|
else if (navigator.userAgent.indexOf(" Edge/") !== -1) {
|
||||||
|
this.browserCache = 'edge';
|
||||||
|
}
|
||||||
|
else if (window.chrome) {
|
||||||
|
this.browserCache = 'chrome';
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.browserCache;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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';
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user