Bonk Commands

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

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

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