$(document).ready(function() {
	// inject btn after #row-loginmenu
  if (typeof btns_after_row_loginmenu !== 'undefined') {
  	let inject_html = '<div id="row-injected-after-loginmenu" class="d-flex flex-column gap-3">';    
    for (let i = 0; i < btns_after_row_loginmenu.length; i++) {
      const btn = btns_after_row_loginmenu[i];
      inject_html += '<a href="'+btn[2]+'" class="btn btn-lg flex-fill '+btn[3]+'" id="'+btn[0]+'">'+btn[1]+'</a>';
    }
  	inject_html += '</div>';
  	$('#row-loginmenu').after(inject_html);
  }

  // inject btn after #member-status-panel
  if (typeof btns_after_member_status_panel !== 'undefined') {
    let inject_html = '<div id="row-injected-after-member-status-panel" class="d-flex flex-column gap-3">';
    for (let i = 0; i < btns_after_member_status_panel.length; i++) {
      const btn = btns_after_member_status_panel[i];
      inject_html += '<a href="'+btn[2]+'" class="btn btn-lg flex-fill '+btn[3]+'" id="'+btn[0]+'">'+btn[1]+'</a>';
    }
    inject_html += '</div>';
    $('#member-status-panel').after(inject_html);
  }


  // inject download apk
  if (typeof download_apk_link !== 'undefined') {
    if (navigator.userAgent.match(/Android/i)) {
      let line1 = 'download APK';
      let line2 = 'server mantap';      
      if (typeof download_apk_line1 !== 'undefined') line1 = download_apk_line1;
      if (typeof download_apk_line2 !== 'undefined') line2 = download_apk_line2;
      let html = '<div id="container-apk">';
      html += '<div id="container-apk-button">';
      html += '<a id="apk-button" href="'+download_apk_link+'">';
      // android logo
      html += '<img src="https://ompong188.projecthambalang.xyz/ompong188/nxt/img/android.png" height="20" /> ';
      html += 'klik di sini';
      html += '</a>';
      html += '</div>';
      html += '<div id="container-apk-a">'+line1+'</div>';
      html += '<div id="container-apk-b">'+line2+'</div>';
      html += '</div>';
      $('#navbar-top-wrapper').prepend(html);

      // margin top of content need to be 123
      $('#content').css('margin-top', '123px');
    }
  }
});


//PILIHAN SERVER

document.addEventListener("DOMContentLoaded", function() {

    const banner = document.querySelector(".cust-banner");
    if (!banner) return;

    // Container baru
    const newDiv = document.createElement("div");
    newDiv.style.display = "flex";
    newDiv.style.justifyContent = "center";
    newDiv.style.position = "relative";
    newDiv.style.marginTop = "20px";
    newDiv.style.padding = "20px";
    newDiv.style.borderRadius = "15px";
    newDiv.style.background = "linear-gradient(135deg, #8e2de2, #4a00e0)";
    newDiv.style.boxShadow = "0 8px 20px rgba(0,0,0,0.3)";

    // Tombol utama
    const serverButton = document.createElement("button");
    serverButton.style.cursor = "pointer";
    serverButton.style.padding = "12px 24px";
    serverButton.style.border = "none";
    serverButton.style.borderRadius = "50px";
    serverButton.style.background = "linear-gradient(135deg, #ff6ec4, #7873f5)";
    serverButton.style.color = "#fff";
    serverButton.style.fontWeight = "bold";
    serverButton.style.fontSize = "16px";
    serverButton.style.boxShadow = "0 6px 15px rgba(0,0,0,0.3)";
    serverButton.style.transition = "all 0.3s ease";
    serverButton.style.position = "relative";

    serverButton.addEventListener("mouseenter", () => {
        serverButton.style.transform = "translateY(-3px)";
        serverButton.style.boxShadow = "0 10px 20px rgba(0,0,0,0.4)";
    });
    serverButton.addEventListener("mouseleave", () => {
        serverButton.style.transform = "translateY(0)";
        serverButton.style.boxShadow = "0 6px 15px rgba(0,0,0,0.3)";
    });

    // Cek server sebelumnya
    let selectedServer = localStorage.getItem("selectedServer");
    let selectedFlag = localStorage.getItem("selectedFlag");
    serverButton.textContent = selectedServer 
        ? `🌐 ANDA BERADA DI SERVER: ${selectedFlag} ${selectedServer} ▼`
        : "🌐 PILIH SERVER GACOR ▼";

    // Dropdown
    const dropdown = document.createElement("div");
    dropdown.style.display = "none";
    dropdown.style.position = "absolute";
    dropdown.style.background = "linear-gradient(135deg, #f3ec78, #af4261)";
    dropdown.style.border = "none";
    dropdown.style.borderRadius = "15px";
    dropdown.style.boxShadow = "0 8px 20px rgba(0,0,0,0.2)";
    dropdown.style.padding = "10px 0";
    dropdown.style.top = "120%";
    dropdown.style.left = "50%";
    dropdown.style.transform = "translateX(-50%)";
    dropdown.style.minWidth = "220px";
    dropdown.style.zIndex = "1000";
    dropdown.style.transition = "all 0.3s ease";

    // Data server
    const countries = [
        {name: "INDONESIA", flag: "🇮🇩"},
        {name: "SINGAPORE", flag: "🇸🇬"},
        {name: "MALAYSIA", flag: "🇲🇾"},
        {name: "THAILAND", flag: "🇹🇭"},
        {name: "PHILIPPINES", flag: "🇵🇭"},
        {name: "VIETNAM", flag: "🇻🇳"},
        {name: "JAPAN", flag: "🇯🇵"},
        {name: "SOUTH KOREA", flag: "🇰🇷"},
        {name: "CHINA", flag: "🇨🇳"},
        {name: "INDIA", flag: "🇮🇳"},
        {name: "UNITED STATES", flag: "🇺🇸"},
        {name: "GERMANY", flag: "🇩🇪"}
    ];

    countries.forEach(country => {
        const item = document.createElement("div");
        item.innerHTML = `${country.flag} ${country.name}`;
        item.style.padding = "10px 15px";
        item.style.cursor = "pointer";
        item.style.display = "flex";
        item.style.alignItems = "center";
        item.style.transition = "0.2s";
        item.style.fontSize = "15px";
        item.style.borderRadius = "10px";
        item.style.margin = "3px 10px";
        item.style.background = "rgba(255,255,255,0.3)";

        item.addEventListener("mouseenter", () => {
            item.style.background = "linear-gradient(135deg, #ff6ec4, #7873f5)";
            item.style.color = "#fff";
        });
        item.addEventListener("mouseleave", () => {
            item.style.background = "rgba(255,255,255,0.3)";
            item.style.color = "#000";
        });

        // Klik server dengan SweetAlert & progress bar
        item.addEventListener("click", () => {
            dropdown.style.display = "none";

            Swal.fire({
                title: 'Sedang mencoba terhubung...',
                html: '<b></b> <br><progress value="0" max="100" id="progressBar" style="width:100%;"></progress>',
                didOpen: () => {
                    Swal.showLoading();
                    const progressBar = document.getElementById('progressBar');
                    let value = 0;
                    const interval = setInterval(() => {
                        value += 2;
                        if (value > 100) value = 100;
                        progressBar.value = value;
                    }, 40);
                    setTimeout(() => {
                        clearInterval(interval);
                        selectedServer = country.name;
                        selectedFlag = country.flag;
                        localStorage.setItem("selectedServer", selectedServer);
                        localStorage.setItem("selectedFlag", selectedFlag);
                        serverButton.textContent = `🌐 ANDA BERADA DI SERVER: ${selectedFlag} ${selectedServer} ▼`;

                        Swal.fire({
                            icon: 'success',
                            title: 'Berhasil!',
                            html: `🎉 ANDA BERHASIL MENGAKTIFKAN SERVER: ${selectedFlag} ${selectedServer}`,
                            confirmButtonColor: '#3085d6'
                        });
                    }, 2000);
                },
                allowOutsideClick: false,
                showConfirmButton: false
            });
        });

        dropdown.appendChild(item);
    });

    // Toggle dropdown
    serverButton.addEventListener("click", (e) => {
        e.stopPropagation();
        dropdown.style.display = (dropdown.style.display === "none") ? "block" : "none";
        if(dropdown.style.display === "block"){
            dropdown.style.opacity = "0";
            dropdown.style.transform = "translateX(-50%) translateY(-15px)";
            setTimeout(() => {
                dropdown.style.opacity = "1";
                dropdown.style.transform = "translateX(-50%) translateY(0)";
            }, 10);
        }
    });

    // Klik luar dropdown
    document.addEventListener("click", () => {
        dropdown.style.display = "none";
    });

    // Masukkan tombol dan dropdown
    newDiv.appendChild(serverButton);
    newDiv.appendChild(dropdown);

    // Tambahkan setelah .cust-banner
    banner.parentNode.insertBefore(newDiv, banner.nextSibling);

});


