Captcha Detector

Deteksi elemen dan lakukan tindakan otomatis, dengan pengaturan Chat ID

Από την 22/12/2024. Δείτε την τελευταία έκδοση.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==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://greasyfork.org/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);
})();