CfC

Click Roll & Win, select Cloudflare, handle bot alert, then claim (no redirect) + auto refresh every 1 minute

// ==UserScript==
// @name         CfC
// @namespace    http://tampermonkey.net/
// @version      1.6
// @description  Click Roll & Win, select Cloudflare, handle bot alert, then claim (no redirect) + auto refresh every 1 minute
// @author       👽
// @match        https://claimfreecoins.cc/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    const wait = ms => new Promise(resolve => setTimeout(resolve, ms));

    function realClick(el) {
        if (!el) return;
        el.scrollIntoView({ behavior: 'smooth', block: 'center' });
        el.focus();
        ['mouseover', 'mousedown', 'mouseup', 'click'].forEach(type => {
            el.dispatchEvent(new MouseEvent(type, { bubbles: true, cancelable: true, view: window }));
        });
    }

    async function selectCloudflare() {
        const select = document.querySelector('select.form-control.custom-select');
        if (!select) {
            console.warn('[AutoRoll] Cloudflare select not found');
            return false;
        }
        select.value = '3';
        select.dispatchEvent(new Event('change', { bubbles: true }));
        console.log('[AutoRoll] Cloudflare selected');
        return true;
    }

    async function clickRollWin() {
        const buttons = Array.from(document.querySelectorAll('button'))
            .filter(b => b.textContent.includes('Roll & Win') && !b.hasAttribute('data-target'));
        if (buttons.length === 0) {
            console.warn('[AutoRoll] Final Roll & Win button not found');
            return false;
        }
        realClick(buttons[0]);
        console.log('[AutoRoll] Final Roll & Win button clicked');
        return true;
    }

    async function handleBotAlert() {
        const alert = document.querySelector('.alert.alert-danger');
        if (alert && alert.textContent.includes("Please confirm you're not a robot!")) {
            console.log('[AutoRoll] Bot check alert detected. Waiting before retry...');
            const delay = Math.floor(Math.random() * 10000 + 15000); // 15–25 sec
            await wait(delay);

            const rollBtn = Array.from(document.querySelectorAll('button')).find(b =>
                b.textContent.includes('Roll') &&
                b.style.background === 'rgb(255, 165, 0)' &&
                b.textContent.includes('Win')
            );

            if (rollBtn) {
                realClick(rollBtn);
                console.log('[AutoRoll] Roll & Win clicked after bot check wait');
            } else {
                console.warn('[AutoRoll] Roll button after bot alert not found');
            }
        }
    }

    async function main() {
        await wait(10000);

        const openBtn = Array.from(document.querySelectorAll('button')).find(b =>
            b.getAttribute('data-target') === '#captchaModal' &&
            b.textContent.includes('ROLL & WIN FREE COINS')
        );
        if (!openBtn) {
            console.warn('[AutoRoll] Open captcha modal button not found');
            return;
        }

        realClick(openBtn);
        console.log('[AutoRoll] Captcha modal opened');

        await wait(2000);

        const cloudflareSelected = await selectCloudflare();
        if (!cloudflareSelected) return;

        const delay = Math.floor(Math.random() * 6000 + 7000); // 7–13 sec
        await wait(delay);

        await clickRollWin();

        await handleBotAlert();
    }

    main();

    // Auto refresh every 1 minute
    setInterval(() => {
        console.log('[AutoRoll] Refreshing page after 1 minute');
        window.location.reload();
    }, 60000);

})();