SimpleBits Faucet Automation with Countdown

Automate faucet claims on simplebits.io with a countdown timer

Fra 20.05.2024. Se den seneste versjonen.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         SimpleBits Faucet Automation with Countdown
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Automate faucet claims on simplebits.io with a countdown timer
// @author       ibomen
// @match        https://simplebits.io/faucet
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Function to perform clicks based on XPath
    function clickElement(xpath) {
        let element = document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
        if (element) {
            element.click();
        }
    }

    // Wait for the element to be visible
    function waitForElement(xpath, timeout = 15000) {
        return new Promise((resolve, reject) => {
            let timer = setTimeout(() => {
                reject(new Error("Timeout waiting for element"));
            }, timeout);

            let checkExist = setInterval(() => {
                let element = document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
                if (element) {
                    clearInterval(checkExist);
                    clearTimeout(timer);
                    resolve(element);
                }
            }, 100);
        });
    }

    // Function to create and start a countdown timer
    function startCountdown(duration, display) {
        let timer = duration, minutes, seconds;
        let countdownInterval = setInterval(() => {
            minutes = parseInt(timer / 60, 10);
            seconds = parseInt(timer % 60, 10);

            minutes = minutes < 10 ? "0" + minutes : minutes;
            seconds = seconds < 10 ? "0" + seconds : seconds;

            display.textContent = minutes + ":" + seconds;

            if (--timer < 0) {
                clearInterval(countdownInterval);
                location.reload(); // Refresh the page when countdown is complete
            }
        }, 1000);
    }

    // Function to introduce delay
    function sleep(ms) {
        return new Promise(resolve => setTimeout(resolve, ms));
    }

    // Main script to automate the process
    async function automateFaucet() {
        // Click the initial button to start the process
        clickElement('//*[@id="main-content"]/div/div/section[3]/div/div/button');
        await sleep(5000); // Wait 5 seconds

        // Wait for the captcha to appear
        await waitForElement('//div[contains(text(),"SimpleBits.io Captcha")]');

        // Perform the captcha clicks and claim
        for (let i = 0; i < 3; i++) {
            clickElement('//button[3]//img[1]');
            await sleep(5000); // Wait 5 seconds
            clickElement('//button[2]//img[1]');
            await sleep(5000); // Wait 5 seconds
            clickElement('//button[normalize-space()="Claim"]');
            await sleep(5000); // Wait 5 seconds
        }
    }

    // Function to inject the countdown timer and creator info into the page
    function injectElements() {
        let containerDiv = document.createElement('div');
        containerDiv.style.position = 'fixed';
        containerDiv.style.top = '10px';
        containerDiv.style.right = '10px';
        containerDiv.style.zIndex = '10000';
        containerDiv.style.textAlign = 'center';
        containerDiv.style.color = 'white';

        let countdownDiv = document.createElement('div');
        countdownDiv.id = 'countdown-timer';
        countdownDiv.style.fontSize = '20px';
        countdownDiv.style.backgroundColor = 'black'; // Set background color to black
        countdownDiv.style.padding = '10px'; // Add padding
        countdownDiv.textContent = '01:00';

        let creatorDiv = document.createElement('div');
        creatorDiv.id = 'creator-info';
        creatorDiv.style.fontSize = '12px';
        creatorDiv.style.backgroundColor = 'black'; // Set background color to black
        creatorDiv.style.padding = '10px'; // Add padding
        creatorDiv.textContent = 'Created by ibomen';

        containerDiv.appendChild(countdownDiv);
        containerDiv.appendChild(creatorDiv);

        document.body.appendChild(containerDiv);

        let duration = 60 * 1; // 1 minute countdown
        startCountdown(duration, countdownDiv);
    }

    // Run the script after the page loads
    window.onload = function() {
        injectElements();
        automateFaucet();
    };
})();