FLBOT_NO1

free crypto + Dice roll

// ==UserScript==
// @name         FLBOT_NO1
// @namespace    http://tampermonkey.net/
// @version      1.2
// @description  free crypto + Dice roll
// @author       Peckovic
// @license      MIT
// @match        *://*.suipick.io/*
// @match        *://*.tonpick.game/*
// @match        *://*.polpick.io/*
// @match        *://*.solpick.io/*
// @match        *://*.tronpick.io/*
// @match        *://*.dogepick.io/*
// @match        *://*.bnbpick.io/*
// @match        *://*.litepick.io/*
// @match        *://*.freetron.in/*
// @match        *://*.freebnb.in/*
// @match        *://*.freexrp.in/*
// @match        *://*.freetoncoin.in/*
// @match        *://*.usdpick.io/*
// @match        *://*.freeshib.in/*
// @match        *://*.freebitco.in/*
// @grant        none
// ==/UserScript==

(function () {
  if (window.top !== window.self || window.FLBOTv5_started) return;
  window.FLBOTv5_started = true;

  // Tab focus management
  document.addEventListener('visibilitychange', function() {
    if (document.hidden) {
      window.focus();
      if (!window.flbotAudio) {
        window.flbotAudio = new Audio();
        window.flbotAudio.src = "data:audio/wav;base64,UklGRl9vT19XQVZFZm10IBAAAAABAAEAQB8AAEAfAAABAAgAZGF0YQ...";
        window.flbotAudio.loop = true;
        window.flbotAudio.volume = 0;
      }
      window.flbotAudio.play().catch(e => console.log("[FLBOT] Audio play prevented:", e));
    }
  });

  // Poboljšane funkcije za čuvanje statistika
  function getStatsKey() {
    return `flbot_stats_${location.hostname}`;
  }

  function loadStats() {
    const statsKey = getStatsKey();
    const saved = localStorage.getItem(statsKey);
    if (saved) {
      try {
        return JSON.parse(saved);
      } catch (e) {
        console.log("[FLBOT] Greška pri učitavanju statistika:", e);
        return { profit: 0, totalBet: 0, rolls: 0, wins: 0, losses: 0, lastUpdate: Date.now() };
      }
    }
    return { profit: 0, totalBet: 0, rolls: 0, wins: 0, losses: 0, lastUpdate: Date.now() };
  }

  function saveStats(stats) {
    const statsKey = getStatsKey();
    stats.lastUpdate = Date.now();
    localStorage.setItem(statsKey, JSON.stringify(stats));
  }

  function resetStats() {
    const statsKey = getStatsKey();
    localStorage.removeItem(statsKey);
    console.log("[FLBOT] Statistike resetovane za", location.hostname);
  }

  function mergeStats(oldStats, newStats) {
    // Spaja stare i nove statistike, uzimajući veće vrednosti za ključne metrike
    return {
      profit: Math.max(oldStats.profit || 0, newStats.profit || 0),
      totalBet: Math.max(oldStats.totalBet || 0, newStats.totalBet || 0),
      rolls: Math.max(oldStats.rolls || 0, newStats.rolls || 0),
      wins: Math.max(oldStats.wins || 0, newStats.wins || 0),
      losses: Math.max(oldStats.losses || 0, newStats.losses || 0),
      lastUpdate: Date.now()
    };
  }

  const sites = [
    { host: "suipick.io", aff: "https://suipick.io/?ref=peckovic", dice: "https://suipick.io/dice.php", minBet: 0.000010000, usesIframe: false },
    { host: "tonpick.game", aff: "https://tonpick.game/?ref=ba1tazar666", dice: "https://tonpick.game/dice.php", minBet: 0.00001000, usesIframe: false },
    { host: "polpick.io", aff: "https://polpick.io/?ref=ba1tazar666", dice: "https://polpick.io/dice.php", minBet: 0.00001000, usesIframe: false },
    { host: "solpick.io", aff: "https://solpick.io/?ref=ba1tazar666", dice: "https://solpick.io/dice.php", minBet: 0.00000010, usesIframe: false },
    { host: "tronpick.io", aff: "https://tronpick.io/?ref=ba1tazar666", dice: "https://tronpick.io/dice.php", minBet: 0.000100, usesIframe: false },
    { host: "dogepick.io", aff: "https://dogepick.io/?ref=ba1tazar666", dice: "https://dogepick.io/dice.php", minBet: 0.00010000, usesIframe: false },
    { host: "bnbpick.io", aff: "https://bnbpick.io/?ref=ba1tazar666", dice: "https://bnbpick.io/dice.php", minBet: 0.00000001, usesIframe: false },
    { host: "litepick.io", aff: "https://litepick.io/?ref=ba1tazar666", dice: "https://litepick.io/dice.php", minBet: 0.00000010, usesIframe: false },
    { host: "freetron.in", aff: "https://freetron.in/faucet", dice: "https://freetron.in/games/dice", minBet: 0.0005, usesIframe: true },
    { host: "freebnb.in", aff: "https://freebnb.in/faucet", dice: "https://freebnb.in/games/dice", minBet: 0.00000010, usesIframe: true },
    { host: "freexrp.in", aff: "https://freexrp.in/faucet", dice: "https://freexrp.in/games/dice", minBet: 0.000050, usesIframe: true },
    { host: "freetoncoin.in", aff: "https://freetoncoin.in/faucet", dice: "https://freetoncoin.in/games/dice", minBet: 0.00001000, usesIframe: true },
    { host: "usdpick.io", aff: "https://usdpick.io/faucet", dice: "https://usdpick.io/games/dice", minBet: 0.00005, usesIframe: false },
    { host: "freeshib.in", aff: "https://freeshib.in/faucet", dice: "https://freeshib.in/games/dice", minBet: 10.00000000, usesIframe: true },
    { host: "freebitco.in", aff: "https://freebitco.in/?op=home#", dice: "https://freebitco.in/?op=home#", minBet: 0.00000001, usesIframe: false }
  ];

  const ROTATE_IN = 60;
  let countdown = ROTATE_IN;
  let wentToDice = false;
  let index = parseInt(localStorage.getItem("flbot_index") || "0");
  let botIsPlaying = false;
  let diceBotActive = false;
  let currentBet = 0;
  let baseBet = 0;
  let winChance = 49.5;
  let high = true;
  let autoMode = true;

  function nextSite() {
    index = (index + 1) % sites.length;
    localStorage.setItem("flbot_index", index);
    return sites[index];
  }

  function getCurrentIndex() {
    const currentSite = getCurrentSite();
    if (!currentSite) return 0;
    return sites.findIndex(site => site.host === currentSite.host);
  }

  function getCurrentSite() {
    return sites.find(site => location.hostname.includes(site.host));
  }

  function getCurrentBalance() {
    const balanceSelectors = [
      'span.balance',
      '.balance',
      '#balance',
      'span[id*="balance"]',
      'div[id*="balance"]',
      '.user-balance',
      'span.text-xs.font-bold',
      '#user_balance',
      'span.user-balance',
      '.wallet-balance',
      '#wallet_balance',
      'span.amount',
      '.amount',
      '#amount',
      'span[class*="balance"]',
      'div[class*="balance"]',
    ];

    // Prvo proveri glavni dokument
    for (const selector of balanceSelectors) {
      const element = document.querySelector(selector);
      if (element) {
        const balanceText = element.textContent || element.innerText || '';
        const balanceMatch = balanceText.match(/[\d,.]+/);
        if (balanceMatch) {
          const balance = parseFloat(balanceMatch[0].replace(/,/g, ''));
          if (!isNaN(balance)) {
            console.log(`[FLBOT] Pronađen balans: ${balance} (selektor: ${selector})`);
            return balance;
          }
        }
      }
    }

    // Ako nije pronađeno u glavnom dokumentu, proveri iframe
    const iframe = document.querySelector('iframe');
    if (iframe && iframe.contentDocument) {
      for (const selector of balanceSelectors) {
        const element = iframe.contentDocument.querySelector(selector);
        if (element) {
          const balanceText = element.textContent || element.innerText || '';
          const balanceMatch = balanceText.match(/[\d,.]+/);
          if (balanceMatch) {
            const balance = parseFloat(balanceMatch[0].replace(/,/g, ''));
            if (!isNaN(balance)) {
              console.log(`[FLBOT] Pronađen balans u iframe-u: ${balance} (selektor: ${selector})`);
              return balance;
            }
          }
        }
      }
    }

    console.log("[FLBOT] Balans nije pronađen ili je 0");
    return 0;
  }

  function isBalanceSufficient(currentBalance, requiredBet) {
    const bufferMultiplier = 10;
    const requiredBalance = requiredBet * bufferMultiplier;
    return currentBalance >= requiredBalance;
  }

  function switchToNextSiteDueToBalance() {
    if (diceBotActive) {
      console.log("[FLBOT] ⚠️ Dice bot je aktivan - neću prebaciti na sljedeći sajt zbog balansa");
      return;
    }

    console.log("[FLBOT] ⚠️ Nedovoljan balans - prebacujem na sljedeći sajt");
    botIsPlaying = false;
    updatePanel();

    setTimeout(() => {
      const next = nextSite();
      location.href = next.aff;
    }, 3000);
  }

  function createPanel() {
  const panel = document.createElement("div");
  panel.id = "flbotPanel";
  panel.style = `
    position: fixed;
    bottom: 10px;
    right: 10px;
    background: rgba(0,0,0,0.8);
    color: #fff;
    font-family: Arial, sans-serif;
    font-size: 12px;
    padding: 10px;
    border-radius: 8px;
    width: auto;
    min-width: 260px;
    max-width: 100%;
    max-height: none;
    overflow-y: visible;
    z-index: 9999999;
    box-shadow: 0 0 10px #000;
  `;
  panel.innerHTML = `
    <div style="font-weight: bold; margin-bottom: 6px; text-align: center;">FLBOT Panel v1.0</div>
    <div>Tab Status: <span id="flbotFocusStatus" style="color: #4CAF50;">Active</span></div>
    <div>Countdown: <span id="flbotCountdown">${countdown}</span>s</div>
    <div>Status: <span id="flbotStatus">Čekam...</span></div>
    <div>Balance: <span id="flbotBalance">Provjeram...</span></div>
    <div style="margin-top: 8px; font-weight: bold;">Sajtovi:</div>
    <ul id="flbotSiteList" style="padding-left: 18px; margin: 4px 0 0 0; white-space: nowrap;"></ul>

    <!-- STEP 1 - positioned exactly like in screenshot -->
    <div id="flbot-step1" style="
      position: absolute;
      top: 90px;
      left: 170px;
      color: white;
      font-size: 14px;
      font-weight: bold;
      text-align: center;
      line-height: 1.2;
    ">
      Step 1<br>
      <span style="font-size: 20px; color: #4CAF50;">↓</span>
    </div>

    <!-- Auto Play dugme -->
    <button id="flbot-play" disabled style="
      margin-top: 10px;
      background: gray;
      color: white;
      border: none;
      padding: 6px 50px;
      font-size: 14px;
      font-weight: bold;
      border-radius: 4px;
      cursor: not-allowed;
      display: block;
      margin-left:auto;
      margin-right: 0;
    ">Auto Play</button>

    <!-- Step 2 - positioned exactly like in screenshot -->
    <div id="flbot-Step2" style="
      position: absolute;
      bottom: 10px;
      left: 20%;
      transform: translateX(-50%);
      color: white;
      font-size: 14px;
      font-weight: bold;
      text-align: center;
      line-height: 1.2;
    ">
      <span style="font-size: 12px; font-weight: bold;">Step 2</span>
<span style="font-size: 20px; margin-left: 5px; color: #4CAF50;">→</span>


    </div>
  `;
  document.body.appendChild(panel);
}


  function updatePanel() {
    const countdownEl = document.getElementById("flbotCountdown");
    if (countdownEl) countdownEl.textContent = countdown;

    const statusEl = document.getElementById("flbotStatus");
    if (statusEl) {
      statusEl.textContent = botIsPlaying ? "Bot igra..." : "Čekam...";
      statusEl.style.color = botIsPlaying ? "#4CAF50" : "#fff";
    }

    const focusStatusEl = document.getElementById("flbotFocusStatus");
    if (focusStatusEl) {
      focusStatusEl.textContent = document.hidden ? "Inactive" : "Active";
      focusStatusEl.style.color = document.hidden ? "red" : "#4CAF50";
    }

    const balanceEl = document.getElementById("flbotBalance");
    if (balanceEl) {
      const currentBalance = getCurrentBalance();
      if (currentBalance > 0) {
        balanceEl.textContent = currentBalance.toFixed(8);
        balanceEl.style.color = "#4CAF50";
      } else {
        balanceEl.textContent = "0 ili N/A";
        balanceEl.style.color = "#ff6b6b";
      }
    }

    const siteListEl = document.getElementById("flbotSiteList");
    if (!siteListEl) return;

    siteListEl.innerHTML = "";
    const currentSite = getCurrentSite();
    sites.forEach((site, i) => {
      const li = document.createElement("li");
      li.style.cursor = "default";
      li.style.padding = "2px 6px";
      li.style.borderRadius = "4px";
      li.style.display = "flex";
      li.style.alignItems = "center";
      li.style.justifyContent = "space-between";
      li.title = site.aff;

      const siteText = document.createElement("span");
      siteText.textContent = `${i + 1}. ${site.host}`;

      const regBtn = document.createElement("button");
      regBtn.textContent = "REG";
      regBtn.style.background = "#000";
      regBtn.style.color = "#fff";
      regBtn.style.border = "1px solid #333";
      regBtn.style.padding = "2px 8px";
      regBtn.style.borderRadius = "4px";
      regBtn.style.cursor = "pointer";
      regBtn.style.fontSize = "10px";
      regBtn.style.marginLeft = "5px";
      regBtn.style.minWidth = "105px";
      regBtn.style.height = "20px";
      regBtn.style.transition = "transform 0.2s ease";
      regBtn.onmouseover = () => regBtn.style.transform = "scale(1.1)";
      regBtn.onmouseout = () => regBtn.style.transform = "scale(1)";
      regBtn.onclick = () => location.href = site.aff;

      li.appendChild(siteText);
      li.appendChild(regBtn);

      if (site === currentSite) {
        li.style.backgroundColor = "#4CAF50";
        li.style.fontWeight = "bold";
        li.style.color = "#fff";
      } else {
        li.style.backgroundColor = "transparent";
        li.style.color = "#ccc";
      }

      siteListEl.appendChild(li);
    });
  }

  function startCountdown() {
    const timer = setInterval(() => {
      countdown--;
      updatePanel();

      if (countdown <= 10 && !wentToDice) {
        const site = getCurrentSite();
        if (site) {
          if (site.host === "freebitco.in") {
            wentToDice = true;
            const next = nextSite();
            location.href = next.aff;
            clearInterval(timer);
          } else if (!location.href.includes("/dice") && !location.href.includes("/games/dice")) {
            wentToDice = true;
            location.href = site.dice;
            clearInterval(timer);
          }
        }
      }

      if (countdown <= 0) {
        if (diceBotActive) {
          console.log("[FLBOT] ⚠️ Dice bot je aktivan - neću prebaciti na sljedeći sajt zbog timeout-a");
          return;
        }

        const next = nextSite();
        location.href = next.aff;
        clearInterval(timer);
      }
    }, 1000);
  }

  function startDiceTimeout() {
    console.log('[FLBOT] Pokrećem 10-sekundni timeout za dice...');
    setTimeout(() => {
      if (!botIsPlaying) {
        console.log('[FLBOT] ⏰ Timeout - bot ne igra, prelazim na sledeći sajt');
        const next = nextSite();
        location.href = next.aff;
      } else {
        console.log('[FLBOT] Bot igra, ne prekidam...');
      }
    }, 10000);
  }

  const TURNSTILE_RESPONSE_SELECTOR = 'input[name="cf-turnstile-response"]';
  const CLAIM_BUTTON_TEXT = 'claim';
  let isClaimClicked = false;

  function isVerificationComplete() {
    const input = document.querySelector(TURNSTILE_RESPONSE_SELECTOR);
    return input && input.value.trim() !== '';
  }

  function clickClaimButton() {
    if (isClaimClicked) return;
    const buttons = Array.from(document.querySelectorAll('button, input[type="submit"], input[type="button"]'));
    for (const btn of buttons) {
      const text = (btn.textContent || btn.value || "").trim().toLowerCase();
      if (text === CLAIM_BUTTON_TEXT) {
        console.log("[FLBOT] Verifikacija ok, klik na Claim dugme");
        btn.click();
        isClaimClicked = true;
        break;
      }
    }
  }

  function checkClaimLoop() {
    if (isVerificationComplete()) {
      clickClaimButton();
    } else {
      console.log("[FLBOT] Čekam turnstile verifikaciju...");
    }
  }

  function waitForEl(selector, callback, maxAttempts = 20) {
    let attempts = 0;
    const checkElement = () => {
      const el = document.querySelector(selector);
      if (el) return callback(el);
      attempts++;
      if (attempts < maxAttempts) setTimeout(checkElement, 500);
      else console.warn(`[FLBOT] Element ${selector} nije pronađen nakon ${maxAttempts} pokušaja`);
    };
    checkElement();
  }

  function getIframeDocument(iframe) {
    try {
      return iframe.contentDocument || iframe.contentWindow.document;
    } catch (e) {
      console.error("[FLBOT] Greška pri pristupu iframe dokumentu:", e);
      return null;
    }
  }

  function getDiceElements() {
    const currentSite = getCurrentSite();
    if (!currentSite) return null;

    if (currentSite.usesIframe) {
      const iframe = document.querySelector('iframe');
      if (!iframe) return null;

      const iframeDoc = getIframeDocument(iframe);
      if (!iframeDoc) return null;

      return {
        betInput: iframeDoc.querySelector('#bet_amount'),
        rollBtn: iframeDoc.querySelector('#roll_dice'),
        resultSpan: iframeDoc.querySelector('.result_maker span')
      };
    } else {
      return {
        betInput: document.querySelector('#bet_amount'),
        rollBtn: document.querySelector('#roll_dice'),
        resultSpan: document.querySelector('.result_maker span')
      };
    }
  }

  function startDiceBot() {
    console.log('[FLBOT] Pokrećem dice bot...');

    const site = getCurrentSite();
    if (!site) return;

    const currentBalance = getCurrentBalance();
    const requiredBet = site.minBet;

    if (!isBalanceSufficient(currentBalance, requiredBet)) {
      console.log(`[FLBOT] ⚠️ Nedovoljan balans! Trenutni: ${currentBalance}, Potreban: ${requiredBet * 10}`);
      switchToNextSiteDueToBalance();
      return;
    }

    botIsPlaying = true;
    diceBotActive = true;
    updatePanel();

    baseBet = site.minBet;
    currentBet = baseBet;
    winChance = 49.5;
    high = true;
    autoMode = true;

    let stats = loadStats();
    let { profit, totalBet, rolls, wins, losses } = stats;

    const panel = document.createElement('div');
    panel.style = 'position:fixed;top:550px;right:40px;background:#111;color:#0f0;padding:10px;font-family:monospace;z-index:9999;border:2px solid #0f0;border-radius:8px;';
    panel.innerHTML = `
      <b>🎲 FLBOT - ${site.host}</b><br>
      Balance: <span id="flbot-balance-display">${currentBalance.toFixed(8)}</span><br>
      Rolls: <span id="flbot-rolls">${rolls}</span><br>
      Wins: <span id="flbot-wins">${wins}</span><br>
      Losses: <span id="flbot-losses">${losses}</span><br>
      Profit: <span id="flbot-profit">${profit.toFixed(8)}</span><br>
      Total Bet: <span id="flbot-total">${totalBet.toFixed(8)}</span><br>
      <button id="flbot-reset" style="background:#f00;color:#fff;border:none;padding:5px;margin-top:5px;border-radius:4px;cursor:pointer;">Reset Stats</button>
    `;
    document.body.appendChild(panel);

    document.getElementById('flbot-reset').addEventListener('click', () => {
    resetStats();
    profit = 0;
    totalBet = 0;
    rolls = 0;
    wins = 0;
    losses = 0;
    updateDisplay();
    console.log('[FLBOT] Statistike resetovane');  // Samo log u konzolu, nema prozora
});

    const updateDisplay = () => {
      const currentStats = loadStats();
      document.getElementById('flbot-rolls').textContent = currentStats.rolls;
      document.getElementById('flbot-wins').textContent = currentStats.wins;
      document.getElementById('flbot-losses').textContent = currentStats.losses;
      document.getElementById('flbot-profit').textContent = currentStats.profit.toFixed(8);
      document.getElementById('flbot-total').textContent = currentStats.totalBet.toFixed(8);

      const newBalance = getCurrentBalance();
      const balanceDisplay = document.getElementById('flbot-balance-display');
      if (balanceDisplay) {
        balanceDisplay.textContent = newBalance.toFixed(8);
      }
    };

    const play = () => {
      if (!autoMode) return;

      const diceElements = getDiceElements();
      if (!diceElements || !diceElements.betInput || !diceElements.rollBtn || !diceElements.resultSpan) {
        console.warn('[FLBOT] Nedostaju elementi za dice igru');
        setTimeout(play, 5000);
        return;
      }

      const currentBalance = getCurrentBalance();
      if (!isBalanceSufficient(currentBalance, currentBet)) {
        console.log(`[FLBOT] ⚠️ Nedovoljan balans za bet ${currentBet}! Trenutni balans: ${currentBalance}`);
        botIsPlaying = false;
        diceBotActive = false;
        setTimeout(() => {
          const next = nextSite();
          location.href = next.aff;
        }, 10000);
        return;
      }

      try {
        diceElements.betInput.value = currentBet.toFixed(8);
      } catch (e) {
        console.error('[FLBOT] Greška pri postavljanju vrednosti bet-a:', e);
        setTimeout(play, 5000);
        return;
      }

      console.log("[FLBOT] ⏳ Čekam 10 sekundi prije klika na ROLL DICE...");
      setTimeout(() => {
        const balanceBeforeRoll = getCurrentBalance();
        if (!isBalanceSufficient(balanceBeforeRoll, currentBet)) {
          console.log(`[FLBOT] ⚠️ Balans se promijenio! Čekam 10s...`);
          setTimeout(play, 10000);
          return;
        }

        try {
          diceElements.rollBtn.click();
          console.log("[FLBOT] 🎲 Kliknuo ROLL DICE");

          setTimeout(() => {
            try {
              const resultText = diceElements.resultSpan.textContent;
              const result = parseFloat(resultText);
              if (isNaN(result)) {
                console.warn('[FLBOT] Nevalidan rezultat:', resultText);
                setTimeout(play, 5000);
                return;
              }

              totalBet += currentBet;

              const isWin = (high && result > 100 - winChance) || (!high && result < winChance);
              if (isWin) {
                wins++;
                profit += currentBet * (100 / winChance - 1);
                currentBet = baseBet;

                rolls++;
                const newStats = { profit, totalBet, rolls, wins, losses };
                const mergedStats = mergeStats(loadStats(), newStats);
                saveStats(mergedStats);
                updateDisplay();

                console.log('[FLBOT] ✅ WIN - Čekam 10s i rotiram sajt');
                botIsPlaying = false;
                diceBotActive = false;
                autoMode = false;

                setTimeout(() => {
                  const next = nextSite();
                  location.href = next.aff;
                }, 10000);
                return;
              } else {
                losses++;
                currentBet *= 2;

                const nextBalance = getCurrentBalance();
                if (!isBalanceSufficient(nextBalance, currentBet)) {
                  console.log(`[FLBOT] ⚠️ Sljedeći bet prevelik. Čekam 10s i rotiram`);
                  const newStats = { profit, totalBet, rolls, wins, losses };
                  const mergedStats = mergeStats(loadStats(), newStats);
                  saveStats(mergedStats);
                  botIsPlaying = false;
                  diceBotActive = false;
                  autoMode = false;

                  setTimeout(() => {
                    const next = nextSite();
                    location.href = next.aff;
                  }, 10000);
                  return;
                }
              }

              rolls++;
              const newStats = { profit, totalBet, rolls, wins, losses };
              const mergedStats = mergeStats(loadStats(), newStats);
              saveStats(mergedStats);
              updateDisplay();

              if (autoMode) setTimeout(play, 10000);
            } catch (e) {
              console.error('[FLBOT] Greška pri obradi rezultata:', e);
              setTimeout(play, 10000);
            }
          }, 1500);
        } catch (e) {
          console.error('[FLBOT] Greška pri kliku na roll dugme:', e);
          setTimeout(play, 10000);
        }
      }, 10000);
    };

    play();
  }

  function handleFreeBitcoin() {
    function clickFreeBtcAfterDelay() {
      const freePlayBtn = document.getElementById("free_play_form_button");
      if (freePlayBtn && !freePlayBtn.disabled) {
        console.log("[FLBOT] Čekam 30 sekundi pre klika FREE BTC dugmeta na freebitco.in");
        setTimeout(() => {
          console.log("[FLBOT] Klikćem FREE BTC dugme na freebitco.in");
          freePlayBtn.click();
        }, 30000);
      } else {
        setTimeout(clickFreeBtcAfterDelay, 1000);
      }
    }
    clickFreeBtcAfterDelay();
  }

  createPanel();

  const currentIndex = getCurrentIndex();
  if (currentIndex !== -1) {
    index = currentIndex;
    localStorage.setItem("flbot_index", index);
  }

  const currentSite = getCurrentSite();
  if (currentSite && (location.href.includes("/dice") || location.href.includes("/games/dice"))) {
    startDiceTimeout();
    if (currentSite.usesIframe) {
      console.log('[FLBOT] Detektovana dice stranica sa iframe-om');
      const waitForIframe = setInterval(() => {
        const iframe = document.querySelector("iframe");
        if (iframe) {
          clearInterval(waitForIframe);
          console.log("[FLBOT] Iframe pronađen, pokrećem dice bot");
          setTimeout(() => {
            startDiceBot();
          }, 3000);
        }
      }, 1000);
    } else {
      waitForEl("#bet_amount", () => {
        waitForEl("#roll_dice", () => {
          waitForEl(".result_maker span", startDiceBot);
        });
      });
    }
  } else {
    startCountdown();
    setInterval(checkClaimLoop, 3000);

    if (location.hostname.includes("freebitco.in")) {
      handleFreeBitcoin();
    }
  }

  updatePanel();

  setInterval(updatePanel, 5000);

  setInterval(() => {
    if (document.hidden) {
      window.focus();
    }
  }, 5000);
})();