-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsystemInfo.ts
47 lines (44 loc) · 1.53 KB
/
systemInfo.ts
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
// Function to get system information
export function getSystemInfo() {
const systemInfo = {
userAgent: navigator.userAgent,
platform: navigator.platform,
languages: navigator.languages,
cookieEnabled: navigator.cookieEnabled,
doNotTrack: navigator.doNotTrack,
screenWidth: window.screen.width,
screenHeight: window.screen.height,
colorDepth: window.screen.colorDepth,
timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone,
browserPlugins: getBrowserPlugins(),
javaEnabled: navigator.javaEnabled(),
battery: getBatteryInfo(),
hardwareConcurrency: navigator.hardwareConcurrency,
deviceMemory: navigator.deviceMemory,
// webGLRenderer: getWebGLRenderer(),
};
return systemInfo;
}
function getBrowserPlugins() {
const plugins = [];
for (let i = 0; i < navigator.plugins.length; i++) {
plugins.push({
name: navigator.plugins[i].name,
description: navigator.plugins[i].description,
filename: navigator.plugins[i].filename,
version: navigator.plugins[i].version,
});
}
return plugins;
}
// Helper function to retrieve battery information
function getBatteryInfo() {
if ('getBattery' in navigator) {
return {
charging: navigator.getBattery().then(battery => battery.charging),
level: navigator.getBattery().then(battery => battery.level),
};
} else {
return 'Battery API not supported';
}
}