Bonk Commands

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

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

  1. // ==UserScript==
  2. // @name Bonk Commands
  3. // @namespace https://gf.qytechs.cn/en/scripts/451341-bonk-commands
  4. // @version 8.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(window.location == window.parent.location){
  14. if(document.readyState == "complete"){f();}
  15. else{document.addEventListener('readystatechange',function(){setTimeout(f,1500);});}
  16. }
  17. }
  18.  
  19. BonkCommandsScriptInjector(function(){
  20. var scope = window;
  21.  
  22. scope.Gwindow = document.getElementById("maingameframe").contentWindow;
  23. scope.Gdocument = document.getElementById("maingameframe").contentDocument;
  24. Gwindow.Gwindow = window;
  25. Gwindow.Gdocument = document;
  26.  
  27. scope.link2pastebin = "https://pastebin.com/2b8XqqYu";
  28. scope.link2greasyfork = "https://gf.qytechs.cn/en/scripts/451341-bonk-commands";
  29.  
  30. if(typeof(scope.injectedBonkCommandsScript)=='undefined'){
  31. scope.injectedBonkCommandsScript = true;
  32. }
  33. else{
  34. for (var i = 0; i < 100000; i++){
  35. clearInterval(i);
  36. }
  37. }
  38. scope.GENERATE_COPRIME_NUMBER = function(mini = 0,maxi = 0,coprimewith = 0,choices = []){
  39. if(choices.length == 0){
  40. for(var i = mini;i<maxi+1;i++){
  41. choices.push(i);
  42. }
  43. }
  44. firstTry = choices[Math.floor(Math.random()*choices.length)];
  45. for(var i = 2; i<firstTry+1;i++){
  46. if(firstTry%i == 0 && coprimewith%i == 0){
  47. choices.splice(choices.indexOf(firstTry),1);
  48. if(choices.length == 0){
  49. return 0;
  50. }
  51. return GENERATE_COPRIME_NUMBER(mini,maxi,coprimewith,choices);
  52. }
  53. }
  54. return firstTry;
  55. };
  56. scope.GENERATE_PRIME_NUMBER = function(mini = 0,maxi = 0,choices = []){
  57. if(choices.length == 0){
  58. for(var i = mini;i<maxi+1;i++){
  59. choices.push(i);
  60. }
  61. }
  62. firstTry = choices[Math.floor(Math.random()*choices.length)];
  63. for(var i = 2; i<Math.floor(Math.sqrt(firstTry)+1);i++){
  64. if(i!=firstTry){
  65. if(firstTry%i == 0){
  66. choices.splice(choices.indexOf(firstTry),1);
  67. if(choices.length == 0){
  68. return 0;
  69. }
  70. return GENERATE_PRIME_NUMBER(mini,maxi,choices);
  71. }
  72. }
  73. }
  74. return firstTry;
  75. };
  76.  
  77. scope.GENERATE_KEYS = function(){
  78. interval = [];
  79. for(var i = 100;i<301;i++){
  80. interval.push(i);
  81. }
  82. random_prime = [GENERATE_PRIME_NUMBER(0,0,choices = interval),0];
  83. interval.splice(interval.indexOf(random_prime[0]),1);
  84. random_prime[1] = GENERATE_PRIME_NUMBER(0,0,choices = interval);
  85.  
  86. n = random_prime[0]*random_prime[1];
  87. n2 = (random_prime[0]-1)*(random_prime[1]-1);
  88.  
  89. e = GENERATE_COPRIME_NUMBER(2,n2-1,n2);
  90. d = 0;
  91. redo = true;
  92. for(var i = 0;i<1000000;i++){
  93. if((e*i-1)%n2 == 0 && i!=e){
  94. d = i;
  95. redo = false;
  96. break;
  97. }
  98. }
  99. if(redo){
  100. return GENERATE_KEYS();
  101. }
  102. else{
  103. return [[n,e],[n,d]];
  104. }
  105.  
  106. };
  107. scope.CRYPT_NUMBER = function(key, data){
  108.  
  109. result = 1;
  110.  
  111. for(var i = 0;i<key[1];i++){
  112. result*=data;
  113. result = result%key[0];
  114. }
  115. return result%key[0];
  116.  
  117. };
  118.  
  119. scope.CRYPT_MESSAGE = function(key,data){
  120. var resulttext = [];
  121. for(var i = 0;i<data.length;i++){
  122. resulttext.push(CRYPT_NUMBER(key,data[i]));
  123. }
  124. return resulttext;
  125.  
  126. };
  127.  
  128. if(typeof(scope.originalSend)=='undefined'){scope.originalSend = Gwindow.WebSocket.prototype.send;}
  129. if(typeof(scope.bonkwss)=='undefined'){scope.bonkwss = 0;}
  130. if(typeof(scope.chatlog)=='undefined'){scope.chatlog = ["ROOM START"];}
  131. if(typeof(scope.wsssendrecievelog)=='undefined'){scope.wsssendrecievelog = [];}
  132. if(typeof(scope.wsssendlog)=='undefined'){scope.wsssendlog = [];}
  133. if(typeof(scope.wssrecievelog)=='undefined'){scope.wssrecievelog = [];}
  134. if(typeof(scope.wsslogpaused)=='undefined'){scope.wsslogpaused = false;}
  135. if(typeof(scope.debuggeropen)=='undefined'){scope.debuggeropen = false;}
  136. if(typeof(scope.debuggercount)=='undefined'){scope.debuggercount = true;}
  137. if(typeof(scope.packetcount)=='undefined'){scope.packetcount = 0;}
  138.  
  139. if(typeof(scope.sandboxon)=='undefined'){scope.sandboxon = false;}
  140. if(typeof(scope.sandboxid)=='undefined'){scope.sandboxid = 1;}
  141. if(typeof(scope.playerids)=='undefined'){scope.playerids = {};}
  142. if(typeof(scope.sandboxplayerids)=='undefined'){scope.sandboxplayerids = {};}
  143. if(typeof(scope.originalMapLoad)=='undefined'){scope.originalMapLoad = Gdocument.getElementById("maploadwindowmapscontainer").appendChild;}
  144. if(typeof(scope.originalLobbyChat)=='undefined'){scope.originalLobbyChat = Gdocument.getElementById("newbonklobby_chat_content").appendChild;}
  145. if(typeof(scope.originalIngameChat)=='undefined'){scope.originalIngameChat = Gdocument.getElementById("ingamechatcontent").appendChild;}
  146. 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];}
  147. function sandboxonclick(){
  148. Gdocument.getElementById("roomlistcreatewindowmaxplayers").value = 1;
  149. Gdocument.getElementById("roomlistcreatewindowunlistedcheckbox").checked = true;
  150. Gdocument.getElementById("roomlistcreatecreatebutton").click();
  151. sandboxon = true;
  152. }
  153. function checkboxclearbuttononclick(){
  154. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  155. var e = true;
  156. for(var i = 0; i<classes.length;i++){
  157. if(classes[i].checked == true){
  158. e = false
  159. }
  160. classes[i].checked = false;
  161. }
  162. if(e){
  163. for(var i = 0; i<classes.length;i++){
  164. classes[i].checked = true;
  165. }
  166. }
  167. }
  168. if(Gdocument.getElementById("classic_mid_sandbox")==null){
  169. Gdocument.getElementById("roomlistrefreshbutton").click();
  170. scope.sandboxbutton = Gdocument.createElement("div");
  171. sandboxbutton.id = "classic_mid_sandbox";
  172. sandboxbutton.classList.value = "brownButton brownButton_classic classic_mid_buttons";
  173. sandboxbutton.textContent = "Sandbox";
  174. sandboxbutton.addEventListener("click",sandboxonclick);
  175. Gdocument.getElementById("classic_mid").insertBefore(sandboxbutton,Gdocument.getElementById("classic_mid_news"));
  176.  
  177. }
  178. if(Gdocument.getElementById("clearallcheckboxes")==null){
  179. scope.checkboxclearbutton = Gdocument.createElement("div");
  180. checkboxclearbutton.id = "clearallcheckboxes";
  181. checkboxclearbutton.classList.value = "brownButton brownButton_classic buttonShadow";
  182. checkboxclearbutton.textContent = "On/Off";
  183. checkboxclearbutton.style["position"] = "absolute";
  184. checkboxclearbutton.style["display"] = "none";
  185. if(typeof(ishost)!='undefined'){
  186. if(ishost && stopquickplay == 0){
  187. checkboxclearbutton.style["display"] = "block";
  188. }
  189. }
  190. checkboxclearbutton.style["right"] = "255px";
  191. checkboxclearbutton.style["top"] = "57px";
  192. checkboxclearbutton.style["height"] = "23px";
  193. checkboxclearbutton.style["width"] = "47px";
  194. checkboxclearbutton.style["line-height"] = "23px";
  195. checkboxclearbutton.style["font-size"] = "13px";
  196. checkboxclearbutton.addEventListener("click",checkboxclearbuttononclick);
  197. Gdocument.getElementById("maploadwindow").insertBefore(checkboxclearbutton,Gdocument.getElementById("maploadwindowsearchinput"));
  198.  
  199. }
  200. if(Gdocument.getElementById("BonkCommandsDebuggerContainer")==null){
  201. Gdocument.getElementById("leaveconfirmwindow").style["z-index"]=3;
  202. scope.debuggermenu = Gdocument.createElement("div");
  203. debuggermenu.id = "BonkCommandsDebuggerContainer";
  204. debuggermenu.style["position"] = "absolute";
  205. debuggermenu.style["display"] = "none";
  206. if(typeof(debuggeropen)!='undefined'){
  207. if(debuggeropen){
  208. debuggermenu.style["display"] = "block";
  209. }
  210. }
  211. debuggermenu.style["width"] = Gdocument.getElementById("bonkiocontainer").style["width"];
  212. debuggermenu.style["height"] = Gdocument.getElementById("bonkiocontainer").style["height"];
  213.  
  214. debuggermenu.style["background"] = "rgb(26, 39, 51)";
  215.  
  216. scope.width = parseInt(Gdocument.getElementById("bonkiocontainer").style["width"])-20;
  217. scope.height = parseInt(Gdocument.getElementById("bonkiocontainer").style["height"])-210;
  218.  
  219. scope.logmenu = Gdocument.createElement("div");
  220. logmenu.id = "BonkCommandsWebSocketLog";
  221. logmenu.style["position"] = "absolute";
  222. logmenu.style["width"] = width.toString()+"px";
  223. logmenu.style["height"] = height.toString()+"px";
  224. logmenu.style["top"] = "80px";
  225. logmenu.style["left"] = "10px";
  226. logmenu.style["background"] = "rgb(207, 216, 220)";
  227. scope.logmenutopleft = Gdocument.createElement("div");
  228. logmenutopleft.id = "BonkCommandsWebSocketLog";
  229. logmenutopleft.style["position"] = "absolute";
  230. logmenutopleft.textContent = "Sending";
  231. logmenutopleft.classList = "newbonklobby_boxtop newbonklobby_boxtop_classic";
  232. logmenutopleft.style["width"] = (width/2).toString()+"px";
  233. logmenutopleft.style["height"] = "30px";
  234. logmenutopleft.style["top"] = "-30px";
  235. logmenutopleft.style["background"] = "rgb(0, 150, 136)";
  236. logmenu.appendChild(logmenutopleft);
  237. scope.logmenutopright = Gdocument.createElement("div");
  238. logmenutopright.id = "BonkCommandsWebSocketLog";
  239. logmenutopright.style["position"] = "absolute";
  240. logmenutopright.textContent = "Recieving";
  241. logmenutopright.classList = "newbonklobby_boxtop newbonklobby_boxtop_classic";
  242. logmenutopright.style["width"] = (width/2).toString()+"px";
  243. logmenutopright.style["height"] = "30px";
  244. logmenutopright.style["left"] = (width/2).toString()+"px";
  245. logmenutopright.style["top"] = "-30px";
  246. logmenutopright.style["background"] = "rgb(0, 150, 136)";
  247. logmenu.appendChild(logmenutopright);
  248. scope.logmenutable = Gdocument.createElement("table");
  249. logmenutable.id = "BonkCommandsWebSocketTable";
  250. logmenutable.style["position"] = "absolute";
  251. logmenutable.style["border-spacing"] = "0px";
  252. logmenutable.style["font-size"] = "12px";
  253. logmenutable.style["display"] = "table-cell";
  254. logmenutable.style["width"] = "50%";
  255. logmenutable.style["height"] = "100%";
  256. logmenutable.style["table-layout"] = "fixed";
  257. logmenutable.style["overflow-y"] = "scroll";
  258.  
  259. scope.logmenutable2 = Gdocument.createElement("table");
  260. logmenutable2.id = "BonkCommandsWebSocketTable2";
  261. logmenutable2.style["position"] = "absolute";
  262. logmenutable2.style["width"] = "50%";
  263. logmenutable2.style["left"] = "50%";
  264. logmenutable2.style["font-size"] = "12px";
  265. logmenutable2.style["display"] = "table-cell";
  266. logmenutable2.style["height"] = "100%";
  267. logmenutable2.style["table-layout"] = "fixed";
  268. logmenutable2.style["overflow-y"] = "scroll";
  269. logmenutable2.style["border-spacing"] = "0px";
  270. scope.leftsync = false;
  271. scope.rightsync = false;
  272. logmenutable2.onscroll = function(){
  273. if(!leftsync){
  274. rightsync = true;
  275. logmenutable.scrollTop = this.scrollTop;
  276. }
  277. else{
  278. leftsync = false;
  279. }
  280. };
  281. logmenutable.onscroll = function(){
  282. if(!rightsync){
  283. leftsync = true;
  284. logmenutable2.scrollTop = this.scrollTop;
  285. }
  286. else{
  287. rightsync = false
  288. }
  289. };
  290. logmenu.appendChild(logmenutable);
  291. logmenu.appendChild(logmenutable2);
  292. debuggermenu.appendChild(logmenu);
  293. scope.debuggermenuclose = Gdocument.createElement("div");
  294. debuggermenuclose.id = "debuggerclose";
  295. debuggermenuclose.classList = "windowCloseButton brownButton brownButton_classic buttonShadow";
  296. debuggermenuclose.style["position"] = "absolute";
  297. debuggermenuclose.style["top"] = "40px";
  298. debuggermenuclose.style["right"] = "5px";
  299. debuggermenuclose.onclick = function(){debuggeropen = false;debuggermenu.style["display"] = "none";Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  300. Gdocument.getElementById("ingamechatinputtext").style["display"] = "";};
  301. debuggermenu.appendChild(debuggermenuclose);
  302. scope.debuggerform = Gdocument.createElement("form");
  303. debuggerform.autocomplete = "off";
  304. scope.debuggerinput = Gdocument.createElement("input");
  305. debuggerinput.style["position"] = "absolute";
  306. debuggerinput.style["width"] = width.toString()+"px";
  307. debuggerinput.style["left"] = "10px";
  308. debuggerinput.style["top"] = (height+90).toString()+"px";
  309. debuggerinput.style["font-size"] = "12px";
  310. debuggerinput.style["height"] = "20px";
  311. debuggerform.appendChild(debuggerinput);
  312. scope.debuggersendrecieve = Gdocument.createElement("div");
  313. debuggersendrecieve.style["position"] = "absolute";
  314. debuggersendrecieve.style["width"] = "140px";
  315. debuggersendrecieve.style["left"] = "10px";
  316. debuggersendrecieve.style["top"] = (height+120).toString()+"px";
  317. debuggersendrecieve.style["font-size"] = "15px";
  318. debuggersendrecieve.style["height"] = "20px";
  319. debuggersendrecieve.classList = "brownButton brownButton_classic buttonShadow";
  320. debuggersendrecieve.textContent = "Send";
  321. debuggersendrecieve.value = 0;
  322. debuggersendrecieve.onclick = function(){if(this.value == 0){this.textContent = "Recieve";this.value = 1;}else{this.textContent = "Send";this.value = 0;}};
  323.  
  324. debuggermenu.appendChild(debuggersendrecieve);
  325. scope.debuggerpausebutton = Gdocument.createElement("div");
  326. debuggerpausebutton.style["position"] = "absolute";
  327. debuggerpausebutton.style["width"] = "140px";
  328. debuggerpausebutton.style["left"] = "10px";
  329. debuggerpausebutton.style["top"] = (height+150).toString()+"px";
  330. debuggerpausebutton.style["font-size"] = "15px";
  331. debuggerpausebutton.style["height"] = "20px";
  332. debuggerpausebutton.classList = "brownButton brownButton_classic buttonShadow";
  333. debuggerpausebutton.textContent = "Pause";
  334. debuggerpausebutton.value = 0;
  335. debuggerpausebutton.onclick = function(){if(this.value == 0){this.textContent = "Play";this.value = 1;wsslogpaused = true}else{this.textContent = "Pause";this.value = 0;wsslogpaused = false;}};
  336.  
  337. debuggermenu.appendChild(debuggerpausebutton);
  338. scope.debuggereval = Gdocument.createElement("input");
  339. debuggereval.style["position"] = "absolute";
  340. debuggereval.style["width"] = (width-150).toString()+"px";
  341. debuggereval.style["right"] = "10px";
  342. debuggereval.style["top"] = (height+120).toString()+"px";
  343. debuggereval.style["font-size"] = "12px";
  344. debuggereval.style["height"] = "20px";
  345. debuggereval.addEventListener("keypress",function(e){if(e.repeat){return;}if(e.code == "Enter"){if(debuggersendrecieve.value == 0){SEND(this.value);}else{RECIEVE(this.value);}}});
  346. debuggerform.appendChild(debuggereval);
  347. debuggermenu.appendChild(debuggerform);
  348. Gdocument.getElementById("newbonkgamecontainer").appendChild(debuggermenu);
  349.  
  350. }
  351. scope.updateWssLog = function(){
  352. if(!wsslogpaused){
  353. if(logmenutable.children.length < wsssendrecievelog.length){
  354. var bottomscroll = logmenutable.clientHeight + logmenutable.scrollTop >= logmenutable.scrollHeight-1;
  355. while (logmenutable.children.length>1000) {
  356. logmenutable.removeChild(logmenutable.firstChild);
  357. logmenutable2.removeChild(logmenutable2.firstChild);
  358. }
  359. var loopthro = wsssendrecievelog.slice(packetcount);
  360. for(var i = 0; i < loopthro.length;i++){
  361. packetcount++;
  362. var row = document.createElement("tr");
  363. var row2 = document.createElement("tr");
  364.  
  365. var cell1 = document.createElement("td");
  366. cell1.style["overflow-x"] = "scroll";
  367. cell1.style["padding"] = "0px";
  368. cell1.style["width"] = "100000px";
  369.  
  370. var cell2 = document.createElement("td");
  371. cell2.style["overflow-x"] = "scroll";
  372. cell2.style["padding"] = "0px";
  373. cell2.style["width"] = "100000px";
  374. if(debuggercount){
  375. cell1.style["background"] = "rgb(178, 185, 189)";
  376. debuggercount = false;
  377. }
  378. else{
  379. cell2.style["background"] = "rgb(178, 185, 189)";
  380. debuggercount = true;
  381. }
  382. cell1.textContent = loopthro[i][1];
  383. cell2.textContent = loopthro[i][1];
  384. if(loopthro[i][0] == 0){
  385. cell2.style["color"] = "transparent";
  386. cell1.onclick = function(){debuggerinput.value = this.textContent};
  387. }
  388. else{
  389. cell1.style["color"] = "transparent";
  390. cell2.onclick = function(){debuggerinput.value = this.textContent};
  391. }
  392. row.appendChild(cell1);
  393. row2.appendChild(cell2);
  394. logmenutable.appendChild(row);
  395. logmenutable2.appendChild(row2);
  396. }
  397. while (logmenutable.children.length>1000) {
  398. logmenutable.removeChild(logmenutable.firstChild);
  399. logmenutable2.removeChild(logmenutable2.firstChild);
  400. }
  401. if(bottomscroll){
  402. logmenutable.scrollTop = logmenutable.scrollHeight;
  403. logmenutable2.scrollTop = logmenutable.scrollHeight;
  404. }
  405. }
  406. }
  407. };
  408. Gdocument.getElementById("maploadwindowmapscontainer").appendChild = function(args){
  409. var checkbox = Gdocument.createElement("input");
  410. checkbox.type = "checkbox";
  411. checkbox.style["position"]="absolute";
  412. checkbox.style["margin-top"] = "135px";
  413. checkbox.style["margin-left"] = "140px";
  414. checkbox.style["scale"] = "2";
  415. checkbox.style["display"] = "none";
  416. checkbox.className = "quickplaycheckbox quickplayunchecked";
  417. if(ishost && stopquickplay==0){
  418. checkbox.style["display"] = "block";
  419. checkbox.className = "quickplaycheckbox quickplaychecked";
  420. }
  421. checkbox.checked = true;
  422. checkbox.onclick = function(e){e.stopPropagation();};
  423. args.appendChild(checkbox);
  424. originalMapLoad.call(this,args);
  425. };
  426. Gdocument.getElementById("newbonklobby_chat_content").appendChild = function(args){
  427. if(beenKickedTimeStamp+100>Date.now() && args.children.length>0){
  428. if(args.children[0].textContent.endsWith(" has left the game ") && args.children[0].textContent.startsWith("* ")){
  429. args.children[0].textContent = args.children[0].textContent.substring(0,args.children[0].textContent.length-19)+" has been kicked from the game ";
  430. }
  431. }
  432. originalLobbyChat.call(this,args);
  433. };
  434. Gdocument.getElementById("ingamechatcontent").appendChild = function(args){
  435. if(beenKickedTimeStamp+100>Date.now() && args.children.length>0){
  436. if(args.children[0].textContent.endsWith(" has left the game.") && args.children[0].textContent.startsWith("* ")){
  437. args.children[0].textContent = args.children[0].textContent.substring(0,args.children[0].textContent.length-19)+" has been kicked from the game.";
  438. }
  439. }
  440. if(recordedTimeStamp+100>Date.now() && args.children.length>0){
  441. if(args.children[0].textContent.includes("seconds") && args.children[0].textContent.startsWith("* ")){
  442. args.children[0].textContent = args.children[0].textContent + " - " + playerids[recordedId]
  443. }
  444. }
  445. originalIngameChat.call(this,args);
  446. };
  447. Gwindow.WebSocket.prototype.send = function(args) {
  448. if(this.url.includes(".bonk.io/socket.io/?EIO=3&transport=websocket&sid=")){
  449. bonkwss = this;
  450. wsssendlog.push(args);
  451. wsssendrecievelog.push([0,args]);
  452. if(args.startsWith('42[26,')){
  453. if(sandboxon){
  454. var jsonargs = JSON.parse(args.substring(2))[1];
  455. if(typeof(sandboxplayerids[jsonargs["targetID"]])!='undefined'){
  456. RECIEVE('42[18,'+jsonargs["targetID"]+','+jsonargs["targetTeam"]+']');
  457.  
  458. }
  459. }
  460. }
  461. if(args.startsWith('42[1,')){
  462. return;
  463. }
  464. if(args.startsWith('42[4,')){
  465. var jsonargs = JSON.parse(args.substring(2));
  466. if(sandboxcopyme && typeof(jsonargs[1]["type"])=="undefined"){
  467. var jsonkeys = Object.keys(sandboxplayerids);
  468. for(var i = 0; i<jsonkeys.length;i++){
  469. RECIEVE('42[7,'+jsonkeys[i].toString()+','+JSON.stringify(jsonargs[1])+']');
  470. }
  471. }
  472. args = "42"+JSON.stringify(jsonargs);
  473. }
  474.  
  475. if(args.startsWith('42[5,')){
  476. var jsonargs = JSON.parse(args.substring(2));
  477.  
  478. if(stopquickplay!=1){
  479. jsonargs[1]["gs"]["wl"] = 999;
  480. }
  481. args = "42"+JSON.stringify(jsonargs);
  482. }
  483.  
  484. }
  485. else{
  486. this.onmessage = function(args){return;};
  487. return;
  488.  
  489. }
  490. if(this.url.includes(".bonk.io/socket.io/?EIO=3&transport=websocket&sid=") && !this.injected){
  491. this.injected = true;
  492.  
  493. var originalRecieve = this.onmessage;
  494. this.onmessage = function(args){
  495. wssrecievelog.push(args.data);
  496. wsssendrecievelog.push([1,args.data]);
  497. if(args.data.startsWith('42[1,')){
  498. var jsonargs = JSON.parse(args.data.substring(2));
  499. originalSend.call(this,'42[1,{"id":'+jsonargs[2]+'}]');
  500. }
  501. if(args.data.startsWith('42[24,')){
  502. beenKickedTimeStamp = Date.now();
  503. }
  504. if(args.data.startsWith('42[32')){
  505. SEND('42[4,{"type":"inactive kick counter"}]');
  506. }
  507. if(args.data.startsWith('42[40,')){
  508. recordedTimeStamp = Date.now();
  509. recordedId = JSON.parse(args.data.substring(2))[1];
  510. }
  511. if(args.data.startsWith('42[3,')){
  512. var jsonargs = JSON.parse(args.data.substring(2));
  513. for(var i = 0; i<jsonargs[3].length;i++){
  514. if(jsonargs[3][i]!=null){
  515. playerids[i.toString()] = jsonargs[3][i]["userName"];
  516. }
  517. }
  518. }
  519. if(args.data.startsWith('42[15,')){
  520. var jsonargs = JSON.parse(args.data.substring(2));
  521. gameStartTimeStamp = jsonargs[1];
  522. }
  523. if(args.data.startsWith('42[7,')){
  524. var jsonargs2 = JSON.parse(args.data.substring(2));
  525. var idofpacket = jsonargs2[1];
  526. jsonargs = jsonargs2[2];
  527. if(typeof(jsonargs["type"]) != "undefined"){
  528. if(jsonargs["type"]=="private chat" && jsonargs["to"] == username){
  529. from = jsonargs["from"];
  530. if(Object.keys(playerids).includes(idofpacket.toString())){
  531. from = playerids[idofpacket];
  532. }
  533. if(!ignorepmlist.includes(from)){
  534. if(typeof(jsonargs["message"])=="object" && typeof(jsonargs["password"]) == "object"){
  535. if(public_key[0]==jsonargs["public key"][0] && public_key[1]==jsonargs["public key"][1]){
  536. if(jsonargs["password"].length<=25){
  537. var password = CRYPT_MESSAGE(private_key,jsonargs["password"]);
  538. var decodedtext = jsonargs["message"].slice(0,400);
  539. var encodedtext = "";
  540. for(var i=0;i<decodedtext.length;i++){
  541. if(password[i%password.length]<1000){
  542. encodedtext+=String.fromCharCode(password[i%password.length]^decodedtext[i]);
  543. }
  544. }
  545. 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);';
  546. displayInChat('> '+'<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+from+'</a>'+': ',"#DA0808","#1EBCC1",{sanitize:false},encodedtext);
  547.  
  548. Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true;
  549. Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true;
  550. Laster_message = lastmessage();
  551. }
  552. }
  553. else{
  554. SEND("42"+JSON.stringify([4,{"type":"public key correction","from":username,"to":private_chat_public_key[0],"public key":public_key}]));
  555. }
  556. }
  557. }
  558. }
  559. if(jsonargs["type"]=="request public key" && jsonargs["to"] == username){
  560. SEND("42"+JSON.stringify([4,{"type":"public key","from":username,"public key":public_key}]));
  561. }
  562. if(jsonargs["type"]=="private chat users" && pmuserstimestamp+1500>Date.now()){
  563. if(typeof(jsonargs["from"])!='undefined'){
  564. from = jsonargs["from"];
  565. if(Object.keys(playerids).includes(idofpacket.toString())){
  566. from = playerids[idofpacket];
  567. }
  568. if(!pmusers.includes(from) && username == jsonargs["to"]){
  569. pmusers.push(from);
  570. }
  571. }
  572. }
  573. if(jsonargs["type"]=="request private chat users"){
  574. if(typeof(jsonargs["from"])!='undefined'){
  575. from = jsonargs["from"];
  576. if(Object.keys(playerids).includes(idofpacket.toString())){
  577. from = playerids[idofpacket];
  578. }
  579. SEND("42"+JSON.stringify([4,{"type":"private chat users","from":username,"to":from}]));
  580. }
  581. }
  582. if(jsonargs["type"]=="public key" && request_public_key_time_stamp+1500>Date.now()){
  583. from = jsonargs["from"];
  584. if(Object.keys(playerids).includes(idofpacket.toString())){
  585. from = playerids[idofpacket];
  586. }
  587. if(from == private_chat){
  588. private_chat_public_key = [private_chat,jsonargs["public key"]];
  589. displayInChat("Private chatting with "+private_chat+".","#DA0808","#1EBCC1");
  590. }
  591.  
  592. }
  593. if(jsonargs["type"]=="public key correction" && private_chat_public_key[0] == private_chat){
  594. from = jsonargs["from"];
  595. if(Object.keys(playerids).includes(idofpacket.toString())){
  596. from = playerids[idofpacket];
  597. }
  598. if(from == private_chat){
  599. private_chat_public_key = [private_chat,jsonargs["public key"]];
  600. var text = pmlastmessage;
  601. var password = [];
  602. for(var i = 0;i<10;i++){
  603. password.push(Math.floor(Math.random()*100+50));
  604. }
  605. var text2 = [];
  606. for(var i = 0;i<text.length ;i++){
  607. text2.push(password[i%password.length]^text.slice(0,400).charCodeAt(i));
  608. }
  609. 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)}]));
  610. }
  611. }
  612.  
  613. }
  614. else{
  615. gameStartTimeStamp = Date.now()-1000*jsonargs["f"]/30;
  616. }
  617. }
  618.  
  619. if(args.data.startsWith('42[4,')){
  620. var jsonargs = JSON.parse(args.data.substring(2));
  621. playerids[jsonargs[1]] = jsonargs[3];
  622.  
  623. }
  624. if(args.data.startsWith('42[5,')){
  625. var jsonargs = JSON.parse(args.data.substring(2));
  626. if(typeof(playerids[jsonargs[1]])!='undefined'){
  627. delete playerids[jsonargs[1]];
  628. }
  629. }
  630. return originalRecieve.call(this,args);
  631. };
  632.  
  633. var originalClose = this.onclose;
  634. this.onclose = function () {
  635. window.bonkwss = 0;
  636. return originalClose.call(this);
  637. }
  638.  
  639. }
  640. return originalSend.call(this,args);
  641. };
  642.  
  643. scope.SEND = function(args){
  644. if(bonkwss!=0){
  645. bonkwss.send(args);
  646. }
  647. };
  648. scope.RECIEVE = function(args){
  649. if(bonkwss!=0){
  650. bonkwss.onmessage({data:args});
  651. }
  652. };
  653. Gdocument.getElementById("ingamechatcontent").style["pointer-events"]="all";
  654. Gdocument.getElementById("ingamechatcontent").style["max-height"]="250px";
  655. Gdocument.getElementById("ingamechatcontent").style["height"]="128px";
  656. Gdocument.getElementById("ingamechatbox").style["height"]="250px";
  657.  
  658. document.getElementById('adboxverticalCurse').style["display"] = "none";
  659. document.getElementById('adboxverticalleftCurse').style["display"] = "none";
  660.  
  661.  
  662. scope.dontswitch = false;
  663. scope.username = 0;
  664. scope.timedelay = 1400;
  665. scope.ishost = false;
  666. scope.checkboxhidden = true;
  667. scope.quicki=0;
  668. scope.defaultmode = "d";
  669. scope.recmodebool = false;
  670. scope.shuffle = false;
  671. scope.freejoin = false;
  672. scope.recordedTimeStamp = 0;
  673. scope.recordedId = 0;
  674. scope.beenKickedTimeStamp = 0;
  675. scope.stopquickplay = 1;
  676. scope.currentFrame = 0;
  677. scope.gameStartTimeStamp = 0;
  678. scope.canceled = false;
  679. scope.banned = [];
  680. scope.transitioning = false;
  681. scope.echo_list = [];
  682. scope.message = "";
  683. scope.mode = "";
  684. scope.private_chat = "";
  685. scope.private_chat_public_key = ["",[0,0]];
  686. scope.users = [];
  687. scope.pmusers = [];
  688. scope.pmlastmessage = "";
  689. scope.pmuserstimestamp = 0;
  690. scope.ignorepmlist = [];
  691. scope.scroll = false;
  692. scope.elem = Gdocument.getElementById("maploadwindowmapscontainer");
  693. scope.npermissions = 1;
  694. scope.space_flag = false;
  695. scope.rcaps_flag = false;
  696. scope.number_flag = false;
  697. scope.request_public_key_time_stamp = 0;
  698. scope.sandboxcopyme = false;
  699. scope.help = ["All the commands are:","/help","/?","/advhelp [command]","/space","/rcaps","/number","/echo [username]","/clearecho","/remove [username]","/chatw [username]","/msg [text]","/ignorepm [username]","/pmusers","/lobby","/team [letter]","/scroll","/hidechat","/showchat","/notify","/stopnotify","Host commands are:","/startqp","/stopqp","/next","/previous","/shuffle","/freejoin","/recmode","/defaultmode [mode]","/start","/balanceA [number]","/moveA [letter]","/rounds [number]","/mode [mode]","/ban [username]","/kill [username]","Sandbox commands are:","/addplayer [number]","/delplayer [number]","/copyme","Debugging commands are:","/eval [code]","/debugger","Hotkeys are:","Alt L","Alt C","Host hotkeys are:","Alt S","Alt T","Alt E","Alt K","Alt M","Alt Q","Alt A","Alt D","Alt F","Alt R","Alt I"];
  700.  
  701. scope.adv_help = {"help":"Shows all command names.",
  702. "?":"Shows all command names.",
  703. "advhelp":"Shows a command in detail.",
  704. "space":"Toggles space. When space is on, whatever you type will be spaced apart.",
  705. "rcaps":"Toggles rcaps. When rcaps is on, each letter will randomly get capitalized.",
  706. "number":"Toggles number. When number is on, 'a' becomes 4, 'e' becomes 3, 's' becomes 5, 'o' becomes 0, 'l' and 'i' become 1.",
  707. "echo":"Echoes a username. It copies the username's chat messages.",
  708. "remove":"Removes username from echo list. You will not echo that username anymore.",
  709. "clearecho":"Clears echo list. You will not echo anyone anymore.",
  710. "chatw":"It private chats with username. Type /msg to message that username.",
  711. "msg":"Messages with what username you are chatting with. Type /chatw to chat with a username.",
  712. "ignorepm":"Ignores the username's private chat messages. To unignore, type /ignorepm [username].",
  713. "pmusers":"Dispays who you can private chat with.",
  714. "eval":"Evaluates code. Only use this if you are experienced in javascript.",
  715. "debugger":"Opens debugger.",
  716. "lobby":"Makes lobby visible when you are ingame. Type /lobby again to close lobby.",
  717. "team":"Joins a specific team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  718. "scroll":"Toggles a scrollbar in ingame chat.",
  719. "hidechat":"Hides ingame chat. Type /showchat to show it again.",
  720. "showchat":"Shows ingame chat. /hidechat hides the chat.",
  721. "notify":"You will be notified if a person types @MYUSERNAME",
  722. "stopnotify":"You will not be notified if a person types @MYUSERNAME",
  723. "startqp":"Starts cycling maps in your map menu.",
  724. "stopqp":"Stops cycling maps in your map menu.",
  725. "next":"Skips the map. Usable only with /startqp.",
  726. "previous":"Goes to previous map. Usable only with /startqp.",
  727. "shuffle":"Makes quickplay play random maps instead of in order.",
  728. "freejoin":"Toggles freejoin. If freejoin is on, starts the game instantly if there are 1 or less players currently playing.",
  729. "recmode":"In quickplay, it switches mode to recommended mode, according to editor.",
  730. "defaultmode":"Switches mode to defaultmode if there is no recmode.",
  731. "start":"Starts game instantly.",
  732. "balanceA":"Balances everyone with balance number.",
  733. "moveA":"Sets everyones team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  734. "rounds":"Sets rounds to win.",
  735. "mode":"Switches modes.",
  736. "ban":"Bans username from lobby. If they rejoin, it automatically bans.",
  737. "kill":"Kills the person ingame.",
  738. "addplayer":"In sandbox, it adds players.",
  739. "delplayer":"In sandbox, it deletes players.",
  740. "copyme":"In sandbox, it makes each player copy your movements.",
  741. "Alt L":"Makes lobby visible when you are ingame. Press Alt L again to close lobby.",
  742. "Alt C":"Hides ingame chat. Press Alt C again to show ingame chat.",
  743. "Alt S":"Starts game instantly.",
  744. "Alt T":"Toggles teams.",
  745. "Alt E":"Toggles editor.",
  746. "Alt K":"Exits ingame and returns to lobby.",
  747. "Alt M":"Switches modes.",
  748. "Alt Q":"Toggles quickplay.",
  749. "Alt A":"Skips the map if quickplay is on.",
  750. "Alt D":"Goes to previous map if quickplay is on.",
  751. "Alt F":"Toggles freejoin. If freejoin is on, starts the game instantly if there are 1 or less players currently playing",
  752. "Alt R":"In quickplay, it switches mode to recommended mode, according to editor.",
  753. "Alt I":"Opens debugger."
  754. };
  755.  
  756. elem.onclick=function(e){
  757. if(stopquickplay==0 && ishost == true && e.isTrusted == true){
  758. quicki = (Array.from(e.target.parentElement.parentNode.children).indexOf(e.target.parentNode)-1)%(Gdocument.getElementById("maploadwindowmapscontainer").children.length);
  759. }
  760. };
  761. scope.urlify = function(text) {
  762. return text.replace(/(?:https?:\/\/)?(?:[A-Za-z0-9-ßàÁâãóôþüúðæåïçèõöÿýòäœêëìíøùîûñé]+)(?:\.[A-Za-z0-9-ßàÁâãóôþüúðæåïçèõöÿýòäœêëìíøùîûñé]+)+(?:\/(?:[A-Za-z0-9-._~:/?#\[\]@!$&'()*+,;=]|%[0-9a-fA-F]{2})*)?(?:\?(?:[^=]+=[^&](?:&[^=]+=[^&])*)?)?/g, function(url) {
  763. if(url.startsWith('https://')){return '<a href="' + url + '" target="_blank" style = "color:orange">' + url + '</a>';}
  764. else{return '<a href="https://' + url + '" target="_blank" style = "color:orange">' + url + '</a>';}
  765. })
  766. };
  767.  
  768. scope.fire = function(type,options,d = Gdocument){
  769. var event=new CustomEvent(type);
  770. for(var p in options){
  771. event[p]=options[p];
  772. }
  773. d.dispatchEvent(event);
  774. };
  775.  
  776. scope.chat = function(message){
  777. mess = Gdocument.getElementById("newbonklobby_chat_input").value;
  778. mess2 = Gdocument.getElementById("ingamechatinputtext").value;
  779. Gdocument.getElementById("newbonklobby_chat_input").value = message;
  780. Gdocument.getElementById("ingamechatinputtext").value = message;
  781. fire("keydown",{keyCode:13});
  782. fire("keydown",{keyCode:13});
  783. Gdocument.getElementById("newbonklobby_chat_input").value = mess;
  784. Gdocument.getElementById("ingamechatinputtext").value = mess2;
  785. };
  786. scope.displayInChat = function(message, LobbyColor, InGameColor, options, message2) {
  787. options = options ?? {};
  788. message2 = message2 ?? "";
  789. LobbyColor = LobbyColor ?? "#8800FF";
  790. InGameColor = InGameColor ?? "#AA88FF";
  791. let A = Gdocument.createElement("div");
  792. let B = Gdocument.createElement("span");
  793. B.className = "newbonklobby_chat_status";
  794. B.style.color = LobbyColor;
  795. A.appendChild(B);
  796. B.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  797. B.innerHTML+=urlify(message2.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;'));
  798. let C = Gdocument.createElement("div");
  799. let D = Gdocument.createElement("span");
  800. D.style.color = InGameColor;
  801. C.appendChild(D);
  802. D.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  803. D.innerHTML+=urlify(message2.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;'));
  804.  
  805. let a = false;
  806. if(Gdocument.getElementById("newbonklobby_chat_content").clientHeight + Gdocument.getElementById("newbonklobby_chat_content").scrollTop >= Gdocument.getElementById("newbonklobby_chat_content").scrollHeight-1) {
  807. a = true;
  808. }
  809. Gdocument.getElementById("newbonklobby_chat_content").appendChild(A);
  810. Gdocument.getElementById("ingamechatcontent").appendChild(C);
  811. if (a) { Gdocument.getElementById("newbonklobby_chat_content").scrollTop = Number.MAX_SAFE_INTEGER;};
  812. Gdocument.getElementById("ingamechatcontent").scrollTop = Number.MAX_SAFE_INTEGER;
  813. chat("");
  814. };
  815.  
  816. scope.lobby = function(){
  817. if (Gdocument.getElementById("newbonklobby").style["display"]=="none"){
  818.  
  819. Gdocument.getElementById("newbonklobby_editorbutton").click();
  820. Gdocument.getElementById("mapeditor_close").click();
  821. if(Gdocument.getElementsByClassName("newbonklobby_playerentry").length>0){
  822. Gdocument.getElementById("newbonklobby").style["z-index"]=1;
  823. Gdocument.getElementById("maploadwindowcontainer").style["z-index"]=1;
  824. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=1;
  825. Gdocument.getElementById("pretty_top").style["z-index"]=3;
  826. Gdocument.getElementById("settingsContainer").style["z-index"]=3;
  827. Gdocument.getElementById("leaveconfirmwindow").style["z-index"]=3;
  828. Gdocument.getElementById("hostleaveconfirmwindow").style["z-index"]=3;
  829. debuggermenu.style["z-index"] = 2;
  830. }
  831. else{
  832. Gdocument.getElementById("newbonklobby").style["opacity"]=0;
  833. Gdocument.getElementById("newbonklobby").style["display"]="none";
  834. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
  835.  
  836. }
  837.  
  838. }
  839. else if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  840. Gdocument.getElementById("newbonklobby").style["opacity"]=0;
  841. Gdocument.getElementById("newbonklobby").style["display"]="none";
  842. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
  843.  
  844. }
  845. };
  846.  
  847. scope.lastmessage = function(){
  848. if(Gdocument.getElementById("newbonklobby_chat_content").children.length!=0){
  849. var lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  850. var lm2 = "";
  851. for(var i = 0; i<lm.length;i++){
  852. lm2+=" "+lm[i].textContent.trim();
  853. }
  854. lm2 = lm2.trim();
  855. if(lm2.startsWith("*")){
  856. return lm2;
  857. }
  858. }
  859. if(Gdocument.getElementById("ingamechatcontent").children.length!=0){
  860. var lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  861. var lm2 = "";
  862. for(var i = 0; i<lm.length;i++){
  863. lm2+=" "+lm[i].textContent.trim();
  864. }
  865. return lm2.trim();
  866. }
  867. return "";
  868.  
  869. };
  870. scope.map = function(e){
  871. if(e<0){
  872. displayInChat("There is no previous map.","#DA0808","#1EBCC1");
  873. quicki = 0;
  874. return;
  875. }
  876. if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
  877. displayInChat("Click the maps button.","#DA0808","#1EBCC1");
  878. return;
  879. }
  880.  
  881. setTimeout(function(){if(!canceled){
  882. Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
  883. Gdocument.getElementById("newbonklobby_editorbutton").click();
  884. if(recmodebool && ishost){
  885. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  886. if(mode == "" && defaultmode!="d"){
  887. mode = defaultmode;
  888. }
  889. if(mode != ""){
  890. RECIEVE('42[26,"b","'+mode+'"]');
  891. }
  892. }
  893. Gdocument.getElementById("mapeditor_close").click();
  894. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  895. Gdocument.getElementById("mapeditor_midbox_testbutton").click();}
  896. canceled = false;
  897. transitioning = false;
  898. },timedelay);
  899.  
  900. };
  901.  
  902. scope.gotonextmap = function(e){
  903. if(e<0){
  904. displayInChat("There is no previous map.","#DA0808","#1EBCC1");
  905. quicki = 0;
  906. return;
  907. }
  908. if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
  909. displayInChat("Click the maps button.","#DA0808","#1EBCC1");
  910. return;
  911. }
  912. Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
  913. Gdocument.getElementById("newbonklobby_editorbutton").click();
  914. if(recmodebool && ishost){
  915. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  916. if(mode == "" && defaultmode!="d"){
  917. mode = defaultmode;
  918. }
  919. if(mode != ""){
  920. RECIEVE('42[26,"b","'+mode+'"]');
  921. }
  922. }
  923. Gdocument.getElementById("mapeditor_close").click();
  924. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  925. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  926. Gdocument.getElementById("newbonklobby").style["visibility"] = "visible";
  927. };
  928. scope.commandhandle = function(chat_val){
  929. if (chat_val.substring(1,6)=="echo " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  930. if (chat_val.substring(6).replace(/^\s+|\s+$/g, '')==username){
  931. displayInChat("You cannot echo yourself.","#DA0808","#1EBCC1");
  932. return "";
  933. }
  934. else if (echo_list.indexOf(chat_val.substring(6).replace(/^\s+|\s+$/g, ''))===-1) {
  935.  
  936. echo_list.push(chat_val.substring(6).replace(/^\s+|\s+$/g, ''));
  937. displayInChat(chat_val.substring(6).replace(/^\s+|\s+$/g, '') + " is being echoed.","#DA0808","#1EBCC1");
  938. return "";
  939. }
  940. else{
  941. displayInChat(chat_val.substring(6).replace(/^\s+|\s+$/g, '') + " is already being echoed.","#DA0808","#1EBCC1");
  942. return "";
  943. }
  944. }
  945. else if (chat_val.substring(1,8)=="remove " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  946. if (echo_list.indexOf(chat_val.substring(7).replace(/^\s+|\s+$/g, ''))!==-1){
  947. echo_list.splice(echo_list.indexOf(chat_val.substring(7).replace(/^\s+|\s+$/g, '')),1);
  948. displayInChat(chat_val.substring(7).replace(/^\s+|\s+$/g, '')+" is not being echoed.","#DA0808","#1EBCC1");
  949. return "";
  950. }
  951. else{
  952. displayInChat("You cannot remove someone that you didn't echo.","#DA0808","#1EBCC1");
  953. return "";
  954. }
  955.  
  956. }
  957. else if (chat_val.substring(1,10)=="clearecho"){
  958. echo_list = [];
  959. displayInChat("Cleared the echo list.","#DA0808","#1EBCC1");
  960. return "";
  961. }
  962. else if (chat_val.substring(1,6)=="space"){
  963. if(space_flag == true){
  964. displayInChat("Space is now off.","#DA0808","#1EBCC1");
  965. space_flag = false;
  966. }
  967. else{
  968. displayInChat("Space is now on.","#DA0808","#1EBCC1");
  969. space_flag = true;
  970. }
  971. return "";
  972. }
  973. else if (chat_val.substring(1,6)=="rcaps"){
  974. if(rcaps_flag == true){
  975. displayInChat("Rcaps is now off.","#DA0808","#1EBCC1");
  976. rcaps_flag = false;
  977. }
  978. else{
  979. displayInChat("Rcaps is now on.","#DA0808","#1EBCC1");
  980. rcaps_flag = true;
  981. }
  982.  
  983. return "";
  984. }
  985. else if (chat_val.substring(1,7)=="number"){
  986. if(number_flag == true){
  987. displayInChat("Number is now off.","#DA0808","#1EBCC1");
  988. number_flag = false;
  989. }
  990. else{
  991. displayInChat("Number is now on.","#DA0808","#1EBCC1");
  992. number_flag = true;
  993. }
  994.  
  995. return "";
  996. }
  997. else if (chat_val.substring(1,6)=="eval " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  998. var ev = "";
  999. try{
  1000. ev = eval(chat_val.substring(6).replace(/^\s+|\s+$/g, ''));
  1001. }
  1002. catch(e){
  1003. displayInChat(e.message,"#DA0808","#1EBCC1");
  1004. }
  1005. try{
  1006. displayInChat(ev.toString(),"#DA0808","#1EBCC1");
  1007. }
  1008. catch{
  1009. }
  1010.  
  1011. return "";
  1012.  
  1013. }
  1014.  
  1015. else if (chat_val.substring(1,9)=="hidechat"){
  1016. Gdocument.getElementById("ingamechatcontent").style["max-height"]="0px";
  1017. return "";
  1018. }
  1019. else if (chat_val.substring(1,9)=="showchat"){
  1020. Gdocument.getElementById("ingamechatcontent").style["max-height"]="250px";
  1021. return "";
  1022. }
  1023.  
  1024. else if (chat_val.substring(1,7)=="scroll"){
  1025. if(scroll==false){
  1026. scroll = true;
  1027. Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="scroll";
  1028. Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
  1029. }
  1030. else if(scroll==true){
  1031. scroll = false;
  1032. Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="hidden";
  1033. Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
  1034. }
  1035.  
  1036. return "";
  1037. }
  1038.  
  1039. else if (chat_val.substring(1,7)=="chatw "){
  1040. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '');
  1041.  
  1042. if(username == text){
  1043. displayInChat("You cannot private chat with yourself.","#DA0808","#1EBCC1");
  1044. return "";
  1045. }
  1046. private_chat = text;
  1047.  
  1048. SEND("42"+JSON.stringify([4,{"type":"request public key","from":username,"to":private_chat}]));
  1049. request_public_key_time_stamp = Date.now();
  1050. 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);
  1051. return "";
  1052. }
  1053.  
  1054. else if (chat_val.substring(1,5)=="msg " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  1055. if(private_chat_public_key[1][0] != 0 && private_chat_public_key[1][1] != 0 && private_chat_public_key[0] == private_chat){
  1056. var text = chat_val.substring(5).replace(/^\s+|\s+$/g, '');
  1057. var password = [];
  1058. for(var i = 0;i<10;i++){
  1059. password.push(Math.floor(Math.random()*100+50));
  1060. }
  1061. var text2 = [];
  1062. for(var i = 0;i<text.slice(0,400).length ;i++){
  1063. text2.push(password[i%password.length]^text.slice(0,400).charCodeAt(i));
  1064. }
  1065. pmlastmessage = text.slice(0,400);
  1066. 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)}]));
  1067. displayInChat("> "+username+": "+text,"#DA0808","#1EBCC1");
  1068.  
  1069. }
  1070. return "";
  1071. }
  1072. else if (chat_val.substring(1,10)=="ignorepm " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  1073. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  1074. if(ignorepmlist.includes(text)){
  1075. var index = ignorepmlist.indexOf(text);
  1076. ignorepmlist.splice(index,1);
  1077. displayInChat("You are not ignoring private messages from "+text+".","#DA0808","#1EBCC1");
  1078.  
  1079. }
  1080. else{
  1081. ignorepmlist.push(text);
  1082. displayInChat("You are now ignoring private messages from "+text+".","#DA0808","#1EBCC1");
  1083. }
  1084. return "";
  1085. }
  1086. else if (chat_val.substring(1,8)=="pmusers"){
  1087. pmusers = [];
  1088. SEND("42"+JSON.stringify([4,{"type":"request private chat users","from":username}]));
  1089. pmuserstimestamp = Date.now();
  1090. setTimeout(function(){if(pmusers.length == 0){displayInChat("You cannot private chat with anyone.","#DA0808","#1EBCC1");
  1091. }else{displayInChat("You can private chat with:","#DA0808","#1EBCC1");for(var i = 0;i<pmusers.length;i++){var code = 'Gwindow.private_chat = "'+pmusers[i]+'"; Gwindow.SEND("42"+JSON.stringify([4,{"type":"request public key","from":Gwindow.username,"to":Gwindow.private_chat}])); Gwindow.request_public_key_time_stamp = Date.now(); setTimeout(function(){if(Gwindow.private_chat_public_key[0]!=Gwindow.private_chat){Gwindow.displayInChat("Failed to connect to "+Gwindow.private_chat+".","#DA0808","#1EBCC1");Gwindow.private_chat = Gwindow.private_chat_public_key[0];}},1600);';displayInChat('<a onclick = \''+code+'\' href = "javascript:void(0);" style = "color:green">'+pmusers[i]+'</a>',"#DA0808","#1EBCC1",{sanitize:false}); Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true; Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true; Laster_message = lastmessage(); }}},1600);
  1092. return "";
  1093. }
  1094. else if (chat_val.substring(1,6)=="lobby"){
  1095. lobby();
  1096. return "";
  1097. }
  1098. else if (chat_val.substring(1,9)=="debugger"){
  1099. if(Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"] == "none"){
  1100. debuggeropen = true;
  1101. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="block";
  1102. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="none";
  1103. Gdocument.getElementById("ingamechatinputtext").style["display"] = "none";
  1104. }
  1105. else{
  1106. debuggeropen = false;
  1107. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="none";
  1108. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  1109. Gdocument.getElementById("ingamechatinputtext").style["display"] = "";
  1110. }
  1111. return "";
  1112. }
  1113. else if (chat_val.substring(1,6)=="team " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  1114. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  1115. if(text == "r"){Gdocument.getElementById("newbonklobby_redbutton").click();}
  1116. else if(text == "g"){Gdocument.getElementById("newbonklobby_greenbutton").click();}
  1117. else if(text == "y"){Gdocument.getElementById("newbonklobby_yellowbutton").click();}
  1118. else if(text == "b"){Gdocument.getElementById("newbonklobby_bluebutton").click();}
  1119. else if(text == "s"){Gdocument.getElementById("newbonklobby_specbutton").click();}
  1120. else if(text == "f"){Gdocument.getElementById("newbonklobby_ffabutton").click();}
  1121. return "";
  1122. }
  1123. else if (chat_val.substring(1,7)=="notify"){
  1124.  
  1125. npermissions = 1;
  1126. return "";
  1127. }
  1128. else if (chat_val.substring(1,11)=="stopnotify"){
  1129.  
  1130. npermissions = 0;
  1131. return "";
  1132. }
  1133. else if (chat_val.substring(1,5)=="help" || chat_val.substring(1,2)=="?"){
  1134. for(var i = 0;i<help.length;i++){
  1135. displayInChat(help[i],"#DA0808","#1EBCC1");
  1136.  
  1137. }
  1138. return "";
  1139. }
  1140. else if (chat_val.substring(1,9)=="advhelp " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  1141. var text = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  1142. if(typeof(adv_help[text])!='undefined'){
  1143. displayInChat(adv_help[text],"#DA0808","#1EBCC1");
  1144. }
  1145. return "";
  1146. }
  1147. else if(ishost){
  1148.  
  1149. if (chat_val.substring(1,5)=="next" && stopquickplay == 0){
  1150. if(shuffle){
  1151. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  1152. var available = [];
  1153. var availableindexes = [];
  1154. var notempty = false;
  1155. for(var i = 0; i<e.length;i++){
  1156. var a = false;
  1157. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  1158. available.push(a);
  1159. if(a){
  1160. availableindexes.push(i);
  1161. notempty = true;
  1162. }
  1163. }
  1164. if(notempty){
  1165.  
  1166. if(availableindexes.length!=1){
  1167. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  1168. }
  1169. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  1170. }
  1171. }
  1172. else{
  1173. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  1174. var available = [];
  1175. var availableindexes = [];
  1176. var notempty = false;
  1177. for(var i = 0; i<e.length;i++){
  1178. var a = false;
  1179. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  1180. available.push(a);
  1181. if(a){
  1182. availableindexes.push(i);
  1183. notempty = true;
  1184. }
  1185. }
  1186. if(notempty){
  1187. var above = [];
  1188. for(var i = 0;i<availableindexes.length;i++){
  1189. if(availableindexes[i]>quicki){
  1190. above.push(availableindexes[i]);
  1191. }
  1192. }
  1193. if(above.length>0){
  1194. quicki = above[0];
  1195. }
  1196. else{
  1197. quicki = availableindexes[0];
  1198. }
  1199. }
  1200. }
  1201. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  1202. displayInChat("Switched to next map.","#DA0808","#1EBCC1");
  1203. return "";
  1204.  
  1205. }
  1206. else if (chat_val.substring(1,9)=="freejoin"){
  1207. if(freejoin == false){
  1208. freejoin = true;
  1209. displayInChat("Freejoin is now on.","#DA0808","#1EBCC1");
  1210.  
  1211. }
  1212. else{
  1213. freejoin = false;
  1214. displayInChat("Freejoin is now off.","#DA0808","#1EBCC1");
  1215. }
  1216.  
  1217. return "";
  1218.  
  1219. }
  1220.  
  1221. else if (chat_val.substring(1,9)=="previous" && stopquickplay == 0){
  1222. if(shuffle){
  1223. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  1224. var available = [];
  1225. var availableindexes = [];
  1226. var notempty = false;
  1227. for(var i = 0; i<e.length;i++){
  1228. var a = false;
  1229. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  1230. available.push(a);
  1231. if(a){
  1232. availableindexes.push(i);
  1233. notempty = true;
  1234. }
  1235. }
  1236. if(notempty){
  1237.  
  1238. if(availableindexes.length!=1){
  1239. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  1240. }
  1241. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  1242. }
  1243. }
  1244. else{
  1245. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  1246. var available = [];
  1247. var availableindexes = [];
  1248. var notempty = false;
  1249. for(var i = 0; i<e.length;i++){
  1250. var a = false;
  1251. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  1252. available.push(a);
  1253. if(a){
  1254. availableindexes.push(i);
  1255. notempty = true;
  1256. }
  1257. }
  1258. if(notempty){
  1259. var above = [];
  1260. for(var i = 0;i<availableindexes.length;i++){
  1261. if(availableindexes[i]<quicki){
  1262. above.push(availableindexes[i]);
  1263. }
  1264. }
  1265. if(above.length>0){
  1266. quicki = above[above.length-1];
  1267. }
  1268. else{
  1269. quicki = availableindexes[availableindexes.length-1];
  1270. }
  1271. }
  1272. }
  1273. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  1274.  
  1275. displayInChat("Switched to previous map.","#DA0808","#1EBCC1");
  1276. return "";
  1277. }
  1278. else if (chat_val.substring(1,6)=="start" && chat_val.length == 6){
  1279. Gdocument.getElementById("newbonklobby_editorbutton").click();
  1280. if(recmodebool && ishost){
  1281. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  1282. if(mode == "" && defaultmode!="d"){
  1283. mode = defaultmode;
  1284. }
  1285. if(mode != ""){
  1286. RECIEVE('42[26,"b","'+mode+'"]');
  1287. }
  1288. }
  1289. Gdocument.getElementById("mapeditor_close").click();
  1290. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  1291. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  1292.  
  1293. return "";
  1294. }
  1295.  
  1296. else if (chat_val.substring(1,8)=="startqp" && stopquickplay == 1){
  1297. stopquickplay = 0;
  1298. quicki = 0;
  1299. displayInChat("Enabled quickplay.","#DA0808","#1EBCC1");
  1300. return "";
  1301. }
  1302. else if (chat_val.substring(1,7)=="stopqp" && stopquickplay == 0){
  1303. stopquickplay = 1;
  1304. quicki = 0;
  1305. displayInChat("Disabled quickplay.","#DA0808","#1EBCC1");
  1306. return "";
  1307. }
  1308.  
  1309. else if (chat_val.substring(1,5)=="ban " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  1310. banned.push(chat_val.substring(5).replace(/^\s+|\s+$/g, ''));
  1311. displayInChat("Banned "+chat_val.substring(5).replace(/^\s+|\s+$/g, '')+".","#DA0808","#1EBCC1");
  1312. return "/kick '" + chat_val.substring(5).replace(/^\s+|\s+$/g, '') + "'";
  1313. }
  1314. else if (chat_val.substring(1,6)=="kill " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  1315. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  1316. var keys = Object.keys(playerids);
  1317. var killid = undefined;
  1318. for(var i = 0; i<keys.length; i++){
  1319. if(playerids[keys[i]] == text){
  1320. killid = keys[i];
  1321. }
  1322. }
  1323. if(typeof(killid)!="undefined" && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  1324. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  1325. SEND('42[25,{"a":{"playersLeft":['+killid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  1326. RECIEVE('42[31,{"a":{"playersLeft":['+killid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  1327. }
  1328. return "";
  1329. }
  1330. else if (chat_val.substring(1,10)=="balanceA " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  1331. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  1332. if(!isNaN(parseInt(text))){
  1333. if(parseInt(text)>=-100 && parseInt(text)<=100){
  1334. var keys = Object.keys(playerids);
  1335. for(var i = 0; i<keys.length;i++){
  1336. SEND('42[29,{"sid":'+keys[i]+',"bal":'+text+'}]');
  1337. RECIEVE('42[36,'+keys[i]+','+text+']');
  1338. }
  1339. }
  1340. }
  1341. return "";
  1342.  
  1343. }
  1344. else if (chat_val.substring(1,7)=="moveA " && chat_val.replace(/^\s+|\s+$/g, '').length>=8){
  1345. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '');
  1346. var keys = Object.keys(playerids);
  1347. if(text == "f"){
  1348. for(var i = 0; i<keys.length;i++){
  1349. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":1}]')
  1350. }
  1351. }
  1352. else if(text == "b"){
  1353. for(var i = 0; i<keys.length;i++){
  1354. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":3}]')
  1355. }
  1356. }
  1357. else if(text == "g"){
  1358. for(var i = 0; i<keys.length;i++){
  1359. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":4}]')
  1360. }
  1361. }
  1362. else if(text == "r"){
  1363. for(var i = 0; i<keys.length;i++){
  1364. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":2}]')
  1365. }
  1366. }
  1367. else if(text == "y"){
  1368. for(var i = 0; i<keys.length;i++){
  1369. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":5}]')
  1370. }
  1371. }
  1372. else if(text == "s"){
  1373. for(var i = 0; i<keys.length;i++){
  1374. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":0}]')
  1375. }
  1376. }
  1377. return "";
  1378. }
  1379. else if (chat_val.substring(1,8)=="rounds " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  1380. var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '');
  1381. if(!isNaN(parseInt(text))){
  1382. text = parseInt(text).toString();
  1383. SEND('42[21,{"w":'+text+'}]');
  1384. RECIEVE('42[27,'+text+']');
  1385. }
  1386. return "";
  1387.  
  1388. }
  1389. else if (chat_val.substring(1,6)=="mode " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  1390. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  1391. var mode = "";
  1392. if(text == "arrows"){
  1393. mode = "ar";
  1394. displayInChat("Changed mode to arrows.","#DA0808","#1EBCC1");
  1395. }
  1396. else if(text == "death arrows"){
  1397. mode = "ard";
  1398. displayInChat("Changed mode to death arrows.","#DA0808","#1EBCC1");
  1399. }
  1400. else if(text == "grapple"){
  1401. mode = "sp";
  1402. displayInChat("Changed mode to grapple.","#DA0808","#1EBCC1");
  1403. }
  1404. else if(text == "classic"){
  1405. mode = "b";
  1406. displayInChat("Changed mode to classic.","#DA0808","#1EBCC1");
  1407.  
  1408. }
  1409. else{
  1410. displayInChat("Mode options:","#DA0808","#1EBCC1");
  1411. displayInChat("classic","#DA0808","#1EBCC1");
  1412. displayInChat("arrows","#DA0808","#1EBCC1");
  1413. displayInChat("death arrows","#DA0808","#1EBCC1");
  1414. displayInChat("grapple","#DA0808","#1EBCC1");
  1415. }
  1416. if(mode != ""){
  1417. SEND('42[20,{"ga":"b","mo":"'+mode+'"}]');
  1418. RECIEVE('42[26,"b","'+mode+'"]');
  1419. }
  1420. return "";
  1421.  
  1422. }
  1423. else if (chat_val.substring(1,13)=="defaultmode " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  1424. var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '');
  1425. if(text == "default"){
  1426. defaultmode = "";
  1427. displayInChat("Changed default mode to default.","#DA0808","#1EBCC1");
  1428. }
  1429. else if(text == "arrows"){
  1430. defaultmode = "ar";
  1431. displayInChat("Changed default mode to arrows.","#DA0808","#1EBCC1");
  1432. }
  1433. else if(text == "death arrows"){
  1434. defaultmode = "ard";
  1435. displayInChat("Changed default mode to death arrows.","#DA0808","#1EBCC1");
  1436. }
  1437. else if(text == "grapple"){
  1438. defaultmode = "sp";
  1439. displayInChat("Changed default mode to grapple.","#DA0808","#1EBCC1");
  1440. }
  1441. else if(text == "classic"){
  1442. defaultmode = "b";
  1443. displayInChat("Changed default mode to classic.","#DA0808","#1EBCC1");
  1444.  
  1445. }
  1446. else{
  1447. displayInChat("Default mode options:","#DA0808","#1EBCC1");
  1448. displayInChat("default","#DA0808","#1EBCC1");
  1449. displayInChat("classic","#DA0808","#1EBCC1");
  1450. displayInChat("arrows","#DA0808","#1EBCC1");
  1451. displayInChat("death arrows","#DA0808","#1EBCC1");
  1452. displayInChat("grapple","#DA0808","#1EBCC1");
  1453. }
  1454. return "";
  1455.  
  1456. }
  1457. else if (chat_val.substring(1,8)=="recmode"){
  1458. if(recmodebool == true){
  1459. recmodebool = false;
  1460. displayInChat("Recmode is now off.","#DA0808","#1EBCC1");
  1461.  
  1462. }
  1463. else{
  1464. recmodebool = true;
  1465. displayInChat("Recmode is now on.","#DA0808","#1EBCC1");
  1466.  
  1467. }
  1468.  
  1469. return "";
  1470.  
  1471. }
  1472. else if (chat_val.substring(1,8)=="shuffle"){
  1473. if(shuffle == true){
  1474. shuffle = false;
  1475. displayInChat("Shuffle is now off.","#DA0808","#1EBCC1");
  1476.  
  1477. }
  1478. else{
  1479. shuffle = true;
  1480. displayInChat("Shuffle is now on.","#DA0808","#1EBCC1");
  1481.  
  1482. }
  1483.  
  1484. return "";
  1485.  
  1486. }
  1487. else if(sandboxon){
  1488. if (chat_val.substring(1,11)=="addplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  1489. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  1490. if(!isNaN(parseInt(text))){
  1491. var text2 = parseInt(text);
  1492. if(text2>0){
  1493. for(var i = 0;i<text2;i++){
  1494. RECIEVE('42[4,'+sandboxid+',"0123456789abcdef","'+sandboxid.toString()+'",true,0,1,{"layers":[],"bc":'+Math.floor(Math.random() * 16777215).toString()+'}]');
  1495. sandboxplayerids[sandboxid] = sandboxid.toString();
  1496. sandboxid+=1;
  1497. }
  1498.  
  1499. }
  1500. }
  1501. return "";
  1502.  
  1503. }
  1504. else if (chat_val.substring(1,11)=="delplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  1505. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  1506. if(!isNaN(parseInt(text))){
  1507. var text2 = parseInt(text);
  1508. if(text2>0){
  1509. if(Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden"){
  1510. var jsonkeys = Object.keys(sandboxplayerids).reverse();
  1511. for(var i = 0;i<text2 && i<jsonkeys.length;i++){
  1512. RECIEVE('42[5,'+jsonkeys[i]+',0]');
  1513. delete sandboxplayerids[jsonkeys[i]];
  1514. }
  1515. }
  1516. else{
  1517. displayInChat("Cannot delete players while ingame.","#DA0808","#1EBCC1");
  1518. }
  1519.  
  1520. }
  1521. }
  1522. return "";
  1523. }
  1524. else if (chat_val.substring(1,7)=="copyme"){
  1525. if(sandboxcopyme == true){
  1526. displayInChat("Copyme is now off.","#DA0808","#1EBCC1");
  1527. sandboxcopyme = false;
  1528. }
  1529. else{
  1530. displayInChat("Copyme is now on.","#DA0808","#1EBCC1");
  1531. sandboxcopyme = true;
  1532. }
  1533.  
  1534. return "";
  1535. }
  1536. }
  1537. }
  1538. return chat_val;
  1539. };
  1540.  
  1541. scope.flag_manage = function(t){
  1542. var text = t;
  1543.  
  1544. if(rcaps_flag == true){
  1545. text = text.split('');
  1546. for(var i = 0; i<text.length;i++){
  1547. if(Math.floor(Math.random()*2)){
  1548. text[i] = text[i].toUpperCase();
  1549. }
  1550. else{
  1551. text[i] = text[i].toLowerCase();
  1552. }
  1553. }
  1554. text = text.join('');
  1555. }
  1556. if(space_flag == true){
  1557. text = text.split('').join(' ')
  1558. }
  1559. if(number_flag == true){
  1560. text = text.replace(/[t|T][Oo]+/g,"2");
  1561. text = text.replace(/[f|F][o|O][r|R]/g,"4");
  1562. text = text.replace(/[a|A][t|T][e|E]/g,"8");
  1563. text = text.replace(/[e|E]/g,"3");
  1564. text = text.replace(/[a|A]/g,"4");
  1565. text = text.replace(/[o|O]/g,"0");
  1566. text = text.replace(/[s|S]/g,"5");
  1567. text = text.replace(/[i|I|l|L]/g,"1");
  1568. }
  1569. return text;
  1570. };
  1571. Gdocument.getElementById("newbonklobby_chat_input").onkeydown = function(e){
  1572. if(e.keyCode==13){
  1573.  
  1574. var chat_val = Gdocument.getElementById("newbonklobby_chat_input").value;
  1575.  
  1576. if (chat_val!="" && chat_val[0]=="/"){
  1577.  
  1578. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  1579. chat(commandhandle(chat_val));
  1580. }
  1581. else{
  1582. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  1583. chat(flag_manage(chat_val));
  1584. }
  1585.  
  1586. }
  1587. };
  1588. Gdocument.getElementById("ingamechatinputtext").onkeydown = function(e){
  1589. if(e.keyCode==13){
  1590.  
  1591. var chat_val = Gdocument.getElementById("ingamechatinputtext").value;
  1592.  
  1593. if (chat_val!="" && chat_val[0]=="/"){
  1594.  
  1595. Gdocument.getElementById("ingamechatinputtext").value = "";
  1596. chat(commandhandle(chat_val));
  1597. }
  1598. else{
  1599. Gdocument.getElementById("ingamechatinputtext").value = "";
  1600. chat(flag_manage(chat_val));
  1601. }
  1602. }
  1603. };
  1604. scope.Last_message = "";
  1605. scope.Laster_message = "";
  1606. scope.new_message = false;
  1607. scope.changed_chat = false;
  1608. scope.interval = setInterval(timeout123,100);
  1609.  
  1610. scope.hotkeys = function(e){
  1611. if(e.repeat){return;}
  1612. var keycode = e.code;
  1613. if(e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  1614. if(ishost){
  1615. if(keycode == "KeyE"){
  1616. if(Gdocument.getElementById("newbonklobby").style["display"] == "block"){
  1617. Gdocument.getElementById("newbonklobby_editorbutton").click();
  1618. }
  1619. else if(Gdocument.getElementById("mapeditorcontainer").style["display"] == "block"){
  1620. Gdocument.getElementById("mapeditor_close").click();
  1621. }
  1622. e.preventDefault();
  1623.  
  1624. }
  1625. else if(keycode == "KeyT"){
  1626. Gdocument.getElementById("newbonklobby_teamsbutton").click();
  1627. e.preventDefault();
  1628. }
  1629. else if(keycode == "KeyM"){
  1630. Gdocument.getElementById("newbonklobby_modebutton").click();
  1631. e.preventDefault();
  1632. }
  1633. else if(keycode == "KeyK"){
  1634. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  1635. Gdocument.getElementById("pretty_top_exit").click();
  1636. }
  1637. e.preventDefault();
  1638. }
  1639. else if(keycode == "KeyS"){
  1640. Gdocument.getElementById("newbonklobby_editorbutton").click();
  1641. if(recmodebool && ishost){
  1642. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  1643. if(mode == "" && defaultmode!="d"){
  1644. mode = defaultmode;
  1645. }
  1646. if(mode != ""){
  1647. RECIEVE('42[26,"b","'+mode+'"]');
  1648. }
  1649. }
  1650. Gdocument.getElementById("mapeditor_close").click();
  1651. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  1652. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  1653. e.preventDefault();
  1654. }
  1655. else if(keycode == "KeyD"){
  1656. if(stopquickplay == 0){
  1657. if(shuffle){
  1658. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  1659. var available = [];
  1660. var availableindexes = [];
  1661. var notempty = false;
  1662. for(var i = 0; i<e2.length;i++){
  1663. var a = false;
  1664. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  1665. available.push(a);
  1666. if(a){
  1667. availableindexes.push(i);
  1668. notempty = true;
  1669. }
  1670. }
  1671. if(notempty){
  1672.  
  1673. if(availableindexes.length!=1){
  1674. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  1675. }
  1676. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  1677. }
  1678. }
  1679. else{
  1680. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  1681. var available = [];
  1682. var availableindexes = [];
  1683. var notempty = false;
  1684. for(var i = 0; i<e2.length;i++){
  1685. var a = false;
  1686. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  1687. available.push(a);
  1688. if(a){
  1689. availableindexes.push(i);
  1690. notempty = true;
  1691. }
  1692. }
  1693. if(notempty){
  1694. var above = [];
  1695. for(var i = 0;i<availableindexes.length;i++){
  1696. if(availableindexes[i]>quicki){
  1697. above.push(availableindexes[i]);
  1698. }
  1699. }
  1700. if(above.length>0){
  1701. quicki = above[0];
  1702. }
  1703. else{
  1704. quicki = availableindexes[0];
  1705. }
  1706. }
  1707. }
  1708. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  1709. }
  1710. e.preventDefault();
  1711. }
  1712. else if(keycode == "KeyA"){
  1713. if(stopquickplay == 0){
  1714. if(shuffle){
  1715. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  1716. var available = [];
  1717. var availableindexes = [];
  1718. var notempty = false;
  1719. for(var i = 0; i<e2.length;i++){
  1720. var a = false;
  1721. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  1722. available.push(a);
  1723. if(a){
  1724. availableindexes.push(i);
  1725. notempty = true;
  1726. }
  1727. }
  1728. if(notempty){
  1729.  
  1730. if(availableindexes.length!=1){
  1731. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  1732. }
  1733. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  1734. }
  1735. }
  1736. else{
  1737. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  1738. var available = [];
  1739. var availableindexes = [];
  1740. var notempty = false;
  1741. for(var i = 0; i<e2.length;i++){
  1742. var a = false;
  1743. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  1744. available.push(a);
  1745. if(a){
  1746. availableindexes.push(i);
  1747. notempty = true;
  1748. }
  1749. }
  1750. if(notempty){
  1751. var above = [];
  1752. for(var i = 0;i<availableindexes.length;i++){
  1753. if(availableindexes[i]<quicki){
  1754. above.push(availableindexes[i]);
  1755. }
  1756. }
  1757. if(above.length>0){
  1758. quicki = above[above.length-1];
  1759. }
  1760. else{
  1761. quicki = availableindexes[availableindexes.length-1];
  1762. }
  1763. }
  1764. }
  1765. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  1766. }
  1767. e.preventDefault();
  1768. }
  1769. else if(keycode == "KeyQ"){
  1770. if(stopquickplay == 1){
  1771. stopquickplay = 0;
  1772. quicki = 0;
  1773. displayInChat("Enabled quickplay.","#DA0808","#1EBCC1");
  1774. }
  1775. else{
  1776. stopquickplay = 1;
  1777. quicki = 0;
  1778. displayInChat("Disabled quickplay.","#DA0808","#1EBCC1");
  1779. }
  1780. e.preventDefault();
  1781. }
  1782. else if(keycode == "KeyR"){
  1783. if(recmodebool == true){
  1784. recmodebool = false;
  1785. displayInChat("Recmode is now off.","#DA0808","#1EBCC1");
  1786.  
  1787. }
  1788. else{
  1789. recmodebool = true;
  1790. displayInChat("Recmode is now on.","#DA0808","#1EBCC1");
  1791.  
  1792. }
  1793. }
  1794. else if(keycode == "KeyF"){
  1795. if(freejoin == false){
  1796. freejoin = true;
  1797. displayInChat("Freejoin is now on.","#DA0808","#1EBCC1");
  1798.  
  1799. }
  1800. else{
  1801. freejoin = false;
  1802. displayInChat("Freejoin is now off.","#DA0808","#1EBCC1");
  1803. }
  1804. e.preventDefault();
  1805. }
  1806. }
  1807. else{
  1808. if(keycode == "KeyE"){
  1809. e.preventDefault();
  1810. }
  1811. else if(keycode == "KeyT"){
  1812. e.preventDefault();
  1813. }
  1814. else if(keycode == "KeyM"){
  1815. e.preventDefault();
  1816. }
  1817. else if(keycode == "KeyK"){
  1818. e.preventDefault();
  1819. }
  1820. else if(keycode == "KeyS"){
  1821. e.preventDefault();
  1822. }
  1823. else if(keycode == "KeyD"){
  1824. e.preventDefault();
  1825. }
  1826. else if(keycode == "KeyA"){
  1827. e.preventDefault();
  1828. }
  1829. else if(keycode == "KeyQ"){
  1830. e.preventDefault();
  1831. }
  1832. else if(keycode == "KeyF"){
  1833. e.preventDefault();
  1834. }
  1835. else if(keycode == "KeyR"){
  1836. e.preventDefault();
  1837. }
  1838.  
  1839. }
  1840. if(keycode == "KeyL"){
  1841. lobby();
  1842. e.preventDefault();
  1843. }
  1844. if(keycode == "KeyC"){
  1845. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  1846. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]=="0px"){
  1847. Gdocument.getElementById("ingamechatcontent").style["max-height"]="250px";
  1848. }
  1849. else{
  1850. Gdocument.getElementById("ingamechatcontent").style["max-height"]="0px";
  1851. }
  1852. }
  1853. e.preventDefault();
  1854. }
  1855. if(keycode == "KeyI"){
  1856. if(Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"] == "none"){
  1857. debuggeropen = true;
  1858. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="block";
  1859. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="none";
  1860. Gdocument.getElementById("ingamechatinputtext").style["display"] = "none";
  1861. }
  1862. else{
  1863. debuggeropen = false;
  1864. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="none";
  1865. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  1866. Gdocument.getElementById("ingamechatinputtext").style["display"] = "";
  1867. }
  1868. e.preventDefault();
  1869. }
  1870. }
  1871. if(!e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  1872. if(keycode == "Slash"){
  1873. if(Gdocument.getElementById("newbonklobby").style["display"]=="block" && Gdocument.getElementById("newbonklobby_chat_input").value == "" && Gdocument.getElementById("maploadwindowcontainer").style["display"]!="block" && Gdocument.getElementById("newbonklobby_chat_input").style["display"]==""){
  1874. Gdocument.getElementById("newbonklobby_chat_input").value = "/";
  1875. if(Gdocument.getElementById("newbonklobby_chat_input").style["pointer-events"] == "none"){
  1876. fire("keydown",{keyCode:13});
  1877. }
  1878. else{
  1879. Gdocument.getElementById("newbonklobby_chat_input").focus();
  1880. }
  1881. e.preventDefault();
  1882.  
  1883. }
  1884. else if(Gdocument.getElementById("ingamechatinputtext").style["visibility"]=="visible" && Gdocument.getElementById("ingamechatinputtext").style["display"]=="" && Gdocument.getElementById("mapeditorcontainer").style["display"]!="block" && Gdocument.getElementById("ingamechatinputtext").value == ""){
  1885. Gdocument.getElementById("ingamechatinputtext").value = "/";
  1886. if(!Gdocument.getElementById("ingamechatinputtext").classList.value.includes("ingamechatinputtextbg")){
  1887. fire("keydown",{keyCode:13});
  1888. }
  1889. else{
  1890. Gdocument.getElementById("ingamechatinputtext").focus();
  1891. }
  1892. e.preventDefault();
  1893.  
  1894. }
  1895. }
  1896. }
  1897. };
  1898.  
  1899. Gdocument.onkeydown = hotkeys;
  1900.  
  1901. Gwindow.addEventListener('resize',function(e){
  1902. debuggermenu.style["width"] = Gdocument.getElementById("bonkiocontainer").style["width"];
  1903. debuggermenu.style["height"] = Gdocument.getElementById("bonkiocontainer").style["height"];
  1904. scope.width = parseInt(Gdocument.getElementById("bonkiocontainer").style["width"])-20;
  1905. scope.height = parseInt(Gdocument.getElementById("bonkiocontainer").style["height"])-210;
  1906. logmenu.style["width"] = width.toString()+"px";
  1907. logmenu.style["height"] = height.toString()+"px";
  1908. logmenutopleft.style["width"] = (width/2).toString()+"px";
  1909. logmenutopright.style["width"] = (width/2).toString()+"px";
  1910. logmenutopright.style["left"] = (width/2).toString()+"px";
  1911. debuggerinput.style["width"] = width.toString()+"px";
  1912. debuggerinput.style["top"] = (height+90).toString()+"px";
  1913. debuggersendrecieve.style["top"] = (height+120).toString()+"px";
  1914. debuggerpausebutton.style["top"] = (height+150).toString()+"px";
  1915. debuggereval.style["width"] = (width-150).toString()+"px";
  1916. debuggereval.style["top"] = (height+120).toString()+"px";},true);
  1917.  
  1918.  
  1919. function timeout123() {
  1920. updateWssLog();
  1921. if(Gdocument.getElementById("gamerenderer").style["visibility"]=="hidden"){
  1922. Gdocument.getElementById("ingamechatcontent").style["max-height"]="250px";
  1923. }
  1924. if(Gdocument.getElementById("sm_connectingContainer").style["visibility"] == "hidden"){
  1925. var chatbox = Gdocument.getElementById("newbonklobby_chat_content");
  1926. while (chatbox.firstChild) {
  1927. chatbox.removeChild(chatbox.firstChild);
  1928. }
  1929. rcaps_flag = false;
  1930. space_flag = false;
  1931. number_flag = false;
  1932. echo_list = [];
  1933. scroll = false;
  1934. stopquickplay = 1;
  1935. checkboxhidden = false;
  1936. freejoin = false;
  1937. shuffle = false;
  1938. defaultmode = "";
  1939. recmodebool = false;
  1940. playerids = {};
  1941. ishost = false;
  1942. sandboxplayerids = {};
  1943. sandboxcopyme = false;
  1944. sandboxon = false;
  1945. sandboxid = 1;
  1946. if(chatlog[chatlog.length-1]!="ROOM END"){
  1947. chatlog.push("ROOM END");
  1948. }
  1949. }
  1950. else{
  1951. if(chatlog[chatlog.length-1]=="ROOM END"){
  1952. chatlog.push("ROOM START");
  1953. }
  1954. }
  1955.  
  1956. if(Gdocument.getElementById("newbonklobby").style["display"]=="block"){
  1957. Gdocument.getElementById("ingamechatinputtext").style["visibility"]="hidden";
  1958. }
  1959. else{
  1960. Gdocument.getElementById("ingamechatinputtext").style["visibility"]="visible";
  1961.  
  1962. }
  1963. mode = Gdocument.getElementById("newbonklobby_modetext").textContent;
  1964. var userlist = Gdocument.getElementsByClassName("newbonklobby_playerentry_name");
  1965. users = [];
  1966. for(var i = 0;i<userlist.length;i++){
  1967. users.push(userlist[i].textContent);
  1968. }
  1969. if(Gdocument.getElementsByClassName('newbonklobby_settings_button brownButton brownButton_classic buttonShadow brownButtonDisabled').length == 0){
  1970. ishost = true;
  1971. }
  1972. else{
  1973. ishost = false;
  1974. }
  1975.  
  1976. if(Gdocument.getElementById("pretty_top_name")!=null){
  1977. username = Gdocument.getElementById("pretty_top_name").textContent;
  1978. }
  1979. try{
  1980. Last_message = lastmessage()
  1981. } catch{
  1982. Last_message = "";
  1983. }
  1984. if (Laster_message != Last_message){
  1985. Laster_message = Last_message;
  1986. if(changed_chat==false){
  1987. new_message = true;
  1988. }
  1989. else{
  1990. changed_chat = false;
  1991. }
  1992. }
  1993. if(new_message){
  1994. chatlog.push(Last_message);
  1995. if(freejoin && Last_message.startsWith("* ") && Last_message.endsWith(" has joined the game") && ishost){
  1996.  
  1997. var userjoined = Last_message.substring(2,Last_message.length-20);
  1998.  
  1999. if(Gdocument.getElementById("newbonklobby").style["display"] != "block"){
  2000. mess2 = Gdocument.getElementById("ingamechatinputtext").value;
  2001. Gdocument.getElementById("ingamechatinputtext").value = "";
  2002. Gdocument.getElementById("newbonklobby_editorbutton").click();
  2003. Gdocument.getElementById("mapeditor_close").click();
  2004. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  2005. Gdocument.getElementById("ingamechatinputtext").value = mess2;
  2006.  
  2007. }
  2008. var playing = Gdocument.getElementsByClassName("newbonklobby_playerentry newbonklobby_playerentry_half");
  2009. var inplaying = false;
  2010. for(var i = 0;i<playing.length;i++){
  2011. if(userjoined == playing[i].children[1].textContent){
  2012. inplaying = true;
  2013. break;
  2014. }
  2015. }
  2016.  
  2017. if(playing.length<=2 && inplaying){
  2018. Gdocument.getElementById("newbonklobby_editorbutton").click();
  2019. Gdocument.getElementById("mapeditor_close").click();
  2020. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  2021. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  2022. if(transitioning == true){
  2023. canceled = true;
  2024. }
  2025. }
  2026.  
  2027. }
  2028. var lm = "";
  2029. try{
  2030. lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  2031. if(typeof(lm[0].parentElement.style["parsed"]) == 'undefined'){
  2032. if (lm[0].className == "newbonklobby_chat_msg_colorbox"){
  2033. lm[2].innerHTML = urlify(lm[2].innerHTML);
  2034. Laster_message = lastmessage();
  2035. lm[0].parentElement.style["parsed"] = true;
  2036. }
  2037. if (lm[0].className == "newbonklobby_chat_status"){
  2038. lm[0].innerHTML = urlify(lm[0].innerHTML);
  2039. Laster_message = lastmessage();
  2040. lm[0].parentElement.style["parsed"] = true;
  2041. }
  2042. }
  2043. }
  2044. catch{
  2045. lm = "";
  2046. }
  2047.  
  2048. if(Last_message.indexOf("@"+username)!=-1 && npermissions == 1){
  2049. if(Notification.requestPermission()){
  2050. var n = new Notification(Last_message);
  2051. }
  2052. }
  2053.  
  2054. try{
  2055. lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  2056. if(typeof(lm[0].parentElement.style["parsed"])=='undefined'){
  2057. if(lm[0].className == "ingamechatname"){
  2058. lm[1].innerHTML = urlify(lm[1].innerHTML);
  2059. Laster_message = lastmessage();
  2060. lm[0].parentElement.style["parsed"] = true;
  2061. }
  2062. if(lm[0].className == ""){
  2063. lm[0].innerHTML = urlify(lm[0].innerHTML);
  2064. Laster_message = lastmessage();
  2065. lm[0].parentElement.style["parsed"] = true;
  2066. }
  2067. }
  2068. }
  2069. catch{
  2070. lm = "";
  2071. }
  2072. for(i=0;i<echo_list.length;i++){
  2073. if(Last_message.substring(0,echo_list[i].length+2) == echo_list[i]+": "){
  2074. message = Last_message.substring(echo_list[i].length+2);
  2075. chat(flag_manage(message));
  2076. }
  2077. }
  2078.  
  2079. }
  2080. if (ishost==true && new_message){
  2081. for(i=0;i<banned.length;i++){
  2082. if(Last_message.startsWith("* "+banned[i]+" has joined the game")){
  2083. chat("/kick '"+banned[i]+"'");
  2084. }
  2085. }
  2086. }
  2087. if(ishost && stopquickplay == 0){
  2088. if(checkboxhidden){
  2089. checkboxhidden = false;
  2090. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  2091. for(var i = 0; i<classes.length;i++){
  2092. classes[i].style["display"] = "block";
  2093. classes[i].className = "quickplaycheckbox quickplaychecked";
  2094. }
  2095. Gdocument.getElementById('clearallcheckboxes').style["display"] = "block";
  2096.  
  2097. }
  2098. if(Gdocument.getElementById("ingamewinner").style["visibility"]=="inherit" && stopquickplay == 0 && dontswitch == false){
  2099. if(shuffle){
  2100. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  2101. var available = [];
  2102. var availableindexes = [];
  2103. var notempty = false;
  2104. for(var i = 0; i<e.length;i++){
  2105. var a = false;
  2106. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  2107. available.push(a);
  2108. if(a){
  2109. availableindexes.push(i);
  2110. notempty = true;
  2111. }
  2112. }
  2113. if(notempty){
  2114.  
  2115. if(availableindexes.length!=1){
  2116. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  2117. }
  2118. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  2119. }
  2120. }
  2121. else{
  2122. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  2123. var available = [];
  2124. var availableindexes = [];
  2125. var notempty = false;
  2126. for(var i = 0; i<e.length;i++){
  2127. var a = false;
  2128. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  2129. available.push(a);
  2130. if(a){
  2131. availableindexes.push(i);
  2132. notempty = true;
  2133. }
  2134. }
  2135. if(notempty){
  2136. var above = [];
  2137. for(var i = 0;i<availableindexes.length;i++){
  2138. if(availableindexes[i]>quicki){
  2139. above.push(availableindexes[i]);
  2140. }
  2141. }
  2142. if(above.length>0){
  2143. quicki = above[0];
  2144. }
  2145. else{
  2146. quicki = availableindexes[0];
  2147. }
  2148. }
  2149. }
  2150. transitioning = true;
  2151. map(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  2152.  
  2153. dontswitch = true;
  2154. setTimeout(function(){Gdocument.getElementById("ingamewinner").style["visibility"]="hidden"; dontswitch = false;},timedelay);
  2155.  
  2156. }
  2157. }
  2158. else{
  2159. if(!checkboxhidden){
  2160. checkboxhidden = true;
  2161. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  2162. for(var i = 0; i<classes.length;i++){
  2163. classes[i].style["display"] = "none";
  2164. classes[i].className = "quickplaycheckbox quickplayunchecked";
  2165. }
  2166. Gdocument.getElementById('clearallcheckboxes').style["display"] = "none";
  2167. }
  2168. }
  2169. new_message = false;
  2170. };
  2171. });

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址