Chapta Solver

Automatically click hCaptcha checkbox and notify via Telegram when detected or solved

目前為 2024-12-21 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Chapta Solver
// @namespace    https://tampermonkey.net/
// @version      1.0
// @description  Automatically click hCaptcha checkbox and notify via Telegram when detected or solved
// @match        https://*.hcaptcha.com/*hcaptcha-challenge*
// @match        https://*.hcaptcha.com/*checkbox*
// @match        https://*.hcaptcha.com/*captcha*
// @grant        GM_xmlhttpRequest
// @license MIT
// ==/UserScript==

(function() {
    var CHECKBOX = "#checkbox";
    var ARIA_CHECKED = "aria-checked";
    var captchaDetected = false; // Flag to track if "Ada Chapta" has been sent

    // Send Telegram message
    function sendTelegramMessage(message) {
        const botToken = "8151644407:AAEzt2C10IC8xGIc_Iaoeno02aPHg-cQFVU";
        let chatId = localStorage.getItem('telegramChatId');
        console.log("Message sent to Telegram:", chatId);
        const url = `https://api.telegram.org/bot${botToken}/sendMessage?chat_id=${chatId}&text=${encodeURIComponent(message)}`;

        GM_xmlhttpRequest({
            method: "GET",
            url: url,
            onload: function(response) {
                console.log('Pesan dikirim ke Telegram:', response.responseText);
            },
            onerror: function(error) {
                console.error('Error mengirim pesan ke Telegram:', error);
            }
        });
    }

    function qSelector(selector) {
        return document.querySelector(selector);
    }

    function isHidden(el) {
        return (el.offsetParent === null);
    }

    function randomDelay() {
        // Generate a random delay between 10000ms (10s) and 25000ms (25s)
        return Math.floor(Math.random() * 75000) + 15000;
    }

    if (window.location.href.includes("checkbox")) {
        var checkboxInterval = setInterval(function() {
            if (!qSelector(CHECKBOX)) {
                // If checkbox is not found, do nothing
            } else if (qSelector(CHECKBOX).getAttribute(ARIA_CHECKED) == "true") {
                clearInterval(checkboxInterval);  // Stop checking if already checked
            } else if (!isHidden(qSelector(CHECKBOX)) && qSelector(CHECKBOX).getAttribute(ARIA_CHECKED) == "false") {
                if (!captchaDetected) {
                    // Send "Ada Chapta" message only once
                    sendTelegramMessage("Ada Chapta");
                    captchaDetected = true; // Set flag to true to prevent repeated messages
                }

                // Introduce a random delay before clicking the checkbox
                setTimeout(function() {
                    qSelector(CHECKBOX).click();
                    sendTelegramMessage("Chapta solved"); // Send message when captcha is solved
                    location.reload();
                }, randomDelay());
            } else {
                return;
            }

        }, 3000);
    }

})();