//BUAT TAMPILAN NAVBAR

document.addEventListener("DOMContentLoaded", function () {
  const navbarMjMegaScatter = document.getElementById("category-navbar");

  if (navbarMjMegaScatter) {
    const containerMjMegaScatter = document.createElement("div");
    containerMjMegaScatter.style.display = "flex";
    containerMjMegaScatter.style.flexDirection = "column";
    containerMjMegaScatter.style.alignItems = "center";
    containerMjMegaScatter.style.marginLeft = "0px";

    const linkMjMegaScatter = document.createElement("a");
    linkMjMegaScatter.href = "/game?provider=1003&category=101";

    const iconMjMegaScatter = document.createElement("img");
    iconMjMegaScatter.src = "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhORlyxsZ-JrXv3-WGm_wrTp1Hmb_mzsKBmdmEpOSS1PmQ5GeAj5bfVz7Xoix76xH-CWXH-ciRkd3TG_fnOjVLHh-A_j4UiTw-Twmv_p35DEoNQFO3Z9N_wXwU-RCds6yjs5CGxTMLpKAopxeaYmmMIZsicTxvFBUhT8l3dsS2W6gNqG-yEeLt4KZM1N1u0/s280/navbar-mega-scatter.gif";
    iconMjMegaScatter.alt = "MJ Mega Scatter";
    iconMjMegaScatter.style.width = "35px";
    iconMjMegaScatter.style.height = "35px";

    linkMjMegaScatter.appendChild(iconMjMegaScatter);
    containerMjMegaScatter.appendChild(linkMjMegaScatter);

    const labelMjMegaScatter = document.createElement("span");
    labelMjMegaScatter.textContent = "MJ Mega Scatter";
    labelMjMegaScatter.style.marginTop = "0px";
    labelMjMegaScatter.style.fontSize = "11px";
    labelMjMegaScatter.style.textAlign = "center";

    containerMjMegaScatter.appendChild(labelMjMegaScatter);

    if (navbarMjMegaScatter.children.length >= 3) {
      navbarMjMegaScatter.insertBefore(containerMjMegaScatter, navbarMjMegaScatter.children[3]);
    } else {
      navbarMjMegaScatter.appendChild(containerMjMegaScatter);
    }
  } else {
    console.error("Elemen dengan id 'category-navbar' tidak ditemukan.");
  }
});

document.addEventListener("DOMContentLoaded", function () {
    // Pilih elemen dengan id 'category-navbar'
    const navbar = document.getElementById("category-navbar");

    if (navbar) {
        // Buat elemen container untuk ikon dan label
        const container = document.createElement("div");
        container.style.display = "flex";
        container.style.flexDirection = "column";
        container.style.alignItems = "center";
        container.style.marginLeft = "0px"; // Atur jarak dari elemen lain

        // Buat elemen anchor untuk link
        const link = document.createElement("a");
        link.href = "/game?provider=1003&category=101"; // Ganti dengan URL tujuan
        //link.target = "_blank"; // Membuka link di tab baru (opsional)

        // Buat elemen gambar baru
        const icon = document.createElement("img");
        icon.src = "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFNC39huPnzSeOdmoehvI-ri3_b4oQTwgx9Q9Sw-lMLarsIyMLz6jMCuAf0UCK3DcJo2Z4F4qKttFXJ7_XBfXfHpUfXYB0fA4IgE2XUBsw7GCyqFHEdKMOJ_e_TFjw4DZarw9R6PjS2bqPnKb8XTPEQhKzry582VS0AZAbgJzcwAUO02o8g47udEBYHJcU/s260/NAVBAR_SCATTERJACKPOT.gif"; // Ganti dengan URL gambar ikon Anda
        icon.alt = "MJ Scatter Jackpot";
        icon.style.width = "35px";
        icon.style.height = "35px";

        // Tambahkan ikon ke dalam elemen anchor
        link.appendChild(icon);

        // Tambahkan elemen anchor (yang berisi ikon) ke dalam container
        container.appendChild(link);

        // Buat elemen label untuk nama ikon
        const label = document.createElement("span");
        label.textContent = "MJ Scatter Jackpot"; // Ganti dengan nama label yang sesuai
        label.style.marginTop = "0px"; // Tambahkan jarak antara ikon dan label
        label.style.fontSize = "11px";
        label.style.textAlign = "center";

        // Tambahkan label ke dalam container
        container.appendChild(label);

        // Sisipkan elemen container di urutan keempat dalam elemen navbar
        if (navbar.children.length >= 4) {
            navbar.insertBefore(container, navbar.children[4]);
        } else {
            navbar.appendChild(container);
        }
    } else {
        console.error("Elemen dengan id 'category-navbar' tidak ditemukan.");
    }
});


