File size: 4,270 Bytes
3616790
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Free Unlimited Google Veo 3 NSFW</title>
    
    <!-- Meta tags untuk mencegah caching halaman HTML -->
    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Expires" content="0">
    
    <style>
        html, body {
            margin: 0;
            padding: 0;
            width: 100%;
            height: 100%;
        }
        #loading {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(255, 255, 255, 0.8);
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: 24px;
            z-index: 1000;
        }
        iframe {
            width: 100%;
            height: 100vh;
            border: none;
        }
    </style>
</head>
<body>
    <div id="loading">Please wait Memilih server optimal...</div>
    <iframe id="streamlit-frame"></iframe>

    <script>
    // Ganti ini dengan versi baru setiap kali Anda update link SERVERS (misalnya "v2", "v3", dll.)
    const VERSION = "v1";  // Ubah ini ke nilai baru untuk memaksa update (contoh: "v2" saat link berubah)

    // Array server dengan link baru Anda (ganti sesuai kebutuhan)
    const SERVERS = [
        "https://glm45.balianone.workers.dev/?embed=true",  // Ganti dengan link baru
        "https://glm45.balianone.workers.dev/?embed=true"   // Ganti dengan link baru
    ];

    // Fungsi untuk mengecek kecepatan respons server (sama seperti sebelumnya, tapi tambah timeout)
    async function checkServerSpeed(url) {
        const start = performance.now();
        try {
            const response = await Promise.race([
                fetch(url, { method: 'HEAD', mode: 'no-cors' }),
                new Promise((_, reject) => setTimeout(() => reject(new Error('Timeout')), 5000))  // Timeout 5 detik
            ]);
            const end = performance.now();
            return end - start;
        } catch (error) {
            console.error(`Error checking ${url}:`, error);
            return Infinity;
        }
    }

    // Fungsi untuk memilih server berdasarkan kecepatan respons
    async function chooseServer() {
        const speeds = await Promise.all(SERVERS.map(checkServerSpeed));
        const fastestIndex = speeds.indexOf(Math.min(...speeds));
        return SERVERS[fastestIndex];
    }

    // Fungsi untuk memuat Streamlit
    async function loadStreamlit() {
        const loadingElement = document.getElementById('loading');
        const iframe = document.getElementById('streamlit-frame');

        // Gunakan key sessionStorage dengan VERSION untuk cache busting
        const storageKey = `streamlitUrl_${VERSION}`;
        let chosenUrl = sessionStorage.getItem(storageKey);

        if (!chosenUrl) {
            // Jika belum ada atau version berubah, pilih server baru dan simpan
            chosenUrl = await chooseServer();
            sessionStorage.setItem(storageKey, chosenUrl);
        }

        // Tambahkan cache busting ke URL iframe (timestamp unik)
        const cacheBuster = new Date().getTime();  // Timestamp untuk memaksa no-cache
        const iframeSrc = `${chosenUrl}&cb=${cacheBuster}`;  // Append ?cb=timestamp jika URL sudah punya query

        // Set src iframe
        iframe.src = iframeSrc;

        // Event onload untuk sembunyikan loading
        iframe.onload = () => {
            loadingElement.style.display = 'none';
        };

        // Fallback: Jika iframe gagal load (misalnya URL lama invalid), pilih ulang
        iframe.onerror = async () => {
            console.warn('Iframe load failed, rechoosing server...');
            sessionStorage.removeItem(storageKey);  // Hapus storage lama
            chosenUrl = await chooseServer();
            sessionStorage.setItem(storageKey, chosenUrl);
            iframe.src = `${chosenUrl}&cb=${new Date().getTime()}`;
        };
    }

    // Jalankan loadStreamlit saat halaman dimuat
    window.onload = loadStreamlit;
    </script>
</body>
</html>