Captcha Detection

Deteksi elemen dan lakukan tindakan otomatis, dengan pengaturan Chat ID

Verze ze dne 21. 12. 2024. Zobrazit nejnovější verzi.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

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