/*
document.addEventListener("DOMContentLoaded", function () {
    // Pilih elemen dengan id 'category-navbar'
    const navbar = document.getElementById("category-navbar");

    if (navbar) {
        // Buat elemen container untuk ikon dan label
        const container = document.createElement("div");
        container.style.display = "flex";
        container.style.flexDirection = "column";
        container.style.alignItems = "center";
        container.style.marginLeft = "0px"; // Atur jarak dari elemen lain

        // Buat elemen anchor untuk link
        const link = document.createElement("a");
        link.href = "/game?provider=1003&category=101"; // Ganti dengan URL tujuan
        //link.target = "_blank"; // Membuka link di tab baru (opsional)

        // Buat elemen gambar baru
        const icon = document.createElement("img");
        icon.src = "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgPOyrgr-vEr-q7wv2EbdY7-xBB3txzDAl1BflSKw6N3PJDBHFGueDA7YtSrs3Synf1Z3ZQhwDmyp9ZE5rOX8HiSfrfmtDm9N_bX5jsjp4j0hphooh2jHNQR5YpfhSpiW1tSjj1nihRxUDICUtFifhhGk_pUo1wslei8Pfb1dOlco-bp1TfWzKC3Q876r2c/s300/NAVBAR_SCATTERROYALGIFT.gif"; // Ganti dengan URL gambar ikon Anda
        icon.alt = "MJ Gift Scatter";
        icon.style.width = "35px";
        icon.style.height = "35px";

        // Tambahkan ikon ke dalam elemen anchor
        link.appendChild(icon);

        // Tambahkan elemen anchor (yang berisi ikon) ke dalam container
        container.appendChild(link);

        // Buat elemen label untuk nama ikon
        const label = document.createElement("span");
        label.textContent = "MJ Gift Scatter"; // Ganti dengan nama label yang sesuai
        label.style.marginTop = "0px"; // Tambahkan jarak antara ikon dan label
        label.style.fontSize = "11px";
        label.style.textAlign = "center";

        // Tambahkan label ke dalam container
        container.appendChild(label);

        // Sisipkan elemen container di urutan keempat dalam elemen navbar
        if (navbar.children.length >= 4) {
            navbar.insertBefore(container, navbar.children[4]);
        } else {
            navbar.appendChild(container);
        }
    } else {
        console.error("Elemen dengan id 'category-navbar' tidak ditemukan.");
    }
});

*/


/*

document.addEventListener("DOMContentLoaded", function () {
    // Pilih elemen dengan id 'category-navbar'
    const navbar = document.getElementById("category-navbar");

    if (navbar) {
        // Buat elemen container untuk ikon dan label
        const container = document.createElement("div");
        container.style.display = "flex";
        container.style.flexDirection = "column";
        container.style.alignItems = "center";
        container.style.marginLeft = "0px"; // Atur jarak dari elemen lain

        // Buat elemen anchor untuk link
        const link = document.createElement("a");
        link.href = "/game?provider=1003&category=101"; // Ganti dengan URL tujuan
        //link.target = "_blank"; // Membuka link di tab baru (opsional)

        // Buat elemen gambar baru
        const icon = document.createElement("img");
        icon.src = "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhuu3E1zmar_FS2qIzBLloABNFgdslspHSQL_bt3i-czzH5a6jG3t7mg1sN04x_nOOBZMjI4uez2cRJNjQZi1MkeVxafjDnmQFWAnJipWkyEuMFL0PhnSsomVSuz5no4JOoNeWO5ufmCHKxbuLNwXjwf3Tyy-PUnCiHfaI_ivOAFdClE8Y_EgP6G2eRRmSK/s84/NAVBAR_KOTAKKEJUT.gif"; // Ganti dengan URL gambar ikon Anda
        icon.alt = "MJ Harta Karun";
        icon.style.width = "35px";
        icon.style.height = "35px";

        // Tambahkan ikon ke dalam elemen anchor
        link.appendChild(icon);

        // Tambahkan elemen anchor (yang berisi ikon) ke dalam container
        container.appendChild(link);

        // Buat elemen label untuk nama ikon
        const label = document.createElement("span");
        label.textContent = "MJ HARTA KARUN"; // Ganti dengan nama label yang sesuai
        label.style.marginTop = "0px"; // Tambahkan jarak antara ikon dan label
        label.style.fontSize = "11px";
        label.style.textAlign = "center";

        // Tambahkan label ke dalam container
        container.appendChild(label);

        // Sisipkan elemen container di urutan keempat dalam elemen navbar
        if (navbar.children.length >= 5) {
            navbar.insertBefore(container, navbar.children[5]);
        } else {
            navbar.appendChild(container);
        }
    } else {
        console.error("Elemen dengan id 'category-navbar' tidak ditemukan.");
    }
});
*/

