Faucetme.xyz Auto faucet

Automatically login, scroll, and click faucet / Ptc

// ==UserScript==
// @name             Faucetme.xyz Auto faucet
// @namespace        bekerja pada tampermonkey maupun violentmonkey
// @version          0.3
// @description      Automatically login, scroll, and click faucet / Ptc
// @grant            GM_getValue
// @grant            GM_setValue
// @grant            GM_addStyle
// @grant            window.onurlchange
// @grant            GM_registerMenuCommand
// @require          https://update.greasyfork.org/scripts/439099/1203718/MonkeyConfig%20Modern%20Reloaded.js
// @match            https://faucetme.xyz/*
// @icon             https://i.ibb.co/XJSPdz0/large.png
// @license          Copyright OjoNgono
// ==/UserScript==

const cfg = new MonkeyConfig({
    title: 'Input Email Faucetpay:',
    menuCommand: true,
    params: {
        Email: {
            label: "Email Faucetpay",
            type: "text",
            default: ''
        },
    }
});
 
const savedEmail = cfg.get('Email');
if (!savedEmail) {
    alert("Silakan masukkan Email Faucetpay di menu pengaturan untuk melanjutkan.");
    return;
}
 
// Fungsi untuk mengisi email
function fillEmail() {
    const emailInput = document.querySelector('input[placeholder="Connect Your FaucetPay Email"]');
    if (emailInput) {
        emailInput.value = savedEmail;
    }
}
 
// Fungsi untuk mengarahkan ulang ke dashboard
function handleDashboardRedirect() {
    if (window.location.href === "https://faucetme.xyz/dashboard") {
        if (!window.localStorage.getItem("redirected")) {
            window.localStorage.setItem("redirected", "true");
            window.location.href = "https://faucetme.xyz/?r=153";
        }
    } else if (window.location.href === "https://faucetme.xyz/?r=153") {
        window.localStorage.removeItem("redirected");
    }
}
 
// Fungsi untuk scroll otomatis dan klik tombol klaim
function smoothScrollAndClick() {
    let scrollDirection = 1;
    const interval = setInterval(() => {
        window.scrollBy({
            top: scrollDirection * window.innerHeight,
            behavior: 'smooth'
        });
 
        if (window.innerHeight + window.scrollY >= document.body.offsetHeight) {
            scrollDirection = -1;
        } else if (window.scrollY === 0) {
            scrollDirection = 1;
        }
 
        const claimButton = document.querySelector('button.btn.btn-primary[type="submit"]');
        if (claimButton && !claimButton.disabled) {
            claimButton.click();
            clearInterval(interval);
        }
    }, 2000);
}
 
// Fungsi untuk memeriksa pesan sukses dan mengarahkan ulang
function checkAndRedirect() {
    const popup = document.querySelector('.swal2-popup.swal2-icon-success');
    if (popup) {
        const successMessage = popup.querySelector('.swal2-title');
        if (successMessage && successMessage.textContent.includes("Success!")) {
            window.location.href = "https://faucetme.xyz/ads";
        }
    }
}
 
// Fungsi klik tombol berdasarkan teks
function clickByText(buttonText) {
    const buttons = document.querySelectorAll('a.btn');
    for (const button of buttons) {
        if (button.textContent.trim() === buttonText) {
            button.click();
            return true;
        }
    }
    return false;
}
 
// Fungsi untuk menunggu dan mengklik tombol berdasarkan teks
function waitAndClick(buttonText, interval = 500, maxAttempts = 20) {
    let attempts = 0;
    const timer = setInterval(() => {
        attempts++;
        if (clickByText(buttonText) || attempts >= maxAttempts) {
            clearInterval(timer);
        }
    }, interval);
}
 
// Fungsi untuk menangani insufficient funds
function handleInsufficientFunds(faucetUrls, currentFaucetIndex) {
    const messagesToCheck = [
        { selector: '.swal2-popup.swal2-icon-warning #swal2-content', text: "You have been rate-limited. Please try again in a few seconds." },
        { selector: '.swal2-popup.swal2-icon-warning #swal2-content', text: "The faucet does not have sufficient funds for this transaction." },
        { selector: '.alert.alert-danger.text-center', text: "Daily claim limit for this coin reached, please comeback again tomorrow, or invite more people to get additional claims." },
        { selector: 'span.text-danger', text: "Balance empty, refilling can take up to 24 hours, please be patient" },
    ];
 
    for (const { selector, text } of messagesToCheck) {
        const element = document.querySelector(selector);
        if (element && element.innerText.trim() === text) {
            if (currentFaucetIndex < faucetUrls.length - 1) {
                currentFaucetIndex++;
                localStorage.setItem("currentFaucetIndex", currentFaucetIndex);
                window.location.href = faucetUrls[currentFaucetIndex];
            } else {
                localStorage.removeItem("currentFaucetIndex");
            }
            return;
        }
    }
}
 
// Fungsi untuk memeriksa tombol dan mengklik
function checkButtonAndRedirect(redirectUrl) {
    const button = document.querySelector('button[data-target="#ptcCaptcha"][data-toggle="modal"].bg-primary.float.bg-success');
    if (!button || button.disabled) {
        window.location.href = redirectUrl;
    }
}
 
// Fungsi klik tombol berdasarkan selector
function clickRewardButton() {
    setTimeout(() => {
        const button = document.getElementById('subbutton');
        if (button && !button.hasAttribute('disabled')) {
            button.click();
        }
    }, 16000);
}
 
// Logika utama berdasarkan URL
if (window.location.href === "https://faucetme.xyz/dashboard") {
    window.addEventListener('load', () => {
        handleDashboardRedirect();
        fillEmail();
        smoothScrollAndClick();
        setInterval(checkAndRedirect, 1000);
    });
}
 
if (window.location.href.startsWith("https://faucetme.xyz/faucet/currency/")) {
    const faucetUrls = [
        "https://faucetme.xyz/faucet/currency/xrp",
        "https://faucetme.xyz/faucet/currency/doge",
        "https://faucetme.xyz/faucet/currency/eth",
        "https://faucetme.xyz/faucet/currency/sol",
        "https://faucetme.xyz/faucet/currency/ltc",
        "https://faucetme.xyz/faucet/currency/bnb"
    ];
    let currentFaucetIndex = parseInt(localStorage.getItem("currentFaucetIndex")) || 0;
 
    handleInsufficientFunds(faucetUrls, currentFaucetIndex);
 
    const claimButton = document.querySelector('button.btn.btn-primary[type="submit"]');
    if (claimButton) {
        setTimeout(() => {
            claimButton.click();
        }, 10000);
    }
}
 
if (window.location.href === "https://faucetme.xyz/ads") {
    const redirectUrl = "https://faucetme.xyz/faucet/currency/trx";
    const interval = setInterval(() => {
        checkButtonAndRedirect(redirectUrl);
    }, 2000);
 
    setTimeout(() => {
        clearInterval(interval);
    }, 10000);
}
 
window.addEventListener('load', () => {
    waitAndClick('Go Claim', 500, 30);
});
 
const targetLink = document.querySelector('a.btn.btn-primary.btn-block.mb-2[href*="/ads/view/"]');
if (targetLink) {
    targetLink.click();
}
 
setInterval(clickRewardButton, 5000);