-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
90 lines (75 loc) · 2.95 KB
/
index.html
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Device Detection App</title>
</head>
<body>
<div id="app"></div>
<script>
const inBrowser = typeof window !== 'undefined';
// get user agent
const UA = inBrowser && window.navigator.userAgent.toLowerCase()
// detect browser
const isIE = UA && /msie|trident/.test(UA)
const isIE9 = UA && UA.indexOf('msie 9.0') > 0
const isEdge = UA && UA.indexOf('edge/') > 0
const isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge
const isPhantomJS = UA && /phantomjs/.test(UA)
const isFF = UA && UA.match(/firefox\/(\d+)/)
// detect OS
const isAndroid = UA && UA.indexOf('android') > 0
const isIOS = UA && /iphone|ipad|ipod|ios/.test(UA)
const isSafari = (window.safari) ? true : false;
const isMobileSafari = !!navigator.userAgent.match(/Version\/[\d\.]+.*Safari/);
// detect device
const isMac = window.navigator.platform.toLowerCase().includes("mac");
const isWindows = window.navigator.platform.toLowerCase().includes("win");
let isWebView = /(Version\/\d+.*\/\d+.0.0.0 Mobile|; ?wv|(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari))/i.test(navigator.userAgent);
const isMetaMask = (ethereum.isMetaMask === true);
let isTouchDevice = null;
let isMobile = window.matchMedia;
if (isMobile) {
let match_mobile = isMobile("(pointer:coarse)");
isTouchDevice = match_mobile.matches;
}
safari = /safari/.test( UA ),
ios = /iphone|ipod|ipad/.test( UA );
if( ios ) {
if ( !safari ) {
isIOSWebView = true;
};
}
document.getElementById("app").innerHTML = `
<h1>Browser checking</h1>
<div><br />
isChrome - ${isChrome}<br /><hr>
isIE - ${isIE}<br /><hr>
isEdge - ${isEdge}<br /><hr>
isIE9 - ${isIE9}<br /><hr>
isPhantomJS - ${isPhantomJS}<br /><hr>
isFF - ${isFF}<br /><hr>
isAndroid - ${isAndroid}<br /><hr>
isIOS - ${isIOS}<br /><hr>
isSafari - ${isSafari}<br /><hr>
isMac - ${isMac}<br /><hr>
isWindows - ${isWindows}<br /><hr>
isMobileSafari - ${isMobileSafari}<br /><hr>
isTouchDevice - ${isTouchDevice ? isTouchDevice : null}<br /><hr>
isWebView - ${isWebView}<br /><hr>
isAlphaWallet - ${ethereum.isAlphaWallet}<br /><hr>
isMEW - ${ethereum.isTrust && ethereum.isMetaMask}<br /><hr>
isRainbowWallet - ${ethereum.isRainbowWallet}<br /><hr>
ImTokenWallet - ${ethereum.ImTokenWallet}<br /><hr>
isCoinBase - ${ethereum.isToshi || ethereum.isCoinBase }<br /><hr>
isGoWallet - ${ethereum.isGoWallet}<br /><hr>
isStatusWallet - ${ethereum.isStatus}<br /><hr>
isTrustWallet - ${ethereum.isTrust}<br /><hr>
isMetaMask - ${ethereum.isMetaMask}<br /><hr>
</div>
`;
</script>
</body>
</html>