-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
69 lines (57 loc) · 1.62 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Use Feature detection instead of user agents -
// http://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser
const isNotBrowser = (typeof window === 'undefined');
let isFirefox = false;
let isChromeOrChromium = false;
let isChrome = false;
let isChromium = false;
let isSafari = false;
let isOpera = false;
let isEdge = false;
let isEdgeChromium = false;
let isBlink = false;
let isIE = false;
if (!isNotBrowser) {
isFirefox = typeof InstallTrigger !== 'undefined';
isChromeOrChromium = !!window.chrome;
isChrome = !!window.chrome;
isChromium = isChromeOrChromium && !window.chrome.webstore && !window.chrome.runtime;
isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0 || (window.safari && window.safari.pushNotification);
isOpera = (!!window.opr && !!window.opr.addons) || !!window.opera;
isEdge = !!window.StyleMedia;
isEdgeChromium = isChromeOrChromium && !!navigator.userAgent.match(/edg/i);
isBlink = (isChrome || isOpera) && !!window.CSS;
isIE = !isChromeOrChromium && !isSafari && !isFirefox && !isOpera && !!document.documentMode;
}
export default {
get isChrome () {
return isChrome;
},
get isChromeOrChromium () {
return isChromeOrChromium;
},
get isChromium () {
return isChromium;
},
get isFirefox () {
return isFirefox;
},
get isSafari () {
return isSafari;
},
get isOpera () {
return isOpera;
},
get isEdge () {
return isEdge;
},
get isEdgeChromium () {
return isEdgeChromium;
},
get isIE () {
return isIE;
},
get isBlink () {
return isBlink;
}
};