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