SatsFaucet Auto Dashboard + Bounty LOOP

Continuous automation: Dashboard → Faucet → Bounty → Claim → wait 1h → repeat

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         SatsFaucet Auto Dashboard + Bounty LOOP
// @namespace    http://tampermonkey.net/
// @version      1.7
// @description  Continuous automation: Dashboard → Faucet → Bounty → Claim → wait 1h → repeat
// @author       Rubystance
// @license      MIT
// @match        https://www.satsfaucet.com/app/*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    const log = (...args) => console.log('[SatsBot]', ...args);

    const ONE_HOUR = 60 * 60 * 1000;
    const STORAGE_KEY = 'satsfaucet_last_claim';

    function isVisible(el) {
        if (!el) return false;
        const r = el.getBoundingClientRect();
        return r.width > 0 && r.height > 0;
    }

    function clickByText(tag, text) {
        const els = [...document.querySelectorAll(tag)];
        return els.find(el =>
            el.textContent.trim().toLowerCase() === text &&
            isVisible(el)
        );
    }

    function clickAllClaimRewards() {
        const buttons = [...document.querySelectorAll('button')];

        buttons.forEach(btn => {
            if (
                btn.textContent.trim().toLowerCase() === 'claim reward' &&
                !btn.disabled &&
                isVisible(btn)
            ) {
                btn.click();
                log('Clicked: Claim reward');

                localStorage.setItem(STORAGE_KEY, Date.now().toString());
            }
        });
    }

    function handleDashboard() {
        const faucet = clickByText('span', 'faucet');
        if (faucet) {
            faucet.click();
            log('Clicked: Faucet (Dashboard)');
        }
    }

    function handleBounty() {
        clickAllClaimRewards();
    }

    function checkCooldownAndRestart() {
        const lastClaim = localStorage.getItem(STORAGE_KEY);
        if (!lastClaim) return;

        const elapsed = Date.now() - Number(lastClaim);

        if (elapsed >= ONE_HOUR) {
            log('Cooldown finished. Restarting routine.');
            localStorage.removeItem(STORAGE_KEY);
            location.href = 'https://www.satsfaucet.com/app/dashboard';
        }
    }

    let lastURL = location.href;

    setInterval(() => {
        if (location.href !== lastURL) {
            lastURL = location.href;
            log('URL changed:', lastURL);
        }

        checkCooldownAndRestart();

        if (lastURL.includes('/app/dashboard')) {
            handleDashboard();
        }

        if (lastURL.includes('/app/bounty')) {
            handleBounty();
        }
    }, 1000);

    const observer = new MutationObserver(() => {
        if (location.href.includes('/app/bounty')) {
            handleBounty();
        }
    });

    observer.observe(document.body, {
        childList: true,
        subtree: true
    });

})();