-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
56 lines (47 loc) · 1.26 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
document.onreadystatechange = function () {
const target = document.querySelector("#jsDetector");
target.innerHTML = "(" + whichBrowser() + ")";
};
function whichBrowser() {
if (isFirefox()) {
return "Firefox";
} else if (isEdge()) {
return "Edge";
} else if (isIE()) {
return "Internet Explorer";
} else if (isOpera()) {
return "Opera";
} else if (isVivaldi()) {
return "Vivalid";
} else if (isChrome()) {
return "Chrome";
} else if (isSafari()) {
return "Safari";
} else {
return "Unknown";
}
}
function agentHas(keyword) {
return navigator.userAgent.toLowerCase().search(keyword.toLowerCase()) > -1;
}
function isIE() {
return !!document.documentMode;
}
function isSafari() {
return (!!window.ApplePaySetupFeature || !!window.safari) && agentHas("Safari") && !agentHas("Chrome") && !agentHas("CriOS");
}
function isChrome() {
return agentHas("CriOS") || agentHas("Chrome") || !!window.chrome;
}
function isFirefox() {
return agentHas("Firefox") || agentHas("FxiOS") || agentHas("Focus");
}
function isEdge() {
return agentHas("Edg");
}
function isOpera() {
return agentHas("OPR");
}
function isVivaldi() {
return agentHas("Vivaldi");
}