-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBrowserScanner.html
209 lines (194 loc) · 9.53 KB
/
BrowserScanner.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Browser & OS Detection Tool</title>
<meta name="description" content="Detect your current browser, version, and operating system with detailed technical insights">
<!-- Open Graph / Twitter -->
<meta property="og:type" content="website">
<meta property="og:title" content="Browser & OS Detection Tool">
<meta property="og:description" content="Instant browser analysis with technical details and security recommendations">
<link rel="icon" href="https://kai9987kai.github.io/favicon.ico">
<!-- Fonts with font-display -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@300;500;700&display=swap">
</head>
<body>
<div id="app"></div>
<script>
// Enhanced browser and OS detection with feature detection
const detectEnvironment = () => {
const ua = navigator.userAgent;
let browser = { name: 'Unknown', version: 'N/A', icon: '🌐' };
let os = { name: 'Unknown', version: 'N/A', icon: '💻' };
// Browser Detection
if (/(opera|opr)/i.test(ua)) {
browser = { name: 'Opera', version: ua.match(/(?:opera|opr)[\s/](\d+(\.\d+)?)/i)?.[1], icon: '🎭' };
} else if (/edg/i.test(ua)) {
browser = { name: 'Microsoft Edge', version: ua.match(/edg\/(\d+\.\d+\.\d+\.\d+)/i)?.[1], icon: '🟦' };
} else if (/chrome|chromium|crios/i.test(ua)) {
browser = { name: 'Chrome', version: ua.match(/(?:chrome|chromium|crios)\/(\d+\.\d+\.\d+\.\d+)/i)?.[1], icon: '🟡' };
} else if (/firefox|fxios/i.test(ua)) {
browser = { name: 'Firefox', version: ua.match(/(?:firefox|fxios)\/(\d+\.\d+)/i)?.[1], icon: '🦊' };
} else if (/safari/i.test(ua)) {
browser = { name: 'Safari', version: ua.match(/version\/(\d+\.\d+)/i)?.[1], icon: '🍏' };
} else if (/trident/i.test(ua)) {
browser = { name: 'Internet Explorer', version: ua.match(/trident\/(\d+\.\d+)/i)?.[1], icon: '🌐' };
}
// Detect Brave
if (navigator.brave?.isBrave) {
browser = { ...browser, name: 'Brave', icon: '🦁' };
}
// OS Detection
if (/windows/i.test(ua)) {
os = { name: 'Windows', version: ua.match(/windows nt (\d+\.\d+)/i)?.[1], icon: '🪟' };
} else if (/macintosh/i.test(ua)) {
os = { name: 'macOS', version: ua.match(/mac os x (\d+[._]\d+)/i)?.[1].replace('_', '.'), icon: '🍎' };
} else if (/android/i.test(ua)) {
os = { name: 'Android', version: ua.match(/android (\d+\.\d+)/i)?.[1], icon: '🤖' };
} else if (/iphone|ipad|ipod/i.test(ua)) {
os = { name: 'iOS', version: ua.match(/os (\d+(_\d+)?)/i)?.[1].replace('_', '.'), icon: '📱' };
} else if (/linux/i.test(ua)) {
os = { name: 'Linux', icon: '🐧' };
}
// Feature Detection
const features = {
webGL: !!window.WebGLRenderingContext,
webRTC: !!window.RTCPeerConnection,
serviceWorker: 'serviceWorker' in navigator,
speechRecognition: 'SpeechRecognition' in window || 'webkitSpeechRecognition' in window
};
return { browser, os, userAgent: ua, features };
};
// Dynamic styling with CSS variables and theme customization
const applyStyles = () => {
const style = document.createElement('style');
style.innerHTML = `
:root {
--primary-color: #636b6f;
--background: #ffffff;
--card-bg: #f8f9fa;
--text-color: #212529;
}
@media (prefers-color-scheme: dark) {
:root {
--background: #121212;
--card-bg: #1e1e1e;
--text-color: #e1e1e1;
}
}
body {
margin: 0;
font-family: 'Inter', system-ui, sans-serif;
background: var(--background);
color: var(--text-color);
transition: background 0.3s ease;
}
.container {
max-width: 800px;
margin: 0 auto;
padding: 2rem;
}
.hero {
text-align: center;
margin-bottom: 3rem;
animation: fadeIn 0.5s ease;
}
.grid {
display: grid;
gap: 1.5rem;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}
.card {
background: var(--card-bg);
border-radius: 12px;
padding: 1.5rem;
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
transition: transform 0.2s ease;
}
.card:hover {
transform: translateY(-3px);
}
.icon {
font-size: 2.5rem;
margin-bottom: 1rem;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(20px); }
to { opacity: 1; transform: translateY(0); }
}
`;
document.head.appendChild(style);
};
// Enhanced content rendering with animations, interaction, and AI insights
const renderContent = () => {
const { browser, os, userAgent, features } = detectEnvironment();
const appDiv = document.getElementById('app');
// AI-driven insights
const aiInsights = [];
if (!features.webGL) aiInsights.push("WebGL is not supported. Consider updating your browser for better performance.");
if (!features.serviceWorker) aiInsights.push("Service Workers are not supported. Offline functionality may be limited.");
appDiv.innerHTML = `
<main class="container">
<div class="hero">
<h1>${browser.icon} Browser & OS Detection</h1>
<p>Your digital environment analysis</p>
</div>
<div class="grid">
<div class="card">
<div class="icon">${browser.icon}</div>
<h2>Browser Details</h2>
<p><strong>Name:</strong> ${browser.name}</p>
<p><strong>Version:</strong> ${browser.version || 'N/A'}</p>
</div>
<div class="card">
<div class="icon">${os.icon}</div>
<h2>Operating System</h2>
<p><strong>Platform:</strong> ${os.name}</p>
<p><strong>Version:</strong> ${os.version || 'N/A'}</p>
</div>
</div>
<div class="card" style="margin-top: 2rem;">
<h3>Technical Details</h3>
<details>
<summary>User Agent String</summary>
<code>${userAgent}</code>
</details>
<button onclick="navigator.clipboard.writeText('${userAgent}')">Copy User Agent</button>
</div>
<div class="card" style="margin-top: 2rem;">
<h3>Feature Support</h3>
<ul>
<li>WebGL: ${features.webGL ? '✅ Supported' : '❌ Not Supported'}</li>
<li>WebRTC: ${features.webRTC ? '✅ Supported' : '❌ Not Supported'}</li>
<li>Service Workers: ${features.serviceWorker ? '✅ Supported' : '❌ Not Supported'}</li>
<li>Voice Recognition: ${features.speechRecognition ? '✅ Supported' : '❌ Not Supported'}</li>
</ul>
</div>
<div class="card" style="margin-top: 2rem;">
<h3>AI Insights</h3>
${aiInsights.length > 0 ? `<ul>${aiInsights.map(insight => `<li>${insight}</li>`).join('')}</ul>` : '<p>No issues detected.</p>'}
</div>
</main>
`;
};
// Initialize with error handling
const init = () => {
try {
applyStyles();
renderContent();
} catch (error) {
document.getElementById('app').innerHTML = `
<div class="container">
<div class="card">
<h2>⚠️ Error</h2>
<p>Could not detect browser environment: ${error.message}</p>
</div>
</div>
`;
}
};
init();
</script>
</body>
</html>