Greasy Fork is available in English.

Cryptocoil Auto Faucet

Automatically Login and Click Faucet

// ==UserScript==
// @name         Cryptocoil Auto Faucet
// @namespace    bekerja pada tampermonkey maupun violentmonkey
// @version      0.3
// @autor        Ojo Ngono
// @description  Automatically Login and Click Faucet
// @grant        GM_getValue
// @grant        GM_setValue
// @grant        GM_addStyle
// @grant        GM_registerMenuCommand
// @require      https://update.greasyfork.org/scripts/439099/1203718/MonkeyConfig%20Modern%20Reloaded.js
// @match        https://cryptocoil.com/*
// @antifeature  referral-link Directs to a referral link when not logged in
// @license      Copyright OjoNgono
// ==/UserScript==

(function() {
    'use strict';

    const bonusUrl = "https://cryptocoil.com/bonus";
    const faucetUrl = "https://cryptocoil.com/faucet";
    const linksUrl = "https://cryptocoil.com/links";

    function scrollToMiddle() {
        window.scrollTo(0, document.body.scrollHeight / 2);
    }

    function clickFaucetButton() {
        let button = document.querySelector('button.btn.btn-success.claim-button');
        if (button && !button.disabled) {
            button.click();
        }
    }

    if (window.location.href === "https://cryptocoil.com/dashboard") {
        window.location.href = bonusUrl;
    }

    if (window.location.href === bonusUrl) {
        setTimeout(() => {
            const errorMessage = document.querySelector('div.swal2-popup.swal2-modal.swal2-icon-error .swal2-html-container');
            if (errorMessage && errorMessage.textContent.trim() === "Invalid claim") {
                window.location.href = faucetUrl;
                return;
            }

            const claimButton = document.querySelector('button.btn.btn-success.btn-block');
            if (claimButton) {
                claimButton.click();
            }
        }, 2000);
    }

    if (window.location.href === faucetUrl) {
        window.addEventListener('load', function() {
            const limitMessage = document.querySelector('div.alert.alert-warning.text-center');
            if (limitMessage && limitMessage.textContent.trim() === "Daily limit reached, claim from Shortlink Wall to earn energy") {
                window.location.href = linksUrl;
                return;
            }

            scrollToMiddle();

            let interval = setInterval(() => {
                clickFaucetButton();

                if (document.querySelector('button.btn.btn-success.claim-button') === null) {
                    clearInterval(interval);
                }
            }, 2000);
        });
    }
})();