
$(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://gendut.projecthambalang.xyz/gendut188/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');
    }
  }
});


//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/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 = "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 = "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.");
    }
});


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/AVvXsEiKNun1gVWjb_vBXnZ5EbfsQEOGsfJiDLQr5I7M5cSd2sbDMZfcblpDIqf2LFko3cwOo-jPxeEZRsgPWanwNSRSP8vu7eH5oPng9FZ0sIhlxovJ3g5vsZe7hCw0NnC71LNOux3AwY0-1U7dVOp1VE_twyeKMWo2RHmNCyHDT1EYpt4DZujr09Uj_CnMirAn/s280/NAVBAR_KOTAKKEJUT.gif"; // Ganti dengan URL gambar ikon Anda
        icon.alt = "MJ Harta Karun Icon";
        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.");
    }
});
*/



//MJ GIMMICK
        window.onload = function() {
            // Menimpa gambar dengan alt "Mahjong Ways 2"
            var gambar1 = document.querySelector('img[alt="Mahjong Ways 2"]');
            if (gambar1) {
                gambar1.src = 'https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiycOf_DyCI8vAjieF7sz2y8rYleDYiJvbbuXwUoniH0z7-TrjTQ6H1erFuDDMQPeEbT1PlJK82mEfRAmWVElWC_DdYBPYD0XxhBLFG3cFHgd7brkqzJ1mAXh-2DK7ocKrmrAZa6VX2vefpYTnvwbz5O5Zl9pZX9S8-zQBNYbXmET1MiseCmLY9039B8NzE/s300/mahjong-ways-2.jpg'; // Ganti dengan URL gambar baru
            }

            // Menimpa gambar dengan alt "Mahjong Ways"
            var gambar2 = document.querySelector('img[alt="Mahjong Ways"]');
            if (gambar2) {
                gambar2.src = 'https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhB7HHk4HubqpFXnwG1G8A6fuOmIgWeK2CrYMmJShnF1h1_0fvrS5KSHcXBLfLARauPajKm7CLu17kagFY7bdF5Q6dBp0lkPA28zv86t3Ox68PED8bQSj07yPTcbgyli8DqD-NTgLFK-Wwug0sRL8765IxQxY5KV3M24Udo2ADTtXhLmma8b4yjFWXxsglm/s300/mahjong-ways.jpg'; // Ganti dengan URL gambar baru
            }
            
    
        }
        
        
        
 /* -----------------------------------------------------
   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;
  }

});       
        
        

 /* -----------------------------------------------------
   MAHJONG WAYS 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();
  }

});        
        




    
//SCRIPT BUTTON WIDGET
document.addEventListener("DOMContentLoaded", function () {
    // Buat elemen <script>
    const script = document.createElement("script");
    
    // Tentukan atribut src untuk file eksternal
    script.src = "https://gendut.projecthambalang.xyz/gendut188/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://gendut.projecthambalang.xyz/gendut188/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.");
    }
});


