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