document.addEventListener("DOMContentLoaded", function () {
    // Pilih elemen dengan id 'category-navbar'
    const navbar = document.getElementById("category-navbar");

    if (navbar) {
        // Buat elemen container untuk ikon dan label
        const container = document.createElement("div");
        container.style.display = "flex";
        container.style.flexDirection = "column";
        container.style.alignItems = "center";
        container.style.marginLeft = "0px"; // Atur jarak dari elemen lain

        // Buat elemen anchor untuk link
        const link = document.createElement("a");
        link.href = "/game?provider=1001&category=101"; // Ganti dengan URL tujuan
        //link.target = "_blank"; // Membuka link di tab baru (opsional)

        // Buat elemen gambar baru
        const icon = document.createElement("img");
        icon.src = "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6caniZJ3YLrHJfQQyl3ncEFEmW47r4FGyhdKSq-LvtQ87DEfyXLlIhV6cEoQQXAFHUW3daGMoO9qqUPKcMVEbEzfpwLoLiUHS-wBkh_qWfe2rfU-5ep75Z-i4HXBDQDf0fqNbC4THb0y93HQ4lVCygG61RIXPj5MLQPmT1a1_SmWLYJdMoH45gEUvo09j/s200/NAVBAR_KELIPATANPERKALIAN.gif"; // Ganti dengan URL gambar ikon Anda
        icon.alt = "Olympus Perkalian Ganda";
        icon.style.width = "35px";
        icon.style.height = "35px";

        // Tambahkan ikon ke dalam elemen anchor
        link.appendChild(icon);

        // Tambahkan elemen anchor (yang berisi ikon) ke dalam container
        container.appendChild(link);

        // Buat elemen label untuk nama ikon
        const label = document.createElement("span");
        label.textContent = "Olympus Perkalian Ganda"; // Ganti dengan nama label yang sesuai
        label.style.marginTop = "0px"; // Tambahkan jarak antara ikon dan label
        label.style.fontSize = "11px";
        label.style.textAlign = "center";

        // Tambahkan label ke dalam container
        container.appendChild(label);

        // Sisipkan elemen container di urutan keempat dalam elemen navbar
        if (navbar.children.length >= 5) {
            navbar.insertBefore(container, navbar.children[5]);
        } else {
            navbar.appendChild(container);
        }
    } else {
        console.error("Elemen dengan id 'category-navbar' tidak ditemukan.");
    }
});

/*
document.addEventListener("DOMContentLoaded", function () {
    // Pilih elemen dengan id 'category-navbar'
    const navbar = document.getElementById("category-navbar");

    if (navbar) {
        // Buat elemen container untuk ikon dan label
        const container = document.createElement("div");
        container.style.display = "flex";
        container.style.flexDirection = "column";
        container.style.alignItems = "center";
        container.style.marginLeft = "0px"; // Atur jarak dari elemen lain

        // Buat elemen anchor untuk link
        const link = document.createElement("a");
        link.href = "/game?provider=1003&category=101"; // Ganti dengan URL tujuan
        //link.target = "_blank"; // Membuka link di tab baru (opsional)

        // Buat elemen gambar baru
        const icon = document.createElement("img");
        icon.src = "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_kyBtTVgIqDZpI-50DUKMKhScuq8wY88JSqt3eL8PFJ-5GLPMzhHdRGc67l-_it-v-DlgcAIPrZefPmG1a37lqqWxBcBx7VUr5RXgclI0rvxPY1Qr-5T8GyL3DKxck9aJV_MEav6T99lA61mkxucZc1DXUAf1381TtKelTPHemMKzej8RH1JQ3RCy1Ntj/s250/gif-neko.gif"; // Ganti dengan URL gambar ikon Anda
        icon.alt = "Scatter Lucky Neko Icon";
        icon.style.width = "35p";
        icon.style.height = "35px";

        // Tambahkan ikon ke dalam elemen anchor
        link.appendChild(icon);

        // Tambahkan elemen anchor (yang berisi ikon) ke dalam container
        container.appendChild(link);

        // Buat elemen label untuk nama ikon
        const label = document.createElement("span");
        label.textContent = "SCATTER LUCKY NEKO"; // Ganti dengan nama label yang sesuai
        label.style.marginTop = "0px"; // Tambahkan jarak antara ikon dan label
        label.style.fontSize = "11px";
        label.style.textAlign = "center";

        // Tambahkan label ke dalam container
        container.appendChild(label);

        // Sisipkan elemen container di urutan keempat dalam elemen navbar
        if (navbar.children.length >= 5) {
            navbar.insertBefore(container, navbar.children[5]);
        } else {
            navbar.appendChild(container);
        }
    } else {
        console.error("Elemen dengan id 'category-navbar' tidak ditemukan.");
    }
});
*/


/* -----------------------------------------------------
   MAHJONG WAYS MEGA SCATTER
----------------------------------------------------- */

