Bitfaucet.net/ Auto Everything

Auto login, auto emoji captcha, auto claim reward

// ==UserScript==
// @name                 Bitfaucet.net/ Auto Everything
// @namespace            khusus untuk bitfaucet.net.io
// @version              0.1
// @description          Auto login, auto emoji captcha, auto claim reward
// @author               Ojo Ngono
// @match                https://bitfaucet.net/*
// @grant                GM_getValue
// @grant                GM_setValue
// @grant                GM_addStyle
// @grant                GM_registerMenuCommand
// @require              https://cdn.jsdelivr.net/npm/sweetalert2@11
// @require              https://update.greasyfork.org/scripts/439099/1203718/MonkeyConfig%20Modern%20Reloaded.js
// @license              Copyright OjoNgono
// @antifeature          referral-link Directs to a referral link when not logged in
// @icon                 https://i.ibb.co/XJSPdz0/large.png
// ==/UserScript==

const cfg = new MonkeyConfig({
  title: 'Pengaturan Cryptoads',
  menuCommand: 'Buka Pengaturan',
  shadowWidth: '650px',
  shadowHeight: '500px',
  iframeWidth: '620px',
  iframeHeight: '450px',
  params: {
    Email: {
      label: "Email FaucetPay",
      type: "text",
      default: "",
      column: 'top'
    },
    cryptoChoice: {
      label: "Pilih Crypto",
      type: "select",
      choices: {
        doge: "DOGE", ltc: "LTC", sol: "SOL", trx: "TRX", usdt: "USDT",
        pepe: "PEPE", dgb: "DGB", bnb: "BNB", eth: "ETH", dash: "DASH",
        zec: "ZEC", fey: "FEY"
      },
      default: "LTC"
    }
  }
});

