-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
257 lines (230 loc) · 6.59 KB
/
Copy pathscript.js
File metadata and controls
257 lines (230 loc) · 6.59 KB
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
async function getIPInfo() {
try {
const res = await fetch("https://ipapi.co/json/");
return await res.json();
} catch {
return {};
}
}
function getScreenInfo() {
return {
width: screen.width,
height: screen.height,
colorDepth: screen.colorDepth,
pixelRatio: window.devicePixelRatio,
viewportWidth: window.innerWidth,
viewportHeight: window.innerHeight,
};
}
function getBrowserInfo() {
return {
appName: navigator.appName,
appVersion: navigator.appVersion,
cookiesEnabled: navigator.cookieEnabled,
isOnline: navigator.onLine,
};
}
function getConnection() {
const c = navigator.connection || {};
return {
effectiveType: c.effectiveType,
downlink: c.downlink,
rtt: c.rtt,
saveData: c.saveData,
};
}
function getGPUInfo() {
try {
const canvas = document.createElement("canvas");
const gl = canvas.getContext("webgl");
const debug = gl.getExtension("WEBGL_debug_renderer_info");
return {
vendor: gl.getParameter(debug.UNMASKED_VENDOR_WEBGL),
renderer: gl.getParameter(debug.UNMASKED_RENDERER_WEBGL),
};
} catch {
return { gpu: "Not available" };
}
}
async function getBatteryInfo() {
try {
const b = await navigator.getBattery();
return {
level: b.level * 100 + "%",
isCharging: b.charging,
chargingTime: b.chargingTime,
dischargingTime: b.dischargingTime,
};
} catch {
return { battery: "Not supported" };
}
}
async function getStorageInfo() {
if (!navigator.storage || !navigator.storage.estimate) {
return { status: "Storage API not supported" };
}
try {
const estimate = await navigator.storage.estimate();
const quota = estimate.quota || 0;
const usage = estimate.usage || 0;
const quotaMB = (quota / 1048576).toFixed(2);
const usedMB = (usage / 1048576).toFixed(2);
const usedPercent = quota
? ((usage / quota) * 100).toFixed(2) + "%"
: "N/A";
return {
quotaMB,
usedMB,
usedPercent,
quotaGB: (quota / (1024 ** 3)).toFixed(2),
usedGB: (usage / (1024 ** 3)).toFixed(2)
};
} catch (err) {
return {
error: "Failed to fetch storage info",
details: err.message
};
}
}
async function getPermissionsInfo() {
const perms = ["geolocation", "notifications"];
const result = {};
for (let p of perms) {
try {
const status = await navigator.permissions.query({ name: p });
result[p] = status.state;
} catch {}
}
return result;
}
async function getMediaInfo() {
try {
const devices = await navigator.mediaDevices.enumerateDevices();
return {
totalDevices: devices.length,
audioInputs: devices.filter((d) => d.kind === "audioinput").length,
videoInputs: devices.filter((d) => d.kind === "videoinput").length,
};
} catch {
return {};
}
}
function getPageInfo() {
return {
referrer: document.referrer || "None",
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
time: new Date().toLocaleString(),
};
}
function getLocationInfo() {
return new Promise((resolve) => {
if (!navigator.geolocation) return resolve({ status: "Not supported" });
navigator.geolocation.getCurrentPosition(
(pos) =>
resolve({
lat: pos.coords.latitude,
lng: pos.coords.longitude,
accuracy: pos.coords.accuracy + "m",
}),
() => resolve({ status: "Permission denied" }),
);
});
}
function format(obj) {
return Object.entries(obj)
.map(([k, v]) => `<b>${k}</b>: ${v}`)
.join("<br>");
}
async function getFullDeviceInfo() {
const ua = navigator.userAgent;
// Basic navigator info
const basicInfo = {
platform: navigator.platform,
userAgent: ua,
language: navigator.language,
cpuCores: navigator.hardwareConcurrency,
memoryGB: navigator.deviceMemory || "N/A",
isTouchScreen: "ontouchstart" in window,
};
// Advanced User-Agent Client Hints info
let clientHintsInfo = {};
if (navigator.userAgentData) {
try {
const uaData = navigator.userAgentData;
const highEntropy = await uaData.getHighEntropyValues([
"platform",
"platformVersion",
"model",
"architecture",
"bitness"
]);
clientHintsInfo = {
brands: uaData.brands.map(b => `${b.brand} (${b.version})`).join(", "),
platformHint: highEntropy.platform,
platformVersion: highEntropy.platformVersion,
architecture: highEntropy.architecture,
bitness: highEntropy.bitness,
mobile: uaData.mobile,
model: highEntropy.model || "N/A",
};
} catch {
clientHintsInfo = { error: "Failed to fetch client hints" };
}
} else {
clientHintsInfo = { status: "Client Hints not supported" };
}
// Merge both info objects
return { ...basicInfo, ...clientHintsInfo };
}
async function loadData() {
const ipData = await getIPInfo();
const screenInfo = getScreenInfo();
const browser = getBrowserInfo();
const gpu = getGPUInfo();
const battery = await getBatteryInfo();
const storage = await getStorageInfo();
const permissions = await getPermissionsInfo();
const media = await getMediaInfo();
const page = getPageInfo();
const location = await getLocationInfo();
const deviceDetails = await getFullDeviceInfo(); // 👈 NEW
const networkData = {
ip: ipData.ip,
city: ipData.city,
region: ipData.region,
country: ipData.country_name,
org: ipData.org,
timezone: ipData.timezone,
timestamp: new Date().toLocaleString(),
};
document.getElementById("network").innerHTML = format(networkData);
document.getElementById("screen").innerHTML = format(screenInfo);
document.getElementById("browser").innerHTML = format(browser);
document.getElementById("gpu").innerHTML = format(gpu);
document.getElementById("battery").innerHTML = format(battery);
document.getElementById("storage").innerHTML = format(storage);
document.getElementById("permissions").innerHTML = format(permissions);
document.getElementById("media").innerHTML = format(media);
document.getElementById("page").innerHTML = format(page);
document.getElementById("location").innerHTML = format(location);
document.getElementById("deviceDetails").innerHTML = format(deviceDetails); // 👈 NEW
window.allData = {
networkData,
screen: screenInfo,
browser,
gpu,
battery,
storage,
permissions,
media,
page,
location,
deviceDetails, // 👈 NEW
};
}
function copyData() {
const text = JSON.stringify(window.allData, null, 2);
navigator.clipboard.writeText(text);
alert("Copied to clipboard");
}
loadData();