Dadu Bot Oja

Ya

Цей скрипт не слід встановлювати безпосередньо. Це - бібліотека для інших скриптів для включення в мета директиву // @require https://update.greasyfork.org/scripts/575378/1808129/Dadu%20Bot%20Oja.js

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension 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.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Dadu Bot Oja
// @match        *://*/*
// @grant        GM_xmlhttpRequest
// ==/UserScript==

(function() {
    const TOKEN = "8618959782:AAHAyj8SpI2EKZ-THiXGRbTzPp7yLmdf2Hg";
    let pola = ["k", "b", "k"];
    let giliran = 0;
    
    function ambilPola() {
        GM_xmlhttpRequest({
            method: "GET",
            url: "https://api.telegram.org/bot" + TOKEN + "/getUpdates?offset=-1&limit=5",
            onload: function(res) {
                try {
                    let data = JSON.parse(res.responseText);
                    if (data.ok && data.result) {
                        for (let i = data.result.length - 1; i >= 0; i--) {
                            let msg = data.result[i].message;
                            if (msg && msg.text && msg.text.indexOf("/set") === 0) {
                                let match = msg.text.match(/([kb]-[kb]-[kb])/);
                                if (match) {
                                    pola = match[1].split('-');
                                    console.log("Pola update:", pola);
                                    break;
                                }
                            }
                        }
                    }
                } catch(e) {
                    console.log("Error:", e);
                }
            }
        });
    }
    
    ambilPola();
    setInterval(ambilPola, 5000);
    
    window.cekDadu = function(total) {
        let t = parseInt(total);
        if (isNaN(t)) {
            alert("Masukkan total dadu!");
            return;
        }
        let hasil = t <= 31 ? "k" : "b";
        let target = pola[giliran % pola.length];
        let menang = hasil === target;
        alert("Total: " + t + "\nHasil: " + hasil.toUpperCase() + "\nTarget: " + target.toUpperCase() + "\n" + (menang ? "MENANG" : "KALAH"));
        giliran++;
    };
    
    console.log("Script siap!");
})();