CloudFlare Challenge Optimized

Automates solving Cloudflare challenges

Version vom 15.05.2024. Aktuellste Version

// ==UserScript==
// @name         CloudFlare Challenge Optimized
// @version      0.1
// @author       AstralRift
// @description  Automates solving Cloudflare challenges
// @namespace    https://greatest.deepsurf.us/users/1300060
// @match        https://challenges.cloudflare.com/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    function attemptChallenge() {
        const stageSpan = document.querySelector("#cf-stage > div.ctp-checkbox-container > label > span");
        if (stageSpan) {
            stageSpan.click();
            return true;
        }

        const verifyButton = document.querySelector("input[value='Verify you are human']");
        if (verifyButton) {
            verifyButton.click();
            return true;
        }

        const checkboxLabel = document.querySelector('.ctp-checkbox-label');
        if (checkboxLabel) {
            checkboxLabel.click();
            return true;
        }

        return false;
    }

    let challengeSolved = attemptChallenge();

    if (!challengeSolved) {
        const observer = new MutationObserver(() => {
            if (attemptChallenge()) {
                observer.disconnect();
            }
        });
        observer.observe(document.body, { childList: true, subtree: true });

        const intervalId = setInterval(() => {
            if (attemptChallenge()) {
                clearInterval(intervalId);
            }
        }, 2000);

        setTimeout(() => {
            clearInterval(intervalId);
            observer.disconnect();
        }, 60000);
    }
})();