Bonk Commands

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

目前为 2023-01-03 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Bonk Commands
  3. // @namespace https://greasyfork.org/en/scripts/451341-bonk-commands
  4. // @version 10.9
  5. // @description Adds lots of commands to bonk.io. Type /? or /help in bonk chat to get started.
  6. // @author LEGENDBOSS123 + left paren + mastery3
  7. // @match https://bonk.io/*
  8. // @run-at document-idle
  9. // @grant none
  10. // @unwrap
  11. // ==/UserScript==
  12. function BonkCommandsScriptInjector(f){
  13. if(window.location == window.parent.location){
  14. if(document.readyState == "complete"){f();}
  15. else{document.addEventListener('readystatechange',function(){setTimeout(f,1500);});}
  16. }
  17. }
  18.  
  19. BonkCommandsScriptInjector(function(){
  20. var scope = window;
  21.  
  22. scope.Gwindow = document.getElementById("maingameframe").contentWindow;
  23. scope.Gdocument = document.getElementById("maingameframe").contentDocument;
  24. Gwindow.Gwindow = window;
  25. Gwindow.Gdocument = document;
  26.  
  27. scope.link2pastebin = "https://pastebin.com/2b8XqqYu";
  28. scope.link2greasyfork = "https://greasyfork.org/en/scripts/451341-bonk-commands";
  29.  
  30. if(typeof(scope.injectedBonkCommandsScript)=='undefined'){
  31. scope.injectedBonkCommandsScript = true;
  32. }
  33. else{
  34. for (var i = 0; i < 100000; i++){
  35. clearInterval(i);
  36. }
  37. }
  38. scope.GENERATE_COPRIME_NUMBER = function(mini = 0,maxi = 0,coprimewith = 0,choices = []){
  39. if(choices.length == 0){
  40. for(var i = mini;i<maxi+1;i++){
  41. choices.push(i);
  42. }
  43. }
  44. firstTry = choices[Math.floor(Math.random()*choices.length)];
  45. for(var i = 2; i<firstTry+1;i++){
  46. if(firstTry%i == 0 && coprimewith%i == 0){
  47. choices.splice(choices.indexOf(firstTry),1);
  48. if(choices.length == 0){
  49. return 0;
  50. }
  51. return GENERATE_COPRIME_NUMBER(mini,maxi,coprimewith,choices);
  52. }
  53. }
  54. return firstTry;
  55. };
  56. scope.GENERATE_PRIME_NUMBER = function(mini = 0,maxi = 0,choices = []){
  57. if(choices.length == 0){
  58. for(var i = mini;i<maxi+1;i++){
  59. choices.push(i);
  60. }
  61. }
  62. firstTry = choices[Math.floor(Math.random()*choices.length)];
  63. for(var i = 2; i<Math.floor(Math.sqrt(firstTry)+1);i++){
  64. if(i!=firstTry){
  65. if(firstTry%i == 0){
  66. choices.splice(choices.indexOf(firstTry),1);
  67. if(choices.length == 0){
  68. return 0;
  69. }
  70. return GENERATE_PRIME_NUMBER(mini,maxi,choices);
  71. }
  72. }
  73. }
  74. return firstTry;
  75. };
  76. scope.SHUFFLE_LIST = function(x){
  77. var nl = x.slice();
  78. for(var i = nl.length - 1;i>0;i--){
  79. var r = Math.floor(Math.random()*(i+1));
  80. var t = nl[i];
  81. nl[i] = nl[r];
  82. nl[r] = t;
  83. }
  84. return nl;
  85. };
  86. scope.GENERATE_KEYS = function(){
  87. interval = [];
  88. for(var i = 100;i<301;i++){
  89. interval.push(i);
  90. }
  91. random_prime = [GENERATE_PRIME_NUMBER(0,0,choices = interval),0];
  92. interval.splice(interval.indexOf(random_prime[0]),1);
  93. random_prime[1] = GENERATE_PRIME_NUMBER(0,0,choices = interval);
  94.  
  95. n = random_prime[0]*random_prime[1];
  96. n2 = (random_prime[0]-1)*(random_prime[1]-1);
  97.  
  98. e = GENERATE_COPRIME_NUMBER(2,n2-1,n2);
  99. d = 0;
  100. redo = true;
  101. for(var i = 0;i<1000000;i++){
  102. if((e*i-1)%n2 == 0 && i!=e){
  103. d = i;
  104. redo = false;
  105. break;
  106. }
  107. }
  108. if(redo){
  109. return GENERATE_KEYS();
  110. }
  111. else{
  112. return [[n,e],[n,d]];
  113. }
  114.  
  115. };
  116. scope.CRYPT_NUMBER = function(key, data){
  117.  
  118. result = 1;
  119.  
  120. for(var i = 0;i<key[1];i++){
  121. result*=data;
  122. result = result%key[0];
  123. }
  124. return result%key[0];
  125.  
  126. };
  127.  
  128. scope.CRYPT_MESSAGE = function(key,data){
  129. var resulttext = [];
  130. for(var i = 0;i<data.length;i++){
  131. resulttext.push(CRYPT_NUMBER(key,data[i]));
  132. }
  133. return resulttext;
  134.  
  135. };
  136. if(typeof(scope.textdecoder)=='undefined'){scope.textdecoder = new Gwindow.TextDecoder;}
  137. if(typeof(scope.textencoder)=='undefined'){scope.textencoder = new Gwindow.TextEncoder;}
  138.  
  139. class bytebuffer2 {
  140. constructor() {
  141. var g1d = [arguments];
  142. this.index = 0;
  143. this.buffer = new ArrayBuffer(100*1024);
  144. this.view = new DataView(this.buffer);
  145. this.implicitClassAliasArray = [];
  146. this.implicitStringArray = [];
  147. this.bodgeCaptureZoneDataIdentifierArray = [];
  148. }
  149. readByte() {
  150. var N0H = [arguments];
  151. N0H[4] = this.view.getUint8(this.index);
  152. this.index += 1;
  153. return N0H[4];
  154. }
  155. writeByte(z0w) {
  156. var v8$ = [arguments];
  157. this.view.setUint8(this.index, v8$[0][0]);
  158. this.index += 1;
  159. }
  160. readInt() {
  161. var A71 = [arguments];
  162. A71[6] = this.view.getInt32(this.index);
  163. this.index += 4;
  164. return A71[6];
  165. }
  166. writeInt(W6i) {
  167. var p5u = [arguments];
  168. this.view.setInt32(this.index, p5u[0][0]);
  169. this.index += 4;
  170. }
  171. readShort() {
  172. var R1R = [arguments];
  173. R1R[9] = this.view.getInt16(this.index);
  174. this.index += 2;
  175. return R1R[9];
  176. }
  177. writeShort(H8B) {
  178. var d_3 = [arguments];
  179. this.view.setInt16(this.index, d_3[0][0]);
  180. this.index += 2;
  181. }
  182. readUint() {
  183. var W2$ = [arguments];
  184. W2$[8] = this.view.getUint32(this.index);
  185. this.index += 4;
  186. return W2$[8];
  187. }
  188. writeUint(B2X) {
  189. var f8B = [arguments];
  190. this.view.setUint32(this.index, f8B[0][0]);
  191. this.index += 4;
  192. }
  193. readBoolean() {
  194. var h6P = [arguments];
  195. h6P[6] = this.readByte();
  196. return h6P[6] == 1;
  197. }
  198. writeBoolean(Y3I) {
  199. var l79 = [arguments];
  200. if (l79[0][0]) {
  201. this.writeByte(1);
  202. } else {
  203. this.writeByte(0);
  204. }
  205. }
  206. readDouble() {
  207. var V60 = [arguments];
  208. V60[4] = this.view.getFloat64(this.index);
  209. this.index += 8;
  210. return V60[4];
  211. }
  212. writeDouble(z4Z) {
  213. var O41 = [arguments];
  214. this.view.setFloat64(this.index, O41[0][0]);
  215. this.index += 8;
  216. }
  217. readFloat() {
  218. var I0l = [arguments];
  219. I0l[5] = this.view.getFloat32(this.index);
  220. this.index += 4;
  221. return I0l[5];
  222. }
  223. writeFloat(y4B) {
  224. var B0v = [arguments];
  225. this.view.setFloat32(this.index, B0v[0][0]);
  226. this.index += 4;
  227. }
  228. readUTF() {
  229. var d6I = [arguments];
  230. d6I[8] = this.readByte();
  231. d6I[7] = this.readByte();
  232. d6I[9] = d6I[8] * 256 + d6I[7];
  233. d6I[1] = new Uint8Array(d6I[9]);
  234. for (d6I[6] = 0; d6I[6] < d6I[9]; d6I[6]++) {
  235. d6I[1][d6I[6]] = this.readByte();
  236. }
  237. return textdecoder.decode(d6I[1]);
  238. }
  239. writeUTF(L3Z) {
  240. var Z75 = [arguments];
  241. Z75[4] = textencoder.encode(Z75[0][0]);
  242. Z75[3] = Z75[4].length;
  243. Z75[5] = Math.floor(Z75[3]/256);
  244. Z75[8] = Z75[3] % 256;
  245. this.writeByte(Z75[5]);
  246. this.writeByte(Z75[8]);
  247. Z75[7] = this;
  248. Z75[4].forEach(I_O);
  249. function I_O(s0Q, H4K, j$o) {
  250. var N0o = [arguments];
  251. Z75[7].writeByte(N0o[0][0]);
  252. }
  253. }
  254. toBase64() {
  255. var P4$ = [arguments];
  256. P4$[4] = "";
  257. P4$[9] = new Uint8Array(this.buffer);
  258. P4$[8] = this.index;
  259. for (P4$[7] = 0; P4$[7] < P4$[8]; P4$[7]++) {
  260. P4$[4] += String.fromCharCode(P4$[9][P4$[7]]);
  261. }
  262. return Gwindow.btoa(P4$[4]);
  263. }
  264. fromBase64(W69, A8Q) {
  265. var o0n = [arguments];
  266. o0n[8] = Gwindow.pako;
  267. o0n[6] = Gwindow.atob(o0n[0][0]);
  268. o0n[9] = o0n[6].length;
  269. o0n[4] = new Uint8Array(o0n[9]);
  270. for (o0n[1] = 0; o0n[1] < o0n[9]; o0n[1]++) {
  271. o0n[4][o0n[1]] = o0n[6].charCodeAt(o0n[1]);
  272. }
  273. if (o0n[0][1] === true) {
  274. o0n[5] = o0n[8].inflate(o0n[4]);
  275. o0n[4] = o0n[5];
  276. }
  277. this.buffer = o0n[4].buffer.slice(
  278. o0n[4].byteOffset,
  279. o0n[4].byteLength + o0n[4].byteOffset
  280. );
  281. this.view = new DataView(this.buffer);
  282. this.index = 0;
  283. }
  284. };
  285.  
  286. if(typeof(scope.originalSend)=='undefined'){scope.originalSend = Gwindow.WebSocket.prototype.send;}
  287. if(typeof(scope.originalXMLOpen)=='undefined'){scope.originalXMLOpen = Gwindow.XMLHttpRequest.prototype.open;}
  288. if(typeof(scope.originalXMLSend)=='undefined'){scope.originalXMLSend = Gwindow.XMLHttpRequest.prototype.send;}
  289. if(typeof(scope.searchrequested)=='undefined'){scope.searchrequested = false;}
  290.  
  291. if(typeof(scope.bonkwss)=='undefined'){scope.bonkwss = 0;}
  292. if(typeof(scope.chatlog)=='undefined'){scope.chatlog = ["ROOM START"];}
  293. if(typeof(scope.wsssendrecievelog)=='undefined'){scope.wsssendrecievelog = [];}
  294. if(typeof(scope.wsssendlog)=='undefined'){scope.wsssendlog = [];}
  295. if(typeof(scope.wssrecievelog)=='undefined'){scope.wssrecievelog = [];}
  296. if(typeof(scope.wsslogpaused)=='undefined'){scope.wsslogpaused = false;}
  297. if(typeof(scope.debuggeropen)=='undefined'){scope.debuggeropen = false;}
  298. if(typeof(scope.debuggercount)=='undefined'){scope.debuggercount = true;}
  299. if(typeof(scope.packetcount)=='undefined'){scope.packetcount = 0;}
  300. if(typeof(scope.requestedmaps)=='undefined'){scope.requestedmaps = [];}
  301. if(typeof(scope.maponclick)=='undefined'){scope.maponclick = 0;}
  302. if(typeof(scope.LZString)=='undefined'){scope.LZString = Gwindow.LZString;}
  303. if(typeof(scope.PSON)=='undefined'){scope.PSON = Gwindow.dcodeIO.PSON;}
  304. if(typeof(scope.bytebuffer)=='undefined'){scope.bytebuffer = Gwindow.dcodeIO.ByteBuffer;}
  305. if(typeof(scope.speech)=='undefined'){scope.speech = new SpeechSynthesisUtterance();speech.pitch = 0.75;}
  306. if(typeof(scope.sayer)=='undefined'){scope.sayer = speechSynthesis;sayer.volume = 0.5;sayer.rate = 1.25;}
  307.  
  308. if(typeof(scope.ISpsonpair)=='undefined'){scope.ISpsonpair = new Gwindow.dcodeIO.PSON.StaticPair(["physics", "shapes", "fixtures", "bodies", "bro", "joints", "ppm", "lights", "spawns", "lasers", "capZones", "type", "w", "h", "c", "a", "v", "l", "s", "sh", "fr", "re", "de", "sn", "fc", "fm", "f", "d", "n", "bg", "lv", "av", "ld", "ad", "fr", "bu", "cf", "rv", "p", "d", "bf", "ba", "bb", "aa", "ab", "axa", "dr", "em", "mmt", "mms", "ms", "ut", "lt", "New body", "Box Shape", "Circle Shape", "Polygon Shape", "EdgeChain Shape", "priority", "Light", "Laser", "Cap Zone", "BG Shape", "Background Layer", "Rotate Joint", "Slider Joint", "Rod Joint", "Gear Joint", 65535, 16777215]);}
  309. if(typeof(scope.sandboxon)=='undefined'){scope.sandboxon = false;}
  310. if(typeof(scope.sandboxid)=='undefined'){scope.sandboxid = 1;}
  311. if(typeof(scope.playerids)=='undefined'){scope.playerids = {};}
  312. if(typeof(scope.myid)=='undefined'){scope.myid = -1;}
  313. if(typeof(scope.hostid)=='undefined'){scope.hostid = -1;}
  314. if(typeof(scope.sandboxplayerids)=='undefined'){scope.sandboxplayerids = {};}
  315. if(typeof(scope.originalMapLoad)=='undefined'){scope.originalMapLoad = Gdocument.getElementById("maploadwindowmapscontainer").appendChild;}
  316. if(typeof(scope.originalLobbyChat)=='undefined'){scope.originalLobbyChat = Gdocument.getElementById("newbonklobby_chat_content").appendChild;}
  317. if(typeof(scope.originalIngameChat)=='undefined'){scope.originalIngameChat = Gdocument.getElementById("ingamechatcontent").appendChild;}
  318. 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];}
  319. if(Gdocument.getElementById("maploadtypedropdowntitlerequested") == null){
  320. scope.clearmaprequests = Gdocument.createElement("div");
  321. clearmaprequests.id = "clearmaprequests";
  322. clearmaprequests.classList.value = "brownButton brownButton_classic buttonShadow";
  323. clearmaprequests.textContent = "Clear";
  324. clearmaprequests.style["position"] = "absolute";
  325. clearmaprequests.style["display"] = "none";
  326. if(typeof(ishost)!='undefined'){
  327. if(ishost && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS"){
  328. clearmaprequests.style["display"] = "block";
  329. }
  330. }
  331. clearmaprequests.style["right"] = "306px";
  332. clearmaprequests.style["top"] = "57px";
  333. clearmaprequests.style["height"] = "23px";
  334. clearmaprequests.style["width"] = "47px";
  335. clearmaprequests.style["line-height"] = "23px";
  336. clearmaprequests.style["font-size"] = "14px";
  337. clearmaprequests.addEventListener("click",function(){
  338. requestedmaps = [];
  339. Gdocument.getElementById("maploadwindowstatustext").style["visibility"] = "inherit";
  340. Gdocument.getElementById("maploadwindowstatustext").textContent = "No Maps";
  341. while(Gdocument.getElementById("maploadwindowmapscontainer").children.length>0){
  342. Gdocument.getElementById("maploadwindowmapscontainer").removeChild(Gdocument.getElementById("maploadwindowmapscontainer").firstChild);
  343. }
  344. });
  345. Gdocument.getElementById("maploadwindow").insertBefore(clearmaprequests,Gdocument.getElementById("maploadwindowsearchinput"));
  346. scope.refreshmaprequests = Gdocument.createElement("div");
  347. refreshmaprequests.id = "refreshmaprequests";
  348. refreshmaprequests.classList.value = "brownButton brownButton_classic buttonShadow";
  349. refreshmaprequests.textContent = "Refresh";
  350. refreshmaprequests.style["position"] = "absolute";
  351. refreshmaprequests.style["display"] = "none";
  352. if(typeof(ishost)!='undefined'){
  353. if(ishost && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS"){
  354. refreshmaprequests.style["display"] = "block";
  355. }
  356. }
  357. refreshmaprequests.style["right"] = "357px";
  358. refreshmaprequests.style["top"] = "57px";
  359. refreshmaprequests.style["height"] = "23px";
  360. refreshmaprequests.style["width"] = "47px";
  361. refreshmaprequests.style["line-height"] = "23px";
  362. refreshmaprequests.style["font-size"] = "14px";
  363. refreshmaprequests.addEventListener("click",function(){
  364. Gdocument.getElementById("maploadtypedropdowntitle").textContent = dropdownrequested.textContent;
  365. Gdocument.getElementById("maploadwindowsearchinput").value = "";
  366. dropdownrequested.style["display"] = "none";
  367. clearmaprequests.style["display"] = "block";
  368. refreshmaprequests.style["display"] = "block";
  369. Gdocument.getElementById("maploadwindowhotnessslider").style["visibility"] = "hidden";
  370. Gdocument.getElementById("maploadwindowsearchoptions").style["visibility"] = "hidden";
  371. searchrequested = true;
  372. Gdocument.getElementById("maploadwindowsearchbutton").click();
  373.  
  374. Gdocument.getElementById("maploadtypedropdowntitle").textContent = "MAP REQUESTS";
  375. });
  376. Gdocument.getElementById("maploadwindow").insertBefore(refreshmaprequests,Gdocument.getElementById("maploadwindowsearchinput"));
  377.  
  378. scope.dropdownrequested = Gdocument.createElement("div");
  379. dropdownrequested.classList = "dropdown-option dropdown_classic";
  380. dropdownrequested.style["display"] = "none";
  381. dropdownrequested.id = "maploadtypedropdowntitlerequested";
  382.  
  383. if(Gdocument.getElementById("maploadtypedropdownoption10").style["display"] == "block"){
  384. dropdownrequested.style["display"] = "block";
  385. }
  386. dropdownrequested.textContent = "MAP REQUESTS";
  387. dropdownrequested.onclick = function(){
  388. Gdocument.getElementById("maploadtypedropdowntitle").textContent = dropdownrequested.textContent;
  389. Gdocument.getElementById("maploadwindowsearchinput").value = "";
  390. dropdownrequested.style["display"] = "none";
  391. clearmaprequests.style["display"] = "block";
  392. refreshmaprequests.style["display"] = "block";
  393. Gdocument.getElementById("maploadwindowhotnessslider").style["visibility"] = "hidden";
  394. Gdocument.getElementById("maploadwindowsearchoptions").style["visibility"] = "hidden";
  395. searchrequested = true;
  396. Gdocument.getElementById("maploadwindowsearchbutton").click();
  397.  
  398. Gdocument.getElementById("maploadtypedropdowntitle").textContent = "MAP REQUESTS";
  399. };
  400. (new MutationObserver(function(){if(Gdocument.getElementById("maploadtypedropdownoption10").style["display"] == "none"){ dropdownrequested.style["display"] = "none"; clearmaprequests.style["display"] = "none";refreshmaprequests.style["display"] = "none"; } else{ dropdownrequested.style["display"] = "block";}})).observe(Gdocument.getElementById("maploadtypedropdownoption10"),{attributes:true,childList:true});
  401. Gdocument.getElementById("maploadtypedropdown").insertBefore(dropdownrequested,Gdocument.getElementById("maploadtypedropdownoption1"));
  402. };
  403.  
  404. function sandboxonclick(){
  405. Gdocument.getElementById("roomlistcreatewindowmaxplayers").value = 1;
  406. Gdocument.getElementById("roomlistcreatewindowunlistedcheckbox").checked = true;
  407. Gdocument.getElementById("roomlistcreatecreatebutton").click();
  408. sandboxon = true;
  409. }
  410. function checkboxclearbuttononclick(){
  411. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  412. var e = true;
  413. for(var i = 0; i<classes.length;i++){
  414. if(classes[i].checked == true){
  415. e = false
  416. }
  417. classes[i].checked = false;
  418. }
  419. if(e){
  420. for(var i = 0; i<classes.length;i++){
  421. classes[i].checked = true;
  422. }
  423. }
  424. }
  425. Gdocument.getElementById("ingamechatcontent").__defineGetter__("childElementCount",function(){return this.children.length/50;});
  426. if(Gdocument.getElementById("classic_mid_sandbox")==null){
  427. Gdocument.getElementById("roomlistrefreshbutton").click();
  428. scope.sandboxbutton = Gdocument.createElement("div");
  429. sandboxbutton.id = "classic_mid_sandbox";
  430. sandboxbutton.classList.value = "brownButton brownButton_classic classic_mid_buttons";
  431. sandboxbutton.textContent = "Sandbox";
  432. sandboxbutton.addEventListener("click",sandboxonclick);
  433. Gdocument.getElementById("classic_mid").insertBefore(sandboxbutton,Gdocument.getElementById("classic_mid_news"));
  434.  
  435. }
  436. if(Gdocument.getElementById("clearallcheckboxes")==null){
  437. scope.checkboxclearbutton = Gdocument.createElement("div");
  438. checkboxclearbutton.id = "clearallcheckboxes";
  439. checkboxclearbutton.classList.value = "brownButton brownButton_classic buttonShadow";
  440. checkboxclearbutton.textContent = "On/Off";
  441. checkboxclearbutton.style["position"] = "absolute";
  442. checkboxclearbutton.style["display"] = "none";
  443. if(typeof(ishost)!='undefined'){
  444. if(ishost && stopquickplay == 0){
  445. checkboxclearbutton.style["display"] = "block";
  446. }
  447. }
  448. checkboxclearbutton.style["right"] = "255px";
  449. checkboxclearbutton.style["top"] = "57px";
  450. checkboxclearbutton.style["height"] = "23px";
  451. checkboxclearbutton.style["width"] = "47px";
  452. checkboxclearbutton.style["line-height"] = "23px";
  453. checkboxclearbutton.style["font-size"] = "13px";
  454. checkboxclearbutton.addEventListener("click",checkboxclearbuttononclick);
  455. Gdocument.getElementById("maploadwindow").insertBefore(checkboxclearbutton,Gdocument.getElementById("maploadwindowsearchinput"));
  456.  
  457. }
  458. scope.holdloadbuttonTimeout = [];
  459. scope.holdloadbutton = function(){
  460. var scrollcount = 0;
  461. var mapwindow = Gdocument.getElementById("maploadwindowmapscontainer");
  462. mapwindow.scroll(0,mapwindow.scrollHeight);
  463. };
  464.  
  465. if(Gdocument.getElementById("mapwindowloadall")==null){
  466. scope.loadall = Gdocument.createElement("div");
  467. loadall.id = "mapwindowloadall";
  468. loadall.classList.value = "brownButton brownButton_classic buttonShadow";
  469. loadall.textContent = "Load";
  470. loadall.style["position"] = "absolute";
  471. loadall.style["display"] = "block";
  472. loadall.style["left"] = "204px";
  473. loadall.style["top"] = "57px";
  474. loadall.style["height"] = "23px";
  475. loadall.style["width"] = "34px";
  476. loadall.style["line-height"] = "23px";
  477. loadall.style["font-size"] = "12px";
  478. var repeat = function(){holdloadbutton();holdloadbuttonTimeout.push(setTimeout(repeat,25));};
  479. loadall.onmousedown = function(){repeat();};
  480. loadall.onmouseup = function(){for(var i = 0; i<holdloadbuttonTimeout.length; i++){clearTimeout(holdloadbuttonTimeout[i]);}};
  481. loadall.onmouseout = function(){for(var i = 0; i<holdloadbuttonTimeout.length; i++){clearTimeout(holdloadbuttonTimeout[i]);}};
  482.  
  483. Gdocument.getElementById("maploadwindow").insertBefore(loadall,Gdocument.getElementById("maploadwindowsearchinput"));
  484.  
  485. }
  486. if(Gdocument.getElementById("BonkCommandsDebuggerContainer")==null){
  487. Gdocument.getElementById("leaveconfirmwindow").style["z-index"]=3;
  488. scope.debuggermenu = Gdocument.createElement("div");
  489. debuggermenu.id = "BonkCommandsDebuggerContainer";
  490. debuggermenu.style["position"] = "absolute";
  491. debuggermenu.style["display"] = "none";
  492. if(typeof(debuggeropen)!='undefined'){
  493. if(debuggeropen){
  494. debuggermenu.style["display"] = "block";
  495. }
  496. }
  497. debuggermenu.style["width"] = Gdocument.getElementById("bonkiocontainer").style["width"];
  498. debuggermenu.style["height"] = Gdocument.getElementById("bonkiocontainer").style["height"];
  499.  
  500. debuggermenu.style["background"] = "rgb(26, 39, 51)";
  501.  
  502. scope.width = parseInt(Gdocument.getElementById("bonkiocontainer").style["width"])-20;
  503. scope.height = parseInt(Gdocument.getElementById("bonkiocontainer").style["height"])-210;
  504.  
  505. scope.logmenu = Gdocument.createElement("div");
  506. logmenu.id = "BonkCommandsWebSocketLog";
  507. logmenu.style["position"] = "absolute";
  508. logmenu.style["width"] = width.toString()+"px";
  509. logmenu.style["height"] = height.toString()+"px";
  510. logmenu.style["top"] = "80px";
  511. logmenu.style["left"] = "10px";
  512. logmenu.style["background"] = "rgb(207, 216, 220)";
  513. scope.logmenutopleft = Gdocument.createElement("div");
  514. logmenutopleft.id = "BonkCommandsWebSocketLog";
  515. logmenutopleft.style["position"] = "absolute";
  516. logmenutopleft.textContent = "Sending";
  517. logmenutopleft.classList = "newbonklobby_boxtop newbonklobby_boxtop_classic";
  518. logmenutopleft.style["width"] = (width/2).toString()+"px";
  519. logmenutopleft.style["height"] = "30px";
  520. logmenutopleft.style["top"] = "-30px";
  521. logmenutopleft.style["background"] = "rgb(0, 150, 136)";
  522. logmenu.appendChild(logmenutopleft);
  523. scope.logmenutopright = Gdocument.createElement("div");
  524. logmenutopright.id = "BonkCommandsWebSocketLog";
  525. logmenutopright.style["position"] = "absolute";
  526. logmenutopright.textContent = "Recieving";
  527. logmenutopright.classList = "newbonklobby_boxtop newbonklobby_boxtop_classic";
  528. logmenutopright.style["width"] = (width/2).toString()+"px";
  529. logmenutopright.style["height"] = "30px";
  530. logmenutopright.style["left"] = (width/2).toString()+"px";
  531. logmenutopright.style["top"] = "-30px";
  532. logmenutopright.style["background"] = "rgb(0, 150, 136)";
  533. logmenu.appendChild(logmenutopright);
  534. scope.logmenutable = Gdocument.createElement("table");
  535. logmenutable.id = "BonkCommandsWebSocketTable";
  536. logmenutable.style["position"] = "absolute";
  537. logmenutable.style["border-spacing"] = "0px";
  538. logmenutable.style["font-size"] = "12px";
  539. logmenutable.style["display"] = "table-cell";
  540. logmenutable.style["width"] = "50%";
  541. logmenutable.style["height"] = "100%";
  542. logmenutable.style["table-layout"] = "fixed";
  543. logmenutable.style["overflow-y"] = "scroll";
  544.  
  545. scope.logmenutable2 = Gdocument.createElement("table");
  546. logmenutable2.id = "BonkCommandsWebSocketTable2";
  547. logmenutable2.style["position"] = "absolute";
  548. logmenutable2.style["width"] = "50%";
  549. logmenutable2.style["left"] = "50%";
  550. logmenutable2.style["font-size"] = "12px";
  551. logmenutable2.style["display"] = "table-cell";
  552. logmenutable2.style["height"] = "100%";
  553. logmenutable2.style["table-layout"] = "fixed";
  554. logmenutable2.style["overflow-y"] = "scroll";
  555. logmenutable2.style["border-spacing"] = "0px";
  556. scope.leftsync = false;
  557. scope.rightsync = false;
  558. logmenutable2.onscroll = function(){
  559. if(!leftsync){
  560. rightsync = true;
  561. logmenutable.scrollTop = this.scrollTop;
  562. }
  563. else{
  564. leftsync = false;
  565. }
  566. };
  567. logmenutable.onscroll = function(){
  568. if(!rightsync){
  569. leftsync = true;
  570. logmenutable2.scrollTop = this.scrollTop;
  571. }
  572. else{
  573. rightsync = false
  574. }
  575. };
  576. logmenu.appendChild(logmenutable);
  577. logmenu.appendChild(logmenutable2);
  578. debuggermenu.appendChild(logmenu);
  579. scope.debuggermenuclose = Gdocument.createElement("div");
  580. debuggermenuclose.id = "debuggerclose";
  581. debuggermenuclose.classList = "windowCloseButton brownButton brownButton_classic buttonShadow";
  582. debuggermenuclose.style["position"] = "absolute";
  583. debuggermenuclose.style["top"] = "40px";
  584. debuggermenuclose.style["right"] = "5px";
  585. debuggermenuclose.onclick = function(){debuggeropen = false;debuggermenu.style["display"] = "none";Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  586. Gdocument.getElementById("ingamechatinputtext").style["display"] = "";};
  587. debuggermenu.appendChild(debuggermenuclose);
  588. scope.debuggerform = Gdocument.createElement("form");
  589. debuggerform.autocomplete = "off";
  590. scope.debuggerinput = Gdocument.createElement("input");
  591. debuggerinput.style["position"] = "absolute";
  592. debuggerinput.style["width"] = width.toString()+"px";
  593. debuggerinput.style["left"] = "10px";
  594. debuggerinput.style["top"] = (height+90).toString()+"px";
  595. debuggerinput.style["font-size"] = "12px";
  596. debuggerinput.style["height"] = "20px";
  597. debuggerform.appendChild(debuggerinput);
  598. scope.debuggersendrecieve = Gdocument.createElement("div");
  599. debuggersendrecieve.style["position"] = "absolute";
  600. debuggersendrecieve.style["width"] = "140px";
  601. debuggersendrecieve.style["left"] = "10px";
  602. debuggersendrecieve.style["top"] = (height+120).toString()+"px";
  603. debuggersendrecieve.style["font-size"] = "15px";
  604. debuggersendrecieve.style["height"] = "20px";
  605. debuggersendrecieve.classList = "brownButton brownButton_classic buttonShadow";
  606. debuggersendrecieve.textContent = "Send";
  607. debuggersendrecieve.value = 0;
  608. debuggersendrecieve.onclick = function(){if(this.value == 0){this.textContent = "Recieve";this.value = 1;}else{this.textContent = "Send";this.value = 0;}};
  609.  
  610. debuggermenu.appendChild(debuggersendrecieve);
  611. scope.debuggerpausebutton = Gdocument.createElement("div");
  612. debuggerpausebutton.style["position"] = "absolute";
  613. debuggerpausebutton.style["width"] = "140px";
  614. debuggerpausebutton.style["left"] = "10px";
  615. debuggerpausebutton.style["top"] = (height+150).toString()+"px";
  616. debuggerpausebutton.style["font-size"] = "15px";
  617. debuggerpausebutton.style["height"] = "20px";
  618. debuggerpausebutton.classList = "brownButton brownButton_classic buttonShadow";
  619. debuggerpausebutton.textContent = "Pause";
  620. debuggerpausebutton.value = 0;
  621. debuggerpausebutton.onclick = function(){if(this.value == 0){this.textContent = "Play";this.value = 1;wsslogpaused = true}else{this.textContent = "Pause";this.value = 0;wsslogpaused = false;}};
  622.  
  623. debuggermenu.appendChild(debuggerpausebutton);
  624. scope.debuggereval = Gdocument.createElement("input");
  625. debuggereval.style["position"] = "absolute";
  626. debuggereval.style["width"] = (width-150).toString()+"px";
  627. debuggereval.style["right"] = "10px";
  628. debuggereval.style["top"] = (height+120).toString()+"px";
  629. debuggereval.style["font-size"] = "12px";
  630. debuggereval.style["height"] = "20px";
  631. debuggereval.addEventListener("keypress",function(e){if(e.repeat){return;}if(e.code == "Enter"){if(debuggersendrecieve.value == 0){SEND(this.value);}else{RECIEVE(this.value);}}});
  632. debuggerform.appendChild(debuggereval);
  633. debuggermenu.appendChild(debuggerform);
  634. Gdocument.getElementById("newbonkgamecontainer").appendChild(debuggermenu);
  635.  
  636. }
  637. scope.ISdecode = function(rawdata) {
  638. rawdata_caseflipped = "";
  639. for (i = 0; i < rawdata.length; i++) {
  640. if (i <= 100 && rawdata.charAt(i) === rawdata.charAt(i).toLowerCase()) {
  641. rawdata_caseflipped += rawdata.charAt(i).toUpperCase();
  642. } else if (i <= 100 && rawdata.charAt(i) === rawdata.charAt(i).toUpperCase()) {
  643. rawdata_caseflipped += rawdata.charAt(i).toLowerCase();
  644. } else {
  645. rawdata_caseflipped += rawdata.charAt(i);
  646. }
  647. }
  648.  
  649. data_deLZd = LZString.decompressFromEncodedURIComponent(rawdata_caseflipped);
  650. databuffer = bytebuffer.fromBase64(data_deLZd);
  651. data = ISpsonpair.decode(databuffer.buffer);
  652. return data;
  653. };
  654. scope.ISencode = function(obj) {
  655. data = ISpsonpair.encode(obj);
  656. b64 = data.toBase64();
  657. lzd = LZString.compressToEncodedURIComponent(b64);
  658.  
  659. caseflipped = "";
  660. for (i = 0; i < lzd.length; i++) {
  661. if (i <= 100 && lzd.charAt(i) === lzd.charAt(i).toLowerCase()) {
  662. caseflipped += lzd.charAt(i).toUpperCase();
  663. } else if (i <= 100 && lzd.charAt(i) === lzd.charAt(i).toUpperCase()) {
  664. caseflipped += lzd.charAt(i).toLowerCase();
  665. } else {
  666. caseflipped += lzd.charAt(i);
  667. }
  668. }
  669.  
  670.  
  671. return caseflipped;
  672. };
  673. scope.decodeIS = function(x){
  674. return ISdecode(x);
  675. };
  676. scope.encodeIS = function(x){
  677. return ISencode(x);
  678. };
  679.  
  680.  
  681. encodeToDatabase = function(mapObject) {
  682. var H_B = [arguments];
  683. H_B[2] = new bytebuffer2;
  684. H_B[5] = mapObject.physics;
  685. mapObject.v = 13;
  686. H_B[2].writeShort(mapObject.v);
  687. H_B[2].writeBoolean(mapObject.s.re);
  688. H_B[2].writeBoolean(mapObject.s.nc);
  689. H_B[2].writeShort(mapObject.s.pq);
  690. H_B[2].writeFloat(mapObject.s.gd);
  691. H_B[2].writeBoolean(mapObject.s.fl);
  692. H_B[2].writeUTF(mapObject.m.rxn);
  693. H_B[2].writeUTF(mapObject.m.rxa);
  694. H_B[2].writeUint(mapObject.m.rxid);
  695. H_B[2].writeShort(mapObject.m.rxdb);
  696. H_B[2].writeUTF(mapObject.m.n);
  697. H_B[2].writeUTF(mapObject.m.a);
  698. H_B[2].writeUint(mapObject.m.vu);
  699. H_B[2].writeUint(mapObject.m.vd);
  700. H_B[2].writeShort(mapObject.m.cr.length);
  701. for (
  702. H_B[62] = 0;
  703. H_B[62] < mapObject.m.cr.length;
  704. H_B[62]++
  705. ) {
  706. H_B[2].writeUTF(mapObject.m.cr[H_B[62]]);
  707. }
  708. H_B[2].writeUTF(mapObject.m.mo);
  709. H_B[2].writeInt(mapObject.m.dbid);
  710. H_B[2].writeBoolean(mapObject.m.pub);
  711. H_B[2].writeInt(mapObject.m.dbv);
  712. H_B[2].writeShort(H_B[5].ppm);
  713. H_B[2].writeShort(H_B[5].bro.length);
  714. for (H_B[31] = 0; H_B[31] < H_B[5].bro.length; H_B[31]++) {
  715. H_B[2].writeShort(H_B[5].bro[H_B[31]]);
  716. }
  717. H_B[2].writeShort(H_B[5].shapes.length);
  718. for (H_B[61] = 0; H_B[61] < H_B[5].shapes.length; H_B[61]++) {
  719. H_B[3] = H_B[5].shapes[H_B[61]];
  720. if (H_B[3].type == "bx") {
  721. H_B[2].writeShort(1);
  722. H_B[2].writeDouble(H_B[3].w);
  723. H_B[2].writeDouble(H_B[3].h);
  724. H_B[2].writeDouble(H_B[3].c[0]);
  725. H_B[2].writeDouble(H_B[3].c[1]);
  726. H_B[2].writeDouble(H_B[3].a);
  727. H_B[2].writeBoolean(H_B[3].sk);
  728. }
  729. if (H_B[3].type == "ci") {
  730. H_B[2].writeShort(2);
  731. H_B[2].writeDouble(H_B[3].r);
  732. H_B[2].writeDouble(H_B[3].c[0]);
  733. H_B[2].writeDouble(H_B[3].c[1]);
  734. H_B[2].writeBoolean(H_B[3].sk);
  735. }
  736. if (H_B[3].type == "po") {
  737. H_B[2].writeShort(3);
  738. H_B[2].writeDouble(H_B[3].s);
  739. H_B[2].writeDouble(H_B[3].a);
  740. H_B[2].writeDouble(H_B[3].c[0]);
  741. H_B[2].writeDouble(H_B[3].c[1]);
  742. H_B[2].writeShort(H_B[3].v.length);
  743. for (H_B[45] = 0; H_B[45] < H_B[3].v.length; H_B[45]++) {
  744. H_B[2].writeDouble(H_B[3].v[H_B[45]][0]);
  745. H_B[2].writeDouble(H_B[3].v[H_B[45]][1]);
  746. }
  747. }
  748. }
  749. H_B[2].writeShort(H_B[5].fixtures.length);
  750. for (H_B[88] = 0; H_B[88] < H_B[5].fixtures.length; H_B[88]++) {
  751. H_B[4] = H_B[5].fixtures[H_B[88]];
  752. H_B[2].writeShort(H_B[4].sh);
  753. H_B[2].writeUTF(H_B[4].n);
  754. if (H_B[4].fr === null) {
  755. H_B[2].writeDouble(Number.MAX_VALUE);
  756. } else {
  757. H_B[2].writeDouble(H_B[4].fr);
  758. }
  759. if (H_B[4].fp === null) {
  760. H_B[2].writeShort(0);
  761. }
  762. if (H_B[4].fp === false) {
  763. H_B[2].writeShort(1);
  764. }
  765. if (H_B[4].fp === true) {
  766. H_B[2].writeShort(2);
  767. }
  768. if (H_B[4].re === null) {
  769. H_B[2].writeDouble(Number.MAX_VALUE);
  770. } else {
  771. H_B[2].writeDouble(H_B[4].re);
  772. }
  773. if (H_B[4].de === null) {
  774. H_B[2].writeDouble(Number.MAX_VALUE);
  775. } else {
  776. H_B[2].writeDouble(H_B[4].de);
  777. }
  778. H_B[2].writeUint(H_B[4].f);
  779. H_B[2].writeBoolean(H_B[4].d);
  780. H_B[2].writeBoolean(H_B[4].np);
  781. H_B[2].writeBoolean(H_B[4].ng);
  782. H_B[2].writeBoolean(H_B[4].ig);
  783. }
  784. H_B[2].writeShort(H_B[5].bodies.length);
  785. for (H_B[41] = 0; H_B[41] < H_B[5].bodies.length; H_B[41]++) {
  786. H_B[9] = H_B[5].bodies[H_B[41]];
  787. H_B[2].writeUTF(H_B[9].type);
  788. H_B[2].writeUTF(H_B[9].n);
  789. H_B[2].writeDouble(H_B[9].p[0]);
  790. H_B[2].writeDouble(H_B[9].p[1]);
  791. H_B[2].writeDouble(H_B[9].a);
  792. H_B[2].writeDouble(H_B[9].fric);
  793. H_B[2].writeBoolean(H_B[9].fricp);
  794. H_B[2].writeDouble(H_B[9].re);
  795. H_B[2].writeDouble(H_B[9].de);
  796. H_B[2].writeDouble(H_B[9].lv[0]);
  797. H_B[2].writeDouble(H_B[9].lv[1]);
  798. H_B[2].writeDouble(H_B[9].av);
  799. H_B[2].writeDouble(H_B[9].ld);
  800. H_B[2].writeDouble(H_B[9].ad);
  801. H_B[2].writeBoolean(H_B[9].fr);
  802. H_B[2].writeBoolean(H_B[9].bu);
  803. H_B[2].writeDouble(H_B[9].cf.x);
  804. H_B[2].writeDouble(H_B[9].cf.y);
  805. H_B[2].writeDouble(H_B[9].cf.ct);
  806. H_B[2].writeBoolean(H_B[9].cf.w);
  807. H_B[2].writeShort(H_B[9].f_c);
  808. H_B[2].writeBoolean(H_B[9].f_1);
  809. H_B[2].writeBoolean(H_B[9].f_2);
  810. H_B[2].writeBoolean(H_B[9].f_3);
  811. H_B[2].writeBoolean(H_B[9].f_4);
  812. H_B[2].writeBoolean(H_B[9].f_p);
  813. H_B[2].writeShort(H_B[9].fx.length);
  814. for (H_B[78] = 0; H_B[78] < H_B[9].fx.length; H_B[78]++) {
  815. H_B[2].writeShort(H_B[9].fx[H_B[78]]);
  816. }
  817. }
  818. H_B[2].writeShort(mapObject.spawns.length);
  819. for (
  820. H_B[74] = 0;
  821. H_B[74] < mapObject.spawns.length;
  822. H_B[74]++
  823. ) {
  824. H_B[6] = mapObject.spawns[H_B[74]];
  825. H_B[2].writeDouble(H_B[6].x);
  826. H_B[2].writeDouble(H_B[6].y);
  827. H_B[2].writeDouble(H_B[6].xv);
  828. H_B[2].writeDouble(H_B[6].yv);
  829. H_B[2].writeShort(H_B[6].priority);
  830. H_B[2].writeBoolean(H_B[6].r);
  831. H_B[2].writeBoolean(H_B[6].f);
  832. H_B[2].writeBoolean(H_B[6].b);
  833. H_B[2].writeBoolean(H_B[6].gr);
  834. H_B[2].writeBoolean(H_B[6].ye);
  835. H_B[2].writeUTF(H_B[6].n);
  836. }
  837. H_B[2].writeShort(mapObject.capZones.length);
  838. for (
  839. H_B[48] = 0;
  840. H_B[48] < mapObject.capZones.length;
  841. H_B[48]++
  842. ) {
  843. H_B[1] = mapObject.capZones[H_B[48]];
  844. H_B[2].writeUTF(H_B[1].n);
  845. H_B[2].writeDouble(H_B[1].l);
  846. H_B[2].writeShort(H_B[1].i);
  847. H_B[2].writeShort(H_B[1].ty);
  848. }
  849. H_B[2].writeShort(H_B[5].joints.length);
  850. for (H_B[69] = 0; H_B[69] < H_B[5].joints.length; H_B[69]++) {
  851. H_B[8] = H_B[5].joints[H_B[69]];
  852. if (H_B[8].type == "rv") {
  853. H_B[2].writeShort(1);
  854. H_B[2].writeDouble(H_B[8].d.la);
  855. H_B[2].writeDouble(H_B[8].d.ua);
  856. H_B[2].writeDouble(H_B[8].d.mmt);
  857. H_B[2].writeDouble(H_B[8].d.ms);
  858. H_B[2].writeBoolean(H_B[8].d.el);
  859. H_B[2].writeBoolean(H_B[8].d.em);
  860. H_B[2].writeDouble(H_B[8].aa[0]);
  861. H_B[2].writeDouble(H_B[8].aa[1]);
  862. }
  863. if (H_B[8].type == "d") {
  864. H_B[2].writeShort(2);
  865. H_B[2].writeDouble(H_B[8].d.fh);
  866. H_B[2].writeDouble(H_B[8].d.dr);
  867. H_B[2].writeDouble(H_B[8].aa[0]);
  868. H_B[2].writeDouble(H_B[8].aa[1]);
  869. H_B[2].writeDouble(H_B[8].ab[0]);
  870. H_B[2].writeDouble(H_B[8].ab[1]);
  871. }
  872. if (H_B[8].type == "lpj") {
  873. H_B[2].writeShort(3);
  874. H_B[2].writeDouble(H_B[8].pax);
  875. H_B[2].writeDouble(H_B[8].pay);
  876. H_B[2].writeDouble(H_B[8].pa);
  877. H_B[2].writeDouble(H_B[8].pf);
  878. H_B[2].writeDouble(H_B[8].pl);
  879. H_B[2].writeDouble(H_B[8].pu);
  880. H_B[2].writeDouble(H_B[8].plen);
  881. H_B[2].writeDouble(H_B[8].pms);
  882. }
  883. if (H_B[8].type == "lsj") {
  884. H_B[2].writeShort(4);
  885. H_B[2].writeDouble(H_B[8].sax);
  886. H_B[2].writeDouble(H_B[8].say);
  887. H_B[2].writeDouble(H_B[8].sf);
  888. H_B[2].writeDouble(H_B[8].slen);
  889. }
  890. H_B[2].writeShort(H_B[8].ba);
  891. H_B[2].writeShort(H_B[8].bb);
  892. H_B[2].writeBoolean(H_B[8].d.cc);
  893. H_B[2].writeDouble(H_B[8].d.bf);
  894. H_B[2].writeBoolean(H_B[8].d.dl);
  895. }
  896. H_B[15] = H_B[2].toBase64();
  897. H_B[30] = LZString.compressToEncodedURIComponent(H_B[15]);
  898. return H_B[30];
  899. };
  900.  
  901.  
  902.  
  903.  
  904.  
  905. scope.decodeFromDatabase = function(map) {
  906. var a8k = [arguments];
  907. b64mapdata = LZString.decompressFromEncodedURIComponent(map);
  908. var binaryReader = new bytebuffer2;
  909. binaryReader.fromBase64(b64mapdata, false);
  910. map = { "v": 1, "s": { "re": false, "nc": false, "pq": 1, "gd": 25, "fl": false }, "physics": { "shapes": [], "fixtures": [], "bodies": [], "bro": [], "joints": [], "ppm": 12 }, "spawns": [], "capZones": [], "m": { "a": "noauthor", "n": "noname", "dbv": 2, "dbid": -1, "authid": -1, "date": "", "rxid": 0, "rxn": "", "rxa": "", "rxdb": 1, "cr": [], "pub": false, "mo": "" } };
  911. map.v = binaryReader.readShort();
  912. if (map.v > 13) {
  913. throw new Error("New map format, this script needs to be updated.");
  914. }
  915. map.s.re = binaryReader.readBoolean();
  916. map.s.nc = binaryReader.readBoolean();
  917. if (map.v >= 3) {
  918. map.s.pq = binaryReader.readShort();
  919. }
  920. if (map.v >= 4 && map.v <= 12) {
  921. map.s.gd = binaryReader.readShort();
  922. } else if (map.v >= 13) {
  923. map.s.gd = binaryReader.readFloat();
  924. }
  925. if (map.v >= 9) {
  926. map.s.fl = binaryReader.readBoolean();
  927. }
  928. map.m.rxn = binaryReader.readUTF();
  929. map.m.rxa = binaryReader.readUTF();
  930. map.m.rxid = binaryReader.readUint();
  931. map.m.rxdb = binaryReader.readShort();
  932. map.m.n = binaryReader.readUTF();
  933. map.m.a = binaryReader.readUTF();
  934. if (map.v >= 10) {
  935. map.m.vu = binaryReader.readUint();
  936. map.m.vd = binaryReader.readUint();
  937. }
  938. if (map.v >= 4) {
  939. cr_count = binaryReader.readShort();
  940. for (cr_iterator = 0; cr_iterator < cr_count; cr_iterator++) {
  941. map.m.cr.push(binaryReader.readUTF());
  942. }
  943. }
  944. if (map.v >= 5) {
  945. map.m.mo = binaryReader.readUTF();
  946. map.m.dbid = binaryReader.readInt();
  947. }
  948. if (map.v >= 7) {
  949. map.m.pub = binaryReader.readBoolean();
  950. }
  951. if (map.v >= 8) {
  952. map.m.dbv = binaryReader.readInt();
  953. }
  954. map.physics.ppm = binaryReader.readShort();
  955. bro_count = binaryReader.readShort();
  956. for (bro_iterator = 0; bro_iterator < bro_count; bro_iterator++) {
  957. map.physics.bro[bro_iterator] = binaryReader.readShort();
  958. }
  959. shape_count = binaryReader.readShort();
  960. for (shape_iterator = 0; shape_iterator < shape_count; shape_iterator++) {
  961. shape_type = binaryReader.readShort();
  962. if (shape_type == 1) {
  963. map.physics.shapes[shape_iterator] = {"type":"bx","w":10,"h":40,"c":[0,0],"a":0,"sk":false};
  964. map.physics.shapes[shape_iterator].w = binaryReader.readDouble();
  965. map.physics.shapes[shape_iterator].h = binaryReader.readDouble();
  966. map.physics.shapes[shape_iterator].c = [binaryReader.readDouble(), binaryReader.readDouble()];
  967. map.physics.shapes[shape_iterator].a = binaryReader.readDouble();
  968. map.physics.shapes[shape_iterator].sk = binaryReader.readBoolean();
  969. }
  970. if (shape_type == 2) {
  971. map.physics.shapes[shape_iterator] = {"type":"ci","r":25,"c":[0,0],"sk":false};
  972. map.physics.shapes[shape_iterator].r = binaryReader.readDouble();
  973. map.physics.shapes[shape_iterator].c = [binaryReader.readDouble(), binaryReader.readDouble()];
  974. map.physics.shapes[shape_iterator].sk = binaryReader.readBoolean();
  975. }
  976. if (shape_type == 3) {
  977. map.physics.shapes[shape_iterator] = {"type":"po","v":[],"s":1,"a":0,"c":[0,0]};
  978. map.physics.shapes[shape_iterator].s = binaryReader.readDouble();
  979. map.physics.shapes[shape_iterator].a = binaryReader.readDouble();
  980. map.physics.shapes[shape_iterator].c = [binaryReader.readDouble(), binaryReader.readDouble()];
  981. point_count = binaryReader.readShort();
  982. map.physics.shapes[shape_iterator].v = [];
  983. for (point_iterator = 0; point_iterator < point_count; point_iterator++) {
  984. map.physics.shapes[shape_iterator].v.push([binaryReader.readDouble(), binaryReader.readDouble()]);
  985. }
  986. }
  987. }
  988. a8k[31] = binaryReader.readShort();
  989. for (a8k[89] = 0; a8k[89] < a8k[31]; a8k[89]++) {
  990. map.physics.fixtures[a8k[89]] = {"n":"Def Fix","fr":0.3,"fp":null,"re":0.8,"de":0.3,"f":5209260,"d":false,"np":false,"ng":false};
  991. map.physics.fixtures[a8k[89]].sh = binaryReader.readShort();
  992. map.physics.fixtures[a8k[89]].n = binaryReader.readUTF();
  993. map.physics.fixtures[a8k[89]].fr = binaryReader.readDouble();
  994. if (map.physics.fixtures[a8k[89]].fr == Number.MAX_VALUE) {
  995. map.physics.fixtures[a8k[89]].fr = null;
  996. }
  997. a8k[22] = binaryReader.readShort();
  998. if (a8k[22] == 0) {
  999. map.physics.fixtures[a8k[89]].fp = null;
  1000. }
  1001. if (a8k[22] == 1) {
  1002. map.physics.fixtures[a8k[89]].fp = false;
  1003. }
  1004. if (a8k[22] == 2) {
  1005. map.physics.fixtures[a8k[89]].fp = true;
  1006. }
  1007. map.physics.fixtures[a8k[89]].re = binaryReader.readDouble();
  1008. if (map.physics.fixtures[a8k[89]].re == Number.MAX_VALUE) {
  1009. map.physics.fixtures[a8k[89]].re = null;
  1010. }
  1011. map.physics.fixtures[a8k[89]].de = binaryReader.readDouble();
  1012. if (map.physics.fixtures[a8k[89]].de == Number.MAX_VALUE) {
  1013. map.physics.fixtures[a8k[89]].de = null;
  1014. }
  1015. map.physics.fixtures[a8k[89]].f = binaryReader.readUint();
  1016. map.physics.fixtures[a8k[89]].d = binaryReader.readBoolean();
  1017. map.physics.fixtures[a8k[89]].np = binaryReader.readBoolean();
  1018. if (map.v >= 11) {
  1019. map.physics.fixtures[a8k[89]].ng = binaryReader.readBoolean();
  1020. }
  1021. if (map.v >= 12) {
  1022. map.physics.fixtures[a8k[89]].ig = binaryReader.readBoolean();
  1023. }
  1024. }
  1025. a8k[41] = binaryReader.readShort();
  1026. for (a8k[20] = 0; a8k[20] < a8k[41]; a8k[20]++) {
  1027. map.physics.bodies[a8k[20]] = {"type":"s","n":"Unnamed","p":[0,0],"a":0,"fric":0.3,"fricp":false,"re":0.8,"de":0.3,"lv":[0,0],"av":0,"ld":0,"ad":0,"fr":false,"bu":false,"cf":{"x":0,"y":0,"w":true,"ct":0},"fx":[],"f_c":1,"f_p":true,"f_1":true,"f_2":true,"f_3":true,"f_4":true};
  1028. map.physics.bodies[a8k[20]].type = binaryReader.readUTF();
  1029. map.physics.bodies[a8k[20]].n = binaryReader.readUTF();
  1030. map.physics.bodies[a8k[20]].p = [binaryReader.readDouble(), binaryReader.readDouble()];
  1031. map.physics.bodies[a8k[20]].a = binaryReader.readDouble();
  1032. map.physics.bodies[a8k[20]].fric = binaryReader.readDouble();
  1033. map.physics.bodies[a8k[20]].fricp = binaryReader.readBoolean();
  1034. map.physics.bodies[a8k[20]].re = binaryReader.readDouble();
  1035. map.physics.bodies[a8k[20]].de = binaryReader.readDouble();
  1036. map.physics.bodies[a8k[20]].lv = [binaryReader.readDouble(), binaryReader.readDouble()];
  1037. map.physics.bodies[a8k[20]].av = binaryReader.readDouble();
  1038. map.physics.bodies[a8k[20]].ld = binaryReader.readDouble();
  1039. map.physics.bodies[a8k[20]].ad = binaryReader.readDouble();
  1040. map.physics.bodies[a8k[20]].fr = binaryReader.readBoolean();
  1041. map.physics.bodies[a8k[20]].bu = binaryReader.readBoolean();
  1042. map.physics.bodies[a8k[20]].cf.x = binaryReader.readDouble();
  1043. map.physics.bodies[a8k[20]].cf.y = binaryReader.readDouble();
  1044. map.physics.bodies[a8k[20]].cf.ct = binaryReader.readDouble();
  1045. map.physics.bodies[a8k[20]].cf.w = binaryReader.readBoolean();
  1046. map.physics.bodies[a8k[20]].f_c = binaryReader.readShort();
  1047. map.physics.bodies[a8k[20]].f_1 = binaryReader.readBoolean();
  1048. map.physics.bodies[a8k[20]].f_2 = binaryReader.readBoolean();
  1049. map.physics.bodies[a8k[20]].f_3 = binaryReader.readBoolean();
  1050. map.physics.bodies[a8k[20]].f_4 = binaryReader.readBoolean();
  1051. if (map.v >= 2) {
  1052. map.physics.bodies[a8k[20]].f_p = binaryReader.readBoolean();
  1053. }
  1054. a8k[50] = binaryReader.readShort();
  1055. for (a8k[66] = 0; a8k[66] < a8k[50]; a8k[66]++) {
  1056. map.physics.bodies[a8k[20]].fx.push(binaryReader.readShort());
  1057. }
  1058. }
  1059. a8k[48] = binaryReader.readShort();
  1060. for (a8k[36] = 0; a8k[36] < a8k[48]; a8k[36]++) {
  1061. map.spawns[a8k[36]] = {"x":400,"y":300,"xv":0,"yv":0,"priority":5,"r":true,"f":true,"b":true,"gr":false,"ye":false,"n":"Spawn"};
  1062. a8k[80] = map.spawns[a8k[36]];
  1063. a8k[80].x = binaryReader.readDouble();
  1064. a8k[80].y = binaryReader.readDouble();
  1065. a8k[80].xv = binaryReader.readDouble();
  1066. a8k[80].yv = binaryReader.readDouble();
  1067. a8k[80].priority = binaryReader.readShort();
  1068. a8k[80].r = binaryReader.readBoolean();
  1069. a8k[80].f = binaryReader.readBoolean();
  1070. a8k[80].b = binaryReader.readBoolean();
  1071. a8k[80].gr = binaryReader.readBoolean();
  1072. a8k[80].ye = binaryReader.readBoolean();
  1073. a8k[80].n = binaryReader.readUTF();
  1074. }
  1075. a8k[40] = binaryReader.readShort();
  1076. for (a8k[18] = 0; a8k[18] < a8k[40]; a8k[18]++) {
  1077. map.capZones[a8k[18]] = {"n":"Cap Zone","ty":1,"l":10,"i":-1};
  1078. map.capZones[a8k[18]].n = binaryReader.readUTF();
  1079. map.capZones[a8k[18]].l = binaryReader.readDouble();
  1080. map.capZones[a8k[18]].i = binaryReader.readShort();
  1081. if (map.v >= 6) {
  1082. map.capZones[a8k[18]].ty = binaryReader.readShort();
  1083. }
  1084. }
  1085. a8k[39] = binaryReader.readShort();
  1086. for (a8k[94] = 0; a8k[94] < a8k[39]; a8k[94]++) {
  1087. a8k[75] = binaryReader.readShort();
  1088. if (a8k[75] == 1) {
  1089. map.physics.joints[a8k[94]] = {"type":"rv","d":{"la":0,"ua":0,"mmt":0,"ms":0,"el":false,"em":false,"cc":false,"bf":0,"dl":true},"aa":[0,0]};
  1090. a8k[53] = map.physics.joints[a8k[94]];
  1091. a8k[53].d.la = binaryReader.readDouble();
  1092. a8k[53].d.ua = binaryReader.readDouble();
  1093. a8k[53].d.mmt = binaryReader.readDouble();
  1094. a8k[53].d.ms = binaryReader.readDouble();
  1095. a8k[53].d.el = binaryReader.readBoolean();
  1096. a8k[53].d.em = binaryReader.readBoolean();
  1097. a8k[53].aa = [binaryReader.readDouble(), binaryReader.readDouble()];
  1098. }
  1099. if (a8k[75] == 2) {
  1100. map.physics.joints[a8k[94]] = {"type":"d","d":{"fh":0,"dr":0,"cc":false,"bf":0,"dl":true},"aa":[0,0],"ab":[0,0]};
  1101. a8k[27] = map.physics.joints[a8k[94]];
  1102. a8k[27].d.fh = binaryReader.readDouble();
  1103. a8k[27].d.dr = binaryReader.readDouble();
  1104. a8k[27].aa = [binaryReader.readDouble(), binaryReader.readDouble()];
  1105. a8k[27].ab = [binaryReader.readDouble(), binaryReader.readDouble()];
  1106. }
  1107. if (a8k[75] == 3) {
  1108. map.physics.joints[a8k[94]] = {"type":"lpj","d":{"cc":false,"bf":0,"dl":true},"pax":0,"pay":0,"pa":0,"pf":0,"pl":0,"pu":0,"plen":0,"pms":0};
  1109. a8k[23] = map.physics.joints[a8k[94]];
  1110. a8k[23].pax = binaryReader.readDouble();
  1111. a8k[23].pay = binaryReader.readDouble();
  1112. a8k[23].pa = binaryReader.readDouble();
  1113. a8k[23].pf = binaryReader.readDouble();
  1114. a8k[23].pl = binaryReader.readDouble();
  1115. a8k[23].pu = binaryReader.readDouble();
  1116. a8k[23].plen = binaryReader.readDouble();
  1117. a8k[23].pms = binaryReader.readDouble();
  1118. }
  1119. if (a8k[75] == 4) {
  1120. map.physics.joints[a8k[94]] = {"type":"lsj","d":{"cc":false,"bf":0,"dl":true},"sax":0,"say":0,"sf":0,"slen":0};
  1121. a8k[47] = map.physics.joints[a8k[94]];
  1122. a8k[47].sax = binaryReader.readDouble();
  1123. a8k[47].say = binaryReader.readDouble();
  1124. a8k[47].sf = binaryReader.readDouble();
  1125. a8k[47].slen = binaryReader.readDouble();
  1126. }
  1127. map.physics.joints[a8k[94]].ba = binaryReader.readShort();
  1128. map.physics.joints[a8k[94]].bb = binaryReader.readShort();
  1129. map.physics.joints[a8k[94]].d.cc = binaryReader.readBoolean();
  1130. map.physics.joints[a8k[94]].d.bf = binaryReader.readDouble();
  1131. map.physics.joints[a8k[94]].d.dl = binaryReader.readBoolean();
  1132.  
  1133. }
  1134. return map;
  1135. };
  1136.  
  1137.  
  1138. scope.updateWssLog = function(){
  1139. if(!wsslogpaused){
  1140. if(logmenutable.children.length < wsssendrecievelog.length){
  1141. var bottomscroll = logmenutable.clientHeight + logmenutable.scrollTop >= logmenutable.scrollHeight-1;
  1142. while (logmenutable.children.length>1000) {
  1143. logmenutable.removeChild(logmenutable.firstChild);
  1144. logmenutable2.removeChild(logmenutable2.firstChild);
  1145. }
  1146. var loopthro = wsssendrecievelog.slice(packetcount);
  1147. for(var i = 0; i < loopthro.length;i++){
  1148. packetcount++;
  1149. var row = document.createElement("tr");
  1150. var row2 = document.createElement("tr");
  1151.  
  1152. var cell1 = document.createElement("td");
  1153. cell1.style["overflow-x"] = "scroll";
  1154. cell1.style["padding"] = "0px";
  1155. cell1.style["width"] = "100000px";
  1156.  
  1157. var cell2 = document.createElement("td");
  1158. cell2.style["overflow-x"] = "scroll";
  1159. cell2.style["padding"] = "0px";
  1160. cell2.style["width"] = "100000px";
  1161. if(debuggercount){
  1162. cell1.style["background"] = "rgb(178, 185, 189)";
  1163. debuggercount = false;
  1164. }
  1165. else{
  1166. cell2.style["background"] = "rgb(178, 185, 189)";
  1167. debuggercount = true;
  1168. }
  1169. cell1.textContent = loopthro[i][1];
  1170. cell2.textContent = loopthro[i][1];
  1171. if(loopthro[i][0] == 0){
  1172. cell2.style["color"] = "transparent";
  1173. cell1.onclick = function(){debuggerinput.value = this.textContent};
  1174. }
  1175. else{
  1176. cell1.style["color"] = "transparent";
  1177. cell2.onclick = function(){debuggerinput.value = this.textContent};
  1178. }
  1179. row.appendChild(cell1);
  1180. row2.appendChild(cell2);
  1181. logmenutable.appendChild(row);
  1182. logmenutable2.appendChild(row2);
  1183. }
  1184. while (logmenutable.children.length>1000) {
  1185. logmenutable.removeChild(logmenutable.firstChild);
  1186. logmenutable2.removeChild(logmenutable2.firstChild);
  1187. }
  1188. if(bottomscroll){
  1189. logmenutable.scrollTop = logmenutable.scrollHeight;
  1190. logmenutable2.scrollTop = logmenutable.scrollHeight;
  1191. }
  1192. }
  1193. }
  1194. };
  1195. Gdocument.getElementById("maploadwindowmapscontainer").appendChild = function(args){
  1196.  
  1197. var checkbox = Gdocument.createElement("input");
  1198. checkbox.type = "checkbox";
  1199. checkbox.style["position"]="absolute";
  1200. checkbox.style["margin-top"] = "135px";
  1201. checkbox.style["margin-left"] = "140px";
  1202. checkbox.style["scale"] = "2";
  1203. checkbox.style["display"] = "none";
  1204. checkbox.className = "quickplaycheckbox quickplayunchecked";
  1205. if(ishost && stopquickplay==0){
  1206. checkbox.style["display"] = "block";
  1207. checkbox.className = "quickplaycheckbox quickplaychecked";
  1208. }
  1209. checkbox.checked = true;
  1210. checkbox.onclick = function(e){e.stopPropagation();};
  1211. args.appendChild(checkbox);
  1212. originalMapLoad.call(this,args);
  1213. };
  1214. Gdocument.getElementById("newbonklobby_chat_content").appendChild = function(args){
  1215. if(beenKickedTimeStamp+100>Date.now() && args.children.length>0){
  1216. if(args.children[0].textContent.endsWith(" has left the game ") && args.children[0].textContent.startsWith("* ")){
  1217. var kickedorbanned = "banned";
  1218. if(onlykicked){
  1219. kickedorbanned = "kicked";
  1220. }
  1221. args.children[0].textContent = args.children[0].textContent.substring(0,args.children[0].textContent.length-19)+" has been "+kickedorbanned+" from the game ";
  1222. }
  1223. }
  1224. originalLobbyChat.call(this,args);
  1225. };
  1226. Gdocument.getElementById("ingamechatcontent").appendChild = function(args){
  1227. if(beenKickedTimeStamp+100>Date.now() && args.children.length>0){
  1228. if(args.children[0].textContent.endsWith(" has left the game.") && args.children[0].textContent.startsWith("* ")){
  1229. var kickedorbanned = "banned";
  1230. if(onlykicked){
  1231. kickedorbanned = "kicked";
  1232. }
  1233. args.children[0].textContent = args.children[0].textContent.substring(0,args.children[0].textContent.length-19)+" has been "+kickedorbanned+" from the game.";
  1234. }
  1235. }
  1236. if(recordedTimeStamp+100>Date.now() && args.children.length>0){
  1237. if(args.children[0].textContent.includes("seconds") && args.children[0].textContent.startsWith("* ")){
  1238. args.children[0].textContent = args.children[0].textContent + " - " + playerids[recordedId].userName;
  1239. }
  1240. }
  1241. originalIngameChat.call(this,args);
  1242. };
  1243. Gwindow.XMLHttpRequest.prototype.open = function(_, url) {
  1244. if (url.includes("scripts/map_get") || url.includes("scripts/map_b1_get") || url.includes("scripts/hotmaps/")) {
  1245. this.isSearchMap = true;
  1246. }
  1247. originalXMLOpen.call(this, ...arguments);
  1248. };
  1249. Gwindow.XMLHttpRequest.prototype.send = function(data) {
  1250. if (this.isSearchMap) {
  1251. this.onreadystatechange = function () {
  1252. if (this.readyState == 4 && searchrequested && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS") {
  1253. searchrequested = false;
  1254. var jsonargs = {r:"success",maps:[],more:true};
  1255. for(var i = 0; i<requestedmaps.length; i++){
  1256. var dec = requestedmaps[i][0];
  1257. var undec = requestedmaps[i][1];
  1258. var map = {};
  1259. map.id = dec["m"]["dbid"];
  1260. map.name = dec["m"]["n"];
  1261. map.authorname = dec["m"]["a"];
  1262. map.leveldata = undec;
  1263. map.publisheddate = dec["m"]["date"];
  1264. map.remixauthor = dec["m"]["rxa"];
  1265. map.remixdb = dec["m"]["rxdb"];
  1266. map.remixid = dec["m"]["rxid"];
  1267. map.remixname = dec["m"]["rxn"];
  1268. map.vd = dec["m"]["vd"];
  1269. map.vu = dec["m"]["vu"];
  1270. jsonargs.maps.push(map);
  1271. }
  1272. jsonargs2 = JSON.stringify(jsonargs);
  1273. function stringifyjsonargs(){
  1274. return jsonargs2;
  1275. }
  1276. this.__defineGetter__("responseText", stringifyjsonargs);
  1277. this.__defineGetter__("response", stringifyjsonargs);
  1278. }
  1279. }
  1280. }
  1281. originalXMLSend.call(this, ...arguments);
  1282. };
  1283. scope.STB = function(x){
  1284. if(x == "0"){
  1285. return 0;
  1286. }
  1287. else{
  1288. return 1;
  1289. }
  1290. };
  1291. scope.GET_KEYS = function(x){
  1292. var x2 = ((x+64)>>>0).toString(2).substring(1).split("");
  1293. return {"left":STB(x2[5]),"right":STB(x2[4]),"up":STB(x2[3]),"down":STB(x2[2]),"heavy":STB(x2[1]),"special":STB(x2[0])}
  1294. };
  1295.  
  1296. scope.SENDFUNCTION = function(args){return args;};
  1297. scope.RECIEVEFUNCTION = function(args){return args;};
  1298. Gwindow.WebSocket.prototype.send = function(args) {
  1299. if(this.url.includes(".bonk.io/socket.io/?EIO=3&transport=websocket&sid=")){
  1300. bonkwss = this;
  1301. if(typeof(args) == "string"){
  1302. args = SENDFUNCTION(args);
  1303. wsssendlog.push(args);
  1304. wsssendrecievelog.push([0,args]);
  1305. if(args.startsWith('42[26,')){
  1306. if(sandboxon){
  1307. var jsonargs = JSON.parse(args.substring(2))[1];
  1308. if(typeof(sandboxplayerids[jsonargs["targetID"]])!='undefined'){
  1309. RECIEVE('42[18,'+jsonargs["targetID"]+','+jsonargs["targetTeam"]+']');
  1310.  
  1311. }
  1312. }
  1313. }
  1314. if(args.startsWith('42[1,')){
  1315. return;
  1316. }
  1317.  
  1318. if(args.startsWith('42[4,')){
  1319. var jsonargs = JSON.parse(args.substring(2));
  1320. if(sandboxcopyme && typeof(jsonargs[1]["i"])!="undefined"){
  1321. var jsonkeys = Object.keys(sandboxplayerids);
  1322. for(var i = 0; i<jsonkeys.length;i++){
  1323. RECIEVE('42[7,'+jsonkeys[i].toString()+','+JSON.stringify(jsonargs[1])+']');
  1324. }
  1325. }
  1326. playerids[myid].lastmove = Date.now();
  1327. if(ishost && typeof(jsonargs[1]["i"])!="undefined"){
  1328. for(var i = 0;i<disabledkeys.length;i++){
  1329. if(GET_KEYS(jsonargs[1]["i"])[disabledkeys[i]]){
  1330. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden" && !killedids.includes(myid)){
  1331. killedids.push(myid);
  1332. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  1333. SEND('42[25,{"a":{"playersLeft":['+myid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  1334. RECIEVE('42[31,{"a":{"playersLeft":['+myid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  1335. break;
  1336. }
  1337. }
  1338. }
  1339. }
  1340. args = "42"+JSON.stringify(jsonargs);
  1341. }
  1342. if(args.startsWith('42[12,')){
  1343. var jsonargs = JSON.parse(args.substring(2))[1];
  1344. playerids["0"] = {"peerID":jsonargs["peerID"],"userName":username,"level":Gdocument.getElementById("pretty_top_level").textContent == "Guest" ? 0 : parseInt(Gdocument.getElementById("pretty_top_level").textContent.substring(3)),"guest":typeof(jsonargs.token)=="undefined","team":1,"avatar":jsonargs["avatar"]};
  1345. myid = 0;
  1346. hostid = 0;
  1347. }
  1348. if(args.startsWith('42[23,') && recteams){
  1349. var jsonargs = JSON.parse(args.substring(2));
  1350. var map = decodeFromDatabase(jsonargs[1]["m"]);
  1351. var spawns = map["spawns"];
  1352. var teamsneeded = true;
  1353. var excludedindexes = [];
  1354. var ffaspawns = false;
  1355. var ffaforsure = false;
  1356. for(var i = 0; i<spawns.length;i++){
  1357. var currentSpawn = spawns[i];
  1358. if(Math.sqrt(currentSpawn.x**2 + currentSpawn.y**2)>=850 || currentSpawn.y>250){
  1359. excludedindexes.push(i);
  1360. }
  1361. else if(!(currentSpawn.f || currentSpawn.r || currentSpawn.b || currentSpawn.gr || currentSpawn.ye)){
  1362. excludedindexes.push(i);
  1363. }
  1364. else if(currentSpawn.f){
  1365. ffaspawns = true;
  1366. if(!(currentSpawn.r || currentSpawn.b || currentSpawn.gr || currentSpawn.ye)){
  1367. excludedindexes.push(i);
  1368. ffaforsure = true
  1369. }
  1370. }
  1371. }
  1372. if(!ffaspawns && !ffaforsure){
  1373. teamsneeded = true;
  1374. }
  1375. else{
  1376. teamsneeded = false;
  1377. }
  1378. if(teamsneeded){
  1379. var newspawns = [];
  1380. for(var i = 0; i<spawns.length;i++){
  1381. if(!excludedindexes.includes(i)){
  1382. newspawns.push({"r":spawns[i]["r"],"g":spawns[i]["gr"],"b":spawns[i]["b"],"y":spawns[i]["ye"],"total":spawns[i]["r"]+spawns[i]["ye"]+spawns[i]["gr"]+spawns[i]["b"],"priority":spawns[i]["priority"]});
  1383. }
  1384. }
  1385. if(newspawns.length>0){
  1386. var teamletters = ["r","g","b","y"];
  1387. var ratios = {"r":0,"g":0,"b":0,"y":0};
  1388. for(var i = 0; i < newspawns.length;i++){
  1389. for(var i2 = 0; i2<teamletters.length;i2++){
  1390. var ct = teamletters[i2];
  1391. if(newspawns[i]["priority"]!=0){
  1392. ratios[ct]+=(newspawns[i][ct])/newspawns[i]["total"]*newspawns[i]["priority"];
  1393. }
  1394. }
  1395. }
  1396. var highest = ["",0];
  1397. for(var i = 0; i<teamletters.length;i++){
  1398. var ct = teamletters[i];
  1399. if(ratios[ct]>0 && highest[1]<ratios[ct]){
  1400. highest = [ct,ratios[ct]];
  1401. }
  1402. }
  1403. if(highest[0]!=""){
  1404. for(var i = 0; i<teamletters.length;i++){
  1405. var ct = teamletters[i];
  1406. ratios[ct] = ratios[ct]/highest[1];
  1407. }
  1408. }
  1409. var playerids3 = Object.keys(playerids);
  1410. var playerids2 = [];
  1411. for(var i = 0; i<playerids3.length;i++){
  1412. if(playerids[playerids3[i]].team>0){
  1413. playerids2.push(playerids3[i]);
  1414. }
  1415. }
  1416. var pi2l = playerids2.length;
  1417. var ratios2 = {"r":0,"r1":0,"g":0,"g1":0,"b":0,"b1":0,"y":0,"y1":0};
  1418. var items = Object.entries(ratios);
  1419. items.sort(function(a,b){return a[1]-b[1];});
  1420. var items = items.map(function(e){return e[0];});
  1421. var highest2 = ["",0];
  1422. while(pi2l>0){
  1423. var done = false;
  1424. for(var i2 = 0; i2<items.length;i2++){
  1425. var ci = items[i2];
  1426. var ci2 = items[i2]+"1";
  1427. for(var i = 0; i<teamletters.length;i++){
  1428. var ct = teamletters[i];
  1429. if(ratios2[ct]>0 && highest2[1]<ratios2[ct]){
  1430. highest2 = [ct,ratios2[ct]];
  1431. }
  1432. }
  1433. if(highest2[0]!=""){
  1434. for(var i = 0; i<teamletters.length;i++){
  1435. var ct = teamletters[i];
  1436. ratios2[ct+"1"] = ratios2[ct]/highest2[1];
  1437. }
  1438. }
  1439. if(ratios[ci]>0 && ratios[ci]>=ratios2[ci2] && pi2l>0){
  1440. ratios2[ci]+=1;
  1441. pi2l--;
  1442. done = true;
  1443. }
  1444. }
  1445. if(pi2l>0 && !done){
  1446. ratios2[highest2[0]]+=1;
  1447. pi2l--;
  1448. }
  1449. }
  1450. SEND('42[32,{"t":true}]');
  1451. RECIEVE('42[39,true]');
  1452. for(var i = 0; i<ratios2["r"];i++){
  1453. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  1454. SEND('42[26,{"targetID":'+pid+',"targetTeam":2}]');
  1455. RECIEVE('42[18,'+pid+',2]');
  1456. }
  1457. for(var i = 0; i<ratios2["g"];i++){
  1458. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  1459. SEND('42[26,{"targetID":'+pid+',"targetTeam":4}]');
  1460. RECIEVE('42[18,'+pid+',4]');
  1461. }
  1462. for(var i = 0; i<ratios2["b"];i++){
  1463. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  1464. SEND('42[26,{"targetID":'+pid+',"targetTeam":3}]');
  1465. RECIEVE('42[18,'+pid+',3]');
  1466. }
  1467. for(var i = 0; i<ratios2["y"];i++){
  1468. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  1469. SEND('42[26,{"targetID":'+pid+',"targetTeam":5}]');
  1470. RECIEVE('42[18,'+pid+',5]');
  1471. }
  1472. }
  1473. }
  1474. else{
  1475. SEND('42[32,{"t":false}]');
  1476. RECIEVE('42[39,false]');
  1477. }
  1478. }
  1479.  
  1480. if(args.startsWith('42[47,') && stopquickplay == 0 && ishost && document.hidden){
  1481. if(shuffle){
  1482. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  1483. var available = [];
  1484. var availableindexes = [];
  1485. var notempty = false;
  1486. for(var i = 0; i<e2.length;i++){
  1487. var a = false;
  1488. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  1489. available.push(a);
  1490. if(a){
  1491. availableindexes.push(i);
  1492. notempty = true;
  1493. }
  1494. }
  1495. if(notempty){
  1496.  
  1497. if(availableindexes.length!=1){
  1498. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  1499. }
  1500. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  1501. }
  1502. }
  1503. else{
  1504. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  1505. var available = [];
  1506. var availableindexes = [];
  1507. var notempty = false;
  1508. for(var i = 0; i<e2.length;i++){
  1509. var a = false;
  1510. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  1511. available.push(a);
  1512. if(a){
  1513. availableindexes.push(i);
  1514. notempty = true;
  1515. }
  1516. }
  1517. if(notempty){
  1518. var above = [];
  1519. for(var i = 0;i<availableindexes.length;i++){
  1520. if(availableindexes[i]>quicki){
  1521. above.push(availableindexes[i]);
  1522. }
  1523. }
  1524. if(above.length>0){
  1525. quicki = above[0];
  1526. }
  1527. else{
  1528. quicki = availableindexes[0];
  1529. }
  1530. }
  1531. }
  1532. canceled = false;
  1533. startedinqp = true;
  1534. window.map(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length),0);
  1535. }
  1536.  
  1537. if(args.startsWith('42[5,')){
  1538. var jsonargs = JSON.parse(args.substring(2));
  1539. if(stopquickplay!=1 && startedinqp){
  1540. startedinqp = false;
  1541. jsonargs[1]["gs"]["wl"] = 999;
  1542. if(!instaqp){
  1543. var jsonargs2 = decodeIS(jsonargs[1]["is"]);
  1544. jsonargs2["ftu"] = 60;
  1545. if(jsonargs2["mm"]["rxa"] != ""){
  1546. jsonargs2["mm"]["a"] = jsonargs2["mm"]["rxa"];
  1547. jsonargs2["mm"]["n"] = jsonargs2["mm"]["rxn"];
  1548. }
  1549. jsonargs2 = encodeIS(jsonargs2);
  1550. jsonargs[1]["is"] = jsonargs2;
  1551. var jsonargs3 = decodeFromDatabase(jsonargs[1]["gs"]["map"]);
  1552. if(jsonargs3["m"]["rxa"] != ""){
  1553. jsonargs3["m"]["a"] = jsonargs3["m"]["rxa"];
  1554. jsonargs3["m"]["n"] = jsonargs3["m"]["rxn"];
  1555. }
  1556.  
  1557. jsonargs3 = encodeToDatabase(jsonargs3);
  1558. jsonargs[1]["gs"]["map"] = jsonargs3;
  1559. }
  1560. }
  1561.  
  1562. args = "42"+JSON.stringify(jsonargs);
  1563. }
  1564. }
  1565.  
  1566. }
  1567. else{
  1568. this.onmessage = function(args){return;};
  1569. return;
  1570.  
  1571. }
  1572. if(this.url.includes(".bonk.io/socket.io/?EIO=3&transport=websocket&sid=") && !this.injected){
  1573. this.injected = true;
  1574.  
  1575. var originalRecieve = this.onmessage;
  1576. this.onmessage = function(args){
  1577. wssrecievelog.push(args.data);
  1578. wsssendrecievelog.push([1,args.data]);
  1579. if(typeof(args.data)=="string"){
  1580. args.data = RECIEVEFUNCTION(args.data);
  1581. wssrecievelog.push(args.data);
  1582. wsssendrecievelog.push([1,args.data]);
  1583. if(args.data.startsWith('42[1,')){
  1584. var jsonargs = JSON.parse(args.data.substring(2));
  1585. originalSend.call(this,'42[1,{"id":'+jsonargs[2]+'}]');
  1586. }
  1587. if(args.data.startsWith('42[24,')){
  1588. beenKickedTimeStamp = Date.now();
  1589. onlykicked = JSON.parse(args.data.substring(2))[2];
  1590. }
  1591. if(args.data.startsWith('42[6,')){
  1592. var jsonargs = JSON.parse(args.data.substring(2));
  1593. if(typeof(playerids[jsonargs[1]])!='undefined'){
  1594. delete playerids[jsonargs[1]];
  1595. }
  1596. hostid = jsonargs[2];
  1597. }
  1598. if(args.data.startsWith('42[41,')){
  1599. var jsonargs = JSON.parse(args.data.substring(2));
  1600. hostid = jsonargs[1]["newHost"];
  1601. }
  1602. if(args.data.startsWith('42[32')){
  1603. SEND('42[4,{"type":"inactive kick counter"}]');
  1604. }
  1605. if(args.data.startsWith('42[18')){
  1606. var jsonargs = JSON.parse(args.data.substring(2));
  1607. playerids[jsonargs[1]].team = jsonargs[2];
  1608. }
  1609. if(args.data.startsWith('42[40,')){
  1610. recordedTimeStamp = Date.now();
  1611. recordedId = JSON.parse(args.data.substring(2))[1];
  1612. }
  1613. if(args.data.startsWith('42[3,')){
  1614. var jsonargs = JSON.parse(args.data.substring(2));
  1615. for(var i = 0; i<jsonargs[3].length;i++){
  1616. if(jsonargs[3][i]!=null){
  1617. playerids[i.toString()] = jsonargs[3][i];
  1618. }
  1619. }
  1620. myid = jsonargs[1];
  1621. hostid = jsonargs[2];
  1622. }
  1623. if(args.data.startsWith('42[15,')){
  1624. var jsonargs = JSON.parse(args.data.substring(2));
  1625. gameStartTimeStamp = jsonargs[1];
  1626. killedids = [];
  1627. }
  1628. if(args.data.startsWith('42[33,')){
  1629. var jsonargs = JSON.parse(args.data.substring(2));
  1630. var decodedmap = decodeFromDatabase(jsonargs[1]);
  1631. if(decodedmap!=0){
  1632. requestedmaps.push([decodedmap,jsonargs[1]]);
  1633. }
  1634. }
  1635. if(args.data.startsWith('42[7,')){
  1636. var jsonargs2 = JSON.parse(args.data.substring(2));
  1637. var idofpacket = jsonargs2[1];
  1638. jsonargs = jsonargs2[2];
  1639. if(typeof(jsonargs["i"]) == "undefined"){
  1640. if(jsonargs["type"]=="private chat" && jsonargs["to"] == username){
  1641. from = jsonargs["from"];
  1642. if(Object.keys(playerids).includes(idofpacket.toString())){
  1643. from = playerids[idofpacket].userName;
  1644. }
  1645. if(!ignorepmlist.includes(from)){
  1646. if(typeof(jsonargs["message"])=="object" && typeof(jsonargs["password"]) == "object"){
  1647. if(public_key[0]==jsonargs["public key"][0] && public_key[1]==jsonargs["public key"][1]){
  1648. if(jsonargs["password"].length<=25){
  1649. var password = CRYPT_MESSAGE(private_key,jsonargs["password"]);
  1650. var decodedtext = jsonargs["message"].slice(0,400);
  1651. var encodedtext = "";
  1652. for(var i=0;i<decodedtext.length;i++){
  1653. if(password[i%password.length]<1000){
  1654. encodedtext+=String.fromCharCode(password[i%password.length]^decodedtext[i]);
  1655. }
  1656. }
  1657. 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);';
  1658. displayInChat('> '+'<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+from+'</a>'+': ',"#DA0808","#1EBCC1",{sanitize:false},encodedtext);
  1659.  
  1660. Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true;
  1661. Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true;
  1662. Laster_message = lastmessage();
  1663. }
  1664. }
  1665. else{
  1666. SEND("42"+JSON.stringify([4,{"type":"public key correction","from":username,"to":private_chat_public_key[0],"public key":public_key}]));
  1667. }
  1668. }
  1669. }
  1670. }
  1671. if(jsonargs["type"]=="request public key" && jsonargs["to"] == username){
  1672. SEND("42"+JSON.stringify([4,{"type":"public key","from":username,"public key":public_key}]));
  1673. }
  1674. if(jsonargs["type"]=="private chat users" && pmuserstimestamp+1500>Date.now()){
  1675. if(typeof(jsonargs["from"])!='undefined'){
  1676. from = jsonargs["from"];
  1677. if(Object.keys(playerids).includes(idofpacket.toString())){
  1678. from = playerids[idofpacket].userName;
  1679. }
  1680. if(!pmusers.includes(from) && username == jsonargs["to"]){
  1681. pmusers.push(from);
  1682. }
  1683. }
  1684. }
  1685. if(jsonargs["type"]=="request private chat users"){
  1686. if(typeof(jsonargs["from"])!='undefined'){
  1687. from = jsonargs["from"];
  1688. if(Object.keys(playerids).includes(idofpacket.toString())){
  1689. from = playerids[idofpacket].userName;
  1690. }
  1691. SEND("42"+JSON.stringify([4,{"type":"private chat users","from":username,"to":from}]));
  1692. }
  1693. }
  1694. if(jsonargs["type"]=="public key" && request_public_key_time_stamp+1500>Date.now()){
  1695. from = jsonargs["from"];
  1696. if(Object.keys(playerids).includes(idofpacket.toString())){
  1697. from = playerids[idofpacket].userName;
  1698. }
  1699. if(from == private_chat){
  1700. private_chat_public_key = [private_chat,jsonargs["public key"]];
  1701. displayInChat("Private chatting with "+private_chat+".","#DA0808","#1EBCC1");
  1702. }
  1703.  
  1704. }
  1705. if(jsonargs["type"]=="public key correction" && private_chat_public_key[0] == private_chat){
  1706. from = jsonargs["from"];
  1707. if(Object.keys(playerids).includes(idofpacket.toString())){
  1708. from = playerids[idofpacket].userName;
  1709. }
  1710. if(from == private_chat){
  1711. private_chat_public_key = [private_chat,jsonargs["public key"]];
  1712. var text = pmlastmessage;
  1713. var password = [];
  1714. for(var i = 0;i<10;i++){
  1715. password.push(Math.floor(Math.random()*100+50));
  1716. }
  1717. var text2 = [];
  1718. for(var i = 0;i<text.length ;i++){
  1719. text2.push(password[i%password.length]^text.slice(0,400).charCodeAt(i));
  1720. }
  1721. 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)}]));
  1722. }
  1723. }
  1724.  
  1725. }
  1726. else{
  1727. var now = Date.now();
  1728. gameStartTimeStamp = now-1000*jsonargs["f"]/30;
  1729. playerids[idofpacket.toString()].lastmove = now;
  1730. if(ishost){
  1731. for(var i = 0;i<disabledkeys.length;i++){
  1732. var get_keys_var = GET_KEYS(jsonargs["i"]);
  1733. if(get_keys_var[disabledkeys[i]]){
  1734. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden" && !killedids.includes(idofpacket)){
  1735. killedids.push(idofpacket);
  1736. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  1737. SEND('42[25,{"a":{"playersLeft":['+idofpacket.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  1738. RECIEVE('42[31,{"a":{"playersLeft":['+idofpacket.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  1739. break;
  1740. }
  1741. }
  1742. }
  1743. }
  1744. }
  1745. }
  1746.  
  1747. if(args.data.startsWith('42[4,')){
  1748. var jsonargs = JSON.parse(args.data.substring(2));
  1749. if(ishost){
  1750. if(jointext!=""){
  1751. chat(flag_manage(jointext.replaceAll("username",jsonargs[3])));
  1752. }
  1753. if(freejoin){
  1754. var count = 0;
  1755. var keys = Object.keys(playerids);
  1756. for(var i = 0; i<keys.length;i++){
  1757. if(playerids[keys[i]].team!=0){
  1758. count++;
  1759. }
  1760. }
  1761. if(count <= 1 && jsonargs[6]!=0){
  1762. setTimeout(function(){
  1763. Gdocument.getElementById("newbonklobby_editorbutton").click();
  1764. Gdocument.getElementById("mapeditor_close").click();
  1765. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  1766. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  1767. if(transitioning == true){
  1768. canceled = true;
  1769. }
  1770. },0);
  1771. }
  1772. }
  1773. }
  1774. playerids[jsonargs[1]] = {"peerID":jsonargs[2],"userName":jsonargs[3],"guest":jsonargs[4],"level":jsonargs[5],"team":jsonargs[6],"avatar":jsonargs[7]};
  1775.  
  1776. }
  1777. if(args.data.startsWith('42[5,')){
  1778. var jsonargs = JSON.parse(args.data.substring(2));
  1779. if(typeof(playerids[jsonargs[1]])!='undefined'){
  1780. delete playerids[jsonargs[1]];
  1781. }
  1782. }
  1783. }
  1784. return originalRecieve.call(this,args);
  1785. };
  1786.  
  1787. var originalClose = this.onclose;
  1788. this.onclose = function () {
  1789. window.bonkwss = 0;
  1790. return originalClose.call(this);
  1791. }
  1792.  
  1793. }
  1794. return originalSend.call(this,args);
  1795. };
  1796.  
  1797. scope.SEND = function(args){
  1798. if(bonkwss!=0){
  1799. bonkwss.send(args);
  1800. }
  1801. };
  1802. scope.RECIEVE = function(args){
  1803. if(bonkwss!=0){
  1804. bonkwss.onmessage({data:args});
  1805. }
  1806. };
  1807.  
  1808.  
  1809.  
  1810. scope.dontswitch = false;
  1811. scope.username = 0;
  1812. scope.timedelay = 1400;
  1813. scope.ishost = false;
  1814. scope.checkboxhidden = true;
  1815. scope.quicki=0;
  1816. scope.defaultmode = "d";
  1817. scope.recmodebool = false;
  1818. scope.shuffle = false;
  1819. scope.startedinqp = false;
  1820. scope.instaqp = false;
  1821. scope.freejoin = false;
  1822. scope.recordedTimeStamp = 0;
  1823. scope.recordedId = 0;
  1824. scope.smartteams = false;
  1825. scope.beenKickedTimeStamp = 0;
  1826. scope.stopquickplay = 1;
  1827. scope.currentFrame = 0;
  1828. scope.text2speech = false;
  1829. scope.gameStartTimeStamp = 0;
  1830. scope.canceled = false;
  1831. scope.banned = [];
  1832. scope.transitioning = false;
  1833. scope.echo_list = [];
  1834. scope.echoAppend = "";
  1835. scope.message = "";
  1836. scope.mode = "";
  1837. scope.private_chat = "";
  1838. scope.private_chat_public_key = ["",[0,0]];
  1839. scope.disabledkeys = [];
  1840. scope.actuallyhost = false;
  1841. scope.pmusers = [];
  1842. scope.pmlastmessage = "";
  1843. scope.pmuserstimestamp = 0;
  1844. scope.ignorepmlist = [];
  1845. scope.scroll = false;
  1846. scope.elem = Gdocument.getElementById("maploadwindowmapscontainer");
  1847. scope.npermissions = 1;
  1848. scope.space_flag = false;
  1849. scope.rcaps_flag = false;
  1850. scope.number_flag = false;
  1851. scope.request_public_key_time_stamp = 0;
  1852. scope.sandboxcopyme = false;
  1853. scope.recteams = false;
  1854. scope.chatheight = 128;
  1855. scope.onlykicked = false;
  1856. scope.killedids = [];
  1857. scope.jointext = "";
  1858. scope.afkkill = -1;
  1859. scope.help = ["All the commands are:","/help","/?","/advhelp [command]","/space","/rcaps","/number","/speech","/echo [username]","/clearecho","/remove [username]","/echoappend [text]","/chatw [username]","/msg [text]","/ignorepm [username]","/pmusers","/lobby","/team [letter]","/scroll","/hidechat","/showchat","/notify","/stopnotify","Host commands are:","/startqp","/stopqp","/next","/previous","/shuffle","/instaqp","/freejoin","/recmode","/recteam","/defaultmode [mode]","/start","/balanceA [number]","/moveA [letter]","/rounds [number]","/mode [mode]","/disablekeys [keys]","/jointext [text]","/afkkill [number]","/ban [username]","/kill [username]","Sandbox commands are:","/addplayer [number]","/delplayer [number]","/copyme","Debugging commands are:","/eval [code]","/debugger","Hotkeys are:","Alt L","Alt C","Alt I","Alt <","Alt >","Host hotkeys are:","Alt S","Alt T","Alt E","Alt K","Alt M","Alt Q","Alt A","Alt D","Alt F","Alt R"];
  1860.  
  1861. scope.adv_help = {"help":"Shows all command names.",
  1862. "?":"Shows all command names.",
  1863. "advhelp":"Shows a command in detail.",
  1864. "space":"Toggles space. When space is on, whatever you type will be spaced apart.",
  1865. "rcaps":"Toggles rcaps. When rcaps is on, each letter will randomly get capitalized.",
  1866. "number":"Toggles number. When number is on, 'a' becomes 4, 'e' becomes 3, 's' becomes 5, 'o' becomes 0, 'l' and 'i' become 1.",
  1867. "speech":"Turns on text to speech for the chat.",
  1868. "echo":"Echoes a username. It copies the username's chat messages.",
  1869. "echoappend":"Appends the text to the end of each echo.",
  1870. "remove":"Removes username from echo list. You will not echo that username anymore.",
  1871. "clearecho":"Clears echo list. You will not echo anyone anymore.",
  1872. "chatw":"It private chats with username. Type /msg to message that username.",
  1873. "msg":"Messages with what username you are chatting with. Type /chatw to chat with a username.",
  1874. "ignorepm":"Ignores the username's private chat messages. To unignore, type /ignorepm [username].",
  1875. "pmusers":"Dispays who you can private chat with.",
  1876. "eval":"Evaluates code. Only use this if you are experienced in javascript.",
  1877. "debugger":"Opens debugger.",
  1878. "lobby":"Makes lobby visible when you are ingame. Type /lobby again to close lobby.",
  1879. "team":"Joins a specific team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  1880. "scroll":"Toggles a scrollbar in ingame chat.",
  1881. "hidechat":"Hides ingame chat. Type /showchat to show it again.",
  1882. "showchat":"Shows ingame chat. /hidechat hides the chat.",
  1883. "notify":"You will be notified if a person types @MYUSERNAME",
  1884. "stopnotify":"You will not be notified if a person types @MYUSERNAME",
  1885. "startqp":"Starts cycling maps in your map menu.",
  1886. "stopqp":"Stops cycling maps in your map menu.",
  1887. "next":"Skips the map. Usable only with /startqp.",
  1888. "previous":"Goes to previous map. Usable only with /startqp.",
  1889. "shuffle":"Makes quickplay play random maps instead of in order.",
  1890. "freejoin":"Toggles freejoin. If freejoin is on, starts the game instantly if there are 1 or less players currently playing.",
  1891. "recmode":"In quickplay, it switches mode to recommended mode, according to editor.",
  1892. "recteam":"In quickplay, it sorts people into teams when teams are necessary.",
  1893. "defaultmode":"Switches mode to defaultmode if there is no recmode.",
  1894. "start":"Starts game instantly.",
  1895. "instaqp":"Rounds will instantly start without a countdown.",
  1896. "balanceA":"Balances everyone with balance number.",
  1897. "moveA":"Sets everyones team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  1898. "rounds":"Sets rounds to win.",
  1899. "mode":"Switches modes.",
  1900. "disablekeys":"If anyone presses a disabled key, they get killed. Key options: left right up down heavy special.",
  1901. "jointext":"Chats the jointext whenever someone joins. \"username\" will get replaced by the joining person's username.",
  1902. "afkkill":"If a person stays afk for that many seconds, they get automatically killed.",
  1903. "ban":"Bans username from lobby. If they rejoin, it automatically bans.",
  1904. "kill":"Kills the person ingame.",
  1905. "addplayer":"In sandbox, it adds players.",
  1906. "delplayer":"In sandbox, it deletes players.",
  1907. "copyme":"In sandbox, it makes each player copy your movements.",
  1908. "Alt L":"Makes lobby visible when you are ingame. Press Alt L again to close lobby.",
  1909. "Alt C":"Hides ingame chat. Press Alt C again to show ingame chat.",
  1910. "Alt S":"Starts game instantly.",
  1911. "Alt T":"Toggles teams.",
  1912. "Alt E":"Toggles editor.",
  1913. "Alt K":"Exits ingame and returns to lobby.",
  1914. "Alt M":"Switches modes.",
  1915. "Alt Q":"Toggles quickplay.",
  1916. "Alt A":"Skips the map if quickplay is on.",
  1917. "Alt D":"Goes to previous map if quickplay is on.",
  1918. "Alt F":"Toggles freejoin. If freejoin is on, starts the game instantly if there are 1 or less players currently playing",
  1919. "Alt R":"In quickplay, it switches mode to recommended mode, according to editor.",
  1920. "Alt I":"Opens debugger.",
  1921. "Alt <":"Lowers ingame chat height.",
  1922. "Alt >":"Highers ingame chat height"
  1923. };
  1924. Gdocument.getElementById("ingamechatcontent").style["pointer-events"]="all";
  1925. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  1926. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  1927. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  1928.  
  1929. document.getElementById('adboxverticalCurse').style["display"] = "none";
  1930. document.getElementById('adboxverticalleftCurse').style["display"] = "none";
  1931. elem.onclick=function(e){
  1932. if(stopquickplay==0 && ishost == true && e.isTrusted == true){
  1933. quicki = (Array.from(e.target.parentElement.parentNode.children).indexOf(e.target.parentNode)-1)%(Gdocument.getElementById("maploadwindowmapscontainer").children.length);
  1934. }
  1935. };
  1936. scope.urlify = function(text) {
  1937. return text.replace(/(?:https?:\/\/)?(?:[A-Za-z0-9-ßàÁâãóôþüúðæåïçèõöÿýòäœêëìíøùîûñé]+)(?:\.[A-Za-z0-9-ßàÁâãóôþüúðæåïçèõöÿýòäœêëìíøùîûñé]+)+(?:\/(?:[A-Za-z0-9-._~:/?#\[\]@!$&'()*+,;=]|%[0-9a-fA-F]{2})*)?(?:\?(?:[^=]+=[^&](?:&[^=]+=[^&])*)?)?/g, function(url) {
  1938. if(url.startsWith('https://')){return '<a href="' + url + '" target="_blank" style = "color:orange">' + url + '</a>';}
  1939. else{return '<a href="https://' + url + '" target="_blank" style = "color:orange">' + url + '</a>';}
  1940. })
  1941. };
  1942.  
  1943. scope.fire = function(type,options,d = Gdocument){
  1944. var event=new CustomEvent(type);
  1945. for(var p in options){
  1946. event[p]=options[p];
  1947. }
  1948. d.dispatchEvent(event);
  1949. };
  1950.  
  1951. scope.chat = function(message){
  1952. mess = Gdocument.getElementById("newbonklobby_chat_input").value;
  1953. mess2 = Gdocument.getElementById("ingamechatinputtext").value;
  1954. Gdocument.getElementById("newbonklobby_chat_input").value = message;
  1955. Gdocument.getElementById("ingamechatinputtext").value = message;
  1956. fire("keydown",{keyCode:13});
  1957. fire("keydown",{keyCode:13});
  1958. Gdocument.getElementById("newbonklobby_chat_input").value = mess;
  1959. Gdocument.getElementById("ingamechatinputtext").value = mess2;
  1960. };
  1961. scope.displayInChat = function(message, LobbyColor, InGameColor, options, message2, BringDown) {
  1962. options = options ?? {};
  1963. BringDown = BringDown ?? false;
  1964. message2 = message2 ?? "";
  1965. LobbyColor = LobbyColor ?? "#8800FF";
  1966. InGameColor = InGameColor ?? "#AA88FF";
  1967. let A = Gdocument.createElement("div");
  1968. let B = Gdocument.createElement("span");
  1969. B.className = "newbonklobby_chat_status";
  1970. B.style.color = LobbyColor;
  1971. A.appendChild(B);
  1972. B.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  1973. B.innerHTML+=urlify(message2.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;'));
  1974. let C = Gdocument.createElement("div");
  1975. let D = Gdocument.createElement("span");
  1976. D.style.color = InGameColor;
  1977. C.appendChild(D);
  1978. D.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  1979. D.innerHTML+=urlify(message2.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;'));
  1980. let a = BringDown;
  1981. if(Gdocument.getElementById("newbonklobby_chat_content").clientHeight + Gdocument.getElementById("newbonklobby_chat_content").scrollTop >= Gdocument.getElementById("newbonklobby_chat_content").scrollHeight-1) {
  1982. a = true;
  1983. }
  1984. Gdocument.getElementById("newbonklobby_chat_content").appendChild(A);
  1985. Gdocument.getElementById("ingamechatcontent").appendChild(C);
  1986. if (a) { Gdocument.getElementById("newbonklobby_chat_content").scrollTop = Number.MAX_SAFE_INTEGER;};
  1987. Gdocument.getElementById("ingamechatcontent").scrollTop = Number.MAX_SAFE_INTEGER;
  1988. chat("");
  1989. };
  1990.  
  1991. scope.lobby = function(){
  1992. if (Gdocument.getElementById("newbonklobby").style["display"]=="none"){
  1993.  
  1994. Gdocument.getElementById("newbonklobby_editorbutton").click();
  1995. Gdocument.getElementById("mapeditor_close").click();
  1996. if(Gdocument.getElementById("newbonklobby_playerbox_elementcontainer").children.length+Gdocument.getElementById("newbonklobby_specbox_elementcontainer").children.length-3>0){
  1997. Gdocument.getElementById("newbonklobby").style["z-index"]=1;
  1998. Gdocument.getElementById("maploadwindowcontainer").style["z-index"]=1;
  1999. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=1;
  2000. Gdocument.getElementById("pretty_top").style["z-index"]=3;
  2001. Gdocument.getElementById("settingsContainer").style["z-index"]=3;
  2002. Gdocument.getElementById("leaveconfirmwindow").style["z-index"]=3;
  2003. Gdocument.getElementById("hostleaveconfirmwindow").style["z-index"]=3;
  2004. debuggermenu.style["z-index"] = 2;
  2005. }
  2006. else{
  2007. Gdocument.getElementById("newbonklobby").style["opacity"]=0;
  2008. Gdocument.getElementById("newbonklobby").style["display"]="none";
  2009. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
  2010.  
  2011. }
  2012.  
  2013. }
  2014. else if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  2015. Gdocument.getElementById("newbonklobby").style["opacity"]=0;
  2016. Gdocument.getElementById("newbonklobby").style["display"]="none";
  2017. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
  2018.  
  2019. }
  2020. };
  2021.  
  2022. scope.lastmessage = function(){
  2023. if(Gdocument.getElementById("newbonklobby_chat_content").children.length!=0){
  2024. var lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  2025. var lm2 = "";
  2026. for(var i = 0; i<lm.length;i++){
  2027. lm2+=" "+lm[i].textContent.trim();
  2028. }
  2029. lm2 = lm2.trim();
  2030. if(lm2.startsWith("*")){
  2031. return lm2;
  2032. }
  2033. }
  2034. if(Gdocument.getElementById("ingamechatcontent").children.length!=0){
  2035. var lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  2036. var lm2 = "";
  2037. for(var i = 0; i<lm.length;i++){
  2038. lm2+=" "+lm[i].textContent.trim();
  2039. }
  2040. return lm2.trim();
  2041. }
  2042. return "";
  2043.  
  2044. };
  2045. scope.map = function(e,t=timedelay){
  2046. if(e<0){
  2047. displayInChat("There is no previous map.","#DA0808","#1EBCC1");
  2048. quicki = 0;
  2049. return;
  2050. }
  2051. if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
  2052. displayInChat("Click the maps button.","#DA0808","#1EBCC1");
  2053. return;
  2054. }
  2055.  
  2056. setTimeout(function(){if(!canceled){
  2057. startedinqp = true;
  2058. Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
  2059. Gdocument.getElementById("newbonklobby_editorbutton").click();
  2060. if(recmodebool && ishost){
  2061. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  2062. if(mode == "" && defaultmode!="d"){
  2063. mode = defaultmode;
  2064. }
  2065. if(mode != ""){
  2066. RECIEVE('42[26,"b","'+mode+'"]');
  2067. }
  2068. }
  2069. var displayblock = Gdocument.getElementById("newbonklobby").style["display"] == "block";
  2070. Gdocument.getElementById("mapeditorcontainer").style["display"] = "none";
  2071. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  2072. if(displayblock){
  2073. Gdocument.getElementById("newbonklobby").style["display"] = "block";
  2074. }
  2075. Gdocument.getElementById("mapeditor_midbox_testbutton").click();}
  2076. canceled = false;
  2077. transitioning = false;
  2078. },t);
  2079.  
  2080. };
  2081.  
  2082. scope.gotonextmap = function(e){
  2083. if(e<0){
  2084. displayInChat("There is no previous map.","#DA0808","#1EBCC1");
  2085. quicki = 0;
  2086. return;
  2087. }
  2088. if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
  2089. displayInChat("Click the maps button.","#DA0808","#1EBCC1");
  2090. return;
  2091. }
  2092. Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
  2093. Gdocument.getElementById("newbonklobby_editorbutton").click();
  2094. if(recmodebool && ishost){
  2095. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  2096. if(mode == "" && defaultmode!="d"){
  2097. mode = defaultmode;
  2098. }
  2099. if(mode != ""){
  2100. RECIEVE('42[26,"b","'+mode+'"]');
  2101. }
  2102. }
  2103. startedinqp = true;
  2104. var displayblock = Gdocument.getElementById("newbonklobby").style["display"] == "block";
  2105. Gdocument.getElementById("mapeditorcontainer").style["display"] = "none";
  2106. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  2107. if(displayblock){
  2108. Gdocument.getElementById("newbonklobby").style["display"] = "block";
  2109. }
  2110. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  2111. Gdocument.getElementById("newbonklobby").style["visibility"] = "visible";
  2112. };
  2113. scope.commandhandle = function(chat_val){
  2114. if (chat_val.substring(1,6)=="echo " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  2115. if (chat_val.substring(6).replace(/^\s+|\s+$/g, '')==username){
  2116. displayInChat("You cannot echo yourself.","#DA0808","#1EBCC1");
  2117. return "";
  2118. }
  2119. else if (echo_list.indexOf(chat_val.substring(6).replace(/^\s+|\s+$/g, ''))===-1) {
  2120.  
  2121. echo_list.push(chat_val.substring(6).replace(/^\s+|\s+$/g, ''));
  2122. displayInChat(chat_val.substring(6).replace(/^\s+|\s+$/g, '') + " is being echoed.","#DA0808","#1EBCC1");
  2123. return "";
  2124. }
  2125. else{
  2126. displayInChat(chat_val.substring(6).replace(/^\s+|\s+$/g, '') + " is already being echoed.","#DA0808","#1EBCC1");
  2127. return "";
  2128. }
  2129. }
  2130. else if (chat_val.substring(1,8)=="remove " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  2131. if (echo_list.indexOf(chat_val.substring(7).replace(/^\s+|\s+$/g, ''))!==-1){
  2132. echo_list.splice(echo_list.indexOf(chat_val.substring(7).replace(/^\s+|\s+$/g, '')),1);
  2133. displayInChat(chat_val.substring(7).replace(/^\s+|\s+$/g, '')+" is not being echoed.","#DA0808","#1EBCC1");
  2134. return "";
  2135. }
  2136. else{
  2137. displayInChat("You cannot remove someone that you didn't echo.","#DA0808","#1EBCC1");
  2138. return "";
  2139. }
  2140.  
  2141. }
  2142. else if (chat_val.substring(1,12)=="echoappend " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  2143. echoAppend = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  2144. displayInChat(echoAppend +" will be appended to each echo. Type \"/echoappend\" to reset echoappend.","#DA0808","#1EBCC1");
  2145. return "";
  2146.  
  2147. }
  2148. else if (chat_val.substring(1,11)=="echoappend"){
  2149. echoAppend = "";
  2150. displayInChat("Reset echoappend.","#DA0808","#1EBCC1");
  2151. return "";
  2152.  
  2153. }
  2154. else if (chat_val.substring(1,10)=="clearecho"){
  2155. echo_list = [];
  2156. displayInChat("Cleared the echo list.","#DA0808","#1EBCC1");
  2157. return "";
  2158. }
  2159. else if (chat_val.substring(1,6)=="space"){
  2160. if(space_flag == true){
  2161. displayInChat("Space is now off.","#DA0808","#1EBCC1");
  2162. space_flag = false;
  2163. }
  2164. else{
  2165. displayInChat("Space is now on.","#DA0808","#1EBCC1");
  2166. space_flag = true;
  2167. }
  2168. return "";
  2169. }
  2170. else if (chat_val.substring(1,6)=="rcaps"){
  2171. if(rcaps_flag == true){
  2172. displayInChat("Rcaps is now off.","#DA0808","#1EBCC1");
  2173. rcaps_flag = false;
  2174. }
  2175. else{
  2176. displayInChat("Rcaps is now on.","#DA0808","#1EBCC1");
  2177. rcaps_flag = true;
  2178. }
  2179.  
  2180. return "";
  2181. }
  2182. else if (chat_val.substring(1,7)=="number"){
  2183. if(number_flag == true){
  2184. displayInChat("Number is now off.","#DA0808","#1EBCC1");
  2185. number_flag = false;
  2186. }
  2187. else{
  2188. displayInChat("Number is now on.","#DA0808","#1EBCC1");
  2189. number_flag = true;
  2190. }
  2191.  
  2192. return "";
  2193. }
  2194. else if (chat_val.substring(1,7)=="speech"){
  2195. if(text2speech == true){
  2196. displayInChat("Text to speech is now off.","#DA0808","#1EBCC1");
  2197. text2speech = false;
  2198. }
  2199. else{
  2200. displayInChat("Text to speech is now on.","#DA0808","#1EBCC1");
  2201. text2speech = true;
  2202. }
  2203.  
  2204. return "";
  2205. }
  2206. else if (chat_val.substring(1,6)=="eval " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  2207. var ev = "";
  2208. try{
  2209. ev = eval(chat_val.substring(6).replace(/^\s+|\s+$/g, ''));
  2210. }
  2211. catch(e){
  2212. displayInChat(e.message,"#DA0808","#1EBCC1");
  2213. }
  2214. try{
  2215. displayInChat(ev.toString(),"#DA0808","#1EBCC1");
  2216. }
  2217. catch{
  2218. }
  2219.  
  2220. return "";
  2221.  
  2222. }
  2223.  
  2224. else if (chat_val.substring(1,9)=="hidechat"){
  2225. Gdocument.getElementById("ingamechatcontent").style["max-height"]="0px";
  2226. return "";
  2227. }
  2228. else if (chat_val.substring(1,9)=="showchat"){
  2229. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  2230. return "";
  2231. }
  2232.  
  2233. else if (chat_val.substring(1,7)=="scroll"){
  2234. if(scroll==false){
  2235. scroll = true;
  2236. Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="scroll";
  2237. Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
  2238. }
  2239. else if(scroll==true){
  2240. scroll = false;
  2241. Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="hidden";
  2242. Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
  2243. }
  2244.  
  2245. return "";
  2246. }
  2247.  
  2248. else if (chat_val.substring(1,7)=="chatw "){
  2249. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '');
  2250.  
  2251. if(username == text){
  2252. displayInChat("You cannot private chat with yourself.","#DA0808","#1EBCC1");
  2253. return "";
  2254. }
  2255. private_chat = text;
  2256.  
  2257. SEND("42"+JSON.stringify([4,{"type":"request public key","from":username,"to":private_chat}]));
  2258. request_public_key_time_stamp = Date.now();
  2259. 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);
  2260. return "";
  2261. }
  2262.  
  2263. else if (chat_val.substring(1,5)=="msg " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  2264. if(private_chat_public_key[1][0] != 0 && private_chat_public_key[1][1] != 0 && private_chat_public_key[0] == private_chat){
  2265. var text = chat_val.substring(5).replace(/^\s+|\s+$/g, '');
  2266. var password = [];
  2267. for(var i = 0;i<10;i++){
  2268. password.push(Math.floor(Math.random()*100+50));
  2269. }
  2270. var text2 = [];
  2271. for(var i = 0;i<text.slice(0,400).length ;i++){
  2272. text2.push(password[i%password.length]^text.slice(0,400).charCodeAt(i));
  2273. }
  2274. pmlastmessage = text.slice(0,400);
  2275. 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)}]));
  2276. displayInChat("> "+username+": "+text,"#DA0808","#1EBCC1");
  2277.  
  2278. }
  2279. return "";
  2280. }
  2281. else if (chat_val.substring(1,10)=="ignorepm " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  2282. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  2283. if(ignorepmlist.includes(text)){
  2284. var index = ignorepmlist.indexOf(text);
  2285. ignorepmlist.splice(index,1);
  2286. displayInChat("You are not ignoring private messages from "+text+".","#DA0808","#1EBCC1");
  2287.  
  2288. }
  2289. else{
  2290. ignorepmlist.push(text);
  2291. displayInChat("You are now ignoring private messages from "+text+".","#DA0808","#1EBCC1");
  2292. }
  2293. return "";
  2294. }
  2295. else if (chat_val.substring(1,8)=="pmusers"){
  2296. pmusers = [];
  2297. SEND("42"+JSON.stringify([4,{"type":"request private chat users","from":username}]));
  2298. pmuserstimestamp = Date.now();
  2299. setTimeout(function(){if(pmusers.length == 0){displayInChat("You cannot private chat with anyone.","#DA0808","#1EBCC1");
  2300. }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);
  2301. return "";
  2302. }
  2303. else if (chat_val.substring(1,6)=="lobby"){
  2304. lobby();
  2305. return "";
  2306. }
  2307. else if (chat_val.substring(1,9)=="debugger"){
  2308. if(Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"] == "none"){
  2309. debuggeropen = true;
  2310. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="block";
  2311. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="none";
  2312. Gdocument.getElementById("ingamechatinputtext").style["display"] = "none";
  2313. }
  2314. else{
  2315. debuggeropen = false;
  2316. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="none";
  2317. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  2318. Gdocument.getElementById("ingamechatinputtext").style["display"] = "";
  2319. }
  2320. return "";
  2321. }
  2322. else if (chat_val.substring(1,6)=="team " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  2323. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  2324. if(text == "r"){Gdocument.getElementById("newbonklobby_redbutton").click();}
  2325. else if(text == "g"){Gdocument.getElementById("newbonklobby_greenbutton").click();}
  2326. else if(text == "y"){Gdocument.getElementById("newbonklobby_yellowbutton").click();}
  2327. else if(text == "b"){Gdocument.getElementById("newbonklobby_bluebutton").click();}
  2328. else if(text == "s"){Gdocument.getElementById("newbonklobby_specbutton").click();}
  2329. else if(text == "f"){Gdocument.getElementById("newbonklobby_ffabutton").click();}
  2330. return "";
  2331. }
  2332. else if (chat_val.substring(1,7)=="notify"){
  2333.  
  2334. npermissions = 1;
  2335. return "";
  2336. }
  2337. else if (chat_val.substring(1,11)=="stopnotify"){
  2338.  
  2339. npermissions = 0;
  2340. return "";
  2341. }
  2342. else if (chat_val.substring(1,5)=="help" || chat_val.substring(1,2)=="?"){
  2343. for(var i = 0;i<help.length;i++){
  2344. if(help[i].startsWith("/")){
  2345. var splitted = help[i].substring(1).split(" ");
  2346. var command = splitted[0];
  2347. var rest = "";
  2348. if(splitted.length>1){
  2349. rest = " "+splitted.slice(1).join(" ");
  2350. }
  2351. displayInChat("/"+'<a onclick = \'Gwindow.displayInChat("'+adv_help[command]+'","#009398","#DA0808",{sanitize:true},"",true);\' style = "color:green;" href = "javascript:void(0);">'+command+'</a>'+rest,"#DA0808","#1EBCC1",{sanitize:false});
  2352. }
  2353. else{
  2354. displayInChat(help[i],"#DA0808","#1EBCC1");
  2355. }
  2356.  
  2357. }
  2358. return "";
  2359. }
  2360. else if (chat_val.substring(1,9)=="advhelp " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  2361. var text = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  2362. if(typeof(adv_help[text])!='undefined'){
  2363. displayInChat(adv_help[text],"#DA0808","#1EBCC1");
  2364. }
  2365. return "";
  2366. }
  2367. else if(ishost){
  2368.  
  2369. if (chat_val.substring(1,5)=="next" && stopquickplay == 0){
  2370. if(shuffle){
  2371. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  2372. var available = [];
  2373. var availableindexes = [];
  2374. var notempty = false;
  2375. for(var i = 0; i<e.length;i++){
  2376. var a = false;
  2377. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  2378. available.push(a);
  2379. if(a){
  2380. availableindexes.push(i);
  2381. notempty = true;
  2382. }
  2383. }
  2384. if(notempty){
  2385.  
  2386. if(availableindexes.length!=1){
  2387. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  2388. }
  2389. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  2390. }
  2391. }
  2392. else{
  2393. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  2394. var available = [];
  2395. var availableindexes = [];
  2396. var notempty = false;
  2397. for(var i = 0; i<e.length;i++){
  2398. var a = false;
  2399. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  2400. available.push(a);
  2401. if(a){
  2402. availableindexes.push(i);
  2403. notempty = true;
  2404. }
  2405. }
  2406. if(notempty){
  2407. var above = [];
  2408. for(var i = 0;i<availableindexes.length;i++){
  2409. if(availableindexes[i]>quicki){
  2410. above.push(availableindexes[i]);
  2411. }
  2412. }
  2413. if(above.length>0){
  2414. quicki = above[0];
  2415. }
  2416. else{
  2417. quicki = availableindexes[0];
  2418. }
  2419. }
  2420. }
  2421. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  2422. displayInChat("Switched to next map.","#DA0808","#1EBCC1");
  2423. return "";
  2424.  
  2425. }
  2426. else if (chat_val.substring(1,9)=="freejoin"){
  2427. if(freejoin == false){
  2428. freejoin = true;
  2429. displayInChat("Freejoin is now on.","#DA0808","#1EBCC1");
  2430.  
  2431. }
  2432. else{
  2433. freejoin = false;
  2434. displayInChat("Freejoin is now off.","#DA0808","#1EBCC1");
  2435. }
  2436.  
  2437. return "";
  2438.  
  2439. }
  2440. else if (chat_val.substring(1,8)=="instaqp"){
  2441. if(instaqp == false){
  2442. instaqp = true;
  2443. displayInChat("Instaqp is now on.","#DA0808","#1EBCC1");
  2444.  
  2445. }
  2446. else{
  2447. instaqp = false;
  2448. displayInChat("Instaqp is now off.","#DA0808","#1EBCC1");
  2449. }
  2450.  
  2451. return "";
  2452.  
  2453. }
  2454.  
  2455. else if (chat_val.substring(1,9)=="previous" && stopquickplay == 0){
  2456. if(shuffle){
  2457. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  2458. var available = [];
  2459. var availableindexes = [];
  2460. var notempty = false;
  2461. for(var i = 0; i<e.length;i++){
  2462. var a = false;
  2463. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  2464. available.push(a);
  2465. if(a){
  2466. availableindexes.push(i);
  2467. notempty = true;
  2468. }
  2469. }
  2470. if(notempty){
  2471.  
  2472. if(availableindexes.length!=1){
  2473. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  2474. }
  2475. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  2476. }
  2477. }
  2478. else{
  2479. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  2480. var available = [];
  2481. var availableindexes = [];
  2482. var notempty = false;
  2483. for(var i = 0; i<e.length;i++){
  2484. var a = false;
  2485. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  2486. available.push(a);
  2487. if(a){
  2488. availableindexes.push(i);
  2489. notempty = true;
  2490. }
  2491. }
  2492. if(notempty){
  2493. var above = [];
  2494. for(var i = 0;i<availableindexes.length;i++){
  2495. if(availableindexes[i]<quicki){
  2496. above.push(availableindexes[i]);
  2497. }
  2498. }
  2499. if(above.length>0){
  2500. quicki = above[above.length-1];
  2501. }
  2502. else{
  2503. quicki = availableindexes[availableindexes.length-1];
  2504. }
  2505. }
  2506. }
  2507. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  2508.  
  2509. displayInChat("Switched to previous map.","#DA0808","#1EBCC1");
  2510. return "";
  2511. }
  2512. else if (chat_val.substring(1,6)=="start" && chat_val.length == 6){
  2513. Gdocument.getElementById("newbonklobby_editorbutton").click();
  2514. if(recmodebool && ishost){
  2515. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  2516. if(mode == "" && defaultmode!="d"){
  2517. mode = defaultmode;
  2518. }
  2519. if(mode != ""){
  2520. RECIEVE('42[26,"b","'+mode+'"]');
  2521. }
  2522. }
  2523. Gdocument.getElementById("mapeditor_close").click();
  2524. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  2525. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  2526.  
  2527. return "";
  2528. }
  2529.  
  2530. else if (chat_val.substring(1,8)=="startqp" && stopquickplay == 1){
  2531. stopquickplay = 0;
  2532. quicki = 0;
  2533. displayInChat("Enabled quickplay.","#DA0808","#1EBCC1");
  2534. return "";
  2535. }
  2536. else if (chat_val.substring(1,7)=="stopqp" && stopquickplay == 0){
  2537. stopquickplay = 1;
  2538. quicki = 0;
  2539. displayInChat("Disabled quickplay.","#DA0808","#1EBCC1");
  2540. return "";
  2541. }
  2542.  
  2543. else if (chat_val.substring(1,5)=="ban " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  2544. banned.push(chat_val.substring(5).replace(/^\s+|\s+$/g, ''));
  2545. displayInChat("Banned "+chat_val.substring(5).replace(/^\s+|\s+$/g, '')+".","#DA0808","#1EBCC1");
  2546. return "/kick '" + chat_val.substring(5).replace(/^\s+|\s+$/g, '') + "'";
  2547. }
  2548. else if (chat_val.substring(1,6)=="kill " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  2549. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  2550. var keys = Object.keys(playerids);
  2551. var killid = undefined;
  2552. for(var i = 0; i<keys.length; i++){
  2553. if(playerids[keys[i]].userName == text){
  2554. killid = keys[i];
  2555. }
  2556. }
  2557. if(typeof(killid)!="undefined" && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden" && !killedids.includes(killid)){
  2558. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  2559. killedids.push(killid);
  2560. SEND('42[25,{"a":{"playersLeft":['+killid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  2561. RECIEVE('42[31,{"a":{"playersLeft":['+killid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  2562. }
  2563. return "";
  2564. }
  2565. else if (chat_val.substring(1,10)=="balanceA " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  2566. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  2567. if(!isNaN(parseInt(text))){
  2568. if(parseInt(text)>=-100 && parseInt(text)<=100){
  2569. var keys = Object.keys(playerids);
  2570. for(var i = 0; i<keys.length;i++){
  2571. SEND('42[29,{"sid":'+keys[i]+',"bal":'+text+'}]');
  2572. RECIEVE('42[36,'+keys[i]+','+text+']');
  2573. }
  2574. }
  2575. }
  2576. return "";
  2577.  
  2578. }
  2579. else if (chat_val.substring(1,7)=="moveA " && chat_val.replace(/^\s+|\s+$/g, '').length>=8){
  2580. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '');
  2581. var keys = Object.keys(playerids);
  2582. if(text == "f"){
  2583. for(var i = 0; i<keys.length;i++){
  2584. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":1}]')
  2585. }
  2586. }
  2587. else if(text == "b"){
  2588. for(var i = 0; i<keys.length;i++){
  2589. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":3}]')
  2590. }
  2591. }
  2592. else if(text == "g"){
  2593. for(var i = 0; i<keys.length;i++){
  2594. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":4}]')
  2595. }
  2596. }
  2597. else if(text == "r"){
  2598. for(var i = 0; i<keys.length;i++){
  2599. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":2}]')
  2600. }
  2601. }
  2602. else if(text == "y"){
  2603. for(var i = 0; i<keys.length;i++){
  2604. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":5}]')
  2605. }
  2606. }
  2607. else if(text == "s"){
  2608. for(var i = 0; i<keys.length;i++){
  2609. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":0}]')
  2610. }
  2611. }
  2612. return "";
  2613. }
  2614. else if (chat_val.substring(1,8)=="rounds " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  2615. var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '');
  2616. if(!isNaN(parseInt(text))){
  2617. text = parseInt(text).toString();
  2618. SEND('42[21,{"w":'+text+'}]');
  2619. RECIEVE('42[27,'+text+']');
  2620. }
  2621. return "";
  2622.  
  2623. }
  2624. else if (chat_val.substring(1,6)=="mode " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  2625. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  2626. var mode = "";
  2627. if(text == "arrows"){
  2628. mode = "ar";
  2629. displayInChat("Changed mode to arrows.","#DA0808","#1EBCC1");
  2630. }
  2631. else if(text == "death arrows"){
  2632. mode = "ard";
  2633. displayInChat("Changed mode to death arrows.","#DA0808","#1EBCC1");
  2634. }
  2635. else if(text == "grapple"){
  2636. mode = "sp";
  2637. displayInChat("Changed mode to grapple.","#DA0808","#1EBCC1");
  2638. }
  2639. else if(text == "classic"){
  2640. mode = "b";
  2641. displayInChat("Changed mode to classic.","#DA0808","#1EBCC1");
  2642.  
  2643. }
  2644. else{
  2645. displayInChat("Mode options:","#DA0808","#1EBCC1");
  2646. displayInChat("classic","#DA0808","#1EBCC1");
  2647. displayInChat("arrows","#DA0808","#1EBCC1");
  2648. displayInChat("death arrows","#DA0808","#1EBCC1");
  2649. displayInChat("grapple","#DA0808","#1EBCC1");
  2650. }
  2651. if(mode != ""){
  2652. SEND('42[20,{"ga":"b","mo":"'+mode+'"}]');
  2653. RECIEVE('42[26,"b","'+mode+'"]');
  2654. }
  2655. return "";
  2656.  
  2657. }
  2658. else if (chat_val.substring(1,13)=="disablekeys " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  2659. var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '');
  2660. var keys = text.split(" ");
  2661. var disabledkeys2 = [];
  2662. var possiblekeys = ["left","right","up","down","heavy","special"];
  2663. for(var i = 0; i<keys.length; i++){
  2664. if(keys[i]!="" && !disabledkeys2.includes(keys[i])){
  2665. if(possiblekeys.includes(keys[i])){
  2666. disabledkeys2.push(keys[i]);
  2667. }
  2668. else{
  2669. displayInChat("Key options: " + possiblekeys.join(" ") + ".","#DA0808","#1EBCC1");
  2670. return "";
  2671. }
  2672. }
  2673. }
  2674. disabledkeys = disabledkeys2;
  2675. displayInChat("Set disabled keys to: " + disabledkeys.join(" ") + ".","#DA0808","#1EBCC1");
  2676. displayInChat("Type /disablekeys to reset disabled keys.","#DA0808","#1EBCC1");
  2677. return "";
  2678.  
  2679. }
  2680. else if (chat_val.substring(1,12)=="disablekeys"){
  2681. displayInChat("Reset disabled keys.","#DA0808","#1EBCC1");
  2682. disabledkeys = [];
  2683. return "";
  2684.  
  2685. }
  2686. else if (chat_val.substring(1,10)=="jointext " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  2687. jointext = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  2688. displayInChat("Set jointext to: " + jointext,"#DA0808","#1EBCC1");
  2689. displayInChat("Type /jointext to reset jointext.","#DA0808","#1EBCC1");
  2690. return "";
  2691.  
  2692. }
  2693. else if (chat_val.substring(1,9)=="jointext"){
  2694. jointext = "";
  2695. displayInChat("Reset jointext.","#DA0808","#1EBCC1");
  2696. return "";
  2697.  
  2698. }
  2699. else if (chat_val.substring(1,9)=="afkkill " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  2700. var text = parseFloat(chat_val.substring(9).replace(/^\s+|\s+$/g, ''));
  2701. if(typeof(text)!="NaN"){
  2702. displayInChat("Set afk kill to: " + text.toString()+" seconds.","#DA0808","#1EBCC1");
  2703. displayInChat("Type /afkkill to reset afk kill.","#DA0808","#1EBCC1");
  2704. var keys = Object.keys(playerids);
  2705. var now = Date.now();
  2706. for(var i = 0;i<keys.length;i++){
  2707. playerids[keys[i]].lastmove = now;
  2708. }
  2709. afkkill = text;
  2710. }
  2711. else{
  2712. displayInChat("Afk kill is a number.","#DA0808","#1EBCC1");
  2713. }
  2714. return "";
  2715.  
  2716. }
  2717. else if (chat_val.substring(1,9)=="afkkill"){
  2718. afkkill = -1;
  2719. displayInChat("Reset afk kill.","#DA0808","#1EBCC1");
  2720. return "";
  2721.  
  2722. }
  2723. else if (chat_val.substring(1,13)=="defaultmode " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  2724. var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '');
  2725. if(text == "default"){
  2726. defaultmode = "";
  2727. displayInChat("Changed default mode to default.","#DA0808","#1EBCC1");
  2728. }
  2729. else if(text == "arrows"){
  2730. defaultmode = "ar";
  2731. displayInChat("Changed default mode to arrows.","#DA0808","#1EBCC1");
  2732. }
  2733. else if(text == "death arrows"){
  2734. defaultmode = "ard";
  2735. displayInChat("Changed default mode to death arrows.","#DA0808","#1EBCC1");
  2736. }
  2737. else if(text == "grapple"){
  2738. defaultmode = "sp";
  2739. displayInChat("Changed default mode to grapple.","#DA0808","#1EBCC1");
  2740. }
  2741. else if(text == "classic"){
  2742. defaultmode = "b";
  2743. displayInChat("Changed default mode to classic.","#DA0808","#1EBCC1");
  2744.  
  2745. }
  2746. else{
  2747. displayInChat("Default mode options:","#DA0808","#1EBCC1");
  2748. displayInChat("default","#DA0808","#1EBCC1");
  2749. displayInChat("classic","#DA0808","#1EBCC1");
  2750. displayInChat("arrows","#DA0808","#1EBCC1");
  2751. displayInChat("death arrows","#DA0808","#1EBCC1");
  2752. displayInChat("grapple","#DA0808","#1EBCC1");
  2753. }
  2754. return "";
  2755.  
  2756. }
  2757. else if (chat_val.substring(1,8)=="recmode"){
  2758. if(recmodebool == true){
  2759. recmodebool = false;
  2760. displayInChat("Recmode is now off.","#DA0808","#1EBCC1");
  2761.  
  2762. }
  2763. else{
  2764. recmodebool = true;
  2765. displayInChat("Recmode is now on.","#DA0808","#1EBCC1");
  2766.  
  2767. }
  2768.  
  2769. return "";
  2770.  
  2771. }
  2772. else if (chat_val.substring(1,8)=="recteam"){
  2773. if(recteams == true){
  2774. recteams = false;
  2775. displayInChat("Recteam is now off.","#DA0808","#1EBCC1");
  2776.  
  2777. }
  2778. else{
  2779. recteams = true;
  2780. displayInChat("Recteam is now on.","#DA0808","#1EBCC1");
  2781.  
  2782. }
  2783. return "";
  2784. }
  2785. else if (chat_val.substring(1,8)=="shuffle"){
  2786. if(shuffle == true){
  2787. shuffle = false;
  2788. displayInChat("Shuffle is now off.","#DA0808","#1EBCC1");
  2789.  
  2790. }
  2791. else{
  2792. shuffle = true;
  2793. displayInChat("Shuffle is now on.","#DA0808","#1EBCC1");
  2794.  
  2795. }
  2796.  
  2797. return "";
  2798.  
  2799. }
  2800. else if(sandboxon){
  2801. if (chat_val.substring(1,11)=="addplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  2802. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  2803. if(!isNaN(parseInt(text))){
  2804. var text2 = parseInt(text);
  2805. if(text2>0){
  2806. for(var i = 0;i<text2;i++){
  2807. RECIEVE('42[4,'+sandboxid+',"0123456789abcdef","'+sandboxid.toString()+'",true,0,1,{"layers":[],"bc":'+Math.floor(Math.random() * 16777215).toString()+'}]');
  2808. sandboxplayerids[sandboxid] = sandboxid.toString();
  2809. sandboxid+=1;
  2810. }
  2811.  
  2812. }
  2813. }
  2814. return "";
  2815.  
  2816. }
  2817. else if (chat_val.substring(1,11)=="delplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  2818. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  2819. if(!isNaN(parseInt(text))){
  2820. var text2 = parseInt(text);
  2821. if(text2>0){
  2822. if(Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden"){
  2823. var jsonkeys = Object.keys(sandboxplayerids).reverse();
  2824. for(var i = 0;i<text2 && i<jsonkeys.length;i++){
  2825. RECIEVE('42[5,'+jsonkeys[i]+',0]');
  2826. delete sandboxplayerids[jsonkeys[i]];
  2827. }
  2828. }
  2829. else{
  2830. displayInChat("Cannot delete players while ingame.","#DA0808","#1EBCC1");
  2831. }
  2832.  
  2833. }
  2834. }
  2835. return "";
  2836. }
  2837. else if (chat_val.substring(1,7)=="copyme"){
  2838. if(sandboxcopyme == true){
  2839. displayInChat("Copyme is now off.","#DA0808","#1EBCC1");
  2840. sandboxcopyme = false;
  2841. }
  2842. else{
  2843. displayInChat("Copyme is now on.","#DA0808","#1EBCC1");
  2844. sandboxcopyme = true;
  2845. }
  2846.  
  2847. return "";
  2848. }
  2849. }
  2850. }
  2851. return chat_val;
  2852. };
  2853.  
  2854. scope.flag_manage = function(t){
  2855. var text = t;
  2856.  
  2857. if(rcaps_flag == true){
  2858. text = text.split('');
  2859. for(var i = 0; i<text.length;i++){
  2860. if(Math.floor(Math.random()*2)){
  2861. text[i] = text[i].toUpperCase();
  2862. }
  2863. else{
  2864. text[i] = text[i].toLowerCase();
  2865. }
  2866. }
  2867. text = text.join('');
  2868. }
  2869. if(space_flag == true){
  2870. text = text.split('').join(' ')
  2871. }
  2872. if(number_flag == true){
  2873. text = text.replace(/[t|T][Oo]+/g,"2");
  2874. text = text.replace(/[f|F][o|O][r|R]/g,"4");
  2875. text = text.replace(/[a|A][t|T][e|E]/g,"8");
  2876. text = text.replace(/[e|E]/g,"3");
  2877. text = text.replace(/[a|A]/g,"4");
  2878. text = text.replace(/[o|O]/g,"0");
  2879. text = text.replace(/[s|S]/g,"5");
  2880. text = text.replace(/[i|I|l|L]/g,"1");
  2881. }
  2882. return text;
  2883. };
  2884. Gdocument.getElementById("newbonklobby_chat_input").onkeydown = function(e){
  2885. if(e.keyCode==13){
  2886.  
  2887. var chat_val = Gdocument.getElementById("newbonklobby_chat_input").value;
  2888.  
  2889. if (chat_val!="" && chat_val[0]=="/"){
  2890.  
  2891. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  2892. chat(commandhandle(chat_val));
  2893. }
  2894. else{
  2895. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  2896. chat(flag_manage(chat_val));
  2897. }
  2898.  
  2899. }
  2900. };
  2901. Gdocument.getElementById("ingamechatinputtext").onkeydown = function(e){
  2902. if(e.keyCode==13){
  2903.  
  2904. var chat_val = Gdocument.getElementById("ingamechatinputtext").value;
  2905.  
  2906. if (chat_val!="" && chat_val[0]=="/"){
  2907.  
  2908. Gdocument.getElementById("ingamechatinputtext").value = "";
  2909. chat(commandhandle(chat_val));
  2910. }
  2911. else{
  2912. Gdocument.getElementById("ingamechatinputtext").value = "";
  2913. chat(flag_manage(chat_val));
  2914. }
  2915. }
  2916. };
  2917. scope.Last_message = "";
  2918. scope.Laster_message = "";
  2919. scope.new_message = false;
  2920. scope.changed_chat = false;
  2921. scope.interval = setInterval(timeout123,60);
  2922.  
  2923. scope.hotkeys = function(e){
  2924. var keycode = e.code;
  2925. if(e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  2926. if(keycode == "Period"){
  2927. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]!="0px"){
  2928. chatheight+=5;
  2929. if(chatheight>600){chatheight = 600;}
  2930. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  2931. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  2932. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  2933. }
  2934. e.preventDefault();
  2935. }
  2936. if(keycode == "Comma"){
  2937. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]!="0px"){
  2938. chatheight-=5;
  2939. if(chatheight<100){chatheight = 100;}
  2940. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  2941. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  2942. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  2943. }
  2944. e.preventDefault();
  2945. }
  2946. }
  2947. if(e.repeat){return;}
  2948. if(e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  2949. if(ishost){
  2950. if(keycode == "KeyE"){
  2951. if(Gdocument.getElementById("newbonklobby").style["display"] == "block"){
  2952. Gdocument.getElementById("newbonklobby_editorbutton").click();
  2953. }
  2954. else if(Gdocument.getElementById("mapeditorcontainer").style["display"] == "block"){
  2955. Gdocument.getElementById("mapeditor_close").click();
  2956. }
  2957. e.preventDefault();
  2958.  
  2959. }
  2960. else if(keycode == "KeyT"){
  2961. Gdocument.getElementById("newbonklobby_teamsbutton").click();
  2962. e.preventDefault();
  2963. }
  2964. else if(keycode == "KeyM"){
  2965. Gdocument.getElementById("newbonklobby_modebutton").click();
  2966. e.preventDefault();
  2967. }
  2968. else if(keycode == "KeyK"){
  2969. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  2970. Gdocument.getElementById("pretty_top_exit").click();
  2971. }
  2972. e.preventDefault();
  2973. }
  2974. else if(keycode == "KeyS"){
  2975. Gdocument.getElementById("newbonklobby_editorbutton").click();
  2976. if(recmodebool && ishost){
  2977. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  2978. if(mode == "" && defaultmode!="d"){
  2979. mode = defaultmode;
  2980. }
  2981. if(mode != ""){
  2982. RECIEVE('42[26,"b","'+mode+'"]');
  2983. }
  2984. }
  2985. Gdocument.getElementById("mapeditor_close").click();
  2986. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  2987. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  2988. e.preventDefault();
  2989. }
  2990. else if(keycode == "KeyD"){
  2991. if(stopquickplay == 0){
  2992. if(shuffle){
  2993. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  2994. var available = [];
  2995. var availableindexes = [];
  2996. var notempty = false;
  2997. for(var i = 0; i<e2.length;i++){
  2998. var a = false;
  2999. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  3000. available.push(a);
  3001. if(a){
  3002. availableindexes.push(i);
  3003. notempty = true;
  3004. }
  3005. }
  3006. if(notempty){
  3007.  
  3008. if(availableindexes.length!=1){
  3009. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  3010. }
  3011. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  3012. }
  3013. }
  3014. else{
  3015. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  3016. var available = [];
  3017. var availableindexes = [];
  3018. var notempty = false;
  3019. for(var i = 0; i<e2.length;i++){
  3020. var a = false;
  3021. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  3022. available.push(a);
  3023. if(a){
  3024. availableindexes.push(i);
  3025. notempty = true;
  3026. }
  3027. }
  3028. if(notempty){
  3029. var above = [];
  3030. for(var i = 0;i<availableindexes.length;i++){
  3031. if(availableindexes[i]>quicki){
  3032. above.push(availableindexes[i]);
  3033. }
  3034. }
  3035. if(above.length>0){
  3036. quicki = above[0];
  3037. }
  3038. else{
  3039. quicki = availableindexes[0];
  3040. }
  3041. }
  3042. }
  3043. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  3044. }
  3045. e.preventDefault();
  3046. }
  3047. else if(keycode == "KeyA"){
  3048. if(stopquickplay == 0){
  3049. if(shuffle){
  3050. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  3051. var available = [];
  3052. var availableindexes = [];
  3053. var notempty = false;
  3054. for(var i = 0; i<e2.length;i++){
  3055. var a = false;
  3056. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  3057. available.push(a);
  3058. if(a){
  3059. availableindexes.push(i);
  3060. notempty = true;
  3061. }
  3062. }
  3063. if(notempty){
  3064.  
  3065. if(availableindexes.length!=1){
  3066. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  3067. }
  3068. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  3069. }
  3070. }
  3071. else{
  3072. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  3073. var available = [];
  3074. var availableindexes = [];
  3075. var notempty = false;
  3076. for(var i = 0; i<e2.length;i++){
  3077. var a = false;
  3078. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  3079. available.push(a);
  3080. if(a){
  3081. availableindexes.push(i);
  3082. notempty = true;
  3083. }
  3084. }
  3085. if(notempty){
  3086. var above = [];
  3087. for(var i = 0;i<availableindexes.length;i++){
  3088. if(availableindexes[i]<quicki){
  3089. above.push(availableindexes[i]);
  3090. }
  3091. }
  3092. if(above.length>0){
  3093. quicki = above[above.length-1];
  3094. }
  3095. else{
  3096. quicki = availableindexes[availableindexes.length-1];
  3097. }
  3098. }
  3099. }
  3100. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  3101. }
  3102. e.preventDefault();
  3103. }
  3104. else if(keycode == "KeyQ"){
  3105. if(stopquickplay == 1){
  3106. stopquickplay = 0;
  3107. quicki = 0;
  3108. displayInChat("Enabled quickplay.","#DA0808","#1EBCC1");
  3109. }
  3110. else{
  3111. stopquickplay = 1;
  3112. quicki = 0;
  3113. displayInChat("Disabled quickplay.","#DA0808","#1EBCC1");
  3114. }
  3115. e.preventDefault();
  3116. }
  3117. else if(keycode == "KeyR"){
  3118. if(recmodebool == true){
  3119. recmodebool = false;
  3120. displayInChat("Recmode is now off.","#DA0808","#1EBCC1");
  3121.  
  3122. }
  3123. else{
  3124. recmodebool = true;
  3125. displayInChat("Recmode is now on.","#DA0808","#1EBCC1");
  3126.  
  3127. }
  3128. }
  3129. else if(keycode == "KeyF"){
  3130. if(freejoin == false){
  3131. freejoin = true;
  3132. displayInChat("Freejoin is now on.","#DA0808","#1EBCC1");
  3133.  
  3134. }
  3135. else{
  3136. freejoin = false;
  3137. displayInChat("Freejoin is now off.","#DA0808","#1EBCC1");
  3138. }
  3139. e.preventDefault();
  3140. }
  3141. }
  3142. else{
  3143. if(keycode == "KeyE"){
  3144. e.preventDefault();
  3145. }
  3146. else if(keycode == "KeyT"){
  3147. e.preventDefault();
  3148. }
  3149. else if(keycode == "KeyM"){
  3150. e.preventDefault();
  3151. }
  3152. else if(keycode == "KeyK"){
  3153. e.preventDefault();
  3154. }
  3155. else if(keycode == "KeyS"){
  3156. e.preventDefault();
  3157. }
  3158. else if(keycode == "KeyD"){
  3159. e.preventDefault();
  3160. }
  3161. else if(keycode == "KeyA"){
  3162. e.preventDefault();
  3163. }
  3164. else if(keycode == "KeyQ"){
  3165. e.preventDefault();
  3166. }
  3167. else if(keycode == "KeyF"){
  3168. e.preventDefault();
  3169. }
  3170. else if(keycode == "KeyR"){
  3171. e.preventDefault();
  3172. }
  3173.  
  3174. }
  3175. if(keycode == "KeyL"){
  3176. lobby();
  3177. e.preventDefault();
  3178. }
  3179. if(keycode == "KeyC"){
  3180. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  3181. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]=="0px"){
  3182. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  3183. }
  3184. else{
  3185. Gdocument.getElementById("ingamechatcontent").style["max-height"]="0px";
  3186. }
  3187. }
  3188. e.preventDefault();
  3189. }
  3190. if(keycode == "KeyI"){
  3191. if(Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"] == "none"){
  3192. debuggeropen = true;
  3193. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="block";
  3194. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="none";
  3195. Gdocument.getElementById("ingamechatinputtext").style["display"] = "none";
  3196. }
  3197. else{
  3198. debuggeropen = false;
  3199. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="none";
  3200. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  3201. Gdocument.getElementById("ingamechatinputtext").style["display"] = "";
  3202. }
  3203. e.preventDefault();
  3204. }
  3205. }
  3206. if(!e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  3207. if(keycode == "Slash" && !(Gdocument.getElementById("gmeditor")?.style["transform"] == "scale(1)")){
  3208. 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"]==""){
  3209. Gdocument.getElementById("newbonklobby_chat_input").value = "/";
  3210. if(Gdocument.getElementById("newbonklobby_chat_input").style["pointer-events"] == "none"){
  3211. fire("keydown",{keyCode:13});
  3212. }
  3213. else{
  3214. Gdocument.getElementById("newbonklobby_chat_input").focus();
  3215. }
  3216. e.preventDefault();
  3217.  
  3218. }
  3219. else if(Gdocument.getElementById("ingamechatinputtext").style["visibility"]=="visible" && Gdocument.getElementById("ingamechatinputtext").style["display"]=="" && Gdocument.getElementById("mapeditorcontainer").style["display"]!="block" && Gdocument.getElementById("ingamechatinputtext").value == ""){
  3220. Gdocument.getElementById("ingamechatinputtext").value = "/";
  3221. if(!Gdocument.getElementById("ingamechatinputtext").classList.value.includes("ingamechatinputtextbg")){
  3222. fire("keydown",{keyCode:13});
  3223. }
  3224. else{
  3225. Gdocument.getElementById("ingamechatinputtext").focus();
  3226. }
  3227. e.preventDefault();
  3228.  
  3229. }
  3230. }
  3231. }
  3232. };
  3233.  
  3234. Gdocument.onkeydown = hotkeys;
  3235.  
  3236. Gwindow.addEventListener('resize',function(e){
  3237. debuggermenu.style["width"] = Gdocument.getElementById("bonkiocontainer").style["width"];
  3238. debuggermenu.style["height"] = Gdocument.getElementById("bonkiocontainer").style["height"];
  3239. scope.width = parseInt(Gdocument.getElementById("bonkiocontainer").style["width"])-20;
  3240. scope.height = parseInt(Gdocument.getElementById("bonkiocontainer").style["height"])-210;
  3241. logmenu.style["width"] = width.toString()+"px";
  3242. logmenu.style["height"] = height.toString()+"px";
  3243. logmenutopleft.style["width"] = (width/2).toString()+"px";
  3244. logmenutopright.style["width"] = (width/2).toString()+"px";
  3245. logmenutopright.style["left"] = (width/2).toString()+"px";
  3246. debuggerinput.style["width"] = width.toString()+"px";
  3247. debuggerinput.style["top"] = (height+90).toString()+"px";
  3248. debuggersendrecieve.style["top"] = (height+120).toString()+"px";
  3249. debuggerpausebutton.style["top"] = (height+150).toString()+"px";
  3250. debuggereval.style["width"] = (width-150).toString()+"px";
  3251. debuggereval.style["top"] = (height+120).toString()+"px";},true);
  3252.  
  3253.  
  3254. function timeout123() {
  3255. updateWssLog();
  3256. if(afkkill>0 && ishost){
  3257. var keys = Object.keys(playerids);
  3258. var now = Date.now();
  3259. currentFrame = Math.floor((now - gameStartTimeStamp)/1000*30);
  3260. for(var i = 0; i<keys.length;i++){
  3261. if(typeof(playerids[keys[i]].lastmove)=="undefined"){
  3262. playerids[keys[i]].lastmove = now;
  3263. }
  3264. else{
  3265. if(now-playerids[keys[i]].lastmove>=afkkill*1000 && now-gameStartTimeStamp>=afkkill*1000 && !killedids.includes(keys[i])){
  3266. killedids.push(keys[i]);
  3267. SEND('42[25,{"a":{"playersLeft":['+keys[i]+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  3268. RECIEVE('42[31,{"a":{"playersLeft":['+keys[i]+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  3269. break;
  3270. }
  3271. }
  3272. }
  3273. }
  3274. if(ishost && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS"){
  3275. clearmaprequests.style["display"] = "block";
  3276. refreshmaprequests.style["display"] = "block";
  3277. }
  3278. else{
  3279. clearmaprequests.style["display"] = "none";
  3280. refreshmaprequests.style["display"] = "none";
  3281. }
  3282. if(Gdocument.getElementById("gamerenderer").style["visibility"]=="hidden"){
  3283. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  3284. }
  3285. if(Gdocument.getElementById("maploadwindowmapscontainer").children.length>0 && maponclick == 0){
  3286. maponclick = Gdocument.getElementById("maploadwindowmapscontainer").children[0].onclick;
  3287. }
  3288. if(Gdocument.getElementById("sm_connectingContainer").style["visibility"] == "hidden"){
  3289. var chatbox = Gdocument.getElementById("newbonklobby_chat_content");
  3290. while (chatbox.firstChild) {
  3291. chatbox.removeChild(chatbox.firstChild);
  3292. }
  3293. rcaps_flag = false;
  3294. space_flag = false;
  3295. number_flag = false;
  3296. echo_list = [];
  3297. scroll = false;
  3298. stopquickplay = 1;
  3299. checkboxhidden = false;
  3300. freejoin = false;
  3301. shuffle = false;
  3302. defaultmode = "";
  3303. recmodebool = false;
  3304. recteams = false;
  3305. playerids = {};
  3306. afkkill = -1;
  3307. jointext = "";
  3308. ishost = false;
  3309. sandboxplayerids = {};
  3310. sandboxcopyme = false;
  3311. sandboxon = false;
  3312. sandboxid = 1;
  3313. disabledkeys = [];
  3314. myid = -1;
  3315. hostid = -1;
  3316. if(chatlog[chatlog.length-1]!="ROOM END"){
  3317. chatlog.push("ROOM END");
  3318. }
  3319. }
  3320. else{
  3321. if(chatlog[chatlog.length-1]=="ROOM END"){
  3322. chatlog.push("ROOM START");
  3323. }
  3324. }
  3325.  
  3326. if(Gdocument.getElementById("newbonklobby").style["display"]=="block"){
  3327. Gdocument.getElementById("ingamechatinputtext").style["visibility"]="hidden";
  3328. }
  3329. else{
  3330. Gdocument.getElementById("ingamechatinputtext").style["visibility"]="visible";
  3331.  
  3332. }
  3333. mode = Gdocument.getElementById("newbonklobby_modetext").textContent;
  3334. if(Gdocument.getElementsByClassName('newbonklobby_settings_button brownButton brownButton_classic buttonShadow brownButtonDisabled').length == 0 && Gdocument.getElementById("newbonklobby_playerbox_elementcontainer").children.length+Gdocument.getElementById("newbonklobby_specbox_elementcontainer").children.length-3
  3335. >0){
  3336. ishost = true;
  3337. }
  3338. else{
  3339. ishost = actuallyhost;
  3340. }
  3341.  
  3342. if(Gdocument.getElementById("pretty_top_name")!=null){
  3343. username = Gdocument.getElementById("pretty_top_name").textContent;
  3344. }
  3345. try{
  3346. Last_message = lastmessage()
  3347. } catch{
  3348. Last_message = "";
  3349. }
  3350. if (Laster_message != Last_message){
  3351. Laster_message = Last_message;
  3352. if(changed_chat==false){
  3353. new_message = true;
  3354. }
  3355. else{
  3356. changed_chat = false;
  3357. }
  3358. }
  3359. if(new_message){
  3360. chatlog.push(Last_message);
  3361. var lm = "";
  3362. try{
  3363. lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  3364. if(typeof(lm[0].parentElement.style["parsed"]) == 'undefined'){
  3365. if (lm[0].className == "newbonklobby_chat_msg_colorbox"){
  3366. lm[2].innerHTML = urlify(lm[2].innerHTML);
  3367. Laster_message = lastmessage();
  3368. lm[0].parentElement.style["parsed"] = true;
  3369. }
  3370. if (lm[0].className == "newbonklobby_chat_status"){
  3371. lm[0].innerHTML = urlify(lm[0].innerHTML);
  3372. Laster_message = lastmessage();
  3373. lm[0].parentElement.style["parsed"] = true;
  3374. }
  3375. }
  3376. }
  3377. catch{
  3378. lm = "";
  3379. }
  3380.  
  3381. if(Last_message.indexOf("@"+username)!=-1 && npermissions == 1){
  3382. if(Notification.requestPermission()){
  3383. var n = new Notification(Last_message);
  3384. }
  3385. }
  3386.  
  3387. try{
  3388. lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  3389. if(typeof(lm[0].parentElement.style["parsed"])=='undefined'){
  3390. if(lm[0].className == "ingamechatname"){
  3391. lm[1].innerHTML = urlify(lm[1].innerHTML);
  3392. Laster_message = lastmessage();
  3393. lm[0].parentElement.style["parsed"] = true;
  3394. }
  3395. if(lm[0].className == ""){
  3396. lm[0].innerHTML = urlify(lm[0].innerHTML);
  3397. Laster_message = lastmessage();
  3398. lm[0].parentElement.style["parsed"] = true;
  3399. }
  3400. }
  3401. }
  3402. catch{
  3403. lm = "";
  3404. }
  3405. for(i=0;i<echo_list.length;i++){
  3406. if(Last_message.substring(0,echo_list[i].length+2) == echo_list[i]+": "){
  3407. message = Last_message.substring(echo_list[i].length+2);
  3408. chat(flag_manage(message+" "+echoAppend));
  3409. }
  3410. }
  3411. if(text2speech){
  3412. if(!sayer.speaking){
  3413. if(Last_message.includes(": ")){
  3414. speech.text = Last_message.substring(0,Last_message.indexOf(":")).toLowerCase();
  3415. speech.rate = 2.25;
  3416. sayer.speak(speech);
  3417. speech.text = Last_message.substring(Last_message.indexOf(": ")+3).toLowerCase();
  3418. speech.rate = 1.25;
  3419. sayer.speak(speech);
  3420. }
  3421. else{
  3422. speech.text = Last_message.toLowerCase();
  3423. sayer.speak(speech);
  3424. }
  3425. }
  3426. }
  3427. }
  3428. if (ishost==true && new_message){
  3429. for(i=0;i<banned.length;i++){
  3430. if(Last_message.startsWith("* "+banned[i]+" has joined the game")){
  3431. chat("/kick '"+banned[i]+"'");
  3432. }
  3433. }
  3434. }
  3435. if(ishost && stopquickplay == 0){
  3436. if(checkboxhidden){
  3437. checkboxhidden = false;
  3438. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  3439. for(var i = 0; i<classes.length;i++){
  3440. classes[i].style["display"] = "block";
  3441. classes[i].className = "quickplaycheckbox quickplaychecked";
  3442. }
  3443. Gdocument.getElementById('clearallcheckboxes').style["display"] = "block";
  3444.  
  3445. }
  3446. if(Gdocument.getElementById("ingamewinner").style["visibility"]=="inherit" && stopquickplay == 0 && dontswitch == false && !document.hidden){
  3447. if(shuffle){
  3448. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  3449. var available = [];
  3450. var availableindexes = [];
  3451. var notempty = false;
  3452. for(var i = 0; i<e.length;i++){
  3453. var a = false;
  3454. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  3455. available.push(a);
  3456. if(a){
  3457. availableindexes.push(i);
  3458. notempty = true;
  3459. }
  3460. }
  3461. if(notempty){
  3462. if(availableindexes.length!=1){
  3463. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  3464. }
  3465. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  3466. }
  3467. }
  3468. else{
  3469. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  3470. var available = [];
  3471. var availableindexes = [];
  3472. var notempty = false;
  3473. for(var i = 0; i<e.length;i++){
  3474. var a = false;
  3475. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  3476. available.push(a);
  3477. if(a){
  3478. availableindexes.push(i);
  3479. notempty = true;
  3480. }
  3481. }
  3482. if(notempty){
  3483. var above = [];
  3484. for(var i = 0;i<availableindexes.length;i++){
  3485. if(availableindexes[i]>quicki){
  3486. above.push(availableindexes[i]);
  3487. }
  3488. }
  3489. if(above.length>0){
  3490. quicki = above[0];
  3491. }
  3492. else{
  3493. quicki = availableindexes[0];
  3494. }
  3495. }
  3496. }
  3497. transitioning = true;
  3498. startedinqp = true;
  3499. map(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  3500. dontswitch = true;
  3501. setTimeout(function(){Gdocument.getElementById("ingamewinner").style["visibility"]="hidden"; dontswitch = false;},timedelay);
  3502. }
  3503. }
  3504. else{
  3505. if(!checkboxhidden){
  3506. checkboxhidden = true;
  3507. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  3508. for(var i = 0; i<classes.length;i++){
  3509. classes[i].style["display"] = "none";
  3510. classes[i].className = "quickplaycheckbox quickplayunchecked";
  3511. }
  3512. Gdocument.getElementById('clearallcheckboxes').style["display"] = "none";
  3513. }
  3514. }
  3515. new_message = false;
  3516. };
  3517. });