Dadu Bot Ojann

djdj

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

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