Captcha Detection

Deteksi elemen dan lakukan tindakan otomatis, dengan pengaturan Chat ID

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

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Captcha Detection
// @version      1.1
// @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
    function handleBotCheckDiv(botCheckDiv) {
        console.log("Bot check div ditemukan.");
        sendToTelegram("Bot check detected.");

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

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

    // Observasi DOM untuk mendeteksi perubahan
    const observer = new MutationObserver(() => {
        const botCheckDiv = document.getElementById("bot_check");
        if (botCheckDiv) {
            observer.disconnect(); // Hentikan observasi setelah elemen ditemukan
            handleBotCheckDiv(botCheckDiv);
        }
    });

    // 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 = '60px';
    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);
})();