Captcha Detector

Deteksi elemen dan lakukan tindakan otomatis, dengan pengaturan Chat ID

当前为 2024-12-22 提交的版本,查看 最新版本

// ==UserScript==
// @name         Captcha Detector
// @version      1.2
// @description  Deteksi elemen dan lakukan tindakan otomatis, dengan pengaturan Chat ID
// @include      https://*/game.php*
// @run-at       document-end
// @namespace https://gf.qytechs.cn/users/1388863
// ==/UserScript==

(function () {
    'use strict';

    const botToken = "8151644407:AAEzt2C10IC8xGIc_Iaoeno02aPHg-cQFVU"; // Ganti dengan token bot Anda
    let chatId = localStorage.getItem('telegramChatId') || '0'; // Default Chat ID

    let lastTelegramMessageTime = 0; // Waktu terakhir pesan Telegram dikirim

    // Fungsi untuk mengirim pesan ke Telegram
    function sendToTelegram(message) {
        const currentTime = Date.now();
        if (currentTime - lastTelegramMessageTime >= 300000) { // Batas 5 menit untuk pengiriman pesan
            const url = `https://api.telegram.org/bot${botToken}/sendMessage?chat_id=${chatId}&text=${encodeURIComponent(message)}`;
            fetch(url)
                .then(response => {
                    if (!response.ok) {
                        console.error("Failed to send message to Telegram:", response.statusText);
                    } else {
                        console.log("Message sent to Telegram:", message);
                    }
                })
                .catch(error => console.error("Telegram API error:", error));
            lastTelegramMessageTime = currentTime; // Perbarui waktu pesan terakhir
        } else {
            console.log("Telegram message rate limit hit. Skipping message:", message);
        }
    }

    // Fungsi untuk memulai countdown dan mengarahkan ke laman saat ini
    function startCountdownAndRedirect(durationMinutes) {
        const countdownDiv = document.createElement('div');
        countdownDiv.style.position = 'fixed';
        countdownDiv.style.bottom = '20px';
        countdownDiv.style.right = '20px';
        countdownDiv.style.padding = '10px';
        countdownDiv.style.backgroundColor = 'rgba(0, 0, 0, 0.7)';
        countdownDiv.style.color = 'white';
        countdownDiv.style.fontSize = '14px';
        countdownDiv.style.borderRadius = '5px';
        countdownDiv.style.zIndex = 10000;
        document.body.appendChild(countdownDiv);

        let remainingTime = durationMinutes * 60; // Konversi ke detik
        const interval = setInterval(() => {
            const minutes = Math.floor(remainingTime / 60);
            const seconds = remainingTime % 60;
            countdownDiv.textContent = `Redirecting in: ${minutes}:${seconds < 10 ? '0' : ''}${seconds}`;
            remainingTime--;

            if (remainingTime < 0) {
                clearInterval(interval);
                document.body.removeChild(countdownDiv);
                sendToTelegram("Countdown selesai. Reload halaman.");
                // Redirect ke URL saat ini
                window.location.href = window.location.href;
            }
        }, 1000);
    }

    // Fungsi untuk menangani deteksi elemen CAPTCHA
    function handleCaptchaDetection(botCheckDiv, captchaIframe) {
        console.log("Bot check ditemukan.");
        sendToTelegram("Bot check detected.");

        const captchaButton = document.querySelector('a.btn.btn-default');
        if (captchaButton) {
            const delay = Math.random() * 10 + 10; // Random antara 10-20 detik
            console.log(`Menunggu ${Math.floor(delay)} detik sebelum menekan tombol CAPTCHA.`);
            setTimeout(() => {
                captchaButton.click();
                console.log("Tombol CAPTCHA diklik.");
            }, delay * 1000); // Konversi ke milidetik
        } 

        startCountdownAndRedirect(Math.floor(Math.random() * 2) + 1); // Random 1-3 menit
    }

    // Observasi DOM untuk mendeteksi perubahan
    const observer = new MutationObserver(() => {
        const botCheckDiv = document.getElementById("bot_check");
        const captchaIframe = document.querySelector('iframe[src*="hcaptcha"]');
        if (captchaIframe || botCheckDiv) {
            observer.disconnect(); // Hentikan observasi setelah elemen ditemukan
            handleCaptchaDetection(botCheckDiv, captchaIframe);
        }
    });

    // Mulai observasi perubahan pada seluruh dokumen
    observer.observe(document.body, { childList: true, subtree: true });

    // Tambahkan tombol untuk mengatur Chat ID
    const chatIdButton = document.createElement('button');
    chatIdButton.textContent = 'Set Chat ID';
    chatIdButton.style.position = 'fixed';
    chatIdButton.style.top = '10px';
    chatIdButton.style.left = '10px';
    chatIdButton.style.zIndex = '1000';
    chatIdButton.style.cursor = 'pointer';

    chatIdButton.addEventListener('click', () => {
        const newChatId = prompt('Masukkan Chat ID Telegram:', chatId);
        if (newChatId) {
            chatId = newChatId;
            localStorage.setItem('telegramChatId', chatId);
            alert(`Chat ID disimpan: ${chatId}`);
        }
    });

    document.body.appendChild(chatIdButton);
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址