Bonk Commands

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

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

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