Bonk Commands

Adds lots of commands to bonk.io. Type /? or /help in bonk chat to get started.

Από την 15/09/2022. Δείτε την τελευταία έκδοση.

// ==UserScript==
// @name         Bonk Commands
// @namespace    http://tampermonkey.net/
// @version      0.4
// @description  Adds lots of commands to bonk.io. Type /? or /help in bonk chat to get started.
// @author       LEGENDBOSS123 + left paren + mastery3
// @license MIT
// @match        https://bonk.io/gameframe-release.html
// @run-at       document-end
// @grant        none
// ==/UserScript==
setTimeout(function(){
var link = "https://pastebin.com/2b8XqqYu";

var Gdocument = document;
var Gwindow = window;
if(typeof(originalSend)=='undefined'){var originalSend = Gwindow.WebSocket.prototype.send;}
if(typeof(bonkwss)=='undefined'){var bonkwss = 0;}
        
Gwindow.WebSocket.prototype.send = function(args) {
    if(this.url.includes(".bonk.io/socket.io/?EIO=3&transport=websocket&sid=")){window.bonkwss = this;}
    if(this.url.includes(".bonk.io/socket.io/?EIO=3&transport=websocket&sid=") && !this.injected){
        this.injected = true;
        
        var originalRecieve = this.onmessage;
        
        this.onmessage = function(args){   
            if(args.data.startsWith('42[7')){
                var jsonargs = JSON.parse(args.data.substring(2))[2];
                if(typeof(jsonargs["type"]) != "undefined"){
                    if(jsonargs["type"]=="private chat" && (jsonargs["to"] == username)){
                        if(typeof(jsonargs["message"])=="object"){
                            var decodedtext = CRYPT_MESSAGE(private_key,jsonargs["message"].slice(0,400));
                            var encodedtext = "";
                            for(var i=0;i<decodedtext.length;i++){
                                encodedtext+=String.fromCharCode(decodedtext[i]);
                            }
                            displayInChat("> "+jsonargs["from"]+": "+CRYPT_MESSAGE(private_key,jsonargs["message"].slice(0,400)),"#DA0808","#1EBCC1");
                        }
                    }
                    if(jsonargs["type"]=="request public key" && jsonargs["to"] == username){
                        SEND("42"+JSON.stringify([4,{"type":"public key","from":username,"public key":public_key}]));
                    }
                    if(jsonargs["type"]=="public key" && jsonargs["from"] == private_chat && request_public_key_time_stamp+1000>Date.now()){
                        private_chat_public_key = [private_chat,jsonargs["public key"]];
                        displayInChat("Private chatting with "+private_chat+".","#DA0808","#1EBCC1");

                    }

                }
            }
            return originalRecieve.call(this,args);
        };
        
        var originalClose = this.onclose;
        this.onclose = function () {
            window.bonkwss = 0;
            return originalClose.call(this);
        }
        
        
    }
    if(args.startsWith('42[4,')){
        var jsonargs = JSON.parse(args.substring(2))[1];
        if(typeof(jsonargs["type"]) != "undefined"){
        }
    }
    if(stopquickplay!=1){
        args = args.replace('"wl":3','"wl":999');
    }
    
    return originalSend.call(this,args);
};



function SEND(args){
    if(bonkwss!=0){
        bonkwss.send(args);
    }
}

Gdocument.getElementById("ingamechatcontent").style["pointer-events"]="all";
Gdocument.getElementById("ingamechatcontent").style["max-height"]="250px";
Gdocument.getElementById("ingamechatcontent").style["height"]="128px";
Gdocument.getElementById("ingamechatbox").style["height"]="250px";

setTimeout(function(){document.getElementById('adboxverticalCurse').style["display"] = "none";
document.getElementById('adboxverticalleftCurse').style["display"] = "none";},3000);


function GENERATE_PRIME_NUMBER(mini = 0,maxi = 0,choices = []){
    if(choices.length == 0){
        for(var i = mini;i<maxi+1;i++){
            choices.push(i);
        }
    }
    firstTry = choices[Math.floor(Math.random()*choices.length)];
    for(var i = 2; i<Math.floor(Math.sqrt(firstTry)+1);i++){
        if(i!=firstTry){
            if(firstTry%i == 0){
                choices.splice(choices.indexOf(firstTry),1);
                if(choices.length == 0){
                    return 0;
                }
                return GENERATE_PRIME_NUMBER(mini,maxi,choices);
            }
        }
    }
    return firstTry;
}
    
function GENERATE_KEYS(){
    interval = [];
    for(var i = 250;i<1001;i++){
        interval.push(i);
    }
    random_prime = [GENERATE_PRIME_NUMBER(0,0,choices = interval),0];
    interval.splice(interval.indexOf(random_prime[0]),1);
    random_prime[1] = GENERATE_PRIME_NUMBER(0,0,choices = interval);

    n = random_prime[0]*random_prime[1];
    n2 = (random_prime[0]-1)*(random_prime[1]-1);


    e = GENERATE_PRIME_NUMBER(2,n2-1);
    d = 0;
    redo = true;
    for(var i = 0;i<1000000;i++){
        if((e*i-1)%n2 == 0 && i!=e){
            d = i;
            redo = false;
            break;
        }
    }
    if(redo){
        return GENERATE_KEYS();
    }
    else{
        return [[n,e],[n,d]];
    }

}
function CRYPT_NUMBER(key, data){

    result = 1;
    
    for(var i = 0;i<key[1];i++){
        result*=data;
        result = result%key[0];
    }
    return result%key[0];

}

function CRYPT_MESSAGE(key,data){
    var resulttext = [];
    for(var i = 0;i<data.length;i++){
        resulttext.push(CRYPT_NUMBER(key,data[i]));
    }
    return resulttext;

}


var dontswitch = false;
var username = 0;
var timedelay = 1400;
var ishost = false;
var quicki=0;
var freejoin = false;
var stopquickplay = 1;
var canceled = false;
var banned = [];
var transitioning = false;
var echo_list = [];
var message = "";
var mode = "";
var private_chat = "";
var private_chat_public_key = ["",[0,0]];
var users = [];
var scroll = false;
var elem = Gdocument.getElementById("maploadwindowmapscontainer");
var npermissions = 1;
var space_flag = false;
var rcaps_flag = false;
var number_flag = false;
var private_chat_keys = GENERATE_KEYS();
var private_key = private_chat_keys[0];
var public_key = private_chat_keys[1];
var request_public_key_time_stamp = 0;
elem.onclick=function(e){
    if(stopquickplay==0 && ishost == true && e.isTrusted == true){
        quicki = (Array.from(e.target.parentElement.parentNode.children).indexOf(e.target.parentNode)-1)%(Gdocument.getElementById("maploadwindowmapscontainer").children.length);
    }
};
function urlify(text) {
    return text.replace(/(?:https?:\/\/)?(?:[A-Za-z0-9-ßàÁâãóôþüúðæåïçèõöÿýòäœêëìíøùîûñé]+)(?:\.[A-Za-z0-9-ßàÁâãóôþüúðæåïçèõöÿýòäœêëìíøùîûñé]+)+(?:\/(?:[A-Za-z0-9-._~:/?#\[\]@!$&'()*+,;=]|%[0-9a-fA-F]{2})*)?(?:\?(?:[^=]+=[^&](?:&[^=]+=[^&])*)?)?/g, function(url) {
    return '<a href="' + url + '" target="_blank" style = "color:orange">' + url + '</a>';
  })
}


function fire(type,options,d = Gdocument){
     var event=new CustomEvent(type);
     for(var p in options){
         event[p]=options[p];
     }
     d.dispatchEvent(event);
}


function chat(message){
    mess = Gdocument.getElementById("newbonklobby_chat_input").value;
    mess2 = Gdocument.getElementById("ingamechatinputtext").value;
    Gdocument.getElementById("newbonklobby_chat_input").value = message;
    Gdocument.getElementById("ingamechatinputtext").value = message;
    fire("keydown",{keyCode:13});
    fire("keydown",{keyCode:13});
    Gdocument.getElementById("newbonklobby_chat_input").value = mess;
    Gdocument.getElementById("ingamechatinputtext").value = mess2;
}
function displayInChat(message, LobbyColor, InGameColor, options) {
            options = options ?? {};
            LobbyColor = LobbyColor ?? "#8800FF";
            InGameColor = InGameColor ?? "#AA88FF";
            let A = Gdocument.createElement("div");
            let B = Gdocument.createElement("span");
            B.className = "newbonklobby_chat_status";
            B.style.color = LobbyColor;
            A.appendChild(B);
            B.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
            let C = Gdocument.createElement("div");
            let D = Gdocument.createElement("span");
            D.style.color = InGameColor;
            C.appendChild(D);
            D.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
            let a = false;
            if(Gdocument.getElementById("newbonklobby_chat_content").scrollHeight - Gdocument.getElementById("newbonklobby_chat_content").scrollTop > Gdocument.getElementById("newbonklobby_chat_content").clientHeight - 1) {
                a = true;
            }
            Gdocument.getElementById("newbonklobby_chat_content").appendChild(A);
            Gdocument.getElementById("ingamechatcontent").appendChild(C);
            if (a) { Gdocument.getElementById("newbonklobby_chat_content").scrollTop = Number.MAX_SAFE_INTEGER;};
            Gdocument.getElementById("ingamechatcontent").scrollTop = Number.MAX_SAFE_INTEGER;
}


function lobby(){
    if (Gdocument.getElementById("newbonklobby").style["display"]=="none"){
        
        
        Gdocument.getElementById("mapeditorcontainer").click();
        Gdocument.getElementById("mapeditor_close").click();
        if(Gdocument.getElementsByClassName("newbonklobby_playerentry").length>0){
            Gdocument.getElementById("newbonklobby").style["opacity"]=1;
            Gdocument.getElementById("newbonklobby").style["display"]="block";
            Gdocument.getElementById("newbonklobby").style["z-index"]=1;
            Gdocument.getElementById("maploadwindowcontainer").style["z-index"]=1;
            Gdocument.getElementById("mapeditorcontainer").style["z-index"]=1;
            Gdocument.getElementById("pretty_top").style["z-index"]=2;
            Gdocument.getElementById("settingsContainer").style["z-index"]=2;
            Gdocument.getElementById("leaveconfirmwindow").style["z-index"]=2;
            Gdocument.getElementById("hostleaveconfirmwindow").style["z-index"]=2;
            }
        else{
            Gdocument.getElementById("newbonklobby").style["opacity"]=0;
            Gdocument.getElementById("newbonklobby").style["display"]="none";
            Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
        }
        
    }
    else if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
        Gdocument.getElementById("newbonklobby").style["opacity"]=0;
        Gdocument.getElementById("newbonklobby").style["display"]="none";
        Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
    }
}

function lastmessage(){
    if(Gdocument.getElementById("newbonklobby_chat_content").children.length!=0){
        var lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
        var lm2 = "";
        for(var i = 0; i<lm.length;i++){
            lm2+="  "+lm[i].textContent.trim();
        }
        lm2 = lm2.trim();
        if(lm2.startsWith("*")){
            return lm2;
        }
    }
    if(Gdocument.getElementById("ingamechatcontent").children.length!=0){
        var lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
        var lm2 = "";
        for(var i = 0; i<lm.length;i++){
            lm2+="  "+lm[i].textContent.trim();
        }
        return lm2.trim();
    }
    return "";

}
function map(e){
    if(e<0){
        displayInChat("There is no previous map.","#DA0808","#1EBCC1");
        quicki = 0;
        return;
    }
    if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
        displayInChat("Click the maps button.","#DA0808","#1EBCC1");
        return;
    }
    
    setTimeout(function(){if(!canceled){
                          Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
                          Gdocument.getElementById("newbonklobby_editorbutton").click();
                          Gdocument.getElementById("mapeditor_close").click();
                          Gdocument.getElementById("newbonklobby").style["display"] = "none";
                          Gdocument.getElementById("mapeditor_midbox_testbutton").click();}
                          canceled = false;
                          transitioning = false;
                         },timedelay);
    
    
}

function gotonextmap(e){
    if(e<0){
        displayInChat("There is no previous map.","#DA0808","#1EBCC1");
        quicki = 0;
        return;
    }
    if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
        displayInChat("Click the maps button.","#DA0808","#1EBCC1");
        return;
    }
    Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
    Gdocument.getElementById("newbonklobby_editorbutton").click();
    Gdocument.getElementById("mapeditor_close").click();
    Gdocument.getElementById("newbonklobby").style["display"] = "none";
    Gdocument.getElementById("mapeditor_midbox_testbutton").click();
    Gdocument.getElementById("newbonklobby").style["visibility"] = "visible";
    
    
    
    

}
function commandhandle(chat_val){
    if (chat_val.substring(1,6)=="echo " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
        if (chat_val.substring(6).replace(/^\s+|\s+$/g, '')==username){
            displayInChat("You cannot echo yourself.","#DA0808","#1EBCC1");
            return "";
        }
        else if (echo_list.indexOf(chat_val.substring(6).replace(/^\s+|\s+$/g, ''))===-1) {
            
            echo_list.push(chat_val.substring(6).replace(/^\s+|\s+$/g, ''));
            displayInChat(chat_val.substring(6).replace(/^\s+|\s+$/g, '') + " is being echoed.","#DA0808","#1EBCC1");
            return "";
        }
        else{
            displayInChat(chat_val.substring(6).replace(/^\s+|\s+$/g, '') + " is already being echoed.","#DA0808","#1EBCC1");
            return "";
        }
    }
    else if (chat_val.substring(1,8)=="remove "  && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
        if (echo_list.indexOf(chat_val.substring(7).replace(/^\s+|\s+$/g, ''))!==-1){
            echo_list.splice(echo_list.indexOf(chat_val.substring(7).replace(/^\s+|\s+$/g, '')),1);
            displayInChat(chat_val.substring(7).replace(/^\s+|\s+$/g, '')+" is not being echoed.","#DA0808","#1EBCC1");
            return "";
        }
        else{
            displayInChat("You cannot remove someone that you didn't echo.","#DA0808","#1EBCC1");
            return "";
        }
        
    }
    else if (chat_val.substring(1,10)=="clearecho"){
        echo_list = [];
        displayInChat("Cleared the echo list.","#DA0808","#1EBCC1");
        return "";
    }
    else if (chat_val.substring(1,6)=="space"){
        if(space_flag == true){
            displayInChat("Space is now off.","#DA0808","#1EBCC1");
            space_flag = false;
        }
        else{
            displayInChat("Space is now on.","#DA0808","#1EBCC1");
            space_flag = true;
        }
        return "";
    }
    else if (chat_val.substring(1,6)=="rcaps"){
        if(rcaps_flag == true){
            displayInChat("Rcaps is now off.","#DA0808","#1EBCC1");
            rcaps_flag = false;
        }
        else{
            displayInChat("Rcaps is now on.","#DA0808","#1EBCC1");
            rcaps_flag = true;
        }
        
        return "";
    }
    else if (chat_val.substring(1,7)=="number"){
        if(number_flag == true){
            displayInChat("Number is now off.","#DA0808","#1EBCC1");
            number_flag = false;
        }
        else{
            displayInChat("Number is now on.","#DA0808","#1EBCC1");
            number_flag = true;
        }
        
        return "";
    }
    else if (chat_val.substring(1,12)=="requestfake" && chat_val.replace(/^\s+|\s+$/g, '').length>=13){
        var mess = chat_val.substring(13).replace(/^\s+|\s+$/g, '');
        var result;
        var key;
        try{
            result = JSON.parse("{"+mess.replaceAll(",",":")+"}");
            if(Object.keys(result).length!=1){
                throw "";
            }
            else{
                key = Object.keys(result)[0];
            }
            SEND('42'+JSON.stringify([27,{"m":"","mapname":key.replaceAll(":",","),"mapauthor":result[key].replaceAll(":",",")}]));
            return "";
        }
        catch{
            displayInChat('Format: /requestfake "mapname", "mapauthor"',"#DA0808","#1EBCC1");
            return "";
        }
        return "";
        
    }
    else if (chat_val.substring(1,6)=="eval " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
        var ev = "";
        try{
            ev = eval(chat_val.substring(6).replace(/^\s+|\s+$/g, ''));
        }
        catch(e){
            displayInChat(e.message,"#DA0808","#1EBCC1");
        }
        try{
            displayInChat(ev.toString(),"#DA0808","#1EBCC1");
        }
        catch{
        }
        
        return "";
    
    }
    else if (chat_val.substring(1,9)=="hidechat"){
        Gdocument.getElementById("ingamechatcontent").style["max-height"]="0px";
        return "";
    }
    else if (chat_val.substring(1,9)=="showchat"){
        Gdocument.getElementById("ingamechatcontent").style["max-height"]="250px";
        return "";
    }
    
    else if (chat_val.substring(1,7)=="scroll"){
        if(scroll==false){
            scroll = true;
            Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="scroll";
            Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
        }
        else if(scroll==true){
            scroll = false;
            Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="hidden";
            Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
        }
        
        return "";
    }
    

    else if (chat_val.substring(1,7)=="chatw "){
        var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '');
        
        if(username == text){
            displayInChat("You cannot private chat with yourself.","#DA0808","#1EBCC1");
            return "";
        }
        private_chat = text;
        
        SEND("42"+JSON.stringify([4,{"type":"request public key","from":username,"to":private_chat}]));
        request_public_key_time_stamp = Date.now();
        setTimeout(function(){if(private_chat_public_key[0]!=private_chat){displayInChat("Failed to connect to "+private_chat+".","#DA0808","#1EBCC1");private_chat = private_chat_public_key[0];}},1050);
        return "";
    }
    
    
    else if (chat_val.substring(1,5)=="msg " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
        if(private_chat_public_key[1][0] != 0 && private_chat_public_key[1][1] != 0 && private_chat_public_key[0] == private_chat){
            var text = chat_val.substring(5).replace(/^\s+|\s+$/g, '');
            SEND("42"+JSON.stringify([4,{"type":"private chat","from":username,"to":private_chat,"message":CRYPT_MESSAGE(private_chat_public_key[1],text)}]));
            var text2 = [];
            for(var i = 0;i<text.slice(0,400).length ;i++){
                text2.push(text.slice(0,400).charCodeAt(i));
            }
            displayInChat("> "+username+": "+text2,"#DA0808","#1EBCC1");

            
        }
        return "";
    }
    else if (chat_val.substring(1,6)=="lobby"){
        lobby();
        return "";
    }
    else if (chat_val.substring(1,6)=="team " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
        var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
        if(text == "r"){Gdocument.getElementById("newbonklobby_redbutton").click();}
        else if(text == "g"){Gdocument.getElementById("newbonklobby_greenbutton").click();}
        else if(text == "y"){Gdocument.getElementById("newbonklobby_yellowbutton").click();}
        else if(text == "b"){Gdocument.getElementById("newbonklobby_bluebutton").click();}
        else if(text == "s"){Gdocument.getElementById("newbonklobby_specbutton").click();}
        else if(text == "f"){Gdocument.getElementById("newbonklobby_ffabutton").click();}
        return "";
    }
    else if (chat_val.substring(1,7)=="notify"){
        
        npermissions = 1;
        return "";
    }
    else if (chat_val.substring(1,11)=="stopnotify"){
        
        npermissions = 0;
        return "";
    }
    else if (chat_val.substring(1,5)=="help" || chat_val.substring(1,2)=="?"){
        displayInChat("All the commands are:","#DA0808","#1EBCC1");
        displayInChat("/help","#DA0808","#1EBCC1");
        displayInChat("/?","#DA0808","#1EBCC1");
        displayInChat("/space","#DA0808","#1EBCC1");
        displayInChat("/rcaps","#DA0808","#1EBCC1");
        displayInChat("/number","#DA0808","#1EBCC1");
        displayInChat("/echo [username]","#DA0808","#1EBCC1");
        displayInChat("/remove [username]","#DA0808","#1EBCC1");
        displayInChat("/clearecho","#DA0808","#1EBCC1");
        displayInChat("/chatw [username]","#DA0808","#1EBCC1");
        displayInChat("/msg [text]","#DA0808","#1EBCC1");
        displayInChat("/requestfake \"[mapname]\", \"[mapauthor]\"","#DA0808","#1EBCC1");
        displayInChat("/eval [code]","#DA0808","#1EBCC1");
        displayInChat("/lobby","#DA0808","#1EBCC1");
        displayInChat("/team [letter]","#DA0808","#1EBCC1");
        displayInChat("/scroll","#DA0808","#1EBCC1");
        displayInChat("/hidechat","#DA0808","#1EBCC1");
        displayInChat("/showchat","#DA0808","#1EBCC1");
        displayInChat("/notify","#DA0808","#1EBCC1");
        displayInChat("/stopnotify","#DA0808","#1EBCC1");
        displayInChat("Host commands are:","#DA0808","#1EBCC1");        
        displayInChat("/startqp","#DA0808","#1EBCC1");
        displayInChat("/stopqp","#DA0808","#1EBCC1");
        displayInChat("/next","#DA0808","#1EBCC1");
        displayInChat("/previous","#DA0808","#1EBCC1");
        displayInChat("/start","#DA0808","#1EBCC1");
        displayInChat("/ban [username]","#DA0808","#1EBCC1");
        return "";
    }
    else if(ishost){
        if (chat_val.substring(1,5)=="next" && stopquickplay == 0){
            quicki++;
            gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
            displayInChat("Switched to next map.","#DA0808","#1EBCC1");
            return "";

        }
        else if (chat_val.substring(1,9)=="freejoin"){
            if(freejoin == false){
                freejoin = true;
                displayInChat("Freejoin is now on.","#DA0808","#1EBCC1");

            }
            else{
                freejoin = false;
                displayInChat("Freejoin is now off.","#DA0808","#1EBCC1");
            }
            
            return "";

        }
        
        else if (chat_val.substring(1,9)=="previous" && stopquickplay == 0){
            quicki--;
            gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
            
            displayInChat("Switched to previous map.","#DA0808","#1EBCC1");
            return "";
        }
        else if (chat_val.substring(1,6)=="start" && chat_val.length == 6){
            Gdocument.getElementById("newbonklobby_editorbutton").click();
            Gdocument.getElementById("mapeditor_close").click();
            Gdocument.getElementById("newbonklobby").style["display"] = "none";
            Gdocument.getElementById("mapeditor_midbox_testbutton").click();
            
            return "";
        }
        
        else if (chat_val.substring(1,8)=="startqp" && stopquickplay == 1){
            stopquickplay = 0;
            quicki = 0;
            displayInChat("Enabled quickplay.","#DA0808","#1EBCC1");
            return "";
        }
        else if (chat_val.substring(1,7)=="stopqp" && stopquickplay == 0){
            stopquickplay = 1;
            quicki = 0;
            displayInChat("Disabled quickplay.","#DA0808","#1EBCC1");
            return "";
        }
        

        
        else if (chat_val.substring(1,5)=="ban " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
            banned.push(chat_val.substring(5).replace(/^\s+|\s+$/g, ''));
            displayInChat("Banned "+chat_val.substring(5).replace(/^\s+|\s+$/g, '')+".","#DA0808","#1EBCC1");
            return "/kick '" + chat_val.substring(5).replace(/^\s+|\s+$/g, '') + "'";
        }
 
    }
    return chat_val;
}
function flag_manage(t){
    var text = t;
            
    if(rcaps_flag == true){
        text = text.split('');
        for(var i = 0; i<text.length;i++){
            if(Math.floor(Math.random()*2)){
                text[i] = text[i].toUpperCase();
            }
            else{
                text[i] = text[i].toLowerCase();
            }
        }
        text = text.join('');
    }
    if(space_flag == true){
        text = text.split('').join(' ')
    }
    if(number_flag == true){
        text = text.replace(/[t|T][Oo]+/g,"2");
        text = text.replace(/[f|F][o|O][r|R]/g,"4");
        text = text.replace(/[a|A][t|T][e|E]/g,"8");
        text = text.replace(/[e|E]/g,"3");
        text = text.replace(/[a|A]/g,"4");
        text = text.replace(/[o|O]/g,"0");
        text = text.replace(/[s|S]/g,"5");
        text = text.replace(/[i|I|l|L]/g,"1");
    }
    return text;
    
}
(function(){
var newbonklobby_chat_input_old = Gdocument.getElementById("newbonklobby_chat_input").onkeydown ?? (function(){});
Gdocument.getElementById("newbonklobby_chat_input").onkeydown = function(e){
    newbonklobby_chat_input_old(e);
    if(e.keyCode==13){
 
        var chat_val = Gdocument.getElementById("newbonklobby_chat_input").value;
        
        if (chat_val!="" && chat_val[0]=="/"){
 
            Gdocument.getElementById("newbonklobby_chat_input").value = "";
            chat(commandhandle(chat_val));
        }
        else{
            Gdocument.getElementById("newbonklobby_chat_input").value = "";
            chat(flag_manage(chat_val));
        }
        chat_val = Gdocument.getElementById("ingamechatinputtext").value;
        if (chat_val!="" && chat_val[0]=="/"){
 
            Gdocument.getElementById("ingamechatinputtext").value = "";
                chat(commandhandle(chat_val));
        }
        else{
            Gdocument.getElementById("ingamechatinputtext").value = "";
            chat(flag_manage(chat_val));
        }
        
    }
 
    
}
})();
(function(){
var ingame_chat_input_old = Gdocument.getElementById("ingamechatinputtext").onkeydown ?? (function(){});
Gdocument.getElementById("ingamechatinputtext").onkeydown = function(e){
    ingame_chat_input_old(e);
    if(e.keyCode==13){
 
        var chat_val = Gdocument.getElementById("newbonklobby_chat_input").value;
        if (chat_val!="" && chat_val[0]=="/"){
 
            Gdocument.getElementById("newbonklobby_chat_input").value = "";
            chat(commandhandle(chat_val));
        }
        else{
            Gdocument.getElementById("newbonklobby_chat_input").value = "";
            chat(flag_manage(chat_val));
        }
        chat_val = Gdocument.getElementById("ingamechatinputtext").value;
        
        if (chat_val!="" && chat_val[0]=="/"){
 
            Gdocument.getElementById("ingamechatinputtext").value = "";
            chat(commandhandle(chat_val));
        }   
        else{
            Gdocument.getElementById("ingamechatinputtext").value = "";
            chat(flag_manage(chat_val));
        }
    }
}
})();
Last_message = "";
Laster_message = "";
var new_message = false;
var changed_chat = false;
interval = setInterval(timeout123,100);
function timeout123() {
    
    if(Gdocument.getElementById("mainmenuelements").style["display"] == "block"){
        var chatbox = Gdocument.getElementById("newbonklobby_chat_content");
        while (chatbox.firstChild) {
            chatbox.removeChild(chatbox.firstChild);
        }   
        rcaps_flag = false;
        space_flag = false;
        number_flag = false;
        echo_list = [];
        scroll = false;
        stopquickplay = 1;
        freejoin = false;

    }
    if(Gdocument.getElementById("ingametextwarning_afk").style["display"]=="table"){
        Gdocument.getElementById("pretty_top_settings").click();
        key2 = Gdocument.getElementById("redefineControls_table").children[0].children[5].children[1].innerHTML.charCodeAt(0);
        Gdocument.getElementById("settings_close").click();

        if(key2>0){
            fire("keydown",{keyCode:key2},Gwindow);
            setTimeout(function(){fire("keyup",{keyCode:key2},Gwindow)},100);
        }
        
        
    }
      
    
    if(Gdocument.getElementById("newbonklobby").style["display"]=="block"){
        Gdocument.getElementById("ingamechatinputtext").style["visibility"]="hidden";
    }
    else{
        Gdocument.getElementById("ingamechatinputtext").style["visibility"]="visible";

    }
    mode = Gdocument.getElementById("newbonklobby_modetext").textContent;
    var userlist = Gdocument.getElementsByClassName("newbonklobby_playerentry_name");
    users = [];
    for(var i = 0;i<userlist.length;i++){
        users.push(userlist[i].textContent);
    }
    if(Gdocument.getElementsByClassName('newbonklobby_settings_button brownButton brownButton_classic buttonShadow brownButtonDisabled').length == 0){
        ishost = true;
    }
    else if(Gdocument.getElementsByClassName('newbonklobby_settings_button brownButton brownButton_classic buttonShadow brownButtonDisabled').length == 4){
        ishost = false;
    }
    
    if(Gdocument.getElementById("pretty_top_name")!=null){
        username = Gdocument.getElementById("pretty_top_name").textContent;
    }
    try{
        Last_message = lastmessage()
    } catch{
        Last_message = "";
    }
    if (Laster_message != Last_message){
        Laster_message = Last_message;
        if(changed_chat==false){
            new_message = true;
        }
        else{
            changed_chat = false;
        }
    }
    if(new_message){
        if(freejoin && Last_message.startsWith("* ") && Last_message.endsWith(" has joined the game") && ishost){
            
            var userjoined = Last_message.substring(2,Last_message.length-20);
            
            if(Gdocument.getElementById("newbonklobby").style["display"] != "block"){
                mess2 = Gdocument.getElementById("ingamechatinputtext").value;
                Gdocument.getElementById("ingamechatinputtext").value = "";
                Gdocument.getElementById("newbonklobby_editorbutton").click();
                Gdocument.getElementById("mapeditor_close").click();
                Gdocument.getElementById("newbonklobby").style["display"] = "none";
                Gdocument.getElementById("ingamechatinputtext").value = mess2;

            }
            var playing = Gdocument.getElementsByClassName("newbonklobby_playerentry newbonklobby_playerentry_half");
            var inplaying = false;
            for(var i = 0;i<playing.length;i++){
                if(userjoined == playing[i].children[1].textContent){
                    inplaying = true;
                    break;
                }
            }
            
            if(playing.length<=2 && inplaying){
                Gdocument.getElementById("newbonklobby_editorbutton").click();
                Gdocument.getElementById("mapeditor_close").click();
                Gdocument.getElementById("newbonklobby").style["display"] = "none";
                Gdocument.getElementById("mapeditor_midbox_testbutton").click();
                if(transitioning == true){
                    canceled = true;
                }
            }
            
        }
        var lm = "";
        try{
            lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
            if (lm[0].className == "newbonklobby_chat_msg_colorbox"){
                lm[2].innerHTML = urlify(lm[2].innerHTML);
                Laster_message = lastmessage();
            }
            if (lm[0].className == "newbonklobby_chat_status"){
                lm[0].innerHTML = urlify(lm[0].innerHTML);
                Laster_message = lastmessage();
            }
        }
        catch{
            lm = "";
        }
        
        if(Last_message.indexOf("@"+username)!=-1 && npermissions == 1){
            var n = new Notification(Last_message);
        }
        
        try{
            lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
            if(lm[0].className == "ingamechatname"){
                lm[1].innerHTML = urlify(lm[1].innerHTML);
                Laster_message = lastmessage();
            }
            if(lm[0].className == ""){
                lm[0].innerHTML = urlify(lm[0].innerHTML);
                Laster_message = lastmessage();
            }
        }
        catch{
            lm = "";
        }
        

        for(i=0;i<echo_list.length;i++){
            if(Last_message.substring(0,echo_list[i].length+2) == echo_list[i]+": "){
                message = Last_message.substring(echo_list[i].length+2);
                chat(flag_manage(message));
            }
        }
    }
    if (ishost==true && new_message){
        for(i=0;i<banned.length;i++){
            if(Last_message == "* "+banned[i]+" has joined the game "){
                chat("/kick '"+banned[i]+"'");
            }
        }
    }
    if(ishost == true && stopquickplay == 0){
        
        if(Gdocument.getElementById("ingamewinner").style["visibility"]=="inherit" && stopquickplay == 0 && dontswitch == false){
            quicki++;
            transitioning = true;
            map(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
            
            dontswitch = true;
            setTimeout(function(){Gdocument.getElementById("ingamewinner").style["visibility"]="hidden"; dontswitch = false;},timedelay);
            
        }
    }
    new_message = false;
}

},5000)
长期地址
遇到问题?请前往 GitHub 提 Issues,或加Q群1031348184

赞助商

Fishcpy

广告

Rainyun

注册一下就行

Rainyun

一年攒够 12 元