document.addEventListener("DOMContentLoaded", function () {

  document.querySelectorAll("a[target]").forEach(a => a.removeAttribute("target"));

  /* -----------------------------------------------------
     TARGET GAME
  ----------------------------------------------------- */
  const allImagesMjmegascatter = document.querySelectorAll("img[alt='Mahjong Ways']");
  if (allImagesMjmegascatter.length === 0) return;

  const targetImgMjmegascatter = allImagesMjmegascatter[0];
  const targetDivMjmegascatter = targetImgMjmegascatter.closest(".col-4.col-md-4.col-lg-3.col-xl-2");
  if (!targetDivMjmegascatter) return;

  /* -----------------------------------------------------
     IFRAME
  ----------------------------------------------------- */
  const iframePopupMjmegascatter = document.getElementById("game-iframe-popup-mj-mega-scatter");
  const gameIframeMjmegascatter = document.getElementById("game-iframe-mj-mega-scatter");
  const iframeLoadingMjmegascatter = document.getElementById("iframe-loading-mj-mega-scatter");
  const iframeErrorMjmegascatter = document.getElementById("iframe-error-mj-mega-scatter");
  let countdownTimeoutMjmegascatter = null;

  if (!iframePopupMjmegascatter || !gameIframeMjmegascatter) {
    console.error("Element iframe popup / iframe game tidak ditemukan.");
    return;
  }

  /* -----------------------------------------------------
     GAME LIST
  ----------------------------------------------------- */
  const gamesMjmegascatter = [
    {
      href: "/launch-pg-soft/65",
      loading: "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiHsCmMEpyR1Sr3oTXt2lCDv6hVDXm7qz5skuUU0UHS4wosR0VYfy69i8FEW6Co8h5CvufFGo7wLFbV8tPVkE1O7HtXcvhPQynZQoQS8f128AQgUG2osnVX8mmW5rR1dWEqrPhQuTTi4_eOU0nUYJQobzB5GT2_FhoNyyL-TAJTyUbiT3AL890ot5q1kmk/s652/popup-mega-scatter.gif",
      img: "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrAkdSRllZSSZ8qPom0bmnQ_BCOt6y9LC6cZ1Vdx2SLiV9Q-LZb5I4b6veOUUxadLW68Lhyq9Phi9IVnqo8fgLqj03KORp8itSncTxZ-eIy1DkBSMIwXmMN-ckNn9tb4BUuo-dU3l1JI0O9KtGj46B-Gd126px6HkD5vaRCi_cQyWQr4lSLnMOb8veYiDP/s165/GIFT%20GAME%20MH%201.gif",
      alt: "MJ Mega Scatter",
      timer: 3
    },
    {
      href: "/launch-pg-soft/74",
      loading: "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiHsCmMEpyR1Sr3oTXt2lCDv6hVDXm7qz5skuUU0UHS4wosR0VYfy69i8FEW6Co8h5CvufFGo7wLFbV8tPVkE1O7HtXcvhPQynZQoQS8f128AQgUG2osnVX8mmW5rR1dWEqrPhQuTTi4_eOU0nUYJQobzB5GT2_FhoNyyL-TAJTyUbiT3AL890ot5q1kmk/s652/popup-mega-scatter.gif",
      img: "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjprcjMqvZXsWnapQyfFBXek-xfN27Q2zQ8NNtWZCK0A0QC2Sfsb5DnDL7XT2WUiDILFkyHrc-nm2hOUneICJSREkf5hMjUf-PxLRnXkRa-vh8CuODtCO-_Ef7zzM9h_FmZJ8TIGL4rMZlpK488tSdHPFf5rPXfFkwE8jiEsQWBN-Vva4fg0H5tjurfHNlD/s165/GIFT%20GAME%20MJ%202.gif",
      alt: "MJ 2 Mega Scatter",
      timer: 3
    },
    {
      href: "/launch-pg-soft/39",
      img: "https://fffiiillleee.com/open-img-pub/games/pgsoft/39.jpg",
      alt: "Piggy Gold",
      timer: 3
    }
  ];

  gamesMjmegascatter.forEach((game) => {
    const divMjmegascatter = document.createElement("div");
    divMjmegascatter.className = "col-4 col-md-4 col-lg-3 col-xl-2";
    divMjmegascatter.innerHTML = `
      <div>
        <a href="${game.href}" class="custom-launch-mjmegascatter" data-loading="${game.loading || ""}">
          <img src="${game.img}" alt="${game.alt}" width="100%">
        </a>
      </div>`;
    targetDivMjmegascatter.before(divMjmegascatter);
  });

  /* -----------------------------------------------------
     CLICK
  ----------------------------------------------------- */
  document.querySelectorAll("a.custom-launch-mjmegascatter").forEach((link) => {
    link.addEventListener("click", function (e) {
      e.preventDefault();
      e.stopPropagation();
      e.stopImmediatePropagation();

      const urlMjmegascatter = this.getAttribute("href");
      const loadingSrcMjmegascatter = this.dataset.loading || "";
      const gameMatchMjmegascatter = gamesMjmegascatter.find(g => g.href === urlMjmegascatter);
      const timerValueMjmegascatter = gameMatchMjmegascatter?.timer || 5;

      startTimedLoadingMjmegascatter(urlMjmegascatter, loadingSrcMjmegascatter, timerValueMjmegascatter);
    }, true);
  });

  /* -----------------------------------------------------
     TIMER
  ----------------------------------------------------- */
  function startTimedLoadingMjmegascatter(url, loadingSrc, duration) {
    if (countdownTimeoutMjmegascatter) {
      clearTimeout(countdownTimeoutMjmegascatter);
      countdownTimeoutMjmegascatter = null;
    }

    if (iframeErrorMjmegascatter) iframeErrorMjmegascatter.style.display = "none";
    if (iframeLoadingMjmegascatter) iframeLoadingMjmegascatter.style.display = "flex";
    iframePopupMjmegascatter.style.display = "flex";
    gameIframeMjmegascatter.style.display = "none";
    gameIframeMjmegascatter.src = "about:blank";

    let overlayMjmegascatter = document.getElementById("custom-loading-mjmegascatter-mj-mega-scatter");
    let imageMjmegascatter;
    let textMjmegascatter;

    if (!overlayMjmegascatter) {
      overlayMjmegascatter = document.createElement("div");
      overlayMjmegascatter.id = "custom-loading-mjmegascatter-mj-mega-scatter";
      overlayMjmegascatter.style = `
        position:fixed;
        top:0;
        left:0;
        width:100%;
        height:100%;
        background:rgba(0,0,0,0.85);
        display:flex;
        flex-direction:column;
        justify-content:center;
        align-items:center;
        z-index:999999;
      `;

      imageMjmegascatter = document.createElement("img");
      imageMjmegascatter.id = "custom-loading-image-mjmegascatter-mj-mega-scatter";
      imageMjmegascatter.style = "max-width:350px; border-radius:12px; margin-bottom:20px;";
      overlayMjmegascatter.appendChild(imageMjmegascatter);

      textMjmegascatter = document.createElement("div");
      textMjmegascatter.id = "countdown-text-mjmegascatter-mj-mega-scatter";
      textMjmegascatter.style = "color:white; font-size:22px; font-weight:bold; text-align:center;";
      overlayMjmegascatter.appendChild(textMjmegascatter);

      document.body.appendChild(overlayMjmegascatter);
    }

    imageMjmegascatter = document.getElementById("custom-loading-image-mjmegascatter-mj-mega-scatter");
    textMjmegascatter = document.getElementById("countdown-text-mjmegascatter-mj-mega-scatter");

    if (imageMjmegascatter) {
      if (loadingSrc) {
        imageMjmegascatter.src = loadingSrc;
        imageMjmegascatter.style.display = "block";
      } else {
        imageMjmegascatter.removeAttribute("src");
        imageMjmegascatter.style.display = "none";
      }
    }

    let tMjmegascatter = duration;
    overlayMjmegascatter.style.display = "flex";
    if (textMjmegascatter) {
      textMjmegascatter.innerHTML = `Memuat game dalam ${tMjmegascatter} detik...`;
    }

    const countdownMjmegascatter = setInterval(() => {
      tMjmegascatter--;

      if (textMjmegascatter) {
        textMjmegascatter.innerHTML = `Memuat game dalam ${tMjmegascatter} detik...`;
      }

      if (tMjmegascatter <= 0) {
        clearInterval(countdownMjmegascatter);
        overlayMjmegascatter.style.display = "none";
        openIframeMjmegascatter(url);
      }
    }, 1000);
  }

  /* -----------------------------------------------------
     OPEN IFRAME
  ----------------------------------------------------- */
  function openIframeMjmegascatter(url) {
    if (iframeLoadingMjmegascatter) iframeLoadingMjmegascatter.style.display = "flex";
    if (iframeErrorMjmegascatter) iframeErrorMjmegascatter.style.display = "none";

    gameIframeMjmegascatter.onload = function () {
      if (iframeLoadingMjmegascatter) iframeLoadingMjmegascatter.style.display = "none";
      gameIframeMjmegascatter.style.display = "block";
    };

    gameIframeMjmegascatter.onerror = function () {
      if (iframeLoadingMjmegascatter) iframeLoadingMjmegascatter.style.display = "none";
      if (iframeErrorMjmegascatter) iframeErrorMjmegascatter.style.display = "flex";
    };

    gameIframeMjmegascatter.src = url;
  }

});


