// ==UserScript==
// @name Bonk Commands
// @namespace http://tampermonkey.net/
// @version 2.3
// @description Adds lots of commands to bonk.io. Type /? or /help in bonk chat to get started.
// @author LEGENDBOSS123 + left paren + mastery3
// @match https://bonk.io/*
// @run-at document-end
// @grant none
// ==/UserScript==
setTimeout(function(){
var link2pastebin = "https://pastebin.com/2b8XqqYu";
var link2greasyfork = "https://gf.qytechs.cn/en/scripts/451341-bonk-commands";
var Gdocument = document.getElementById("maingameframe").contentDocument;
var Gwindow = document.getElementById("maingameframe").contentWindow;
if(typeof(originalSend)=='undefined'){var originalSend = Gwindow.WebSocket.prototype.send;}
if(typeof(bonkwss)=='undefined'){var bonkwss = 0;}
if(typeof(sandboxon)=='undefined'){var sandboxon = false;}
if(typeof(sandboxid)=='undefined'){var sandboxid = 1;}
if(typeof(playerids)=='undefined'){var playerids = {};}
if(typeof(sandboxplayerids)=='undefined'){var sandboxplayerids = {};}
function sandboxonclick(){
Gdocument.getElementById("roomlistcreatewindowmaxplayers").value = 1;
Gdocument.getElementById("roomlistcreatewindowunlistedcheckbox").checked = true;
Gdocument.getElementById("roomlistcreatecreatebutton").click();
sandboxon = true;
}
if(Gdocument.getElementById("clasic_mid_sandbox")==null){
Gdocument.getElementById("roomlistrefreshbutton").click();
var sandboxbutton = Gdocument.createElement("div");
sandboxbutton.id = "clasic_mid_sandbox";
sandboxbutton.classList.value = "brownButton brownButton_classic classic_mid_buttons";
sandboxbutton.textContent = "SANDBOX";
sandboxbutton.addEventListener("click",sandboxonclick);
Gdocument.getElementById("classic_mid").insertBefore(sandboxbutton,Gdocument.getElementById("classic_mid_news"));
}
Gwindow.WebSocket.prototype.send = function(args) {
if(this.url.includes(".bonk.io/socket.io/?EIO=3&transport=websocket&sid=")){
bonkwss = this;
if(args.startsWith('42[26,')){
if(sandboxon){
var jsonargs = JSON.parse(args.substring(2))[1];
if(typeof(sandboxplayerids[jsonargs["targetID"]])!='undefined'){
RECIEVE('42[18,'+jsonargs["targetID"]+','+jsonargs["targetTeam"]+']');
}
}
}
if(args.startsWith('42[4,')){
var jsonargs = JSON.parse(args.substring(2));
if(sandboxcopyme && typeof(jsonargs[1]["type"])=="undefined"){
var jsonkeys = Object.keys(sandboxplayerids);
for(var i = 0; i<jsonkeys.length;i++){
RECIEVE('42[7,'+jsonkeys[i].toString()+','+JSON.stringify(jsonargs[1])+']');
}
}
args = "42"+JSON.stringify(jsonargs);
}
if(args.startsWith('42[5,')){
var jsonargs = JSON.parse(args.substring(2));
if(stopquickplay!=1){
jsonargs[1]["gs"]["wl"] = 999;
}
if(recmodebool){
Gdocument.getElementById("newbonklobby_editorbutton").click();
var newmode = Gdocument.getElementById("mapeditor_modeselect").value;
Gdocument.getElementById("mapeditor_close").click();
if(newmode!=""){
RECIEVE('42[26,"b","'+newmode+'"]');
}
else{
if(defaultmode != ""){
RECIEVE('42[26,"b","'+defaultmode+'"]');
}
}
}
args = "42"+JSON.stringify(jsonargs);
}
}
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[1,')){
var jsonargs = JSON.parse(args.data.substring(2));
SEND('42[1,{"id":'+jsonargs[2]+'}]');
}
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" && typeof(jsonargs["password"]) == "object"){
var password = CRYPT_MESSAGE(private_key,jsonargs["password"]);
var decodedtext = jsonargs["message"].slice(0,400);
var encodedtext = "";
for(var i=0;i<decodedtext.length;i++){
if(password[i%password.length]<1000){
encodedtext+=String.fromCharCode(password[i%password.length]^decodedtext[i]);
}
}
displayInChat("> "+jsonargs["from"]+": "+encodedtext,"#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+1500>Date.now()){
private_chat_public_key = [private_chat,jsonargs["public key"]];
displayInChat("Private chatting with "+private_chat+".","#DA0808","#1EBCC1");
}
}
}
if(args.data.startsWith('42[4,')){
var jsonargs = JSON.parse(args.data.substring(2));
playerids[jsonargs[1]] = jsonargs[3];
}
if(args.data.startsWith('42[5,')){
var jsonargs = JSON.parse(args.data.substring(2));
if(typeof(playerids[jsonargs[1]])!='undefined'){
delete playerids[jsonargs[1]];
}
}
return originalRecieve.call(this,args);
};
var originalClose = this.onclose;
this.onclose = function () {
window.bonkwss = 0;
return originalClose.call(this);
}
}
return originalSend.call(this,args);
};
function SEND(args){
if(bonkwss!=0){
bonkwss.send(args);
}
}
function RECIEVE(args){
if(bonkwss!=0){
bonkwss.onmessage({data: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 = 100;i<301;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 defaultmode = "d";
var recmodebool = false;
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;
var sandboxcopyme = false;
var help = ["All the commands are:","/help","/?","/advhelp [command]","/space","/rcaps","/number","/echo [username]","/remove [username]","/clearecho","/chatw [username]","/msg [text]","/requestfake \"[mapname]\", \"[mapauthor]\"","/eval [code]","/lobby","/team [letter]","/scroll","/hidechat","/showchat","/notify","/stopnotify","Host commands are:","/startqp","/stopqp","/next","/previous","/freejoin","/start","/balanceA [number]","/rounds [number]","/ban [username]","Sandbox commands are:","/addplayer [number]","/delplayer [number]","/copyme"];
var adv_help = {"help":"Shows all command names.",
"?":"Shows all command names.",
"advhelp":"Shows a command in detail.",
"space":"Toggles space. When space is on, whatever you type will be spaced apart.",
"rcaps":"Toggles rcaps. When rcaps is on, each letter will randomly get capitalized.",
"number":"Toggles number. When number is on, 'a' becomes 4, 'e' becomes 3, 's' becomes 5, 'o' becomes 0, 'l' and 'i' become 1.",
"echo":"Echoes a username. It copies the username's chat messages.",
"remove":"Removes username from echo list. You will not echo that username anymore.",
"clearecho":"Clears echo list. You will not echo anyone anymore.",
"chatw":"It private chats with username. Type /msg to message that username.",
"msg":"Messages with what username you are chatting with. Type /chatw to chat with a username.",
"requestfake":"Requests a fake map. The host will not see the request.",
"eval":"Evaluates code. Only use this if you are experienced in javascript.",
"lobby":"Makes lobby visible when you are ingame. Type /lobby again to close lobby.",
"team":"Joins a specific team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
"scroll":"Toggles a scrollbar in ingame chat.",
"hidechat":"Hides ingame chat. Type /showchat to show it again.",
"showchat":"Shows ingame chat. /hidechat hides the chat.",
"notify":"You will be notified if a person types @MYUSERNAME",
"stopnotify":"You will not be notified if a person types @MYUSERNAME",
"startqp":"Starts cycling maps in your map menu.",
"stopqp":"Stops cycling maps in your map menu.",
"next":"Skips the map. Usable only with /startqp.",
"previous":"Goes to previous map. Usable only with /startqp.",
"freejoin":"Toggles freejoin. If freejoin is on, starts the game instantly if there are 1 or less players currently playing",
"start":"Starts game instantly.",
"balanceA":"Balances everyone with balance number.",
"rounds":"Sets rounds to win.",
"ban":"Bans username from lobby. If they rejoin, it automatically bans.",
"addplayer":"In sandbox, it adds players",
"delplayer":"In sandbox, it deletes players",
"copyme":"In sandbox, it makes each player copy your movements."};
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, '&').replace(/>/g, '>').replace(/</g, '<') : 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, '&').replace(/>/g, '>').replace(/</g, '<') : 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("newbonklobby_editorbutton").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];}},1600);
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, '');
var password = [];
for(var i = 0;i<5;i++){
password.push(Math.floor(Math.random()*100+50));
}
var text2 = [];
for(var i = 0;i<text.slice(0,400).length ;i++){
text2.push(password[i%password.length]^text.slice(0,400).charCodeAt(i));
}
SEND("42"+JSON.stringify([4,{"type":"private chat","from":username,"to":private_chat,"message":text2,"password":CRYPT_MESSAGE(private_chat_public_key[1],password)}]));
displayInChat("> "+username+": "+text,"#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)=="?"){
for(var i = 0;i<help.length;i++){
displayInChat(help[i],"#DA0808","#1EBCC1");
}
return "";
}
else if (chat_val.substring(1,9)=="advhelp " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
var text = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
if(typeof(adv_help[text])!='undefined'){
displayInChat(adv_help[text],"#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, '') + "'";
}
else if (chat_val.substring(1,10)=="balanceA " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
if(!isNaN(parseInt(text))){
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");
for(var i = 0; i<playing.length;i++){
chat("/balance \""+playing[i].children[1].textContent+"\" "+text)
}
}
return "";
}
else if (chat_val.substring(1,8)=="rounds " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '');
if(!isNaN(parseInt(text))){
text = parseInt(text).toString();
SEND('42[21,{w:'+text+'}]');
RECIEVE('42[27,'+text+']');
}
return "";
}
else if (chat_val.substring(1,13)=="defaultmode " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '');
if(text == "default"){
defaultmode = "";
displayInChat("Changed default mode to default.","#DA0808","#1EBCC1");
}
else if(text == "arrows"){
defaultmode = "ar";
displayInChat("Changed default mode to arrows.","#DA0808","#1EBCC1");
}
else if(text == "death arrows"){
defaultmode = "ard";
displayInChat("Changed default mode to death arrows.","#DA0808","#1EBCC1");
}
else if(text == "grapple"){
defaultmode = "sp";
displayInChat("Changed default mode to grapple.","#DA0808","#1EBCC1");
}
else if(text == "classic"){
defaultmode = "b";
displayInChat("Changed default mode to classic.","#DA0808","#1EBCC1");
}
else{
displayInChat("Default mode options:","#DA0808","#1EBCC1");
displayInChat("default","#DA0808","#1EBCC1");
displayInChat("classic","#DA0808","#1EBCC1");
displayInChat("arrows","#DA0808","#1EBCC1");
displayInChat("death arrows","#DA0808","#1EBCC1");
displayInChat("grapple","#DA0808","#1EBCC1");
}
return "";
}
else if (chat_val.substring(1,8)=="recmode"){
if(recmodebool == true){
recmodebool = false;
displayInChat("Recmode is now off.","#DA0808","#1EBCC1");
}
else{
recmodebool = true;
displayInChat("Recmode is now on.","#DA0808","#1EBCC1");
}
return "";
}
else if(sandboxon){
if (chat_val.substring(1,11)=="addplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
if(!isNaN(parseInt(text))){
var text2 = parseInt(text);
if(text2>0){
for(var i = 0;i<text2;i++){
RECIEVE('42[4,'+sandboxid+',"0123456789abcdef","'+sandboxid.toString()+'",true,0,1,{"layers":[],"bc":'+Math.floor(Math.random() * 16777215).toString()+'}]');
sandboxplayerids[sandboxid] = sandboxid.toString();
sandboxid+=1;
}
}
}
return "";
}
else if (chat_val.substring(1,11)=="delplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
if(!isNaN(parseInt(text))){
var text2 = parseInt(text);
if(text2>0){
if(Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden"){
var jsonkeys = Object.keys(sandboxplayerids).reverse();
for(var i = 0;i<text2 && i<jsonkeys.length;i++){
RECIEVE('42[5,'+jsonkeys[i]+',0]');
delete sandboxplayerids[jsonkeys[i]];
}
}
else{
displayInChat("Cannot delete players while ingame.","#DA0808","#1EBCC1");
}
}
}
return "";
}
else if (chat_val.substring(1,7)=="copyme"){
if(sandboxcopyme == true){
displayInChat("Copyme is now off.","#DA0808","#1EBCC1");
sandboxcopyme = false;
}
else{
displayInChat("Copyme is now on.","#DA0808","#1EBCC1");
sandboxcopyme = true;
}
return "";
}
}
}
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("sm_connectingContainer").style["visibility"] == "hidden"){
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;
defaultmode = "";
recmodebool = false;
playerids = {};
sandboxplayerids = {};
sandboxcopyme = false;
sandboxon = false;
sandboxid = 1;
}
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)