-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
135 lines (114 loc) · 4.46 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>WebView检测</title>
<style>
body {
padding: 20px;
font-family: Arial, sans-serif;
}
.info-box {
border: 1px solid #ccc;
padding: 10px;
margin: 10px 0;
border-radius: 5px;
}
.label {
font-weight: bold;
color: #333;
}
.value {
color: #666;
word-break: break-all;
}
</style>
</head>
<body>
<h2>WebView 信息检测</h2>
<div id="info"></div>
<script>
function getWebViewInfo() {
const info = document.getElementById('info');
let infoHTML = '';
// 获取 User Agent
infoHTML += createInfoBox('User Agent', navigator.userAgent);
// 检测是否是X5内核
const isX5 = navigator.userAgent.toLowerCase().indexOf('tbs') > -1
|| navigator.userAgent.toLowerCase().indexOf('x5') > -1;
infoHTML += createInfoBox('是否是X5内核', isX5 ? '是' : '否');
// 提取X5版本号(如果存在)
const x5VersionMatch = navigator.userAgent.match(/TBS\/([\d.]+)/i)
|| navigator.userAgent.match(/X5\/([\d.]+)/i);
if (x5VersionMatch) {
infoHTML += createInfoBox('X5版本号', x5VersionMatch[1]);
}
// 提取Chrome版本
const chromeVersion = getChromeVersion();
infoHTML += createInfoBox('Chrome版本', chromeVersion);
// 获取浏览器详细信息
const browserInfo = getBrowserInfo();
infoHTML += createInfoBox('浏览器信息', browserInfo);
// WebView API版本
infoHTML += createInfoBox('WebView API版本', getWebViewVersion());
// 系统平台信息
infoHTML += createInfoBox('平台', navigator.platform);
// 获取设备像素比
infoHTML += createInfoBox('设备像素比', window.devicePixelRatio);
// 检查WebView特性支持
const features = checkWebViewFeatures();
infoHTML += createInfoBox('WebView特性支持', features);
info.innerHTML = infoHTML;
}
function createInfoBox(label, value) {
return `
<div class="info-box">
<div class="label">${label}:</div>
<div class="value">${value}</div>
</div>
`;
}
function getChromeVersion() {
const raw = navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);
return raw ? raw[2] : '未检测到';
}
function getBrowserInfo() {
const ua = navigator.userAgent;
let browserInfo = '';
if (ua.includes('Firefox')) {
browserInfo = 'Firefox';
} else if (ua.includes('Chrome')) {
browserInfo = 'Chrome';
} else if (ua.includes('Safari')) {
browserInfo = 'Safari';
} else if (ua.includes('Edge')) {
browserInfo = 'Edge';
} else if (ua.includes('MSIE') || ua.includes('Trident/')) {
browserInfo = 'Internet Explorer';
} else {
browserInfo = '未知浏览器';
}
return browserInfo;
}
function getWebViewVersion() {
// 尝试获取WebView版本信息
const matches = navigator.userAgent.match(/Android [\d.]+/);
return matches ? matches[0] : '未知';
}
function checkWebViewFeatures() {
const features = [];
// 检查常见的WebView特性
if ('serviceWorker' in navigator) features.push('Service Workers');
if ('geolocation' in navigator) features.push('Geolocation');
if ('WebSocket' in window) features.push('WebSocket');
if ('localStorage' in window) features.push('LocalStorage');
if ('indexedDB' in window) features.push('IndexedDB');
if ('Notification' in window) features.push('Notifications');
return features.join(', ');
}
// 页面加载完成后执行检测
window.onload = getWebViewInfo;
</script>
</body>
</html>