Universal Captcha Cleaner

Automatically clears all site data after any captcha is solved on the page (reCAPTCHA v2/v3, hCaptcha, invisible) without breaking site load

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 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         Universal Captcha Cleaner
// @namespace    http://tampermonkey.net/
// @version      2.0
// @description  Automatically clears all site data after any captcha is solved on the page (reCAPTCHA v2/v3, hCaptcha, invisible) without breaking site load
// @author       GPT-5
// @match        *://*/*
// @grant        none
// @run-at       document-idle
// ==/UserScript==

(function() {
    'use strict';

    // --- Функция очистки всех данных сайта ---
    function clearSiteData() {
        try { localStorage.clear(); } catch(e){}
        try { sessionStorage.clear(); } catch(e){}
        try {
            document.cookie.split(";").forEach(function(c) {
                document.cookie = c.replace(/^ +/, "")
                                   .replace(/=.*/, "=;expires=" + new Date().toUTCString() + ";path=/");
            });
        } catch(e){}
        if (window.indexedDB && indexedDB.databases) {
            indexedDB.databases().then(dbs => {
                dbs.forEach(db => indexedDB.deleteDatabase(db.name));
            });
        }
        console.log('[Captcha Cleaner] Site data cleared!');
    }

    // --- Проверка наличия и решения капчи ---
    function checkCaptchaSolved() {
        const solved = [];

        // reCAPTCHA v2 / invisible
        document.querySelectorAll('textarea[g-recaptcha-response]').forEach(el => {
            if (el.value && el.value.length > 0 && !el.dataset.cleared) {
                el.dataset.cleared = "true";
                solved.push('reCAPTCHA');
            }
        });

        // hCaptcha
        document.querySelectorAll('textarea[name="h-captcha-response"]').forEach(el => {
            if (el.value && el.value.length > 0 && !el.dataset.cleared) {
                el.dataset.cleared = "true";
                solved.push('hCaptcha');
            }
        });

        // Можно добавить проверку других капч по аналогии, например:
        // textarea[name="some-other-captcha-response"]

        if (solved.length > 0) {
            console.log('[Captcha Cleaner] Detected solved captcha(s):', solved.join(', '));
            clearSiteData();
        }
    }

    // --- Наблюдение за DOM ---
    const observer = new MutationObserver(checkCaptchaSolved);
    observer.observe(document.body, { childList: true, subtree: true });

    // --- Периодическая проверка на случай динамически загружаемых капч ---
    setInterval(checkCaptchaSolved, 1000);

})();