Bonk Commands

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

当前为 2022-10-09 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Bonk Commands
  3. // @namespace https://greasyfork.org/en/scripts/451341-bonk-commands
  4. // @version 4.9
  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.  
  13. function BonkCommandsScriptInjector(f){
  14. if(document.readyState == "complete"){f();}
  15. else{document.addEventListener('readystatechange',function(){setTimeout(f,1500);});}
  16. }
  17.  
  18. BonkCommandsScriptInjector(function(){
  19. var scope = window;
  20.  
  21. scope.Gwindow = document.getElementById("maingameframe").contentWindow;
  22. scope.Gdocument = document.getElementById("maingameframe").contentDocument;
  23.  
  24. scope.link2pastebin = "https://pastebin.com/2b8XqqYu";
  25. scope.link2greasyfork = "https://greasyfork.org/en/scripts/451341-bonk-commands";
  26.  
  27. if(typeof(scope.injectedBonkCommandsScript)=='undefined'){
  28. scope.injectedBonkCommandsScript = true;
  29. }
  30. else{
  31. for (var i = 0; i < 100000; i++){
  32. clearInterval(i);
  33. }
  34. }
  35. scope.GENERATE_PRIME_NUMBER = function(mini = 0,maxi = 0,choices = []){
  36. if(choices.length == 0){
  37. for(var i = mini;i<maxi+1;i++){
  38. choices.push(i);
  39. }
  40. }
  41. firstTry = choices[Math.floor(Math.random()*choices.length)];
  42. for(var i = 2; i<Math.floor(Math.sqrt(firstTry)+1);i++){
  43. if(i!=firstTry){
  44. if(firstTry%i == 0){
  45. choices.splice(choices.indexOf(firstTry),1);
  46. if(choices.length == 0){
  47. return 0;
  48. }
  49. return GENERATE_PRIME_NUMBER(mini,maxi,choices);
  50. }
  51. }
  52. }
  53. return firstTry;
  54. };
  55.  
  56. scope.GENERATE_KEYS = function(){
  57. interval = [];
  58. for(var i = 100;i<301;i++){
  59. interval.push(i);
  60. }
  61. random_prime = [GENERATE_PRIME_NUMBER(0,0,choices = interval),0];
  62. interval.splice(interval.indexOf(random_prime[0]),1);
  63. random_prime[1] = GENERATE_PRIME_NUMBER(0,0,choices = interval);
  64.  
  65. n = random_prime[0]*random_prime[1];
  66. n2 = (random_prime[0]-1)*(random_prime[1]-1);
  67.  
  68. e = GENERATE_PRIME_NUMBER(2,n2-1);
  69. d = 0;
  70. redo = true;
  71. for(var i = 0;i<1000000;i++){
  72. if((e*i-1)%n2 == 0 && i!=e){
  73. d = i;
  74. redo = false;
  75. break;
  76. }
  77. }
  78. if(redo){
  79. return GENERATE_KEYS();
  80. }
  81. else{
  82. return [[n,e],[n,d]];
  83. }
  84.  
  85. };
  86. scope.CRYPT_NUMBER = function(key, data){
  87.  
  88. result = 1;
  89.  
  90. for(var i = 0;i<key[1];i++){
  91. result*=data;
  92. result = result%key[0];
  93. }
  94. return result%key[0];
  95.  
  96. };
  97.  
  98. scope.CRYPT_MESSAGE = function(key,data){
  99. var resulttext = [];
  100. for(var i = 0;i<data.length;i++){
  101. resulttext.push(CRYPT_NUMBER(key,data[i]));
  102. }
  103. return resulttext;
  104.  
  105. };
  106.  
  107. if(typeof(scope.originalSend)=='undefined'){scope.originalSend = Gwindow.WebSocket.prototype.send;}
  108. if(typeof(scope.bonkwss)=='undefined'){scope.bonkwss = 0;}
  109. if(typeof(scope.sandboxon)=='undefined'){scope.sandboxon = false;}
  110. if(typeof(scope.sandboxid)=='undefined'){scope.sandboxid = 1;}
  111. if(typeof(scope.playerids)=='undefined'){scope.playerids = {};}
  112. if(typeof(scope.pingids)=='undefined'){scope.pingids = {};}
  113. if(typeof(scope.sandboxplayerids)=='undefined'){scope.sandboxplayerids = {};}
  114. if(typeof(scope.originalLobbyChat)=='undefined'){scope.originalLobbyChat = Gdocument.getElementById("newbonklobby_chat_content").appendChild;}
  115. if(typeof(scope.originalIngameChat)=='undefined'){scope.originalIngameChat = Gdocument.getElementById("ingamechatcontent").appendChild;}
  116. 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];}
  117. function sandboxonclick(){
  118. Gdocument.getElementById("roomlistcreatewindowmaxplayers").value = 1;
  119. Gdocument.getElementById("roomlistcreatewindowunlistedcheckbox").checked = true;
  120. Gdocument.getElementById("roomlistcreatecreatebutton").click();
  121. sandboxon = true;
  122. }
  123. if(Gdocument.getElementById("classic_mid_sandbox")==null){
  124. Gdocument.getElementById("roomlistrefreshbutton").click();
  125. scope.sandboxbutton = Gdocument.createElement("div");
  126. sandboxbutton.id = "classic_mid_sandbox";
  127. sandboxbutton.classList.value = "brownButton brownButton_classic classic_mid_buttons";
  128. sandboxbutton.textContent = "SANDBOX";
  129. sandboxbutton.addEventListener("click",sandboxonclick);
  130. Gdocument.getElementById("classic_mid").insertBefore(sandboxbutton,Gdocument.getElementById("classic_mid_news"));
  131.  
  132. }
  133. Gdocument.getElementById("newbonklobby_chat_content").appendChild = function(args){
  134. if(beenKickedTimeStamp+100>Date.now() && args.children.length>0){
  135. if(args.children[0].textContent.endsWith(" has left the game ") && args.children[0].textContent.startsWith("* ")){
  136. args.children[0].textContent = args.children[0].textContent.substring(0,args.children[0].textContent.length-19)+" has been kicked from the game ";
  137. }
  138. }
  139. originalLobbyChat.call(this,args);
  140. };
  141. Gdocument.getElementById("ingamechatcontent").appendChild = function(args){
  142. if(beenKickedTimeStamp+100>Date.now() && args.children.length>0){
  143. if(args.children[0].textContent.endsWith(" has left the game.") && args.children[0].textContent.startsWith("* ")){
  144. args.children[0].textContent = args.children[0].textContent.substring(0,args.children[0].textContent.length-19)+" has been kicked from the game.";
  145. }
  146. }
  147. originalIngameChat.call(this,args);
  148. };
  149. Gwindow.WebSocket.prototype.send = function(args) {
  150. if(this.url.includes(".bonk.io/socket.io/?EIO=3&transport=websocket&sid=")){
  151. bonkwss = this;
  152. if(args.startsWith('42[26,')){
  153. if(sandboxon){
  154. var jsonargs = JSON.parse(args.substring(2))[1];
  155. if(typeof(sandboxplayerids[jsonargs["targetID"]])!='undefined'){
  156. RECIEVE('42[18,'+jsonargs["targetID"]+','+jsonargs["targetTeam"]+']');
  157.  
  158. }
  159. }
  160. }
  161. if(args.startsWith('42[4,')){
  162. var jsonargs = JSON.parse(args.substring(2));
  163. if(sandboxcopyme && typeof(jsonargs[1]["type"])=="undefined"){
  164. var jsonkeys = Object.keys(sandboxplayerids);
  165. for(var i = 0; i<jsonkeys.length;i++){
  166. RECIEVE('42[7,'+jsonkeys[i].toString()+','+JSON.stringify(jsonargs[1])+']');
  167. }
  168. }
  169. args = "42"+JSON.stringify(jsonargs);
  170. }
  171.  
  172. if(args.startsWith('42[5,')){
  173. var jsonargs = JSON.parse(args.substring(2));
  174.  
  175. if(stopquickplay!=1){
  176. jsonargs[1]["gs"]["wl"] = 999;
  177. }
  178. if(recmodebool){
  179. Gdocument.getElementById("newbonklobby_editorbutton").click();
  180. var newmode = Gdocument.getElementById("mapeditor_modeselect").value;
  181. Gdocument.getElementById("mapeditor_close").click();
  182.  
  183. if(newmode!=""){
  184. RECIEVE('42[26,"b","'+newmode+'"]');
  185. }
  186. else{
  187. if(defaultmode != ""){
  188. RECIEVE('42[26,"b","'+defaultmode+'"]');
  189. }
  190. }
  191. }
  192. args = "42"+JSON.stringify(jsonargs);
  193. }
  194.  
  195. }
  196. if(this.url.includes(".bonk.io/socket.io/?EIO=3&transport=websocket&sid=") && !this.injected){
  197. this.injected = true;
  198.  
  199. var originalRecieve = this.onmessage;
  200. this.onmessage = function(args){
  201. if(args.data.startsWith('42[24,')){
  202. beenKickedTimeStamp = Date.now();
  203. }
  204. if(args.data.startsWith('42[1,')){
  205. var jsonargs = JSON.parse(args.data.substring(2));
  206. SEND('42[1,{"id":'+jsonargs[2]+'}]');
  207. pingids = jsonargs[1];
  208. }
  209. if(args.data.startsWith('42[7,')){
  210. var jsonargs = JSON.parse(args.data.substring(2));
  211. idofpacket = jsonargs[1];
  212. jsonargs = jsonargs[2];
  213. if(typeof(jsonargs["type"]) != "undefined"){
  214. if(jsonargs["type"]=="private chat" && jsonargs["to"] == username){
  215. from = jsonargs["from"];
  216. if(Object.keys(playerids).includes(idofpacket.toString())){
  217. from = playerids[idofpacket];
  218. }
  219. if(!ignorepmlist.includes(from)){
  220. if(typeof(jsonargs["message"])=="object" && typeof(jsonargs["password"]) == "object"){
  221. if(public_key[0]==jsonargs["public key"][0] && public_key[1]==jsonargs["public key"][1]){
  222. var password = CRYPT_MESSAGE(private_key,jsonargs["password"]);
  223. var decodedtext = jsonargs["message"].slice(0,400);
  224. var encodedtext = "";
  225. for(var i=0;i<decodedtext.length;i++){
  226. if(password[i%password.length]<1000){
  227. encodedtext+=String.fromCharCode(password[i%password.length]^decodedtext[i]);
  228. }
  229. }
  230.  
  231. displayInChat("> "+from+": "+encodedtext,"#DA0808","#1EBCC1");
  232. }
  233. else{
  234. SEND("42"+JSON.stringify([4,{"type":"public key correction","from":username,"to":private_chat_public_key[0],"public key":public_key}]));
  235. }
  236. }
  237. }
  238. }
  239. if(jsonargs["type"]=="request public key" && jsonargs["to"] == username){
  240. SEND("42"+JSON.stringify([4,{"type":"public key","from":username,"public key":public_key}]));
  241. }
  242. if(jsonargs["type"]=="private chat users" && pmuserstimestamp+1500>Date.now()){
  243. if(typeof(jsonargs["from"])!='undefined'){
  244. from = jsonargs["from"];
  245. if(Object.keys(playerids).includes(idofpacket.toString())){
  246. from = playerids[idofpacket];
  247. }
  248. if(!pmusers.includes(from) && username == jsonargs["to"]){
  249. pmusers.push(from);
  250. }
  251. }
  252. }
  253. if(jsonargs["type"]=="request private chat users"){
  254. if(typeof(jsonargs["from"])!='undefined'){
  255. from = jsonargs["from"];
  256. if(Object.keys(playerids).includes(idofpacket.toString())){
  257. from = playerids[idofpacket];
  258. }
  259. SEND("42"+JSON.stringify([4,{"type":"private chat users","from":username,"to":from}]));
  260. }
  261. }
  262. if(jsonargs["type"]=="public key" && request_public_key_time_stamp+1500>Date.now()){
  263. from = jsonargs["from"];
  264. if(Object.keys(playerids).includes(idofpacket.toString())){
  265. from = playerids[idofpacket];
  266. }
  267. if(from == private_chat){
  268. private_chat_public_key = [private_chat,jsonargs["public key"]];
  269. displayInChat("Private chatting with "+private_chat+".","#DA0808","#1EBCC1");
  270. }
  271.  
  272. }
  273. if(jsonargs["type"]=="public key correction" && private_chat_public_key[0] == private_chat){
  274. from = jsonargs["from"];
  275. if(Object.keys(playerids).includes(idofpacket.toString())){
  276. from = playerids[idofpacket];
  277. }
  278. if(from == private_chat){
  279. private_chat_public_key = [private_chat,jsonargs["public key"]];
  280. var text = pmlastmessage;
  281. var password = [];
  282. for(var i = 0;i<10;i++){
  283. password.push(Math.floor(Math.random()*100+50));
  284. }
  285. var text2 = [];
  286. for(var i = 0;i<text.length ;i++){
  287. text2.push(password[i%password.length]^text.slice(0,400).charCodeAt(i));
  288. }
  289. 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)}]));
  290. }
  291. }
  292.  
  293. }
  294. }
  295.  
  296. if(args.data.startsWith('42[4,')){
  297. var jsonargs = JSON.parse(args.data.substring(2));
  298. playerids[jsonargs[1]] = jsonargs[3];
  299.  
  300. }
  301. if(args.data.startsWith('42[5,')){
  302. var jsonargs = JSON.parse(args.data.substring(2));
  303. if(typeof(playerids[jsonargs[1]])!='undefined'){
  304. delete playerids[jsonargs[1]];
  305. }
  306. }
  307. return originalRecieve.call(this,args);
  308. };
  309.  
  310. var originalClose = this.onclose;
  311. this.onclose = function () {
  312. window.bonkwss = 0;
  313. return originalClose.call(this);
  314. }
  315.  
  316. }
  317. return originalSend.call(this,args);
  318. };
  319.  
  320. scope.SEND = function(args){
  321. if(bonkwss!=0){
  322. bonkwss.send(args);
  323. }
  324. };
  325. scope.RECIEVE = function(args){
  326. if(bonkwss!=0){
  327. bonkwss.onmessage({data:args});
  328. }
  329. };
  330. Gdocument.getElementById("ingamechatcontent").style["pointer-events"]="all";
  331. Gdocument.getElementById("ingamechatcontent").style["max-height"]="250px";
  332. Gdocument.getElementById("ingamechatcontent").style["height"]="128px";
  333. Gdocument.getElementById("ingamechatbox").style["height"]="250px";
  334.  
  335. document.getElementById('adboxverticalCurse').style["display"] = "none";
  336. document.getElementById('adboxverticalleftCurse').style["display"] = "none";
  337.  
  338.  
  339. scope.dontswitch = false;
  340. scope.username = 0;
  341. scope.timedelay = 1400;
  342. scope.ishost = false;
  343. scope.quicki=0;
  344. scope.defaultmode = "d";
  345. scope.recmodebool = false;
  346. scope.freejoin = false;
  347. scope.beenKickedTimeStamp = 0;
  348. scope.stopquickplay = 1;
  349. scope.canceled = false;
  350. scope.banned = [];
  351. scope.transitioning = false;
  352. scope.echo_list = [];
  353. scope.message = "";
  354. scope.mode = "";
  355. scope.private_chat = "";
  356. scope.private_chat_public_key = ["",[0,0]];
  357. scope.users = [];
  358. scope.pmusers = [];
  359. scope.pmlastmessage = "";
  360. scope.pmuserstimestamp = 0;
  361. scope.ignorepmlist = [];
  362. scope.scroll = false;
  363. scope.elem = Gdocument.getElementById("maploadwindowmapscontainer");
  364. scope.npermissions = 1;
  365. scope.space_flag = false;
  366. scope.rcaps_flag = false;
  367. scope.number_flag = false;
  368. scope.request_public_key_time_stamp = 0;
  369. scope.sandboxcopyme = false;
  370. scope.help = ["All the commands are:","/help","/?","/advhelp [command]","/space","/rcaps","/number","/echo [username]","/remove [username]","/clearecho","/chatw [username]","/msg [text]","/ignorepm [username]","/pmusers","/requestfake \"[mapname]\", \"[mapauthor]\"","/eval [code]","/lobby","/team [letter]","/scroll","/hidechat","/showchat","/notify","/stopnotify","Host commands are:","/startqp","/stopqp","/next","/previous","/freejoin","/start","/balanceA [number]","/rounds [number]","/ban [username]","Sandbox commands are:","/addplayer [number]","/delplayer [number]","/copyme"];
  371.  
  372. scope.adv_help = {"help":"Shows all command names.",
  373. "?":"Shows all command names.",
  374. "advhelp":"Shows a command in detail.",
  375. "space":"Toggles space. When space is on, whatever you type will be spaced apart.",
  376. "rcaps":"Toggles rcaps. When rcaps is on, each letter will randomly get capitalized.",
  377. "number":"Toggles number. When number is on, 'a' becomes 4, 'e' becomes 3, 's' becomes 5, 'o' becomes 0, 'l' and 'i' become 1.",
  378. "echo":"Echoes a username. It copies the username's chat messages.",
  379. "remove":"Removes username from echo list. You will not echo that username anymore.",
  380. "clearecho":"Clears echo list. You will not echo anyone anymore.",
  381. "chatw":"It private chats with username. Type /msg to message that username.",
  382. "msg":"Messages with what username you are chatting with. Type /chatw to chat with a username.",
  383. "ignorepm":"Ignores the username's private chat messages. To unignore, type /ignorepm [username].",
  384. "pmusers":"Dispays who you can private chat with.",
  385. "requestfake":"Requests a fake map. The host will not see the request.",
  386. "eval":"Evaluates code. Only use this if you are experienced in javascript.",
  387. "lobby":"Makes lobby visible when you are ingame. Type /lobby again to close lobby.",
  388. "team":"Joins a specific team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  389. "scroll":"Toggles a scrollbar in ingame chat.",
  390. "hidechat":"Hides ingame chat. Type /showchat to show it again.",
  391. "showchat":"Shows ingame chat. /hidechat hides the chat.",
  392. "notify":"You will be notified if a person types @MYUSERNAME",
  393. "stopnotify":"You will not be notified if a person types @MYUSERNAME",
  394. "startqp":"Starts cycling maps in your map menu.",
  395. "stopqp":"Stops cycling maps in your map menu.",
  396. "next":"Skips the map. Usable only with /startqp.",
  397. "previous":"Goes to previous map. Usable only with /startqp.",
  398. "freejoin":"Toggles freejoin. If freejoin is on, starts the game instantly if there are 1 or less players currently playing",
  399. "start":"Starts game instantly.",
  400. "balanceA":"Balances everyone with balance number.",
  401. "rounds":"Sets rounds to win.",
  402. "ban":"Bans username from lobby. If they rejoin, it automatically bans.",
  403. "addplayer":"In sandbox, it adds players.",
  404. "delplayer":"In sandbox, it deletes players.",
  405. "copyme":"In sandbox, it makes each player copy your movements."};
  406.  
  407. elem.onclick=function(e){
  408. if(stopquickplay==0 && ishost == true && e.isTrusted == true){
  409. quicki = (Array.from(e.target.parentElement.parentNode.children).indexOf(e.target.parentNode)-1)%(Gdocument.getElementById("maploadwindowmapscontainer").children.length);
  410. }
  411. };
  412. scope.urlify = function(text) {
  413. return text.replace(/(?:https?:\/\/)?(?:[A-Za-z0-9-ßàÁâãóôþüúðæåïçèõöÿýòäœêëìíøùîûñé]+)(?:\.[A-Za-z0-9-ßàÁâãóôþüúðæåïçèõöÿýòäœêëìíøùîûñé]+)+(?:\/(?:[A-Za-z0-9-._~:/?#\[\]@!$&'()*+,;=]|%[0-9a-fA-F]{2})*)?(?:\?(?:[^=]+=[^&](?:&[^=]+=[^&])*)?)?/g, function(url) {
  414. return '<a href="' + url + '" target="_blank" style = "color:orange">' + url + '</a>';
  415. })
  416. };
  417.  
  418. scope.fire = function(type,options,d = Gdocument){
  419. var event=new CustomEvent(type);
  420. for(var p in options){
  421. event[p]=options[p];
  422. }
  423. d.dispatchEvent(event);
  424. };
  425.  
  426. scope.chat = function(message){
  427. mess = Gdocument.getElementById("newbonklobby_chat_input").value;
  428. mess2 = Gdocument.getElementById("ingamechatinputtext").value;
  429. Gdocument.getElementById("newbonklobby_chat_input").value = message;
  430. Gdocument.getElementById("ingamechatinputtext").value = message;
  431. fire("keydown",{keyCode:13});
  432. fire("keydown",{keyCode:13});
  433. Gdocument.getElementById("newbonklobby_chat_input").value = mess;
  434. Gdocument.getElementById("ingamechatinputtext").value = mess2;
  435. };
  436. scope.displayInChat = function(message, LobbyColor, InGameColor, options) {
  437. options = options ?? {};
  438. LobbyColor = LobbyColor ?? "#8800FF";
  439. InGameColor = InGameColor ?? "#AA88FF";
  440. let A = Gdocument.createElement("div");
  441. let B = Gdocument.createElement("span");
  442. B.className = "newbonklobby_chat_status";
  443. B.style.color = LobbyColor;
  444. A.appendChild(B);
  445. B.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  446. let C = Gdocument.createElement("div");
  447. let D = Gdocument.createElement("span");
  448. D.style.color = InGameColor;
  449. C.appendChild(D);
  450. D.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  451. let a = false;
  452. if(Gdocument.getElementById("newbonklobby_chat_content").scrollHeight - Gdocument.getElementById("newbonklobby_chat_content").scrollTop > Gdocument.getElementById("newbonklobby_chat_content").clientHeight - 1) {
  453. a = true;
  454. }
  455. Gdocument.getElementById("newbonklobby_chat_content").appendChild(A);
  456. Gdocument.getElementById("ingamechatcontent").appendChild(C);
  457. if (a) { Gdocument.getElementById("newbonklobby_chat_content").scrollTop = Number.MAX_SAFE_INTEGER;};
  458. Gdocument.getElementById("ingamechatcontent").scrollTop = Number.MAX_SAFE_INTEGER;
  459. };
  460.  
  461. scope.lobby = function(){
  462. if (Gdocument.getElementById("newbonklobby").style["display"]=="none"){
  463.  
  464. Gdocument.getElementById("newbonklobby_editorbutton").click();
  465. Gdocument.getElementById("mapeditor_close").click();
  466. if(Gdocument.getElementsByClassName("newbonklobby_playerentry").length>0){
  467. Gdocument.getElementById("newbonklobby").style["z-index"]=1;
  468. Gdocument.getElementById("maploadwindowcontainer").style["z-index"]=1;
  469. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=1;
  470. Gdocument.getElementById("pretty_top").style["z-index"]=2;
  471. Gdocument.getElementById("settingsContainer").style["z-index"]=2;
  472. Gdocument.getElementById("leaveconfirmwindow").style["z-index"]=2;
  473. Gdocument.getElementById("hostleaveconfirmwindow").style["z-index"]=2;
  474. }
  475. else{
  476. Gdocument.getElementById("newbonklobby").style["opacity"]=0;
  477. Gdocument.getElementById("newbonklobby").style["display"]="none";
  478. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
  479. }
  480.  
  481. }
  482. else if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  483. Gdocument.getElementById("newbonklobby").style["opacity"]=0;
  484. Gdocument.getElementById("newbonklobby").style["display"]="none";
  485. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
  486. }
  487. };
  488.  
  489. scope.lastmessage = function(){
  490. if(Gdocument.getElementById("newbonklobby_chat_content").children.length!=0){
  491. var lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  492. var lm2 = "";
  493. for(var i = 0; i<lm.length;i++){
  494. lm2+=" "+lm[i].textContent.trim();
  495. }
  496. lm2 = lm2.trim();
  497. if(lm2.startsWith("*")){
  498. return lm2;
  499. }
  500. }
  501. if(Gdocument.getElementById("ingamechatcontent").children.length!=0){
  502. var lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  503. var lm2 = "";
  504. for(var i = 0; i<lm.length;i++){
  505. lm2+=" "+lm[i].textContent.trim();
  506. }
  507. return lm2.trim();
  508. }
  509. return "";
  510.  
  511. };
  512. scope.map = function(e){
  513. if(e<0){
  514. displayInChat("There is no previous map.","#DA0808","#1EBCC1");
  515. quicki = 0;
  516. return;
  517. }
  518. if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
  519. displayInChat("Click the maps button.","#DA0808","#1EBCC1");
  520. return;
  521. }
  522.  
  523. setTimeout(function(){if(!canceled){
  524. Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
  525. Gdocument.getElementById("newbonklobby_editorbutton").click();
  526. Gdocument.getElementById("mapeditor_close").click();
  527. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  528. Gdocument.getElementById("mapeditor_midbox_testbutton").click();}
  529. canceled = false;
  530. transitioning = false;
  531. },timedelay);
  532.  
  533. };
  534.  
  535. scope.gotonextmap = function(e){
  536. if(e<0){
  537. displayInChat("There is no previous map.","#DA0808","#1EBCC1");
  538. quicki = 0;
  539. return;
  540. }
  541. if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
  542. displayInChat("Click the maps button.","#DA0808","#1EBCC1");
  543. return;
  544. }
  545. Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
  546. Gdocument.getElementById("newbonklobby_editorbutton").click();
  547. Gdocument.getElementById("mapeditor_close").click();
  548. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  549. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  550. Gdocument.getElementById("newbonklobby").style["visibility"] = "visible";
  551. };
  552. scope.commandhandle = function(chat_val){
  553. if (chat_val.substring(1,6)=="echo " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  554. if (chat_val.substring(6).replace(/^\s+|\s+$/g, '')==username){
  555. displayInChat("You cannot echo yourself.","#DA0808","#1EBCC1");
  556. return "";
  557. }
  558. else if (echo_list.indexOf(chat_val.substring(6).replace(/^\s+|\s+$/g, ''))===-1) {
  559.  
  560. echo_list.push(chat_val.substring(6).replace(/^\s+|\s+$/g, ''));
  561. displayInChat(chat_val.substring(6).replace(/^\s+|\s+$/g, '') + " is being echoed.","#DA0808","#1EBCC1");
  562. return "";
  563. }
  564. else{
  565. displayInChat(chat_val.substring(6).replace(/^\s+|\s+$/g, '') + " is already being echoed.","#DA0808","#1EBCC1");
  566. return "";
  567. }
  568. }
  569. else if (chat_val.substring(1,8)=="remove " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  570. if (echo_list.indexOf(chat_val.substring(7).replace(/^\s+|\s+$/g, ''))!==-1){
  571. echo_list.splice(echo_list.indexOf(chat_val.substring(7).replace(/^\s+|\s+$/g, '')),1);
  572. displayInChat(chat_val.substring(7).replace(/^\s+|\s+$/g, '')+" is not being echoed.","#DA0808","#1EBCC1");
  573. return "";
  574. }
  575. else{
  576. displayInChat("You cannot remove someone that you didn't echo.","#DA0808","#1EBCC1");
  577. return "";
  578. }
  579.  
  580. }
  581. else if (chat_val.substring(1,10)=="clearecho"){
  582. echo_list = [];
  583. displayInChat("Cleared the echo list.","#DA0808","#1EBCC1");
  584. return "";
  585. }
  586. else if (chat_val.substring(1,6)=="space"){
  587. if(space_flag == true){
  588. displayInChat("Space is now off.","#DA0808","#1EBCC1");
  589. space_flag = false;
  590. }
  591. else{
  592. displayInChat("Space is now on.","#DA0808","#1EBCC1");
  593. space_flag = true;
  594. }
  595. return "";
  596. }
  597. else if (chat_val.substring(1,6)=="rcaps"){
  598. if(rcaps_flag == true){
  599. displayInChat("Rcaps is now off.","#DA0808","#1EBCC1");
  600. rcaps_flag = false;
  601. }
  602. else{
  603. displayInChat("Rcaps is now on.","#DA0808","#1EBCC1");
  604. rcaps_flag = true;
  605. }
  606.  
  607. return "";
  608. }
  609. else if (chat_val.substring(1,7)=="number"){
  610. if(number_flag == true){
  611. displayInChat("Number is now off.","#DA0808","#1EBCC1");
  612. number_flag = false;
  613. }
  614. else{
  615. displayInChat("Number is now on.","#DA0808","#1EBCC1");
  616. number_flag = true;
  617. }
  618.  
  619. return "";
  620. }
  621. else if (chat_val.substring(1,12)=="requestfake" && chat_val.replace(/^\s+|\s+$/g, '').length>=13){
  622. var mess = chat_val.substring(13).replace(/^\s+|\s+$/g, '');
  623. var result;
  624. var key;
  625. try{
  626. result = JSON.parse("{"+mess.replaceAll(",",":")+"}");
  627. if(Object.keys(result).length!=1){
  628. throw "";
  629. }
  630. else{
  631. key = Object.keys(result)[0];
  632. }
  633. SEND('42'+JSON.stringify([27,{"m":"","mapname":key.replaceAll(":",","),"mapauthor":result[key].replaceAll(":",",")}]));
  634. return "";
  635. }
  636. catch{
  637. displayInChat('Format: /requestfake "mapname", "mapauthor"',"#DA0808","#1EBCC1");
  638. return "";
  639. }
  640. return "";
  641.  
  642. }
  643. else if (chat_val.substring(1,6)=="eval " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  644. var ev = "";
  645. try{
  646. ev = eval(chat_val.substring(6).replace(/^\s+|\s+$/g, ''));
  647. }
  648. catch(e){
  649. displayInChat(e.message,"#DA0808","#1EBCC1");
  650. }
  651. try{
  652. displayInChat(ev.toString(),"#DA0808","#1EBCC1");
  653. }
  654. catch{
  655. }
  656.  
  657. return "";
  658.  
  659. }
  660.  
  661. else if (chat_val.substring(1,9)=="hidechat"){
  662. Gdocument.getElementById("ingamechatcontent").style["max-height"]="0px";
  663. return "";
  664. }
  665. else if (chat_val.substring(1,9)=="showchat"){
  666. Gdocument.getElementById("ingamechatcontent").style["max-height"]="250px";
  667. return "";
  668. }
  669.  
  670. else if (chat_val.substring(1,7)=="scroll"){
  671. if(scroll==false){
  672. scroll = true;
  673. Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="scroll";
  674. Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
  675. }
  676. else if(scroll==true){
  677. scroll = false;
  678. Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="hidden";
  679. Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
  680. }
  681.  
  682. return "";
  683. }
  684.  
  685. else if (chat_val.substring(1,7)=="chatw "){
  686. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '');
  687.  
  688. if(username == text){
  689. displayInChat("You cannot private chat with yourself.","#DA0808","#1EBCC1");
  690. return "";
  691. }
  692. private_chat = text;
  693.  
  694. SEND("42"+JSON.stringify([4,{"type":"request public key","from":username,"to":private_chat}]));
  695. request_public_key_time_stamp = Date.now();
  696. 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);
  697. return "";
  698. }
  699.  
  700. else if (chat_val.substring(1,5)=="msg " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  701. if(private_chat_public_key[1][0] != 0 && private_chat_public_key[1][1] != 0 && private_chat_public_key[0] == private_chat){
  702. var text = chat_val.substring(5).replace(/^\s+|\s+$/g, '');
  703. var password = [];
  704. for(var i = 0;i<10;i++){
  705. password.push(Math.floor(Math.random()*100+50));
  706. }
  707. var text2 = [];
  708. for(var i = 0;i<text.slice(0,400).length ;i++){
  709. text2.push(password[i%password.length]^text.slice(0,400).charCodeAt(i));
  710. }
  711. pmlastmessage = text.slice(0,400);
  712. 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)}]));
  713. displayInChat("> "+username+": "+text,"#DA0808","#1EBCC1");
  714.  
  715. }
  716. return "";
  717. }
  718. else if (chat_val.substring(1,10)=="ignorepm " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  719. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  720. if(ignorepmlist.includes(text)){
  721. var index = ignorepmlist.indexOf(text);
  722. ignorepmlist.splice(index,1);
  723. displayInChat("You are not ignoring private messages from "+text+".","#DA0808","#1EBCC1");
  724.  
  725. }
  726. else{
  727. ignorepmlist.push(text);
  728. displayInChat("You are now ignoring private messages from "+text+".","#DA0808","#1EBCC1");
  729. }
  730. return "";
  731. }
  732. else if (chat_val.substring(1,8)=="pmusers"){
  733. pmusers = [];
  734. SEND("42"+JSON.stringify([4,{"type":"request private chat users","from":username}]));
  735. pmuserstimestamp = Date.now();
  736. setTimeout(function(){if(pmusers.length == 0){displayInChat("You cannot private chat with anyone.","#DA0808","#1EBCC1");
  737. }else{displayInChat("You can private chat with:","#DA0808","#1EBCC1");for(var i = 0;i<pmusers.length;i++){displayInChat("> "+pmusers[i],"#DA0808","#1EBCC1")}}},1600);
  738. return "";
  739. }
  740. else if (chat_val.substring(1,6)=="lobby"){
  741. lobby();
  742. return "";
  743. }
  744. else if (chat_val.substring(1,6)=="team " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  745. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  746. if(text == "r"){Gdocument.getElementById("newbonklobby_redbutton").click();}
  747. else if(text == "g"){Gdocument.getElementById("newbonklobby_greenbutton").click();}
  748. else if(text == "y"){Gdocument.getElementById("newbonklobby_yellowbutton").click();}
  749. else if(text == "b"){Gdocument.getElementById("newbonklobby_bluebutton").click();}
  750. else if(text == "s"){Gdocument.getElementById("newbonklobby_specbutton").click();}
  751. else if(text == "f"){Gdocument.getElementById("newbonklobby_ffabutton").click();}
  752. return "";
  753. }
  754. else if (chat_val.substring(1,7)=="notify"){
  755.  
  756. npermissions = 1;
  757. return "";
  758. }
  759. else if (chat_val.substring(1,11)=="stopnotify"){
  760.  
  761. npermissions = 0;
  762. return "";
  763. }
  764. else if (chat_val.substring(1,5)=="help" || chat_val.substring(1,2)=="?"){
  765. for(var i = 0;i<help.length;i++){
  766. displayInChat(help[i],"#DA0808","#1EBCC1");
  767.  
  768. }
  769. return "";
  770. }
  771. else if (chat_val.substring(1,9)=="advhelp " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  772. var text = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  773. if(typeof(adv_help[text])!='undefined'){
  774. displayInChat(adv_help[text],"#DA0808","#1EBCC1");
  775. }
  776. return "";
  777. }
  778. else if(ishost){
  779.  
  780. if (chat_val.substring(1,5)=="next" && stopquickplay == 0){
  781. quicki++;
  782. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  783. displayInChat("Switched to next map.","#DA0808","#1EBCC1");
  784. return "";
  785.  
  786. }
  787. else if (chat_val.substring(1,9)=="freejoin"){
  788. if(freejoin == false){
  789. freejoin = true;
  790. displayInChat("Freejoin is now on.","#DA0808","#1EBCC1");
  791.  
  792. }
  793. else{
  794. freejoin = false;
  795. displayInChat("Freejoin is now off.","#DA0808","#1EBCC1");
  796. }
  797.  
  798. return "";
  799.  
  800. }
  801.  
  802. else if (chat_val.substring(1,9)=="previous" && stopquickplay == 0){
  803. quicki--;
  804. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  805.  
  806. displayInChat("Switched to previous map.","#DA0808","#1EBCC1");
  807. return "";
  808. }
  809. else if (chat_val.substring(1,6)=="start" && chat_val.length == 6){
  810. Gdocument.getElementById("newbonklobby_editorbutton").click();
  811. Gdocument.getElementById("mapeditor_close").click();
  812. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  813. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  814.  
  815. return "";
  816. }
  817.  
  818. else if (chat_val.substring(1,8)=="startqp" && stopquickplay == 1){
  819. stopquickplay = 0;
  820. quicki = 0;
  821. displayInChat("Enabled quickplay.","#DA0808","#1EBCC1");
  822. return "";
  823. }
  824. else if (chat_val.substring(1,7)=="stopqp" && stopquickplay == 0){
  825. stopquickplay = 1;
  826. quicki = 0;
  827. displayInChat("Disabled quickplay.","#DA0808","#1EBCC1");
  828. return "";
  829. }
  830.  
  831. else if (chat_val.substring(1,5)=="ban " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  832. banned.push(chat_val.substring(5).replace(/^\s+|\s+$/g, ''));
  833. displayInChat("Banned "+chat_val.substring(5).replace(/^\s+|\s+$/g, '')+".","#DA0808","#1EBCC1");
  834. return "/kick '" + chat_val.substring(5).replace(/^\s+|\s+$/g, '') + "'";
  835. }
  836. else if (chat_val.substring(1,10)=="balanceA " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  837. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  838. if(!isNaN(parseInt(text))){
  839. if(Gdocument.getElementById("newbonklobby").style["display"] != "block"){
  840. mess2 = Gdocument.getElementById("ingamechatinputtext").value;
  841. Gdocument.getElementById("ingamechatinputtext").value = "";
  842. Gdocument.getElementById("newbonklobby_editorbutton").click();
  843. Gdocument.getElementById("mapeditor_close").click();
  844. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  845. Gdocument.getElementById("ingamechatinputtext").value = mess2;
  846.  
  847. }
  848. var playing = Gdocument.getElementsByClassName("newbonklobby_playerentry");
  849. for(var i = 0; i<playing.length;i++){
  850. chat("/balance \""+playing[i].children[1].textContent+"\" "+text)
  851. }
  852. }
  853. return "";
  854.  
  855. }
  856. else if (chat_val.substring(1,8)=="rounds " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  857. var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '');
  858. if(!isNaN(parseInt(text))){
  859. text = parseInt(text).toString();
  860. SEND('42[21,{"w":'+text+'}]');
  861. RECIEVE('42[27,'+text+']');
  862. }
  863. return "";
  864.  
  865. }
  866. else if (chat_val.substring(1,13)=="defaultmode " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  867. var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '');
  868. if(text == "default"){
  869. defaultmode = "";
  870. displayInChat("Changed default mode to default.","#DA0808","#1EBCC1");
  871. }
  872. else if(text == "arrows"){
  873. defaultmode = "ar";
  874. displayInChat("Changed default mode to arrows.","#DA0808","#1EBCC1");
  875. }
  876. else if(text == "death arrows"){
  877. defaultmode = "ard";
  878. displayInChat("Changed default mode to death arrows.","#DA0808","#1EBCC1");
  879. }
  880. else if(text == "grapple"){
  881. defaultmode = "sp";
  882. displayInChat("Changed default mode to grapple.","#DA0808","#1EBCC1");
  883. }
  884. else if(text == "classic"){
  885. defaultmode = "b";
  886. displayInChat("Changed default mode to classic.","#DA0808","#1EBCC1");
  887.  
  888. }
  889. else{
  890. displayInChat("Default mode options:","#DA0808","#1EBCC1");
  891. displayInChat("default","#DA0808","#1EBCC1");
  892. displayInChat("classic","#DA0808","#1EBCC1");
  893. displayInChat("arrows","#DA0808","#1EBCC1");
  894. displayInChat("death arrows","#DA0808","#1EBCC1");
  895. displayInChat("grapple","#DA0808","#1EBCC1");
  896. }
  897. return "";
  898.  
  899. }
  900. else if (chat_val.substring(1,8)=="recmode"){
  901. if(recmodebool == true){
  902. recmodebool = false;
  903. displayInChat("Recmode is now off.","#DA0808","#1EBCC1");
  904.  
  905. }
  906. else{
  907. recmodebool = true;
  908. displayInChat("Recmode is now on.","#DA0808","#1EBCC1");
  909.  
  910. }
  911.  
  912. return "";
  913.  
  914. }
  915. else if(sandboxon){
  916. if (chat_val.substring(1,11)=="addplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  917. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  918. if(!isNaN(parseInt(text))){
  919. var text2 = parseInt(text);
  920. if(text2>0){
  921. for(var i = 0;i<text2;i++){
  922. RECIEVE('42[4,'+sandboxid+',"0123456789abcdef","'+sandboxid.toString()+'",true,0,1,{"layers":[],"bc":'+Math.floor(Math.random() * 16777215).toString()+'}]');
  923. sandboxplayerids[sandboxid] = sandboxid.toString();
  924. sandboxid+=1;
  925. }
  926.  
  927. }
  928. }
  929. return "";
  930.  
  931. }
  932. else if (chat_val.substring(1,11)=="delplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  933. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  934. if(!isNaN(parseInt(text))){
  935. var text2 = parseInt(text);
  936. if(text2>0){
  937. if(Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden"){
  938. var jsonkeys = Object.keys(sandboxplayerids).reverse();
  939. for(var i = 0;i<text2 && i<jsonkeys.length;i++){
  940. RECIEVE('42[5,'+jsonkeys[i]+',0]');
  941. delete sandboxplayerids[jsonkeys[i]];
  942. }
  943. }
  944. else{
  945. displayInChat("Cannot delete players while ingame.","#DA0808","#1EBCC1");
  946. }
  947.  
  948. }
  949. }
  950. return "";
  951. }
  952. else if (chat_val.substring(1,7)=="copyme"){
  953. if(sandboxcopyme == true){
  954. displayInChat("Copyme is now off.","#DA0808","#1EBCC1");
  955. sandboxcopyme = false;
  956. }
  957. else{
  958. displayInChat("Copyme is now on.","#DA0808","#1EBCC1");
  959. sandboxcopyme = true;
  960. }
  961.  
  962. return "";
  963. }
  964. }
  965. }
  966. return chat_val;
  967. };
  968.  
  969. scope.flag_manage = function(t){
  970. var text = t;
  971.  
  972. if(rcaps_flag == true){
  973. text = text.split('');
  974. for(var i = 0; i<text.length;i++){
  975. if(Math.floor(Math.random()*2)){
  976. text[i] = text[i].toUpperCase();
  977. }
  978. else{
  979. text[i] = text[i].toLowerCase();
  980. }
  981. }
  982. text = text.join('');
  983. }
  984. if(space_flag == true){
  985. text = text.split('').join(' ')
  986. }
  987. if(number_flag == true){
  988. text = text.replace(/[t|T][Oo]+/g,"2");
  989. text = text.replace(/[f|F][o|O][r|R]/g,"4");
  990. text = text.replace(/[a|A][t|T][e|E]/g,"8");
  991. text = text.replace(/[e|E]/g,"3");
  992. text = text.replace(/[a|A]/g,"4");
  993. text = text.replace(/[o|O]/g,"0");
  994. text = text.replace(/[s|S]/g,"5");
  995. text = text.replace(/[i|I|l|L]/g,"1");
  996. }
  997. return text;
  998. };
  999. Gdocument.getElementById("newbonklobby_chat_input").onkeydown = function(e){
  1000. if(e.keyCode==13){
  1001.  
  1002. var chat_val = Gdocument.getElementById("newbonklobby_chat_input").value;
  1003.  
  1004. if (chat_val!="" && chat_val[0]=="/"){
  1005.  
  1006. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  1007. chat(commandhandle(chat_val));
  1008. }
  1009. else{
  1010. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  1011. chat(flag_manage(chat_val));
  1012. }
  1013. chat_val = Gdocument.getElementById("ingamechatinputtext").value;
  1014. if (chat_val!="" && chat_val[0]=="/"){
  1015.  
  1016. Gdocument.getElementById("ingamechatinputtext").value = "";
  1017. chat(commandhandle(chat_val));
  1018. }
  1019. else{
  1020. Gdocument.getElementById("ingamechatinputtext").value = "";
  1021. chat(flag_manage(chat_val));
  1022. }
  1023.  
  1024. }
  1025. };
  1026. Gdocument.getElementById("ingamechatinputtext").onkeydown = function(e){
  1027. if(e.keyCode==13){
  1028.  
  1029. var chat_val = Gdocument.getElementById("newbonklobby_chat_input").value;
  1030. if (chat_val!="" && chat_val[0]=="/"){
  1031.  
  1032. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  1033. chat(commandhandle(chat_val));
  1034. }
  1035. else{
  1036. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  1037. chat(flag_manage(chat_val));
  1038. }
  1039. chat_val = Gdocument.getElementById("ingamechatinputtext").value;
  1040.  
  1041. if (chat_val!="" && chat_val[0]=="/"){
  1042.  
  1043. Gdocument.getElementById("ingamechatinputtext").value = "";
  1044. chat(commandhandle(chat_val));
  1045. }
  1046. else{
  1047. Gdocument.getElementById("ingamechatinputtext").value = "";
  1048. chat(flag_manage(chat_val));
  1049. }
  1050. }
  1051. };
  1052. scope.Last_message = "";
  1053. scope.Laster_message = "";
  1054. scope.new_message = false;
  1055. scope.changed_chat = false;
  1056. scope.interval = setInterval(timeout123,100);
  1057. function timeout123() {
  1058. if(Gdocument.getElementById("sm_connectingContainer").style["visibility"] == "hidden"){
  1059. var chatbox = Gdocument.getElementById("newbonklobby_chat_content");
  1060. while (chatbox.firstChild) {
  1061. chatbox.removeChild(chatbox.firstChild);
  1062. }
  1063. rcaps_flag = false;
  1064. space_flag = false;
  1065. number_flag = false;
  1066. echo_list = [];
  1067. scroll = false;
  1068. stopquickplay = 1;
  1069. freejoin = false;
  1070. defaultmode = "";
  1071. recmodebool = false;
  1072. playerids = {};
  1073. pingids = {};
  1074. ishost = false;
  1075. sandboxplayerids = {};
  1076. sandboxcopyme = false;
  1077. sandboxon = false;
  1078. sandboxid = 1;
  1079. }
  1080. else{
  1081. var pingidkey = Object.keys(pingids);
  1082. var playeridkey = Object.keys(playerids);
  1083. for(var i = 0; i<pingidkey.length;i++){
  1084. if(!playeridkey.includes(pingidkey[i])){
  1085. var pingtext = Gdocument.getElementsByClassName("newbonklobby_playerentry_pingtext");
  1086. var found = [];
  1087. if(Gdocument.getElementById("newbonklobby").style["display"] != "block"){
  1088. mess2 = Gdocument.getElementById("ingamechatinputtext").value;
  1089. Gdocument.getElementById("ingamechatinputtext").value = "";
  1090. Gdocument.getElementById("newbonklobby_editorbutton").click();
  1091. Gdocument.getElementById("mapeditor_close").click();
  1092. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  1093. Gdocument.getElementById("ingamechatinputtext").value = mess2;
  1094.  
  1095. }
  1096. for(var e=0; e<pingtext.length;e++){
  1097. if(pingtext[e].textContent == pingids[pingidkey[i]].toString()+"ms"){
  1098. found.push(pingtext[e].parentElement);
  1099. }
  1100. }
  1101. if(found.length == 1){
  1102. playerids[pingidkey[i]] = found[0].children[1].textContent;
  1103. break;
  1104. }
  1105. }
  1106. }
  1107. }
  1108. if(Gdocument.getElementById("ingametextwarning_afk").style["display"]=="table"){
  1109. Gdocument.getElementById("pretty_top_settings").click();
  1110. key2 = Gdocument.getElementById("redefineControls_table").children[0].children[5].children[1].innerHTML.charCodeAt(0);
  1111. Gdocument.getElementById("settings_close").click();
  1112.  
  1113. if(key2>0){
  1114. fire("keydown",{keyCode:key2},Gwindow);
  1115. setTimeout(function(){fire("keyup",{keyCode:key2},Gwindow)},100);
  1116. }
  1117.  
  1118. }
  1119.  
  1120. if(Gdocument.getElementById("newbonklobby").style["display"]=="block"){
  1121. Gdocument.getElementById("ingamechatinputtext").style["visibility"]="hidden";
  1122. }
  1123. else{
  1124. Gdocument.getElementById("ingamechatinputtext").style["visibility"]="visible";
  1125.  
  1126. }
  1127. mode = Gdocument.getElementById("newbonklobby_modetext").textContent;
  1128. var userlist = Gdocument.getElementsByClassName("newbonklobby_playerentry_name");
  1129. users = [];
  1130. for(var i = 0;i<userlist.length;i++){
  1131. users.push(userlist[i].textContent);
  1132. }
  1133. if(Gdocument.getElementsByClassName('newbonklobby_settings_button brownButton brownButton_classic buttonShadow brownButtonDisabled').length == 0){
  1134. ishost = true;
  1135. }
  1136. else{
  1137. ishost = false;
  1138. }
  1139.  
  1140. if(Gdocument.getElementById("pretty_top_name")!=null){
  1141. username = Gdocument.getElementById("pretty_top_name").textContent;
  1142. }
  1143. try{
  1144. Last_message = lastmessage()
  1145. } catch{
  1146. Last_message = "";
  1147. }
  1148. if (Laster_message != Last_message){
  1149. Laster_message = Last_message;
  1150. if(changed_chat==false){
  1151. new_message = true;
  1152. }
  1153. else{
  1154. changed_chat = false;
  1155. }
  1156. }
  1157. if(new_message){
  1158. if(freejoin && Last_message.startsWith("* ") && Last_message.endsWith(" has joined the game") && ishost){
  1159.  
  1160. var userjoined = Last_message.substring(2,Last_message.length-20);
  1161.  
  1162. if(Gdocument.getElementById("newbonklobby").style["display"] != "block"){
  1163. mess2 = Gdocument.getElementById("ingamechatinputtext").value;
  1164. Gdocument.getElementById("ingamechatinputtext").value = "";
  1165. Gdocument.getElementById("newbonklobby_editorbutton").click();
  1166. Gdocument.getElementById("mapeditor_close").click();
  1167. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  1168. Gdocument.getElementById("ingamechatinputtext").value = mess2;
  1169.  
  1170. }
  1171. var playing = Gdocument.getElementsByClassName("newbonklobby_playerentry newbonklobby_playerentry_half");
  1172. var inplaying = false;
  1173. for(var i = 0;i<playing.length;i++){
  1174. if(userjoined == playing[i].children[1].textContent){
  1175. inplaying = true;
  1176. break;
  1177. }
  1178. }
  1179.  
  1180. if(playing.length<=2 && inplaying){
  1181. Gdocument.getElementById("newbonklobby_editorbutton").click();
  1182. Gdocument.getElementById("mapeditor_close").click();
  1183. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  1184. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  1185. if(transitioning == true){
  1186. canceled = true;
  1187. }
  1188. }
  1189.  
  1190. }
  1191. var lm = "";
  1192. try{
  1193. lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  1194. if(typeof(lm[0].parentElement.style["parsed"]) == 'undefined'){
  1195. if (lm[0].className == "newbonklobby_chat_msg_colorbox"){
  1196. lm[2].innerHTML = urlify(lm[2].innerHTML);
  1197. Laster_message = lastmessage();
  1198. lm[0].parentElement.style["parsed"] = true;
  1199. }
  1200. if (lm[0].className == "newbonklobby_chat_status"){
  1201. lm[0].innerHTML = urlify(lm[0].innerHTML);
  1202. Laster_message = lastmessage();
  1203. lm[0].parentElement.style["parsed"] = true;
  1204. }
  1205. }
  1206. }
  1207. catch{
  1208. lm = "";
  1209. }
  1210.  
  1211. if(Last_message.indexOf("@"+username)!=-1 && npermissions == 1){
  1212. var n = new Notification(Last_message);
  1213. }
  1214.  
  1215. try{
  1216. lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  1217. if(typeof(lm[0].parentElement.style["parsed"])=='undefined'){
  1218. if(lm[0].className == "ingamechatname"){
  1219. lm[1].innerHTML = urlify(lm[1].innerHTML);
  1220. Laster_message = lastmessage();
  1221. lm[0].parentElement.style["parsed"] = true;
  1222. }
  1223. if(lm[0].className == ""){
  1224. lm[0].innerHTML = urlify(lm[0].innerHTML);
  1225. Laster_message = lastmessage();
  1226. lm[0].parentElement.style["parsed"] = true;
  1227. }
  1228. }
  1229. }
  1230. catch{
  1231. lm = "";
  1232. }
  1233.  
  1234. for(i=0;i<echo_list.length;i++){
  1235. if(Last_message.substring(0,echo_list[i].length+2) == echo_list[i]+": "){
  1236. message = Last_message.substring(echo_list[i].length+2);
  1237. chat(flag_manage(message));
  1238. }
  1239. }
  1240. }
  1241. if (ishost==true && new_message){
  1242. for(i=0;i<banned.length;i++){
  1243. if(Last_message == "* "+banned[i]+" has joined the game "){
  1244. chat("/kick '"+banned[i]+"'");
  1245. }
  1246. }
  1247. }
  1248. if(ishost == true && stopquickplay == 0){
  1249.  
  1250. if(Gdocument.getElementById("ingamewinner").style["visibility"]=="inherit" && stopquickplay == 0 && dontswitch == false){
  1251. quicki++;
  1252. transitioning = true;
  1253. map(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  1254.  
  1255. dontswitch = true;
  1256. setTimeout(function(){Gdocument.getElementById("ingamewinner").style["visibility"]="hidden"; dontswitch = false;},timedelay);
  1257.  
  1258. }
  1259. }
  1260. new_message = false;
  1261. };
  1262. });