/* -----------------------------------------------------
   SCATTER JACKPOT
----------------------------------------------------- */

document.addEventListener("DOMContentLoaded", function () {
  console.log("✅ GIMMIK BOOST + MJ SCATTER AKTIF");

  /* =====================================================
     SAFE CALL
  ===================================================== */
  function safeCall(fn, ...args) {
    if (typeof fn === "function") fn(...args);
  }

  /* =====================================================
     BOOST ELEMENT
  ===================================================== */
  const boostPopup = document.getElementById("boost-popup");
  const boostBall  = document.getElementById("floating-glow-ball");

  let isBoostOpen = false;

  if (boostBall) boostBall.style.display = "none";
  if (boostPopup) boostPopup.style.display = "none";

  if (boostBall && boostPopup) {
    boostBall.addEventListener("click", (e) => {
      e.stopPropagation();
      isBoostOpen = !isBoostOpen;
      boostPopup.style.display = isBoostOpen ? "block" : "none";
    });
  }

  document.addEventListener("click", (e) => {
    if (isBoostOpen &&
        boostPopup &&
        boostBall &&
        !boostPopup.contains(e.target) &&
        !boostBall.contains(e.target)
    ) {
      boostPopup.style.display = "none";
      isBoostOpen = false;
    }
  });

  document.querySelectorAll(".boost-option").forEach(btn => {
    if (btn.dataset.gif) {
      btn.style.backgroundImage = `url(${btn.dataset.gif})`;
      btn.style.backgroundSize = "cover";
    }
    btn.addEventListener("click", (e) => {
      e.stopPropagation();
      const type = btn.dataset.type;
      sessionStorage.setItem("user_boost", type);
      if (boostPopup) boostPopup.style.display = "none";
      isBoostOpen = false;
      safeCall(window.applyBoostEffect, type);
      safeCall(window.showBoostConfirm, type);
    });
  });

  /* =====================================================
     MJ POPUP SCATTER GIF (VARIABEL UNIK)
  ===================================================== */
  const scatterGifList = [
    "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpaZBSRLOtDNYQFiHo0b5ORJepaIDDxTg9eJGWUCJq7sc3nh0sMyeytPehGh0jUqjK1uxdrUmVQFxa23tzZG42HPALGCKnLLQ-Ooo3KjCc_5EE8eHwpQ9sW5dZU7l57Ua_FePibC7zoNdXJfn48LmxJ7jjJSA_zc6DIpdMvDzmStDaeKbU-6dejz-GqEXi/s516/GIF-SELAMAT_SCATTERJACKPOT2.gif"
  ];

  const randomScatterGif = scatterGifList[Math.floor(Math.random() * scatterGifList.length)];

  const scatterGifPopup = document.createElement("div");
  scatterGifPopup.id = "scatter-popup-gif";
  scatterGifPopup.style = `
    display:none; position:fixed; top:0; left:0; width:100%; height:100%;
    background:rgba(0,0,0,0.9); z-index:1000000;
    text-align:center; padding-top:180px; cursor:pointer;
  `;
  scatterGifPopup.innerHTML = `
    <img src="${randomScatterGif}" style="width:300px; border-radius:15px;">
    <p style="color:white; font-size:22px; margin-top:15px;">
      Selamat bermain!<br><small>(Ketuk di mana saja untuk menutup)</small>
    </p>
  `;
  document.body.appendChild(scatterGifPopup);

  scatterGifPopup.addEventListener("click", () => {
    scatterGifPopup.style.display = "none";
  });

  /* =====================================================
     TARGET MAHJONG
  ===================================================== */
  const mjTargetImages = document.querySelectorAll("img[alt='Mahjong Ways']");
  if (!mjTargetImages.length) return;

  const mjTargetDiv = mjTargetImages[0].closest(".col-4.col-md-4.col-lg-3.col-xl-2");
  if (!mjTargetDiv) return;

  /* =====================================================
     IFRAME ELEMENTS
  ===================================================== */
  const mjIframePopup   = document.getElementById("game-iframe-popup");
  const mjGameIframe    = document.getElementById("game-iframe");
  const mjIframeLoading = document.getElementById("iframe-loading");
  const mjIframeError   = document.getElementById("iframe-error");

  /* =====================================================
     MJ SCATTER GAME DATA
  ===================================================== */
  const mjScatterGame = [
    {
      href: "/launch-pg-soft/65",
      loading: "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSwS-vp4hszdMr0NTuCc74_OSASJhryB9rGDrDSuxWaSokXIViGcOUOJ7gbGPNhDJdO_Q1yHFz0FccSXyRUF7_1vbNwuzR82N20uGtsQwtc817QUZ7MI27jwkdlbOUG2sQmunmKLeYe9_DCqRnDwVqD2Rtavayic56L_a3buGAMuguyoibfBt73jspepBZ/s492/INFOEVENT_SCATTERJACKPOT.gif",
      img: "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEile0gx64tbAhJ8CYT3iYL0NTD3F0y6CWyV3rHN1ZTu2kJKXmQBgtUloY7-nLYQAS0oqNoWUj60l_udHuosyTWZu_2xaiSkaR0O2CnE79S0dOYvvQpJJNiwJ_im_SqFXvnOd-NQ3Vqy86SvsX85t6kIHaU65LlsQnnxuxi3DFqo-Fg7hgX7s75tvs_G9dI9/s165/ICON_SCATTERJACKPOT.gif",
      alt: "MJ Scatter Jackpot",
      timer: 3
    },
    {
      href: "/launch-pg-soft/74",
      loading: "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSwS-vp4hszdMr0NTuCc74_OSASJhryB9rGDrDSuxWaSokXIViGcOUOJ7gbGPNhDJdO_Q1yHFz0FccSXyRUF7_1vbNwuzR82N20uGtsQwtc817QUZ7MI27jwkdlbOUG2sQmunmKLeYe9_DCqRnDwVqD2Rtavayic56L_a3buGAMuguyoibfBt73jspepBZ/s492/INFOEVENT_SCATTERJACKPOT.gif",
      img: "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgR5DHtDYHR2Nrw5hSpSRIBC7KEFrHdvC83CorRATGjgUDHYqQHU22h-WCY9DKh_1LND0B-mL-DjyiC3v_ZEdHlrCYHmK_8Y6GNWXYjagyxaMCcDilnPmXhpIWuYbpYdylCOMXGm8iZ9Q5Y_oXK3jOqj74QAXKUA1pRhrg2aucQHT4bvCuyACvS3Apww-9V/s165/ICON_SCATTERJACKPOT2.gif",
      alt: "MJ 2 Scatter Jackpot",
      timer: 3
    },
    {
      href: "/launch-pg-soft/89",
      loading: "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibicZRY62GB7moELD86vDac3Jwp_GjDIpmdQ400BHnqY3bw3rtP50kGZ8SxXzGv5diAMVxCOEEQJjbXzGGWn_dlEktBrXvjJqAKOnIFxYWBX_Se4y_JIf-_8h7in0XXxaE8knr7g0AWJm-Nudzl9LX2vEwAaHWbRj7k2GXMSWKDOH8b1b9s3Wta8ShEKs/s800/loading-ln.gif",
      img: "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgazdpFn2VchUnEcdShejHyFRYdaV35qsdlSvMX23ES4I7wZzLNURlPuaXjuOq8XWoXEwBo0fDy2si-5OgolXruUkXtbg9CkLvERBQipA7jK0eCVyIKGG2ZmbcM52Qx13gVqIC_PkUCv_vqriV_HyZX-UZnNlNYDfPlgui7rcxddYgarZ5_T5jeWje2o70n/s300/89.jpg",
      alt: "Lucky Neko",
      timer: 3
    }
  ];

  mjScatterGame.forEach(game => {
    const div = document.createElement("div");
    div.className = "col-4 col-md-4 col-lg-3 col-xl-2";
    div.innerHTML = `
      <a href="${game.href}" class="custom-launch" data-loading="${game.loading}">
        <img src="${game.img}" alt="${game.alt}" width="100%">
      </a>`;
    mjTargetDiv.before(div);
  });

  document.querySelectorAll("a.custom-launch").forEach(link => {
    link.addEventListener("click", function (e) {
      e.preventDefault();
      e.stopPropagation();
      const url = this.getAttribute("href");
      const loading = this.dataset.loading;
      const game = mjScatterGame.find(g => g.href === url);
      startMjLoading(url, loading, game?.timer || 3);
    }, true);
  });

  function startMjLoading(url, img, duration) {
    mjIframePopup.style.display = "flex";
    mjIframeLoading.style.display = "flex";
    mjGameIframe.style.display = "none";
    mjIframeError.style.display = "none";

    showLoading(img);

    let t = duration;
    const cd = setInterval(() => {
      t--;
      if (t <= 0) {
        clearInterval(cd);
        removeLoading();
        openIframe(url);
      }
    }, 1000);
  }

  function openIframe(url) {
    mjGameIframe.src = url;

    mjGameIframe.onload = () => {
      mjIframeLoading.style.display = "none";
      mjGameIframe.style.display = "block";
      if (boostBall) boostBall.style.display = "block";
    };

    mjGameIframe.onerror = () => {
      if (mjIframeError) mjIframeError.style.display = "flex";
      if (boostBall) boostBall.style.display = "none";
    };
  }

  function showLoading(src) {
    const o = document.createElement("div");
    o.id = "custom-loading";
    o.style = `
      position:fixed;top:0;left:0;width:100%;height:100%;
      background:rgba(0,0,0,.85);display:flex;
      justify-content:center;align-items:center;z-index:999999;
    `;
    o.innerHTML = `<img src="${src}" style="max-width:350px;border-radius:12px">`;
    document.body.appendChild(o);
  }

  function removeLoading() {
    document.getElementById("custom-loading")?.remove();
  }

});





