Greasy Fork 还支持 简体中文。

Bonk Commands

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

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

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