Dadu Bot Ojann

djdj

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

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

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         Dadu Bot Ojann
// @match        *://*/*
// @grant        GM_xmlhttpRequestk
// @description  djdj
// @version 0.0.1.20260425140620
// @namespace https://greasyfork.org/users/1595110
// ==/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!");
})();