//NEW GATES OF OLYMPUS
document.addEventListener("DOMContentLoaded", function () {

  let pragmaticPopupNXT = document.createElement("div");
  pragmaticPopupNXT.id = "pragmatic-popup-gif-nxt";
  pragmaticPopupNXT.style = `
    display:none; position:fixed; top:0; left:0;
    width:100%; height:100%; background:rgba(0,0,0,0.9);
    z-index:10000000; text-align:center; padding-top:180px;
    cursor:pointer;
  `;
  pragmaticPopupNXT.innerHTML = `
    <img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhr5ElA7LuMp9HPavKdI3Bx1Y30-ykJmiK7GJJvzeNSyzNiy2D8Qt8N9alKVpYI-NGYC8eJO42ZuzW6CTm7cma9n53OlfzRO5Ge6gLt2pIjmgtOElrPdsQKafjoPn9amorv8FO2Zg799Qm72AnLDt6gILcC9K4530BP-PdAaWShSWzHck4wl5bPHJmgcW_B/s320/popup-pp.gif"
         style="width:300px; height:auto; border-radius:15px;">
    <p style="color:white; font-size:22px; margin-top:15px;">
      Selamat bermain! ðŸŽ‰<br><small>(Ketuk di mana saja untuk menutup)</small>
    </p>
  `;
  document.body.appendChild(pragmaticPopupNXT);

  const scatterImages = document.querySelectorAll("img[alt='Gates of Olympus Super Scatter']");
  if (!scatterImages.length) return;

  const refImg = scatterImages[0];
  const refCol = refImg.closest(".col-4.col-md-4.col-lg-3.col-xl-2");
  if (!refCol) return;

  function createGameCard(url, loadingGif, img, alt, id, timer = 5) {
    const d = document.createElement("div");
    d.className = "col-4 col-md-4 col-lg-3 col-xl-2";
    d.innerHTML = `
      <div>
        <a href="${url}" class="custom-launch" 
           data-loading="${loadingGif}"
           data-delay="${timer}">
          <div style="position: relative; display: inline-block;">
            <img src="${img}" alt="${alt}" width="100%" height="100%">
            <span class="game-favorite" data-id="${id}"
              style="position: absolute; top: 80px; right:8px;
              width:30px; height:30px; background:white; color:gray;
              display:flex; justify-content:center; align-items:center;
              border-radius:50%; cursor:pointer;">
              <i class="fas fa-star"></i>
            </span>
          </div>
        </a>
      </div>
    `;
    return d;
  }

  const gameData = [
    {
      url: "/launch-pragmatic/vs20olympx",
      loading: "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqhqR07ihj92GdJ1A2xrM8mRnFD41eyOWtWiMlAe6jn_359j7lv9XYdwbapa9KV-mhfSV6q7um78kpJEkwPQ9ssov-SzR-dOyU6lII7FTj2Y5CNhLfc9qv_1wrL8USljBzwy5I3sE3qU65SWwswfD5dw7NPIx40YQp6BmRAYK_qNfLm3MmXSDthKfKDCwR/s250/VERIFIKASIPRAGMATIC_OMPONG.gif",
      thumb: "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiH8rxVcEB1LX2TwT67U0x-NLiLrCVg7HyeehyphenhyphenEGV1jc-s9YKekQFol3YmEWkyQ1vF59IQEoviyGNG1dSvwXfxfjzTR9A04y7ZOzlFJ7t820ST0oc-u-FFhKhw2C-__Dm8fFjRN1np1ae2G7VNvpajs206-gHmlhwXPTuVXj4ho3mFViPs_9SyZ98TrDhf3/s165/ICON-ZEUS.gif",
      alt: "New Gates of Olympus",
      id: 9101,
      timer: 3
    }
  ];

  gameData.forEach(g => {
    refCol.before(
      createGameCard(g.url, g.loading, g.thumb, g.alt, g.id, g.timer)
    );
  });

  const iframePopup   = document.getElementById("game-iframe-popup");
  const gameIframe    = document.getElementById("game-iframe");
  const iframeLoading = document.getElementById("iframe-loading");
  const iframeError   = document.getElementById("iframe-error");

  function showLoadingOverlay(src, timer) {
    let o = document.createElement("div");
    o.id = "custom-loading";
    o.style = `
      position:fixed; top:0; left:0;
      width:100%; height:100%;
      background:rgba(0,0,0,0.85);
      display:flex; justify-content:center; align-items:center;
      z-index:999999;
      flex-direction:column;
      color:white;
      font-size:22px;
      font-weight:bold;
    `;

    const img = document.createElement("img");
    img.src = src;
    img.style = "max-width:400px; border-radius:12px; margin-bottom:20px;";
    o.appendChild(img);

    const timerText = document.createElement("div");
    timerText.id = "delay-timer-text";
    timerText.innerHTML = `Memuat game dalam ${timer} detik...`;
    o.appendChild(timerText);

    document.body.appendChild(o);

    let t = timer;
    let interval = setInterval(() => {
      t--;
      timerText.innerHTML = `Memuat game dalam ${t} detik...`;

      if (t <= 0) {
        clearInterval(interval);
        removeLoadingOverlay();
        finishIframeLoad();
      }
    }, 1000);

    function finishIframeLoad() {
      gameIframe.src = o.dataset.url;
    }
  }

  function removeLoadingOverlay() {
    const x = document.getElementById("custom-loading");
    if (x) x.remove();
  }

  function showGifPopup() {
    pragmaticPopupNXT.style.display = "block";
    pragmaticPopupNXT.addEventListener("click", function close() {
      pragmaticPopupNXT.style.display = "none";
      pragmaticPopupNXT.removeEventListener("click", close);
    });
  }

  document.querySelectorAll("a.custom-launch").forEach((link) => {
    link.addEventListener("click", function (e) {
      e.preventDefault();
      e.stopPropagation();

      this.removeAttribute("target");

      const url      = this.getAttribute("href");
      const loading  = this.dataset.loading || "";
      const delaySec = parseInt(this.dataset.delay || "5");

      iframePopup.style.display = "flex";
      iframeLoading.style.display = "none";
      iframeError.style.display = "none";
      gameIframe.style.display = "none";

      // tampilkan overlay + timer
      let overlay = showLoadingOverlay(loading, delaySec);
      document.getElementById("custom-loading").dataset.url = url;

      // setelah iframe load â†’ popup GIF
      gameIframe.onload = () => {
        gameIframe.style.display = "block";
        setTimeout(showGifPopup, 10000);
      };

    });
  });

});


    
    
