CloudFlare Challenge Optimized

Automates solving Cloudflare Challenges with optimal performance and maintainability

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         CloudFlare Challenge Optimized
// @version      0.3
// @description  Automates solving Cloudflare Challenges with optimal performance and maintainability
// @author       AstralRift
// @namespace    https://greasyfork.org/users/1300060
// @match        https://challenges.cloudflare.com/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    let observer = null;
    let intervalId = null;

    function attemptChallenge() {
        const targets = [
            "#cf-stage > div.ctp-checkbox-container > label > span",
            "input[value='Verify you are human']",
            ".ctp-checkbox-label"
        ];

        for (let selector of targets) {
            const element = document.querySelector(selector);
            if (element) {
                element.click();
                return true;
            }
        }
        return false;
    }

    function setupObserver() {
        observer = new MutationObserver(() => {
            if (attemptChallenge()) {
                disconnectObserver();
                clearInterval(intervalId);
            }
        });

        observer.observe(document.body, { childList: true, subtree: true });
    }

    function disconnectObserver() {
        if (observer) {
            observer.disconnect();
            observer = null;
        }
    }

    function setupInterval() {
        const intervalFunction = () => {
            if (attemptChallenge()) {
                clearInterval(intervalId);
                disconnectObserver();
            }
        };

        intervalId = setInterval(intervalFunction, 1000);

        setTimeout(() => {
            clearInterval(intervalId);
            disconnectObserver();
        }, 60000);
    }

    function handleChallenge() {
        if (!attemptChallenge()) {
            setupObserver();
            setupInterval();
        }
    }

    handleChallenge();
})();