Bonk Commands

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

目前為 2022-10-15 提交的版本,檢視 最新版本

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