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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==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);

})();