Bonk Commands

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

目前為 2022-11-20 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Bonk Commands
  3. // @namespace https://greasyfork.org/en/scripts/451341-bonk-commands
  4. // @version 7.3
  5. // @description Adds lots of commands to bonk.io. Type /? or /help in bonk chat to get started.
  6. // @author LEGENDBOSS123 + left paren + mastery3
  7. // @match https://bonk.io/*
  8. // @run-at document-idle
  9. // @grant none
  10. // @unwrap
  11. // ==/UserScript==
  12. function BonkCommandsScriptInjector(f){
  13. if(window.location == window.parent.location){
  14. if(document.readyState == "complete"){f();}
  15. else{document.addEventListener('readystatechange',function(){setTimeout(f,1500);});}
  16. }
  17. }
  18.  
  19. BonkCommandsScriptInjector(function(){
  20. var scope = window;
  21.  
  22. scope.Gwindow = document.getElementById("maingameframe").contentWindow;
  23. scope.Gdocument = document.getElementById("maingameframe").contentDocument;
  24. Gwindow.Gwindow = window;
  25. Gwindow.Gdocument = document;
  26.  
  27. scope.link2pastebin = "https://pastebin.com/2b8XqqYu";
  28. scope.link2greasyfork = "https://greasyfork.org/en/scripts/451341-bonk-commands";
  29.  
  30. if(typeof(scope.injectedBonkCommandsScript)=='undefined'){
  31. scope.injectedBonkCommandsScript = true;
  32. }
  33. else{
  34. for (var i = 0; i < 100000; i++){
  35. clearInterval(i);
  36. }
  37. }
  38. scope.GENERATE_COPRIME_NUMBER = function(mini = 0,maxi = 0,coprimewith = 0,choices = []){
  39. if(choices.length == 0){
  40. for(var i = mini;i<maxi+1;i++){
  41. choices.push(i);
  42. }
  43. }
  44. firstTry = choices[Math.floor(Math.random()*choices.length)];
  45. for(var i = 2; i<firstTry+1;i++){
  46. if(firstTry%i == 0 && coprimewith%i == 0){
  47. choices.splice(choices.indexOf(firstTry),1);
  48. if(choices.length == 0){
  49. return 0;
  50. }
  51. return GENERATE_COPRIME_NUMBER(mini,maxi,coprimewith,choices);
  52. }
  53. }
  54. return firstTry;
  55. };
  56. scope.GENERATE_PRIME_NUMBER = function(mini = 0,maxi = 0,choices = []){
  57. if(choices.length == 0){
  58. for(var i = mini;i<maxi+1;i++){
  59. choices.push(i);
  60. }
  61. }
  62. firstTry = choices[Math.floor(Math.random()*choices.length)];
  63. for(var i = 2; i<Math.floor(Math.sqrt(firstTry)+1);i++){
  64. if(i!=firstTry){
  65. if(firstTry%i == 0){
  66. choices.splice(choices.indexOf(firstTry),1);
  67. if(choices.length == 0){
  68. return 0;
  69. }
  70. return GENERATE_PRIME_NUMBER(mini,maxi,choices);
  71. }
  72. }
  73. }
  74. return firstTry;
  75. };
  76.  
  77. scope.GENERATE_KEYS = function(){
  78. interval = [];
  79. for(var i = 100;i<301;i++){
  80. interval.push(i);
  81. }
  82. random_prime = [GENERATE_PRIME_NUMBER(0,0,choices = interval),0];
  83. interval.splice(interval.indexOf(random_prime[0]),1);
  84. random_prime[1] = GENERATE_PRIME_NUMBER(0,0,choices = interval);
  85.  
  86. n = random_prime[0]*random_prime[1];
  87. n2 = (random_prime[0]-1)*(random_prime[1]-1);
  88.  
  89. e = GENERATE_COPRIME_NUMBER(2,n2-1,n2);
  90. d = 0;
  91. redo = true;
  92. for(var i = 0;i<1000000;i++){
  93. if((e*i-1)%n2 == 0 && i!=e){
  94. d = i;
  95. redo = false;
  96. break;
  97. }
  98. }
  99. if(redo){
  100. return GENERATE_KEYS();
  101. }
  102. else{
  103. return [[n,e],[n,d]];
  104. }
  105.  
  106. };
  107. scope.CRYPT_NUMBER = function(key, data){
  108.  
  109. result = 1;
  110.  
  111. for(var i = 0;i<key[1];i++){
  112. result*=data;
  113. result = result%key[0];
  114. }
  115. return result%key[0];
  116.  
  117. };
  118.  
  119. scope.CRYPT_MESSAGE = function(key,data){
  120. var resulttext = [];
  121. for(var i = 0;i<data.length;i++){
  122. resulttext.push(CRYPT_NUMBER(key,data[i]));
  123. }
  124. return resulttext;
  125.  
  126. };
  127.  
  128. if(typeof(scope.originalSend)=='undefined'){scope.originalSend = Gwindow.WebSocket.prototype.send;}
  129. if(typeof(scope.bonkwss)=='undefined'){scope.bonkwss = 0;}
  130. if(typeof(scope.chatlog)=='undefined'){scope.chatlog = ["ROOM START"];}
  131. if(typeof(scope.sandboxon)=='undefined'){scope.sandboxon = false;}
  132. if(typeof(scope.sandboxid)=='undefined'){scope.sandboxid = 1;}
  133. if(typeof(scope.playerids)=='undefined'){scope.playerids = {};}
  134. if(typeof(scope.pingids)=='undefined'){scope.pingids = {};}
  135. if(typeof(scope.sandboxplayerids)=='undefined'){scope.sandboxplayerids = {};}
  136. if(typeof(scope.originalMapLoad)=='undefined'){scope.originalMapLoad = Gdocument.getElementById("maploadwindowmapscontainer").appendChild;}
  137. if(typeof(scope.originalLobbyChat)=='undefined'){scope.originalLobbyChat = Gdocument.getElementById("newbonklobby_chat_content").appendChild;}
  138. if(typeof(scope.originalIngameChat)=='undefined'){scope.originalIngameChat = Gdocument.getElementById("ingamechatcontent").appendChild;}
  139. if(typeof(scope.private_chat_keys)=='undefined'){scope.private_chat_keys = GENERATE_KEYS();scope.private_key = private_chat_keys[0];scope.public_key = private_chat_keys[1];}
  140. function sandboxonclick(){
  141. Gdocument.getElementById("roomlistcreatewindowmaxplayers").value = 1;
  142. Gdocument.getElementById("roomlistcreatewindowunlistedcheckbox").checked = true;
  143. Gdocument.getElementById("roomlistcreatecreatebutton").click();
  144. sandboxon = true;
  145. }
  146. function checkboxclearbuttononclick(){
  147. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  148. var e = true;
  149. for(var i = 0; i<classes.length;i++){
  150. if(classes[i].checked == true){
  151. e = false
  152. }
  153. classes[i].checked = false;
  154. }
  155. if(e){
  156. for(var i = 0; i<classes.length;i++){
  157. classes[i].checked = true;
  158. }
  159. }
  160. }
  161. if(Gdocument.getElementById("classic_mid_sandbox")==null){
  162. Gdocument.getElementById("roomlistrefreshbutton").click();
  163. scope.sandboxbutton = Gdocument.createElement("div");
  164. sandboxbutton.id = "classic_mid_sandbox";
  165. sandboxbutton.classList.value = "brownButton brownButton_classic classic_mid_buttons";
  166. sandboxbutton.textContent = "SANDBOX";
  167. sandboxbutton.addEventListener("click",sandboxonclick);
  168. Gdocument.getElementById("classic_mid").insertBefore(sandboxbutton,Gdocument.getElementById("classic_mid_news"));
  169.  
  170. }
  171. if(Gdocument.getElementById("clearallcheckboxes")==null){
  172. scope.checkboxclearbutton = Gdocument.createElement("div");
  173. checkboxclearbutton.id = "clearallcheckboxes";
  174. checkboxclearbutton.classList.value = "brownButton brownButton_classic buttonShadow";
  175. checkboxclearbutton.textContent = "CLEAR ALL";
  176. checkboxclearbutton.style["position"] = "absolute";
  177. checkboxclearbutton.style["display"] = "none";
  178. if(ishost && stopquickplay == 0){
  179. checkboxclearbutton.style["display"] = "block";
  180. }
  181. checkboxclearbutton.style["right"] = "260px";
  182. checkboxclearbutton.style["top"] = "57px";
  183. checkboxclearbutton.style["height"] = "23px";
  184. checkboxclearbutton.style["width"] = "100px";
  185. checkboxclearbutton.style["line-height"] = "23px";
  186. checkboxclearbutton.style["font-size"] = "16px";
  187. checkboxclearbutton.addEventListener("click",checkboxclearbuttononclick);
  188. Gdocument.getElementById("maploadwindow").insertBefore(checkboxclearbutton,Gdocument.getElementById("maploadwindowsearchinput"));
  189.  
  190. }
  191. Gdocument.getElementById("maploadwindowmapscontainer").appendChild = function(args){
  192. var checkbox = Gdocument.createElement("input");
  193. checkbox.type = "checkbox";
  194. checkbox.style["position"]="absolute";
  195. checkbox.style["margin-top"] = "135px";
  196. checkbox.style["margin-left"] = "140px";
  197. checkbox.style["scale"] = "2";
  198. checkbox.style["display"] = "none";
  199. checkbox.className = "quickplaycheckbox quickplayunchecked";
  200. if(ishost && stopquickplay==0){
  201. checkbox.style["display"] = "block";
  202. checkbox.className = "quickplaycheckbox quickplaychecked";
  203. }
  204. checkbox.checked = true;
  205. checkbox.onclick = function(e){e.stopPropagation();};
  206. args.appendChild(checkbox);
  207. originalMapLoad.call(this,args);
  208. };
  209. Gdocument.getElementById("newbonklobby_chat_content").appendChild = function(args){
  210. if(beenKickedTimeStamp+100>Date.now() && args.children.length>0){
  211. if(args.children[0].textContent.endsWith(" has left the game ") && args.children[0].textContent.startsWith("* ")){
  212. args.children[0].textContent = args.children[0].textContent.substring(0,args.children[0].textContent.length-19)+" has been kicked from the game ";
  213. }
  214. }
  215. originalLobbyChat.call(this,args);
  216. };
  217. Gdocument.getElementById("ingamechatcontent").appendChild = function(args){
  218. if(beenKickedTimeStamp+100>Date.now() && args.children.length>0){
  219. if(args.children[0].textContent.endsWith(" has left the game.") && args.children[0].textContent.startsWith("* ")){
  220. args.children[0].textContent = args.children[0].textContent.substring(0,args.children[0].textContent.length-19)+" has been kicked from the game.";
  221. }
  222. }
  223. if(recordedTimeStamp+100>Date.now() && args.children.length>0){
  224. if(args.children[0].textContent.includes("seconds") && args.children[0].textContent.startsWith("* ")){
  225. args.children[0].textContent = args.children[0].textContent + " - " + playerids[recordedId]
  226. }
  227. }
  228. originalIngameChat.call(this,args);
  229. };
  230. Gwindow.WebSocket.prototype.send = function(args) {
  231. if(this.url.includes(".bonk.io/socket.io/?EIO=3&transport=websocket&sid=")){
  232. bonkwss = this;
  233. if(args.startsWith('42[26,')){
  234. if(sandboxon){
  235. var jsonargs = JSON.parse(args.substring(2))[1];
  236. if(typeof(sandboxplayerids[jsonargs["targetID"]])!='undefined'){
  237. RECIEVE('42[18,'+jsonargs["targetID"]+','+jsonargs["targetTeam"]+']');
  238.  
  239. }
  240. }
  241. }
  242. if(args.startsWith('42[4,')){
  243. var jsonargs = JSON.parse(args.substring(2));
  244. if(sandboxcopyme && typeof(jsonargs[1]["type"])=="undefined"){
  245. var jsonkeys = Object.keys(sandboxplayerids);
  246. for(var i = 0; i<jsonkeys.length;i++){
  247. RECIEVE('42[7,'+jsonkeys[i].toString()+','+JSON.stringify(jsonargs[1])+']');
  248. }
  249. }
  250. args = "42"+JSON.stringify(jsonargs);
  251. }
  252.  
  253. if(args.startsWith('42[5,')){
  254. var jsonargs = JSON.parse(args.substring(2));
  255.  
  256. if(stopquickplay!=1){
  257. jsonargs[1]["gs"]["wl"] = 999;
  258. }
  259. args = "42"+JSON.stringify(jsonargs);
  260. }
  261.  
  262. }
  263. if(this.url.includes(".bonk.io/socket.io/?EIO=3&transport=websocket&sid=") && !this.injected){
  264. this.injected = true;
  265.  
  266. var originalRecieve = this.onmessage;
  267. this.onmessage = function(args){
  268. if(args.data.startsWith('42[24,')){
  269. beenKickedTimeStamp = Date.now();
  270. }
  271. if(args.data.startsWith('42[32')){
  272. SEND('42[4,{"type":"inactive kick counter"}]');
  273. }
  274. if(args.data.startsWith('42[40,')){
  275. recordedTimeStamp = Date.now();
  276. recordedId = JSON.parse(args.data.substring(2))[1];
  277. }
  278. if(args.data.startsWith('42[1,')){
  279. var jsonargs = JSON.parse(args.data.substring(2));
  280. SEND('42[1,{"id":'+jsonargs[2]+'}]');
  281. pingids = jsonargs[1];
  282. }
  283. if(args.data.startsWith('42[3,')){
  284. var jsonargs = JSON.parse(args.data.substring(2));
  285. for(var i = 0; i<jsonargs[3].length;i++){
  286. if(jsonargs[3][i]!=null){
  287. playerids[i.toString()] = jsonargs[3][i]["userName"];
  288. }
  289. }
  290. }
  291. if(args.data.startsWith('42[15,')){
  292. var jsonargs = JSON.parse(args.data.substring(2));
  293. gameStartTimeStamp = jsonargs[1];
  294. }
  295. if(args.data.startsWith('42[7,')){
  296. var jsonargs2 = JSON.parse(args.data.substring(2));
  297. var idofpacket = jsonargs2[1];
  298. jsonargs = jsonargs2[2];
  299. if(typeof(jsonargs["type"]) != "undefined"){
  300. if(jsonargs["type"]=="private chat" && jsonargs["to"] == username){
  301. from = jsonargs["from"];
  302. if(Object.keys(playerids).includes(idofpacket.toString())){
  303. from = playerids[idofpacket];
  304. }
  305. if(!ignorepmlist.includes(from)){
  306. if(typeof(jsonargs["message"])=="object" && typeof(jsonargs["password"]) == "object"){
  307. if(public_key[0]==jsonargs["public key"][0] && public_key[1]==jsonargs["public key"][1]){
  308. if(jsonargs["password"].length<=25){
  309. var password = CRYPT_MESSAGE(private_key,jsonargs["password"]);
  310. var decodedtext = jsonargs["message"].slice(0,400);
  311. var encodedtext = "";
  312. for(var i=0;i<decodedtext.length;i++){
  313. if(password[i%password.length]<1000){
  314. encodedtext+=String.fromCharCode(password[i%password.length]^decodedtext[i]);
  315. }
  316. }
  317. var code = 'Gwindow.private_chat = "'+from+'"; Gwindow.SEND("42"+JSON.stringify([4,{"type":"request public key","from":Gwindow.username,"to":Gwindow.private_chat}])); Gwindow.request_public_key_time_stamp = Date.now(); setTimeout(function(){if(Gwindow.private_chat_public_key[0]!=Gwindow.private_chat){Gwindow.displayInChat("Failed to connect to "+Gwindow.private_chat+".","#DA0808","#1EBCC1");Gwindow.private_chat = Gwindow.private_chat_public_key[0];}},1600);';
  318. displayInChat('> '+'<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+from+'</a>'+': ',"#DA0808","#1EBCC1",{sanitize:false},encodedtext);
  319.  
  320. Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true;
  321. Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true;
  322. Laster_message = lastmessage();
  323. }
  324. }
  325. else{
  326. SEND("42"+JSON.stringify([4,{"type":"public key correction","from":username,"to":private_chat_public_key[0],"public key":public_key}]));
  327. }
  328. }
  329. }
  330. }
  331. if(jsonargs["type"]=="request public key" && jsonargs["to"] == username){
  332. SEND("42"+JSON.stringify([4,{"type":"public key","from":username,"public key":public_key}]));
  333. }
  334. if(jsonargs["type"]=="private chat users" && pmuserstimestamp+1500>Date.now()){
  335. if(typeof(jsonargs["from"])!='undefined'){
  336. from = jsonargs["from"];
  337. if(Object.keys(playerids).includes(idofpacket.toString())){
  338. from = playerids[idofpacket];
  339. }
  340. if(!pmusers.includes(from) && username == jsonargs["to"]){
  341. pmusers.push(from);
  342. }
  343. }
  344. }
  345. if(jsonargs["type"]=="request private chat users"){
  346. if(typeof(jsonargs["from"])!='undefined'){
  347. from = jsonargs["from"];
  348. if(Object.keys(playerids).includes(idofpacket.toString())){
  349. from = playerids[idofpacket];
  350. }
  351. SEND("42"+JSON.stringify([4,{"type":"private chat users","from":username,"to":from}]));
  352. }
  353. }
  354. if(jsonargs["type"]=="public key" && request_public_key_time_stamp+1500>Date.now()){
  355. from = jsonargs["from"];
  356. if(Object.keys(playerids).includes(idofpacket.toString())){
  357. from = playerids[idofpacket];
  358. }
  359. if(from == private_chat){
  360. private_chat_public_key = [private_chat,jsonargs["public key"]];
  361. displayInChat("Private chatting with "+private_chat+".","#DA0808","#1EBCC1");
  362. }
  363.  
  364. }
  365. if(jsonargs["type"]=="public key correction" && private_chat_public_key[0] == private_chat){
  366. from = jsonargs["from"];
  367. if(Object.keys(playerids).includes(idofpacket.toString())){
  368. from = playerids[idofpacket];
  369. }
  370. if(from == private_chat){
  371. private_chat_public_key = [private_chat,jsonargs["public key"]];
  372. var text = pmlastmessage;
  373. var password = [];
  374. for(var i = 0;i<10;i++){
  375. password.push(Math.floor(Math.random()*100+50));
  376. }
  377. var text2 = [];
  378. for(var i = 0;i<text.length ;i++){
  379. text2.push(password[i%password.length]^text.slice(0,400).charCodeAt(i));
  380. }
  381. SEND("42"+JSON.stringify([4,{"type":"private chat","from":username,"to":private_chat,"public key":private_chat_public_key[1],"message":text2,"password":CRYPT_MESSAGE(private_chat_public_key[1],password)}]));
  382. }
  383. }
  384.  
  385. }
  386. else{
  387. gameStartTimeStamp = Date.now()-1000*jsonargs["f"]/30;
  388. }
  389. }
  390.  
  391. if(args.data.startsWith('42[4,')){
  392. var jsonargs = JSON.parse(args.data.substring(2));
  393. playerids[jsonargs[1]] = jsonargs[3];
  394.  
  395. }
  396. if(args.data.startsWith('42[5,')){
  397. var jsonargs = JSON.parse(args.data.substring(2));
  398. if(typeof(playerids[jsonargs[1]])!='undefined'){
  399. delete playerids[jsonargs[1]];
  400. }
  401. }
  402. return originalRecieve.call(this,args);
  403. };
  404.  
  405. var originalClose = this.onclose;
  406. this.onclose = function () {
  407. window.bonkwss = 0;
  408. return originalClose.call(this);
  409. }
  410.  
  411. }
  412. return originalSend.call(this,args);
  413. };
  414.  
  415. scope.SEND = function(args){
  416. if(bonkwss!=0){
  417. bonkwss.send(args);
  418. }
  419. };
  420. scope.RECIEVE = function(args){
  421. if(bonkwss!=0){
  422. bonkwss.onmessage({data:args});
  423. }
  424. };
  425. Gdocument.getElementById("ingamechatcontent").style["pointer-events"]="all";
  426. Gdocument.getElementById("ingamechatcontent").style["max-height"]="250px";
  427. Gdocument.getElementById("ingamechatcontent").style["height"]="128px";
  428. Gdocument.getElementById("ingamechatbox").style["height"]="250px";
  429.  
  430. document.getElementById('adboxverticalCurse').style["display"] = "none";
  431. document.getElementById('adboxverticalleftCurse').style["display"] = "none";
  432.  
  433.  
  434. scope.dontswitch = false;
  435. scope.username = 0;
  436. scope.timedelay = 1400;
  437. scope.ishost = false;
  438. scope.checkboxhidden = true;
  439. scope.quicki=0;
  440. scope.defaultmode = "d";
  441. scope.recmodebool = false;
  442. scope.shuffle = false;
  443. scope.freejoin = false;
  444. scope.recordedTimeStamp = 0;
  445. scope.recordedId = 0;
  446. scope.beenKickedTimeStamp = 0;
  447. scope.stopquickplay = 1;
  448. scope.currentFrame = 0;
  449. scope.gameStartTimeStamp = 0;
  450. scope.canceled = false;
  451. scope.banned = [];
  452. scope.transitioning = false;
  453. scope.echo_list = [];
  454. scope.message = "";
  455. scope.mode = "";
  456. scope.private_chat = "";
  457. scope.private_chat_public_key = ["",[0,0]];
  458. scope.users = [];
  459. scope.pmusers = [];
  460. scope.pmlastmessage = "";
  461. scope.pmuserstimestamp = 0;
  462. scope.ignorepmlist = [];
  463. scope.scroll = false;
  464. scope.elem = Gdocument.getElementById("maploadwindowmapscontainer");
  465. scope.npermissions = 1;
  466. scope.space_flag = false;
  467. scope.rcaps_flag = false;
  468. scope.number_flag = false;
  469. scope.request_public_key_time_stamp = 0;
  470. scope.sandboxcopyme = false;
  471. scope.help = ["All the commands are:","/help","/?","/advhelp [command]","/space","/rcaps","/number","/echo [username]","/clearecho","/remove [username]","/chatw [username]","/msg [text]","/ignorepm [username]","/pmusers","/eval [code]","/lobby","/team [letter]","/scroll","/hidechat","/showchat","/notify","/stopnotify","Host commands are:","/startqp","/stopqp","/next","/previous","/shuffle","/freejoin","/recmode","/defaultmode [mode]","/start","/balanceA [number]","/moveA [letter]","/rounds [number]","/mode [mode]","/ban [username]","/kill [username]","Sandbox commands are:","/addplayer [number]","/delplayer [number]","/copyme","Hotkeys are:","Alt L","Alt C","Host hotkeys are:","Alt S","Alt T","Alt E","Alt K","Alt M","Alt Q","Alt A","Alt D","Alt F","Alt R"];
  472.  
  473. scope.adv_help = {"help":"Shows all command names.",
  474. "?":"Shows all command names.",
  475. "advhelp":"Shows a command in detail.",
  476. "space":"Toggles space. When space is on, whatever you type will be spaced apart.",
  477. "rcaps":"Toggles rcaps. When rcaps is on, each letter will randomly get capitalized.",
  478. "number":"Toggles number. When number is on, 'a' becomes 4, 'e' becomes 3, 's' becomes 5, 'o' becomes 0, 'l' and 'i' become 1.",
  479. "echo":"Echoes a username. It copies the username's chat messages.",
  480. "remove":"Removes username from echo list. You will not echo that username anymore.",
  481. "clearecho":"Clears echo list. You will not echo anyone anymore.",
  482. "chatw":"It private chats with username. Type /msg to message that username.",
  483. "msg":"Messages with what username you are chatting with. Type /chatw to chat with a username.",
  484. "ignorepm":"Ignores the username's private chat messages. To unignore, type /ignorepm [username].",
  485. "pmusers":"Dispays who you can private chat with.",
  486. "eval":"Evaluates code. Only use this if you are experienced in javascript.",
  487. "lobby":"Makes lobby visible when you are ingame. Type /lobby again to close lobby.",
  488. "team":"Joins a specific team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  489. "scroll":"Toggles a scrollbar in ingame chat.",
  490. "hidechat":"Hides ingame chat. Type /showchat to show it again.",
  491. "showchat":"Shows ingame chat. /hidechat hides the chat.",
  492. "notify":"You will be notified if a person types @MYUSERNAME",
  493. "stopnotify":"You will not be notified if a person types @MYUSERNAME",
  494. "startqp":"Starts cycling maps in your map menu.",
  495. "stopqp":"Stops cycling maps in your map menu.",
  496. "next":"Skips the map. Usable only with /startqp.",
  497. "previous":"Goes to previous map. Usable only with /startqp.",
  498. "shuffle":"Makes quickplay play random maps instead of in order.",
  499. "freejoin":"Toggles freejoin. If freejoin is on, starts the game instantly if there are 1 or less players currently playing.",
  500. "recmode":"In quickplay, it switches mode to recommended mode, according to editor.",
  501. "defaultmode":"Switches mode to defaultmode if there is no recmode.",
  502. "start":"Starts game instantly.",
  503. "balanceA":"Balances everyone with balance number.",
  504. "moveA":"Sets everyones team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  505. "rounds":"Sets rounds to win.",
  506. "mode":"Switches modes.",
  507. "ban":"Bans username from lobby. If they rejoin, it automatically bans.",
  508. "kill":"Kills the person ingame.",
  509. "addplayer":"In sandbox, it adds players.",
  510. "delplayer":"In sandbox, it deletes players.",
  511. "copyme":"In sandbox, it makes each player copy your movements.",
  512. "Alt L":"Makes lobby visible when you are ingame. Press Alt L again to close lobby.",
  513. "Alt C":"Hides ingame chat. Press Alt C again to show ingame chat.",
  514. "Alt S":"Starts game instantly.",
  515. "Alt T":"Toggles teams.",
  516. "Alt E":"Toggles editor.",
  517. "Alt K":"Exits ingame and returns to lobby.",
  518. "Alt M":"Switches modes.",
  519. "Alt Q":"Toggles quickplay.",
  520. "Alt A":"Skips the map if quickplay is on.",
  521. "Alt D":"Goes to previous map if quickplay is on.",
  522. "Alt F":"Toggles freejoin. If freejoin is on, starts the game instantly if there are 1 or less players currently playing",
  523. "Alt R":"In quickplay, it switches mode to recommended mode, according to editor."
  524. };
  525.  
  526. elem.onclick=function(e){
  527. if(stopquickplay==0 && ishost == true && e.isTrusted == true){
  528. quicki = (Array.from(e.target.parentElement.parentNode.children).indexOf(e.target.parentNode)-1)%(Gdocument.getElementById("maploadwindowmapscontainer").children.length);
  529. }
  530. };
  531. scope.urlify = function(text) {
  532. return text.replace(/(?:https?:\/\/)?(?:[A-Za-z0-9-ßàÁâãóôþüúðæåïçèõöÿýòäœêëìíøùîûñé]+)(?:\.[A-Za-z0-9-ßàÁâãóôþüúðæåïçèõöÿýòäœêëìíøùîûñé]+)+(?:\/(?:[A-Za-z0-9-._~:/?#\[\]@!$&'()*+,;=]|%[0-9a-fA-F]{2})*)?(?:\?(?:[^=]+=[^&](?:&[^=]+=[^&])*)?)?/g, function(url) {
  533. return '<a href="' + url + '" target="_blank" style = "color:orange">' + url + '</a>';
  534. })
  535. };
  536.  
  537. scope.fire = function(type,options,d = Gdocument){
  538. var event=new CustomEvent(type);
  539. for(var p in options){
  540. event[p]=options[p];
  541. }
  542. d.dispatchEvent(event);
  543. };
  544.  
  545. scope.chat = function(message){
  546. mess = Gdocument.getElementById("newbonklobby_chat_input").value;
  547. mess2 = Gdocument.getElementById("ingamechatinputtext").value;
  548. Gdocument.getElementById("newbonklobby_chat_input").value = message;
  549. Gdocument.getElementById("ingamechatinputtext").value = message;
  550. fire("keydown",{keyCode:13});
  551. fire("keydown",{keyCode:13});
  552. Gdocument.getElementById("newbonklobby_chat_input").value = mess;
  553. Gdocument.getElementById("ingamechatinputtext").value = mess2;
  554. };
  555. scope.displayInChat = function(message, LobbyColor, InGameColor, options, message2) {
  556. options = options ?? {};
  557. message2 = message2 ?? "";
  558. LobbyColor = LobbyColor ?? "#8800FF";
  559. InGameColor = InGameColor ?? "#AA88FF";
  560. let A = Gdocument.createElement("div");
  561. let B = Gdocument.createElement("span");
  562. B.className = "newbonklobby_chat_status";
  563. B.style.color = LobbyColor;
  564. A.appendChild(B);
  565. B.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  566. B.innerHTML+=urlify(message2.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;'));
  567. let C = Gdocument.createElement("div");
  568. let D = Gdocument.createElement("span");
  569. D.style.color = InGameColor;
  570. C.appendChild(D);
  571. D.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  572. D.innerHTML+=urlify(message2.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;'));
  573.  
  574. let a = false;
  575. if(Gdocument.getElementById("newbonklobby_chat_content").scrollHeight - Gdocument.getElementById("newbonklobby_chat_content").scrollTop > Gdocument.getElementById("newbonklobby_chat_content").clientHeight - 1) {
  576. a = true;
  577. }
  578. Gdocument.getElementById("newbonklobby_chat_content").appendChild(A);
  579. Gdocument.getElementById("ingamechatcontent").appendChild(C);
  580. if (a) { Gdocument.getElementById("newbonklobby_chat_content").scrollTop = Number.MAX_SAFE_INTEGER;};
  581. Gdocument.getElementById("ingamechatcontent").scrollTop = Number.MAX_SAFE_INTEGER;
  582. chat("");
  583. };
  584.  
  585. scope.lobby = function(){
  586. if (Gdocument.getElementById("newbonklobby").style["display"]=="none"){
  587.  
  588. Gdocument.getElementById("newbonklobby_editorbutton").click();
  589. Gdocument.getElementById("mapeditor_close").click();
  590. if(Gdocument.getElementsByClassName("newbonklobby_playerentry").length>0){
  591. Gdocument.getElementById("newbonklobby").style["z-index"]=1;
  592. Gdocument.getElementById("maploadwindowcontainer").style["z-index"]=1;
  593. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=1;
  594. Gdocument.getElementById("pretty_top").style["z-index"]=2;
  595. Gdocument.getElementById("settingsContainer").style["z-index"]=2;
  596. Gdocument.getElementById("leaveconfirmwindow").style["z-index"]=2;
  597. Gdocument.getElementById("hostleaveconfirmwindow").style["z-index"]=2;
  598. }
  599. else{
  600. Gdocument.getElementById("newbonklobby").style["opacity"]=0;
  601. Gdocument.getElementById("newbonklobby").style["display"]="none";
  602. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
  603. }
  604.  
  605. }
  606. else if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  607. Gdocument.getElementById("newbonklobby").style["opacity"]=0;
  608. Gdocument.getElementById("newbonklobby").style["display"]="none";
  609. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
  610. }
  611. };
  612.  
  613. scope.lastmessage = function(){
  614. if(Gdocument.getElementById("newbonklobby_chat_content").children.length!=0){
  615. var lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  616. var lm2 = "";
  617. for(var i = 0; i<lm.length;i++){
  618. lm2+=" "+lm[i].textContent.trim();
  619. }
  620. lm2 = lm2.trim();
  621. if(lm2.startsWith("*")){
  622. return lm2;
  623. }
  624. }
  625. if(Gdocument.getElementById("ingamechatcontent").children.length!=0){
  626. var lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  627. var lm2 = "";
  628. for(var i = 0; i<lm.length;i++){
  629. lm2+=" "+lm[i].textContent.trim();
  630. }
  631. return lm2.trim();
  632. }
  633. return "";
  634.  
  635. };
  636. scope.map = function(e){
  637. if(e<0){
  638. displayInChat("There is no previous map.","#DA0808","#1EBCC1");
  639. quicki = 0;
  640. return;
  641. }
  642. if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
  643. displayInChat("Click the maps button.","#DA0808","#1EBCC1");
  644. return;
  645. }
  646.  
  647. setTimeout(function(){if(!canceled){
  648. Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
  649. Gdocument.getElementById("newbonklobby_editorbutton").click();
  650. if(recmodebool && ishost){
  651. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  652. if(mode == "" && defaultmode!="d"){
  653. mode = defaultmode;
  654. }
  655. if(mode != ""){
  656. RECIEVE('42[26,"b","'+mode+'"]');
  657. }
  658. }
  659. Gdocument.getElementById("mapeditor_close").click();
  660. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  661. Gdocument.getElementById("mapeditor_midbox_testbutton").click();}
  662. canceled = false;
  663. transitioning = false;
  664. },timedelay);
  665.  
  666. };
  667.  
  668. scope.gotonextmap = function(e){
  669. if(e<0){
  670. displayInChat("There is no previous map.","#DA0808","#1EBCC1");
  671. quicki = 0;
  672. return;
  673. }
  674. if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
  675. displayInChat("Click the maps button.","#DA0808","#1EBCC1");
  676. return;
  677. }
  678. Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
  679. Gdocument.getElementById("newbonklobby_editorbutton").click();
  680. if(recmodebool && ishost){
  681. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  682. if(mode == "" && defaultmode!="d"){
  683. mode = defaultmode;
  684. }
  685. if(mode != ""){
  686. RECIEVE('42[26,"b","'+mode+'"]');
  687. }
  688. }
  689. Gdocument.getElementById("mapeditor_close").click();
  690. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  691. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  692. Gdocument.getElementById("newbonklobby").style["visibility"] = "visible";
  693. };
  694. scope.commandhandle = function(chat_val){
  695. if (chat_val.substring(1,6)=="echo " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  696. if (chat_val.substring(6).replace(/^\s+|\s+$/g, '')==username){
  697. displayInChat("You cannot echo yourself.","#DA0808","#1EBCC1");
  698. return "";
  699. }
  700. else if (echo_list.indexOf(chat_val.substring(6).replace(/^\s+|\s+$/g, ''))===-1) {
  701.  
  702. echo_list.push(chat_val.substring(6).replace(/^\s+|\s+$/g, ''));
  703. displayInChat(chat_val.substring(6).replace(/^\s+|\s+$/g, '') + " is being echoed.","#DA0808","#1EBCC1");
  704. return "";
  705. }
  706. else{
  707. displayInChat(chat_val.substring(6).replace(/^\s+|\s+$/g, '') + " is already being echoed.","#DA0808","#1EBCC1");
  708. return "";
  709. }
  710. }
  711. else if (chat_val.substring(1,8)=="remove " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  712. if (echo_list.indexOf(chat_val.substring(7).replace(/^\s+|\s+$/g, ''))!==-1){
  713. echo_list.splice(echo_list.indexOf(chat_val.substring(7).replace(/^\s+|\s+$/g, '')),1);
  714. displayInChat(chat_val.substring(7).replace(/^\s+|\s+$/g, '')+" is not being echoed.","#DA0808","#1EBCC1");
  715. return "";
  716. }
  717. else{
  718. displayInChat("You cannot remove someone that you didn't echo.","#DA0808","#1EBCC1");
  719. return "";
  720. }
  721.  
  722. }
  723. else if (chat_val.substring(1,10)=="clearecho"){
  724. echo_list = [];
  725. displayInChat("Cleared the echo list.","#DA0808","#1EBCC1");
  726. return "";
  727. }
  728. else if (chat_val.substring(1,6)=="space"){
  729. if(space_flag == true){
  730. displayInChat("Space is now off.","#DA0808","#1EBCC1");
  731. space_flag = false;
  732. }
  733. else{
  734. displayInChat("Space is now on.","#DA0808","#1EBCC1");
  735. space_flag = true;
  736. }
  737. return "";
  738. }
  739. else if (chat_val.substring(1,6)=="rcaps"){
  740. if(rcaps_flag == true){
  741. displayInChat("Rcaps is now off.","#DA0808","#1EBCC1");
  742. rcaps_flag = false;
  743. }
  744. else{
  745. displayInChat("Rcaps is now on.","#DA0808","#1EBCC1");
  746. rcaps_flag = true;
  747. }
  748.  
  749. return "";
  750. }
  751. else if (chat_val.substring(1,7)=="number"){
  752. if(number_flag == true){
  753. displayInChat("Number is now off.","#DA0808","#1EBCC1");
  754. number_flag = false;
  755. }
  756. else{
  757. displayInChat("Number is now on.","#DA0808","#1EBCC1");
  758. number_flag = true;
  759. }
  760.  
  761. return "";
  762. }
  763. else if (chat_val.substring(1,6)=="eval " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  764. var ev = "";
  765. try{
  766. ev = eval(chat_val.substring(6).replace(/^\s+|\s+$/g, ''));
  767. }
  768. catch(e){
  769. displayInChat(e.message,"#DA0808","#1EBCC1");
  770. }
  771. try{
  772. displayInChat(ev.toString(),"#DA0808","#1EBCC1");
  773. }
  774. catch{
  775. }
  776.  
  777. return "";
  778.  
  779. }
  780.  
  781. else if (chat_val.substring(1,9)=="hidechat"){
  782. Gdocument.getElementById("ingamechatcontent").style["max-height"]="0px";
  783. return "";
  784. }
  785. else if (chat_val.substring(1,9)=="showchat"){
  786. Gdocument.getElementById("ingamechatcontent").style["max-height"]="250px";
  787. return "";
  788. }
  789.  
  790. else if (chat_val.substring(1,7)=="scroll"){
  791. if(scroll==false){
  792. scroll = true;
  793. Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="scroll";
  794. Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
  795. }
  796. else if(scroll==true){
  797. scroll = false;
  798. Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="hidden";
  799. Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
  800. }
  801.  
  802. return "";
  803. }
  804.  
  805. else if (chat_val.substring(1,7)=="chatw "){
  806. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '');
  807.  
  808. if(username == text){
  809. displayInChat("You cannot private chat with yourself.","#DA0808","#1EBCC1");
  810. return "";
  811. }
  812. private_chat = text;
  813.  
  814. SEND("42"+JSON.stringify([4,{"type":"request public key","from":username,"to":private_chat}]));
  815. request_public_key_time_stamp = Date.now();
  816. 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);
  817. return "";
  818. }
  819.  
  820. else if (chat_val.substring(1,5)=="msg " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  821. if(private_chat_public_key[1][0] != 0 && private_chat_public_key[1][1] != 0 && private_chat_public_key[0] == private_chat){
  822. var text = chat_val.substring(5).replace(/^\s+|\s+$/g, '');
  823. var password = [];
  824. for(var i = 0;i<10;i++){
  825. password.push(Math.floor(Math.random()*100+50));
  826. }
  827. var text2 = [];
  828. for(var i = 0;i<text.slice(0,400).length ;i++){
  829. text2.push(password[i%password.length]^text.slice(0,400).charCodeAt(i));
  830. }
  831. pmlastmessage = text.slice(0,400);
  832. SEND("42"+JSON.stringify([4,{"type":"private chat","from":username,"to":private_chat,"public key":private_chat_public_key[1],"message":text2,"password":CRYPT_MESSAGE(private_chat_public_key[1],password)}]));
  833. displayInChat("> "+username+": "+text,"#DA0808","#1EBCC1");
  834.  
  835. }
  836. return "";
  837. }
  838. else if (chat_val.substring(1,10)=="ignorepm " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  839. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  840. if(ignorepmlist.includes(text)){
  841. var index = ignorepmlist.indexOf(text);
  842. ignorepmlist.splice(index,1);
  843. displayInChat("You are not ignoring private messages from "+text+".","#DA0808","#1EBCC1");
  844.  
  845. }
  846. else{
  847. ignorepmlist.push(text);
  848. displayInChat("You are now ignoring private messages from "+text+".","#DA0808","#1EBCC1");
  849. }
  850. return "";
  851. }
  852. else if (chat_val.substring(1,8)=="pmusers"){
  853. pmusers = [];
  854. SEND("42"+JSON.stringify([4,{"type":"request private chat users","from":username}]));
  855. pmuserstimestamp = Date.now();
  856. setTimeout(function(){if(pmusers.length == 0){displayInChat("You cannot private chat with anyone.","#DA0808","#1EBCC1");
  857. }else{displayInChat("You can private chat with:","#DA0808","#1EBCC1");for(var i = 0;i<pmusers.length;i++){var code = 'Gwindow.private_chat = "'+pmusers[i]+'"; Gwindow.SEND("42"+JSON.stringify([4,{"type":"request public key","from":Gwindow.username,"to":Gwindow.private_chat}])); Gwindow.request_public_key_time_stamp = Date.now(); setTimeout(function(){if(Gwindow.private_chat_public_key[0]!=Gwindow.private_chat){Gwindow.displayInChat("Failed to connect to "+Gwindow.private_chat+".","#DA0808","#1EBCC1");Gwindow.private_chat = Gwindow.private_chat_public_key[0];}},1600);';displayInChat('<a onclick = \''+code+'\' href = "javascript:void(0);" style = "color:green">'+pmusers[i]+'</a>',"#DA0808","#1EBCC1",{sanitize:false}); Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true; Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true; Laster_message = lastmessage(); }}},1600);
  858. return "";
  859. }
  860. else if (chat_val.substring(1,6)=="lobby"){
  861. lobby();
  862. return "";
  863. }
  864. else if (chat_val.substring(1,6)=="team " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  865. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  866. if(text == "r"){Gdocument.getElementById("newbonklobby_redbutton").click();}
  867. else if(text == "g"){Gdocument.getElementById("newbonklobby_greenbutton").click();}
  868. else if(text == "y"){Gdocument.getElementById("newbonklobby_yellowbutton").click();}
  869. else if(text == "b"){Gdocument.getElementById("newbonklobby_bluebutton").click();}
  870. else if(text == "s"){Gdocument.getElementById("newbonklobby_specbutton").click();}
  871. else if(text == "f"){Gdocument.getElementById("newbonklobby_ffabutton").click();}
  872. return "";
  873. }
  874. else if (chat_val.substring(1,7)=="notify"){
  875.  
  876. npermissions = 1;
  877. return "";
  878. }
  879. else if (chat_val.substring(1,11)=="stopnotify"){
  880.  
  881. npermissions = 0;
  882. return "";
  883. }
  884. else if (chat_val.substring(1,5)=="help" || chat_val.substring(1,2)=="?"){
  885. for(var i = 0;i<help.length;i++){
  886. displayInChat(help[i],"#DA0808","#1EBCC1");
  887.  
  888. }
  889. return "";
  890. }
  891. else if (chat_val.substring(1,9)=="advhelp " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  892. var text = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  893. if(typeof(adv_help[text])!='undefined'){
  894. displayInChat(adv_help[text],"#DA0808","#1EBCC1");
  895. }
  896. return "";
  897. }
  898. else if(ishost){
  899.  
  900. if (chat_val.substring(1,5)=="next" && stopquickplay == 0){
  901. if(shuffle){
  902. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  903. var available = [];
  904. var availableindexes = [];
  905. var notempty = false;
  906. for(var i = 0; i<e.length;i++){
  907. var a = false;
  908. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  909. available.push(a);
  910. if(a){
  911. availableindexes.push(i);
  912. notempty = true;
  913. }
  914. }
  915. if(notempty){
  916.  
  917. if(availableindexes.length!=1){
  918. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  919. }
  920. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  921. }
  922. }
  923. else{
  924. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  925. var available = [];
  926. var availableindexes = [];
  927. var notempty = false;
  928. for(var i = 0; i<e.length;i++){
  929. var a = false;
  930. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  931. available.push(a);
  932. if(a){
  933. availableindexes.push(i);
  934. notempty = true;
  935. }
  936. }
  937. if(notempty){
  938. var above = [];
  939. for(var i = 0;i<availableindexes.length;i++){
  940. if(availableindexes[i]>quicki){
  941. above.push(availableindexes[i]);
  942. }
  943. }
  944. if(above.length>0){
  945. quicki = above[0];
  946. }
  947. else{
  948. quicki = availableindexes[0];
  949. }
  950. }
  951. }
  952. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  953. displayInChat("Switched to next map.","#DA0808","#1EBCC1");
  954. return "";
  955.  
  956. }
  957. else if (chat_val.substring(1,9)=="freejoin"){
  958. if(freejoin == false){
  959. freejoin = true;
  960. displayInChat("Freejoin is now on.","#DA0808","#1EBCC1");
  961.  
  962. }
  963. else{
  964. freejoin = false;
  965. displayInChat("Freejoin is now off.","#DA0808","#1EBCC1");
  966. }
  967.  
  968. return "";
  969.  
  970. }
  971.  
  972. else if (chat_val.substring(1,9)=="previous" && stopquickplay == 0){
  973. if(shuffle){
  974. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  975. var available = [];
  976. var availableindexes = [];
  977. var notempty = false;
  978. for(var i = 0; i<e.length;i++){
  979. var a = false;
  980. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  981. available.push(a);
  982. if(a){
  983. availableindexes.push(i);
  984. notempty = true;
  985. }
  986. }
  987. if(notempty){
  988.  
  989. if(availableindexes.length!=1){
  990. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  991. }
  992. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  993. }
  994. }
  995. else{
  996. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  997. var available = [];
  998. var availableindexes = [];
  999. var notempty = false;
  1000. for(var i = 0; i<e.length;i++){
  1001. var a = false;
  1002. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  1003. available.push(a);
  1004. if(a){
  1005. availableindexes.push(i);
  1006. notempty = true;
  1007. }
  1008. }
  1009. if(notempty){
  1010. var above = [];
  1011. for(var i = 0;i<availableindexes.length;i++){
  1012. if(availableindexes[i]<quicki){
  1013. above.push(availableindexes[i]);
  1014. }
  1015. }
  1016. if(above.length>0){
  1017. quicki = above[above.length-1];
  1018. }
  1019. else{
  1020. quicki = availableindexes[availableindexes.length-1];
  1021. }
  1022. }
  1023. }
  1024. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  1025.  
  1026. displayInChat("Switched to previous map.","#DA0808","#1EBCC1");
  1027. return "";
  1028. }
  1029. else if (chat_val.substring(1,6)=="start" && chat_val.length == 6){
  1030. Gdocument.getElementById("newbonklobby_editorbutton").click();
  1031. if(recmodebool && ishost){
  1032. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  1033. if(mode == "" && defaultmode!="d"){
  1034. mode = defaultmode;
  1035. }
  1036. if(mode != ""){
  1037. RECIEVE('42[26,"b","'+mode+'"]');
  1038. }
  1039. }
  1040. Gdocument.getElementById("mapeditor_close").click();
  1041. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  1042. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  1043.  
  1044. return "";
  1045. }
  1046.  
  1047. else if (chat_val.substring(1,8)=="startqp" && stopquickplay == 1){
  1048. stopquickplay = 0;
  1049. quicki = 0;
  1050. displayInChat("Enabled quickplay.","#DA0808","#1EBCC1");
  1051. return "";
  1052. }
  1053. else if (chat_val.substring(1,7)=="stopqp" && stopquickplay == 0){
  1054. stopquickplay = 1;
  1055. quicki = 0;
  1056. displayInChat("Disabled quickplay.","#DA0808","#1EBCC1");
  1057. return "";
  1058. }
  1059.  
  1060. else if (chat_val.substring(1,5)=="ban " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  1061. banned.push(chat_val.substring(5).replace(/^\s+|\s+$/g, ''));
  1062. displayInChat("Banned "+chat_val.substring(5).replace(/^\s+|\s+$/g, '')+".","#DA0808","#1EBCC1");
  1063. return "/kick '" + chat_val.substring(5).replace(/^\s+|\s+$/g, '') + "'";
  1064. }
  1065. else if (chat_val.substring(1,6)=="kill " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  1066. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  1067. var keys = Object.keys(playerids);
  1068. var killid = undefined;
  1069. for(var i = 0; i<keys.length; i++){
  1070. if(playerids[keys[i]] == text){
  1071. killid = keys[i];
  1072. }
  1073. }
  1074. if(typeof(killid)!="undefined" && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  1075. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  1076. SEND('42[25,{"a":{"playersLeft":['+killid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  1077. RECIEVE('42[31,{"a":{"playersLeft":['+killid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  1078. }
  1079. return "";
  1080. }
  1081. else if (chat_val.substring(1,10)=="balanceA " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  1082. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  1083. if(!isNaN(parseInt(text))){
  1084. if(parseInt(text)>=-100 && parseInt(text)<=100){
  1085. var keys = Object.keys(playerids);
  1086. for(var i = 0; i<keys.length;i++){
  1087. SEND('42[29,{"sid":'+keys[i]+',"bal":'+text+'}]');
  1088. RECIEVE('42[36,'+keys[i]+','+text+']');
  1089. }
  1090. }
  1091. }
  1092. return "";
  1093.  
  1094. }
  1095. else if (chat_val.substring(1,7)=="moveA " && chat_val.replace(/^\s+|\s+$/g, '').length>=8){
  1096. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '');
  1097. var keys = Object.keys(playerids);
  1098. if(text == "f"){
  1099. for(var i = 0; i<keys.length;i++){
  1100. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":1}]')
  1101. }
  1102. }
  1103. else if(text == "b"){
  1104. for(var i = 0; i<keys.length;i++){
  1105. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":3}]')
  1106. }
  1107. }
  1108. else if(text == "g"){
  1109. for(var i = 0; i<keys.length;i++){
  1110. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":4}]')
  1111. }
  1112. }
  1113. else if(text == "r"){
  1114. for(var i = 0; i<keys.length;i++){
  1115. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":2}]')
  1116. }
  1117. }
  1118. else if(text == "y"){
  1119. for(var i = 0; i<keys.length;i++){
  1120. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":5}]')
  1121. }
  1122. }
  1123. else if(text == "s"){
  1124. for(var i = 0; i<keys.length;i++){
  1125. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":0}]')
  1126. }
  1127. }
  1128. return "";
  1129. }
  1130. else if (chat_val.substring(1,8)=="rounds " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  1131. var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '');
  1132. if(!isNaN(parseInt(text))){
  1133. text = parseInt(text).toString();
  1134. SEND('42[21,{"w":'+text+'}]');
  1135. RECIEVE('42[27,'+text+']');
  1136. }
  1137. return "";
  1138.  
  1139. }
  1140. else if (chat_val.substring(1,6)=="mode " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  1141. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  1142. var mode = "";
  1143. if(text == "arrows"){
  1144. mode = "ar";
  1145. displayInChat("Changed mode to arrows.","#DA0808","#1EBCC1");
  1146. }
  1147. else if(text == "death arrows"){
  1148. mode = "ard";
  1149. displayInChat("Changed mode to death arrows.","#DA0808","#1EBCC1");
  1150. }
  1151. else if(text == "grapple"){
  1152. mode = "sp";
  1153. displayInChat("Changed mode to grapple.","#DA0808","#1EBCC1");
  1154. }
  1155. else if(text == "classic"){
  1156. mode = "b";
  1157. displayInChat("Changed mode to classic.","#DA0808","#1EBCC1");
  1158.  
  1159. }
  1160. else{
  1161. displayInChat("Mode options:","#DA0808","#1EBCC1");
  1162. displayInChat("classic","#DA0808","#1EBCC1");
  1163. displayInChat("arrows","#DA0808","#1EBCC1");
  1164. displayInChat("death arrows","#DA0808","#1EBCC1");
  1165. displayInChat("grapple","#DA0808","#1EBCC1");
  1166. }
  1167. if(mode != ""){
  1168. SEND('42[20,{"ga":"b","mo":"'+mode+'"}]');
  1169. RECIEVE('42[26,"b","'+mode+'"]');
  1170. }
  1171. return "";
  1172.  
  1173. }
  1174. else if (chat_val.substring(1,13)=="defaultmode " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  1175. var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '');
  1176. if(text == "default"){
  1177. defaultmode = "";
  1178. displayInChat("Changed default mode to default.","#DA0808","#1EBCC1");
  1179. }
  1180. else if(text == "arrows"){
  1181. defaultmode = "ar";
  1182. displayInChat("Changed default mode to arrows.","#DA0808","#1EBCC1");
  1183. }
  1184. else if(text == "death arrows"){
  1185. defaultmode = "ard";
  1186. displayInChat("Changed default mode to death arrows.","#DA0808","#1EBCC1");
  1187. }
  1188. else if(text == "grapple"){
  1189. defaultmode = "sp";
  1190. displayInChat("Changed default mode to grapple.","#DA0808","#1EBCC1");
  1191. }
  1192. else if(text == "classic"){
  1193. defaultmode = "b";
  1194. displayInChat("Changed default mode to classic.","#DA0808","#1EBCC1");
  1195.  
  1196. }
  1197. else{
  1198. displayInChat("Default mode options:","#DA0808","#1EBCC1");
  1199. displayInChat("default","#DA0808","#1EBCC1");
  1200. displayInChat("classic","#DA0808","#1EBCC1");
  1201. displayInChat("arrows","#DA0808","#1EBCC1");
  1202. displayInChat("death arrows","#DA0808","#1EBCC1");
  1203. displayInChat("grapple","#DA0808","#1EBCC1");
  1204. }
  1205. return "";
  1206.  
  1207. }
  1208. else if (chat_val.substring(1,8)=="recmode"){
  1209. if(recmodebool == true){
  1210. recmodebool = false;
  1211. displayInChat("Recmode is now off.","#DA0808","#1EBCC1");
  1212.  
  1213. }
  1214. else{
  1215. recmodebool = true;
  1216. displayInChat("Recmode is now on.","#DA0808","#1EBCC1");
  1217.  
  1218. }
  1219.  
  1220. return "";
  1221.  
  1222. }
  1223. else if (chat_val.substring(1,8)=="shuffle"){
  1224. if(shuffle == true){
  1225. shuffle = false;
  1226. displayInChat("Shuffle is now off.","#DA0808","#1EBCC1");
  1227.  
  1228. }
  1229. else{
  1230. shuffle = true;
  1231. displayInChat("Shuffle is now on.","#DA0808","#1EBCC1");
  1232.  
  1233. }
  1234.  
  1235. return "";
  1236.  
  1237. }
  1238. else if(sandboxon){
  1239. if (chat_val.substring(1,11)=="addplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  1240. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  1241. if(!isNaN(parseInt(text))){
  1242. var text2 = parseInt(text);
  1243. if(text2>0){
  1244. for(var i = 0;i<text2;i++){
  1245. RECIEVE('42[4,'+sandboxid+',"0123456789abcdef","'+sandboxid.toString()+'",true,0,1,{"layers":[],"bc":'+Math.floor(Math.random() * 16777215).toString()+'}]');
  1246. sandboxplayerids[sandboxid] = sandboxid.toString();
  1247. sandboxid+=1;
  1248. }
  1249.  
  1250. }
  1251. }
  1252. return "";
  1253.  
  1254. }
  1255. else if (chat_val.substring(1,11)=="delplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  1256. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  1257. if(!isNaN(parseInt(text))){
  1258. var text2 = parseInt(text);
  1259. if(text2>0){
  1260. if(Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden"){
  1261. var jsonkeys = Object.keys(sandboxplayerids).reverse();
  1262. for(var i = 0;i<text2 && i<jsonkeys.length;i++){
  1263. RECIEVE('42[5,'+jsonkeys[i]+',0]');
  1264. delete sandboxplayerids[jsonkeys[i]];
  1265. }
  1266. }
  1267. else{
  1268. displayInChat("Cannot delete players while ingame.","#DA0808","#1EBCC1");
  1269. }
  1270.  
  1271. }
  1272. }
  1273. return "";
  1274. }
  1275. else if (chat_val.substring(1,7)=="copyme"){
  1276. if(sandboxcopyme == true){
  1277. displayInChat("Copyme is now off.","#DA0808","#1EBCC1");
  1278. sandboxcopyme = false;
  1279. }
  1280. else{
  1281. displayInChat("Copyme is now on.","#DA0808","#1EBCC1");
  1282. sandboxcopyme = true;
  1283. }
  1284.  
  1285. return "";
  1286. }
  1287. }
  1288. }
  1289. return chat_val;
  1290. };
  1291.  
  1292. scope.flag_manage = function(t){
  1293. var text = t;
  1294.  
  1295. if(rcaps_flag == true){
  1296. text = text.split('');
  1297. for(var i = 0; i<text.length;i++){
  1298. if(Math.floor(Math.random()*2)){
  1299. text[i] = text[i].toUpperCase();
  1300. }
  1301. else{
  1302. text[i] = text[i].toLowerCase();
  1303. }
  1304. }
  1305. text = text.join('');
  1306. }
  1307. if(space_flag == true){
  1308. text = text.split('').join(' ')
  1309. }
  1310. if(number_flag == true){
  1311. text = text.replace(/[t|T][Oo]+/g,"2");
  1312. text = text.replace(/[f|F][o|O][r|R]/g,"4");
  1313. text = text.replace(/[a|A][t|T][e|E]/g,"8");
  1314. text = text.replace(/[e|E]/g,"3");
  1315. text = text.replace(/[a|A]/g,"4");
  1316. text = text.replace(/[o|O]/g,"0");
  1317. text = text.replace(/[s|S]/g,"5");
  1318. text = text.replace(/[i|I|l|L]/g,"1");
  1319. }
  1320. return text;
  1321. };
  1322. Gdocument.getElementById("newbonklobby_chat_input").onkeydown = function(e){
  1323. if(e.keyCode==13){
  1324.  
  1325. var chat_val = Gdocument.getElementById("newbonklobby_chat_input").value;
  1326.  
  1327. if (chat_val!="" && chat_val[0]=="/"){
  1328.  
  1329. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  1330. chat(commandhandle(chat_val));
  1331. }
  1332. else{
  1333. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  1334. chat(flag_manage(chat_val));
  1335. }
  1336.  
  1337. }
  1338. };
  1339. Gdocument.getElementById("ingamechatinputtext").onkeydown = function(e){
  1340. if(e.keyCode==13){
  1341.  
  1342. var chat_val = Gdocument.getElementById("ingamechatinputtext").value;
  1343.  
  1344. if (chat_val!="" && chat_val[0]=="/"){
  1345.  
  1346. Gdocument.getElementById("ingamechatinputtext").value = "";
  1347. chat(commandhandle(chat_val));
  1348. }
  1349. else{
  1350. Gdocument.getElementById("ingamechatinputtext").value = "";
  1351. chat(flag_manage(chat_val));
  1352. }
  1353. }
  1354. };
  1355. scope.Last_message = "";
  1356. scope.Laster_message = "";
  1357. scope.new_message = false;
  1358. scope.changed_chat = false;
  1359. scope.interval = setInterval(timeout123,100);
  1360.  
  1361. scope.hotkeys = function(e){
  1362. if(e.repeat){return;}
  1363. var keycode = e.which || e.keyCode;
  1364. if(e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  1365. if(ishost){
  1366. if(keycode == 69){
  1367. if(Gdocument.getElementById("newbonklobby").style["display"] == "block"){
  1368. Gdocument.getElementById("newbonklobby_editorbutton").click();
  1369. }
  1370. else if(Gdocument.getElementById("mapeditorcontainer").style["display"] == "block"){
  1371. Gdocument.getElementById("mapeditor_close").click();
  1372. }
  1373. e.preventDefault();
  1374.  
  1375. }
  1376. else if(keycode == 84){
  1377. Gdocument.getElementById("newbonklobby_teamsbutton").click();
  1378. e.preventDefault();
  1379. }
  1380. else if(keycode == 77){
  1381. Gdocument.getElementById("newbonklobby_modebutton").click();
  1382. e.preventDefault();
  1383. }
  1384. else if(keycode == 75){
  1385. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  1386. Gdocument.getElementById("pretty_top_exit").click();
  1387. }
  1388. e.preventDefault();
  1389. }
  1390. else if(keycode == 83){
  1391. Gdocument.getElementById("newbonklobby_editorbutton").click();
  1392. if(recmodebool && ishost){
  1393. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  1394. if(mode == "" && defaultmode!="d"){
  1395. mode = defaultmode;
  1396. }
  1397. if(mode != ""){
  1398. RECIEVE('42[26,"b","'+mode+'"]');
  1399. }
  1400. }
  1401. Gdocument.getElementById("mapeditor_close").click();
  1402. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  1403. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  1404. e.preventDefault();
  1405. }
  1406. else if(keycode == 68){
  1407. if(stopquickplay == 0){
  1408. if(shuffle){
  1409. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  1410. var available = [];
  1411. var availableindexes = [];
  1412. var notempty = false;
  1413. for(var i = 0; i<e2.length;i++){
  1414. var a = false;
  1415. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  1416. available.push(a);
  1417. if(a){
  1418. availableindexes.push(i);
  1419. notempty = true;
  1420. }
  1421. }
  1422. if(notempty){
  1423.  
  1424. if(availableindexes.length!=1){
  1425. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  1426. }
  1427. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  1428. }
  1429. }
  1430. else{
  1431. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  1432. var available = [];
  1433. var availableindexes = [];
  1434. var notempty = false;
  1435. for(var i = 0; i<e2.length;i++){
  1436. var a = false;
  1437. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  1438. available.push(a);
  1439. if(a){
  1440. availableindexes.push(i);
  1441. notempty = true;
  1442. }
  1443. }
  1444. if(notempty){
  1445. var above = [];
  1446. for(var i = 0;i<availableindexes.length;i++){
  1447. if(availableindexes[i]>quicki){
  1448. above.push(availableindexes[i]);
  1449. }
  1450. }
  1451. if(above.length>0){
  1452. quicki = above[0];
  1453. }
  1454. else{
  1455. quicki = availableindexes[0];
  1456. }
  1457. }
  1458. }
  1459. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  1460. }
  1461. e.preventDefault();
  1462. }
  1463. else if(keycode == 65){
  1464. if(stopquickplay == 0){
  1465. if(shuffle){
  1466. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  1467. var available = [];
  1468. var availableindexes = [];
  1469. var notempty = false;
  1470. for(var i = 0; i<e2.length;i++){
  1471. var a = false;
  1472. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  1473. available.push(a);
  1474. if(a){
  1475. availableindexes.push(i);
  1476. notempty = true;
  1477. }
  1478. }
  1479. if(notempty){
  1480.  
  1481. if(availableindexes.length!=1){
  1482. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  1483. }
  1484. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  1485. }
  1486. }
  1487. else{
  1488. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  1489. var available = [];
  1490. var availableindexes = [];
  1491. var notempty = false;
  1492. for(var i = 0; i<e2.length;i++){
  1493. var a = false;
  1494. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  1495. available.push(a);
  1496. if(a){
  1497. availableindexes.push(i);
  1498. notempty = true;
  1499. }
  1500. }
  1501. if(notempty){
  1502. var above = [];
  1503. for(var i = 0;i<availableindexes.length;i++){
  1504. if(availableindexes[i]<quicki){
  1505. above.push(availableindexes[i]);
  1506. }
  1507. }
  1508. if(above.length>0){
  1509. quicki = above[above.length-1];
  1510. }
  1511. else{
  1512. quicki = availableindexes[availableindexes.length-1];
  1513. }
  1514. }
  1515. }
  1516. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  1517. }
  1518. e.preventDefault();
  1519. }
  1520. else if(keycode == 81){
  1521. if(stopquickplay == 1){
  1522. stopquickplay = 0;
  1523. quicki = 0;
  1524. displayInChat("Enabled quickplay.","#DA0808","#1EBCC1");
  1525. }
  1526. else{
  1527. stopquickplay = 1;
  1528. quicki = 0;
  1529. displayInChat("Disabled quickplay.","#DA0808","#1EBCC1");
  1530. }
  1531. e.preventDefault();
  1532. }
  1533. else if(keycode == 82){
  1534. if(recmodebool == true){
  1535. recmodebool = false;
  1536. displayInChat("Recmode is now off.","#DA0808","#1EBCC1");
  1537.  
  1538. }
  1539. else{
  1540. recmodebool = true;
  1541. displayInChat("Recmode is now on.","#DA0808","#1EBCC1");
  1542.  
  1543. }
  1544. }
  1545. else if(keycode == 70){
  1546. if(freejoin == false){
  1547. freejoin = true;
  1548. displayInChat("Freejoin is now on.","#DA0808","#1EBCC1");
  1549.  
  1550. }
  1551. else{
  1552. freejoin = false;
  1553. displayInChat("Freejoin is now off.","#DA0808","#1EBCC1");
  1554. }
  1555. e.preventDefault();
  1556. }
  1557. }
  1558. else{
  1559. if(keycode == 69){
  1560. e.preventDefault();
  1561. }
  1562. else if(keycode == 84){
  1563. e.preventDefault();
  1564. }
  1565. else if(keycode == 77){
  1566. e.preventDefault();
  1567. }
  1568. else if(keycode == 75){
  1569. e.preventDefault();
  1570. }
  1571. else if(keycode == 83){
  1572. e.preventDefault();
  1573. }
  1574. else if(keycode == 68){
  1575. e.preventDefault();
  1576. }
  1577. else if(keycode == 65){
  1578. e.preventDefault();
  1579. }
  1580. else if(keycode == 81){
  1581. e.preventDefault();
  1582. }
  1583. else if(keycode == 70){
  1584. e.preventDefault();
  1585. }
  1586. else if(keycode == 82){
  1587. e.preventDefault();
  1588. }
  1589.  
  1590. }
  1591. if(keycode == 76){
  1592. lobby();
  1593. e.preventDefault();
  1594. }
  1595. if(keycode == 67){
  1596. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  1597. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]=="0px"){
  1598. Gdocument.getElementById("ingamechatcontent").style["max-height"]="250px";
  1599. }
  1600. else{
  1601. Gdocument.getElementById("ingamechatcontent").style["max-height"]="0px";
  1602. }
  1603. }
  1604. e.preventDefault();
  1605. }
  1606. }
  1607. };
  1608.  
  1609. Gdocument.onkeydown = hotkeys;
  1610.  
  1611. function timeout123() {
  1612. if(Gdocument.getElementById("gamerenderer").style["visibility"]=="hidden"){
  1613. Gdocument.getElementById("ingamechatcontent").style["max-height"]="250px";
  1614. }
  1615. if(Gdocument.getElementById("sm_connectingContainer").style["visibility"] == "hidden"){
  1616. var chatbox = Gdocument.getElementById("newbonklobby_chat_content");
  1617. while (chatbox.firstChild) {
  1618. chatbox.removeChild(chatbox.firstChild);
  1619. }
  1620. rcaps_flag = false;
  1621. space_flag = false;
  1622. number_flag = false;
  1623. echo_list = [];
  1624. scroll = false;
  1625. stopquickplay = 1;
  1626. checkboxhidden = false;
  1627. freejoin = false;
  1628. shuffle = false;
  1629. defaultmode = "";
  1630. recmodebool = false;
  1631. playerids = {};
  1632. pingids = {};
  1633. ishost = false;
  1634. sandboxplayerids = {};
  1635. sandboxcopyme = false;
  1636. sandboxon = false;
  1637. sandboxid = 1;
  1638. if(chatlog[chatlog.length-1]!="ROOM END"){
  1639. chatlog.push("ROOM END");
  1640. }
  1641. }
  1642. else{
  1643. if(chatlog[chatlog.length-1]=="ROOM END"){
  1644. chatlog.push("ROOM START");
  1645. }
  1646. var pingidkey = Object.keys(pingids);
  1647. var playeridkey = Object.keys(playerids);
  1648. for(var i = 0; i<pingidkey.length;i++){
  1649. if(!playeridkey.includes(pingidkey[i])){
  1650. var pingtext = Gdocument.getElementsByClassName("newbonklobby_playerentry_pingtext");
  1651. var found = [];
  1652. if(Gdocument.getElementById("newbonklobby").style["display"] != "block"){
  1653. mess2 = Gdocument.getElementById("ingamechatinputtext").value;
  1654. Gdocument.getElementById("ingamechatinputtext").value = "";
  1655. Gdocument.getElementById("newbonklobby_editorbutton").click();
  1656. Gdocument.getElementById("mapeditor_close").click();
  1657. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  1658. Gdocument.getElementById("ingamechatinputtext").value = mess2;
  1659.  
  1660. }
  1661. for(var e=0; e<pingtext.length;e++){
  1662. if(pingtext[e].textContent == pingids[pingidkey[i]].toString()+"ms"){
  1663. found.push(pingtext[e].parentElement);
  1664. }
  1665. }
  1666. if(found.length == 1){
  1667. playerids[pingidkey[i]] = found[0].children[1].textContent;
  1668. break;
  1669. }
  1670. }
  1671. }
  1672. pingids = {};
  1673. }
  1674.  
  1675. if(Gdocument.getElementById("newbonklobby").style["display"]=="block"){
  1676. Gdocument.getElementById("ingamechatinputtext").style["visibility"]="hidden";
  1677. }
  1678. else{
  1679. Gdocument.getElementById("ingamechatinputtext").style["visibility"]="visible";
  1680.  
  1681. }
  1682. mode = Gdocument.getElementById("newbonklobby_modetext").textContent;
  1683. var userlist = Gdocument.getElementsByClassName("newbonklobby_playerentry_name");
  1684. users = [];
  1685. for(var i = 0;i<userlist.length;i++){
  1686. users.push(userlist[i].textContent);
  1687. }
  1688. if(Gdocument.getElementsByClassName('newbonklobby_settings_button brownButton brownButton_classic buttonShadow brownButtonDisabled').length == 0){
  1689. ishost = true;
  1690. }
  1691. else{
  1692. ishost = false;
  1693. }
  1694.  
  1695. if(Gdocument.getElementById("pretty_top_name")!=null){
  1696. username = Gdocument.getElementById("pretty_top_name").textContent;
  1697. }
  1698. try{
  1699. Last_message = lastmessage()
  1700. } catch{
  1701. Last_message = "";
  1702. }
  1703. if (Laster_message != Last_message){
  1704. Laster_message = Last_message;
  1705. if(changed_chat==false){
  1706. new_message = true;
  1707. }
  1708. else{
  1709. changed_chat = false;
  1710. }
  1711. }
  1712. if(new_message){
  1713. chatlog.push(Last_message);
  1714. if(freejoin && Last_message.startsWith("* ") && Last_message.endsWith(" has joined the game") && ishost){
  1715.  
  1716. var userjoined = Last_message.substring(2,Last_message.length-20);
  1717.  
  1718. if(Gdocument.getElementById("newbonklobby").style["display"] != "block"){
  1719. mess2 = Gdocument.getElementById("ingamechatinputtext").value;
  1720. Gdocument.getElementById("ingamechatinputtext").value = "";
  1721. Gdocument.getElementById("newbonklobby_editorbutton").click();
  1722. Gdocument.getElementById("mapeditor_close").click();
  1723. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  1724. Gdocument.getElementById("ingamechatinputtext").value = mess2;
  1725.  
  1726. }
  1727. var playing = Gdocument.getElementsByClassName("newbonklobby_playerentry newbonklobby_playerentry_half");
  1728. var inplaying = false;
  1729. for(var i = 0;i<playing.length;i++){
  1730. if(userjoined == playing[i].children[1].textContent){
  1731. inplaying = true;
  1732. break;
  1733. }
  1734. }
  1735.  
  1736. if(playing.length<=2 && inplaying){
  1737. Gdocument.getElementById("newbonklobby_editorbutton").click();
  1738. Gdocument.getElementById("mapeditor_close").click();
  1739. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  1740. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  1741. if(transitioning == true){
  1742. canceled = true;
  1743. }
  1744. }
  1745.  
  1746. }
  1747. var lm = "";
  1748. try{
  1749. lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  1750. if(typeof(lm[0].parentElement.style["parsed"]) == 'undefined'){
  1751. if (lm[0].className == "newbonklobby_chat_msg_colorbox"){
  1752. lm[2].innerHTML = urlify(lm[2].innerHTML);
  1753. Laster_message = lastmessage();
  1754. lm[0].parentElement.style["parsed"] = true;
  1755. }
  1756. if (lm[0].className == "newbonklobby_chat_status"){
  1757. lm[0].innerHTML = urlify(lm[0].innerHTML);
  1758. Laster_message = lastmessage();
  1759. lm[0].parentElement.style["parsed"] = true;
  1760. }
  1761. }
  1762. }
  1763. catch{
  1764. lm = "";
  1765. }
  1766.  
  1767. if(Last_message.indexOf("@"+username)!=-1 && npermissions == 1){
  1768. var n = new Notification(Last_message);
  1769. }
  1770.  
  1771. try{
  1772. lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  1773. if(typeof(lm[0].parentElement.style["parsed"])=='undefined'){
  1774. if(lm[0].className == "ingamechatname"){
  1775. lm[1].innerHTML = urlify(lm[1].innerHTML);
  1776. Laster_message = lastmessage();
  1777. lm[0].parentElement.style["parsed"] = true;
  1778. }
  1779. if(lm[0].className == ""){
  1780. lm[0].innerHTML = urlify(lm[0].innerHTML);
  1781. Laster_message = lastmessage();
  1782. lm[0].parentElement.style["parsed"] = true;
  1783. }
  1784. }
  1785. }
  1786. catch{
  1787. lm = "";
  1788. }
  1789. for(i=0;i<echo_list.length;i++){
  1790. if(Last_message.substring(0,echo_list[i].length+2) == echo_list[i]+": "){
  1791. message = Last_message.substring(echo_list[i].length+2);
  1792. chat(flag_manage(message));
  1793. }
  1794. }
  1795.  
  1796. }
  1797. if (ishost==true && new_message){
  1798. for(i=0;i<banned.length;i++){
  1799. if(Last_message.startsWith("* "+banned[i]+" has joined the game")){
  1800. chat("/kick '"+banned[i]+"'");
  1801. }
  1802. }
  1803. }
  1804. if(ishost && stopquickplay == 0){
  1805. if(checkboxhidden){
  1806. checkboxhidden = false;
  1807. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  1808. for(var i = 0; i<classes.length;i++){
  1809. classes[i].style["display"] = "block";
  1810. classes[i].className = "quickplaycheckbox quickplaychecked";
  1811. }
  1812. Gdocument.getElementById('clearallcheckboxes').style["display"] = "block";
  1813.  
  1814. }
  1815. if(Gdocument.getElementById("ingamewinner").style["visibility"]=="inherit" && stopquickplay == 0 && dontswitch == false){
  1816. if(shuffle){
  1817. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  1818. var available = [];
  1819. var availableindexes = [];
  1820. var notempty = false;
  1821. for(var i = 0; i<e.length;i++){
  1822. var a = false;
  1823. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  1824. available.push(a);
  1825. if(a){
  1826. availableindexes.push(i);
  1827. notempty = true;
  1828. }
  1829. }
  1830. if(notempty){
  1831.  
  1832. if(availableindexes.length!=1){
  1833. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  1834. }
  1835. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  1836. }
  1837. }
  1838. else{
  1839. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  1840. var available = [];
  1841. var availableindexes = [];
  1842. var notempty = false;
  1843. for(var i = 0; i<e.length;i++){
  1844. var a = false;
  1845. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  1846. available.push(a);
  1847. if(a){
  1848. availableindexes.push(i);
  1849. notempty = true;
  1850. }
  1851. }
  1852. if(notempty){
  1853. var above = [];
  1854. for(var i = 0;i<availableindexes.length;i++){
  1855. if(availableindexes[i]>quicki){
  1856. above.push(availableindexes[i]);
  1857. }
  1858. }
  1859. if(above.length>0){
  1860. quicki = above[0];
  1861. }
  1862. else{
  1863. quicki = availableindexes[0];
  1864. }
  1865. }
  1866. }
  1867. transitioning = true;
  1868. map(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  1869.  
  1870. dontswitch = true;
  1871. setTimeout(function(){Gdocument.getElementById("ingamewinner").style["visibility"]="hidden"; dontswitch = false;},timedelay);
  1872.  
  1873. }
  1874. }
  1875. else{
  1876. if(!checkboxhidden){
  1877. checkboxhidden = true;
  1878. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  1879. for(var i = 0; i<classes.length;i++){
  1880. classes[i].style["display"] = "none";
  1881. classes[i].className = "quickplaycheckbox quickplayunchecked";
  1882. }
  1883. Gdocument.getElementById('clearallcheckboxes').style["display"] = "none";
  1884. }
  1885. }
  1886. new_message = false;
  1887. };
  1888. });