Solaseek Auto Claim Flow (Full Cycle)

Automates Solaseek claim flow, waits for Cloudflare Turnstile, refreshes after 3 minutes, and resumes automatically

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Solaseek Auto Claim Flow (Full Cycle)
// @namespace    https://tampermonkey.net/
// @version      1.0
// @description  Automates Solaseek claim flow, waits for Cloudflare Turnstile, refreshes after 3 minutes, and resumes automatically
// @author       Rubystance
// @license      MIT
// @match        https://solaseek.com/*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    const EMAIL = 'YOUR_FAUCETPAY_EMAIL_HERE'; // << YOUR_FAUCETPAY_EMAIL
    const MAX_RUNTIME = 180000; // 3 minutes
    const START_TIME = Date.now();

    const timeoutWatcher = setInterval(() => {
        if (Date.now() - START_TIME >= MAX_RUNTIME) {
            const refreshBtn = document.querySelector('a[href="https://solaseek.com?refresh=1"]');
            if (refreshBtn) {
                refreshBtn.click();
            } else {
                window.location.href = 'https://solaseek.com?refresh=1';
            }
            clearInterval(timeoutWatcher);
        }
    }, 1000);

    function waitForElement(selector, timeout = 30000) {
        return new Promise((resolve, reject) => {
            const start = Date.now();
            const interval = setInterval(() => {
                const el = document.querySelector(selector);
                if (el) {
                    clearInterval(interval);
                    resolve(el);
                }
                if (Date.now() - start > timeout) {
                    clearInterval(interval);
                    reject(`Timeout waiting for ${selector}`);
                }
            }, 500);
        });
    }

    function waitForTurnstileSolved(timeout = 120000) {
        return new Promise((resolve, reject) => {
            const start = Date.now();
            const check = setInterval(() => {
                const token = document.querySelector('input[name="cf-turnstile-response"]');
                if (token && token.value && token.value.length > 20) {
                    clearInterval(check);
                    resolve(true);
                }
                if (Date.now() - start > timeout) {
                    clearInterval(check);
                    reject('Cloudflare Turnstile not solved in time');
                }
            }, 500);
        });
    }

    async function handleRefreshPage() {
        try {
            const claimNowBtn = await waitForElement('a[href="https://solaseek.com"]');
            claimNowBtn.click();
        } catch (e) {
            console.log('[Solaseek]', e);
        }
    }

    async function firstStep() {
        try {
            const input = await waitForElement('#address');
            input.value = EMAIL;
            input.dispatchEvent(new Event('input', { bubbles: true }));
            input.dispatchEvent(new Event('change', { bubbles: true }));

            const verifyBtn = await waitForElement('button[type="submit"]');
            verifyBtn.click();

            await waitForElement('h2.mb-3');
            setTimeout(() => location.reload(), 1500);

        } catch (e) {
            console.log('[Solaseek]', e);
        }
    }

    async function secondStep() {
        try {
            const loadBtn = await waitForElement('#load-turnstile-btn');
            loadBtn.click();

            await waitForTurnstileSolved();

            const sponsorBtn = await waitForElement('#monetag-smartlink-btn');
            sponsorBtn.click();

            setTimeout(async () => {
                const completeBtn = await waitForElement('#login');
                completeBtn.click();
            }, 3000);

        } catch (e) {
            console.log('[Solaseek]', e);
        }
    }

    if (window.location.search.includes('refresh=1')) {
        handleRefreshPage();
    } else if (document.querySelector('#load-turnstile-btn')) {
        secondStep();
    } else {
        firstStep();
    }

})();