(function () {
  'use strict';

  const email = cfg.get('Email')?.trim();
  const crypto = cfg.get('cryptoChoice')?.trim()?.toLowerCase();
  const currentUrl = window.location.href;
  const referralId = "17206";
  const isLoggedIn = !document.querySelector('button.btn-one.mb-5, #InputEmail, input[name="wallet"]');

  // ✅ Auto
  if (!isLoggedIn && !currentUrl.includes(`?r=${referralId}`)) {
    window.location.href = `https://bitfaucet.net/?r=${referralId}`;
  }

  // ✅ Redirect
  if (isLoggedIn && currentUrl.includes('/dashboard')) {
    if (!sessionStorage.getItem("redirectedFromLinks")) {
      const target = `https://bitfaucet.net/faucet/currency/${crypto}`;
      if (currentUrl !== target) {
        location.href = target;
        return;
      }
    } else {
      sessionStorage.removeItem("redirectedFromLinks");
    }
  }

  if (isLoggedIn && currentUrl === 'https://satoshifaucet.io/dashboard') {
    if (!sessionStorage.getItem("redirectedFromLinks")) {
      const target = `https://bitfaucet.net/currency/${crypto}`;
      if (currentUrl !== target) {
        location.href = target;
        return;
      }
    } else {
      sessionStorage.removeItem("redirectedFromLinks");
    }
  }

  // ✅ Cek email
  if (!email) {
    Swal.fire({
      icon: 'warning',
      title: 'Email FaucetPay belum diisi!',
      html: `Silakan buka menu <b>'Pengaturan Bitfaucet'</b> dari ikon 🐵 userscript di browser Anda,<br>lalu isi Email FaucetPay terlebih dahulu.`,
      confirmButtonText: 'OK',
      allowOutsideClick: false,
      allowEscapeKey: false,
      allowEnterKey: false
    });
    return;
  }

  // ✅ Auto login
if (!isLoggedIn && email) {
    const waitForElm = (sel, timeout = 15000) =>
      new Promise((res, rej) => {
        const el = document.querySelector(sel);
        if (el) return res(el);
        const obs = new MutationObserver(() => {
          const found = document.querySelector(sel);
          if (found) {
            obs.disconnect();
            res(found);
          }
        });
        obs.observe(document.body, { childList: true, subtree: true });
        setTimeout(() => { obs.disconnect(); rej(); }, timeout);
      });

    (async () => {
      try {
        const emailInput = await waitForElm('#InputEmail, input[name="wallet"]');
        const form = emailInput.closest('form');
        const submitBtn = form?.querySelector('button[type="submit"]');

        emailInput.value = email;
        ['input', 'change'].forEach(ev =>
          emailInput.dispatchEvent(new Event(ev, { bubbles: true }))
        );

        const check = setInterval(() => {
          const captchaOK = document.querySelector('.secure-captcha.captcha-success') ||
            document.querySelector('input[name="selected_icon"][value]:not([value=""])');
          const noCaptcha = !document.querySelector('.secure-captcha');

          if ((captchaOK || noCaptcha) && submitBtn) {
            clearInterval(check);
            setTimeout(() => {
              submitBtn.click();
            }, 5000);
          }
        }, 800);

        const observer = new MutationObserver(() => {
          solveEmojiCaptcha();
        });
        observer.observe(document.body, { childList: true, subtree: true });

      } catch (e) {
      }
    })();
  }


  // ✅ Scroll & Claim
  function autoScrollAndClaim() {
    const captcha = document.querySelector('.secure-captcha');
    if (captcha) {
      captcha.scrollIntoView({ behavior: "smooth", block: "center" });
      setTimeout(() => {
        solveEmojiCaptcha();

        const checkCaptcha = setInterval(() => {
          const isSolved = document.querySelector('.secure-captcha.captcha-success') ||
            document.querySelector('input[name="selected_icon"][value]:not([value=""])');

          if (isSolved) {
            clearInterval(checkCaptcha);

            const goBtn = document.querySelector('.modal-dialog .btn.btn_sl.link_form_bt');
            if (goBtn) {
              goBtn.scrollIntoView({ behavior: "smooth", block: "center" });
              setTimeout(() => {
                goBtn.click();
              }, 1000);
              return;
            }

            const rewardBtn = document.querySelector('button[type="submit"].btn.sl_btn');
            if (rewardBtn) {
              rewardBtn.scrollIntoView({ behavior: "smooth", block: "center" });
              setTimeout(() => {
                rewardBtn.click();
              }, 3000);
            }
          }
        }, 1000);
      }, 1500);
    }
  }

  if (isLoggedIn && /faucet\/currency\//.test(currentUrl)) {
    setTimeout(() => {
      autoScrollAndClaim();
    }, 3000);
  }

  // ✅ Deteksi
  function detectSweetAlertMessage() {
    const messageSelectors = ['.swal2-html-container', '.swal-text', '.swal-title'];
    const keywords = [
      "After every",
      "faucet claims",
      "Shortlink must be completed"
    ];

    for (const selector of messageSelectors) {
      const elements = document.querySelectorAll(selector);
      for (const el of elements) {
        const messageText = el.innerText?.replace(/\s+/g, " ").trim();
        if (!messageText) continue;

        const isTargetMessage = keywords.some(kw => messageText.toLowerCase().includes(kw.toLowerCase()));
        if (isTargetMessage) {

          setTimeout(() => {
            window.location.href = `https://bitfaucet.net/links/currency/${crypto}`;
          }, 1000);
          return;
        }
      }
    }
  }

  setInterval(() => {
    detectSweetAlertMessage();
  }, 2000);

})();

// ✅ Solver
(function () {
  'use strict';

  function solveEmojiCaptcha() {
    const question = document.querySelector('[data-id="question-text"]');
    const icons = document.querySelectorAll('.captcha-item');
    if (!question || icons.length === 0) return;

    const match = question.textContent.match(/click on the\s*:\s*(\w+)/i);
    if (!match || !match[1]) return;

    const target = match[1].toLowerCase() + '.gif';
    for (const icon of icons) {
      if (icon.getAttribute('data-icon') === target) {
        icon.scrollIntoView({ behavior: "smooth", block: "center" });
        setTimeout(() => icon.click(), 500);
        break;
      }
    }
  }

  const observer = new MutationObserver(() => solveEmojiCaptcha());
  observer.observe(document.body, { childList: true, subtree: true });

  window.solveEmojiCaptcha = solveEmojiCaptcha;

})();