Bonk Commands

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

当前为 2022-11-28 提交的版本,查看 最新版本

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