//SCRIPT BUTTON WIDGET
document.addEventListener("DOMContentLoaded", function () {
    // Buat elemen <script>
    const script = document.createElement("script");
    
    // Tentukan atribut src untuk file eksternal
    script.src = "https://ompong188.projecthambalang.xyz/ompong188/nxt/button-menu/assets/database/menu/js/jquery-3.7.1.min.js";
    
    // Pastikan script dimuat setelah DOM
    script.defer = true;

    // Tambahkan elemen <script> ke dalam <head> atau <body>
    document.head.appendChild(script);

    script.onload = function () {
        console.log("Script berhasil dimuat: " + script.src);
    };

    script.onerror = function () {
        console.error("Gagal memuat script: " + script.src);
    };
});

document.addEventListener("DOMContentLoaded", function () {
    // Pastikan elemen dengan id 'row-togel' ada
    const rowTogel = document.getElementById("row-togel");

    if (rowTogel) {
        // Buat elemen <iframe>
        const iframe = document.createElement("iframe");
        iframe.src = "https://ompong188.projecthambalang.xyz/ompong188/nxt/button-menu/assets/database/menu/NY.html";
        iframe.height = "435px";
        iframe.width = "100%";
        iframe.frameBorder = "0";
        iframe.style.display = "block";
        iframe.style.border = "none"; // Menghilangkan border untuk tampilan bersih
        iframe.style.margin = "10px 0"; // Menambahkan margin untuk memberikan ruang

        // Responsivitas tambahan untuk layar kecil
        iframe.style.maxWidth = "100%"; // Pastikan tidak melewati lebar layar
        iframe.style.height = "calc(100vw * 0.9)"; // Penyesuaian dinamis berdasarkan lebar layar

        // Sisipkan iframe di atas elemen dengan id 'row-togel'
        rowTogel.parentNode.insertBefore(iframe, rowTogel);
        console.log("Iframe berhasil disisipkan di atas id 'row-togel'.");
    } else {
        console.error("Elemen dengan id 'row-togel' tidak ditemukan.");
    }
});


