Bonk Commands

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

当前为 2023-05-10 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Bonk Commands
  3. // @namespace https://greasyfork.org/en/scripts/451341-bonk-commands
  4. // @version 15.3
  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. scope.scope = scope;
  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. clearInterval(injectedBonkCommandsScript);
  35. }
  36. scope.GENERATE_COPRIME_NUMBER = function(mini = 0,maxi = 0,coprimewith = 0,choices = []){
  37. if(choices.length == 0){
  38. for(var i = mini;i<maxi+1;i++){
  39. choices.push(i);
  40. }
  41. }
  42. firstTry = choices[Math.floor(Math.random()*choices.length)];
  43. for(var i = 2; i<firstTry+1;i++){
  44. if(firstTry%i == 0 && coprimewith%i == 0){
  45. choices.splice(choices.indexOf(firstTry),1);
  46. if(choices.length == 0){
  47. return 0;
  48. }
  49. return GENERATE_COPRIME_NUMBER(mini,maxi,coprimewith,choices);
  50. }
  51. }
  52. return firstTry;
  53. };
  54. scope.GENERATE_PRIME_NUMBER = function(mini = 0,maxi = 0,choices = []){
  55. if(choices.length == 0){
  56. for(var i = mini;i<maxi+1;i++){
  57. choices.push(i);
  58. }
  59. }
  60. firstTry = choices[Math.floor(Math.random()*choices.length)];
  61. for(var i = 2; i<Math.floor(Math.sqrt(firstTry)+1);i++){
  62. if(i!=firstTry){
  63. if(firstTry%i == 0){
  64. choices.splice(choices.indexOf(firstTry),1);
  65. if(choices.length == 0){
  66. return 0;
  67. }
  68. return GENERATE_PRIME_NUMBER(mini,maxi,choices);
  69. }
  70. }
  71. }
  72. return firstTry;
  73. };
  74. scope.SHUFFLE_LIST = function(x){
  75. var nl = x.slice();
  76. for(var i = nl.length - 1;i>0;i--){
  77. var r = Math.floor(Math.random()*(i+1));
  78. var t = nl[i];
  79. nl[i] = nl[r];
  80. nl[r] = t;
  81. }
  82. return nl;
  83. };
  84. scope.GENERATE_KEYS = function(){
  85. interval = [];
  86. for(var i = 100;i<301;i++){
  87. interval.push(i);
  88. }
  89. random_prime = [GENERATE_PRIME_NUMBER(0,0,choices = interval),0];
  90. interval.splice(interval.indexOf(random_prime[0]),1);
  91. random_prime[1] = GENERATE_PRIME_NUMBER(0,0,choices = interval);
  92.  
  93. n = random_prime[0]*random_prime[1];
  94. n2 = (random_prime[0]-1)*(random_prime[1]-1);
  95.  
  96. e = GENERATE_COPRIME_NUMBER(2,n2-1,n2);
  97. d = 0;
  98. redo = true;
  99. for(var i = 0;i<1000000;i++){
  100. if((e*i-1)%n2 == 0 && i!=e){
  101. d = i;
  102. redo = false;
  103. break;
  104. }
  105. }
  106. if(redo){
  107. return GENERATE_KEYS();
  108. }
  109. else{
  110. return [[n,e],[n,d]];
  111. }
  112.  
  113. };
  114. scope.CRYPT_NUMBER = function(key, data){
  115.  
  116. result = 1;
  117.  
  118. for(var i = 0;i<key[1];i++){
  119. result*=data;
  120. result = result%key[0];
  121. }
  122. return result%key[0];
  123.  
  124. };
  125.  
  126. scope.CRYPT_MESSAGE = function(key,data){
  127. var resulttext = [];
  128. for(var i = 0;i<data.length;i++){
  129. resulttext.push(CRYPT_NUMBER(key,data[i]));
  130. }
  131. return resulttext;
  132.  
  133. };
  134. if(typeof(scope.textdecoder)=='undefined'){scope.textdecoder = new Gwindow.TextDecoder;}
  135. if(typeof(scope.textencoder)=='undefined'){scope.textencoder = new Gwindow.TextEncoder;}
  136.  
  137. class bytebuffer2 {
  138. constructor() {
  139. var g1d = [arguments];
  140. this.index = 0;
  141. this.buffer = new ArrayBuffer(100*1024);
  142. this.view = new DataView(this.buffer);
  143. this.implicitClassAliasArray = [];
  144. this.implicitStringArray = [];
  145. this.bodgeCaptureZoneDataIdentifierArray = [];
  146. }
  147. readByte() {
  148. var N0H = [arguments];
  149. N0H[4] = this.view.getUint8(this.index);
  150. this.index += 1;
  151. return N0H[4];
  152. }
  153. writeByte(z0w) {
  154. var v8$ = [arguments];
  155. this.view.setUint8(this.index, v8$[0][0]);
  156. this.index += 1;
  157. }
  158. readInt() {
  159. var A71 = [arguments];
  160. A71[6] = this.view.getInt32(this.index);
  161. this.index += 4;
  162. return A71[6];
  163. }
  164. writeInt(W6i) {
  165. var p5u = [arguments];
  166. this.view.setInt32(this.index, p5u[0][0]);
  167. this.index += 4;
  168. }
  169. readShort() {
  170. var R1R = [arguments];
  171. R1R[9] = this.view.getInt16(this.index);
  172. this.index += 2;
  173. return R1R[9];
  174. }
  175. writeShort(H8B) {
  176. var d_3 = [arguments];
  177. this.view.setInt16(this.index, d_3[0][0]);
  178. this.index += 2;
  179. }
  180. readUint() {
  181. var W2$ = [arguments];
  182. W2$[8] = this.view.getUint32(this.index);
  183. this.index += 4;
  184. return W2$[8];
  185. }
  186. writeUint(B2X) {
  187. var f8B = [arguments];
  188. this.view.setUint32(this.index, f8B[0][0]);
  189. this.index += 4;
  190. }
  191. readBoolean() {
  192. var h6P = [arguments];
  193. h6P[6] = this.readByte();
  194. return h6P[6] == 1;
  195. }
  196. writeBoolean(Y3I) {
  197. var l79 = [arguments];
  198. if (l79[0][0]) {
  199. this.writeByte(1);
  200. } else {
  201. this.writeByte(0);
  202. }
  203. }
  204. readDouble() {
  205. var V60 = [arguments];
  206. V60[4] = this.view.getFloat64(this.index);
  207. this.index += 8;
  208. return V60[4];
  209. }
  210. writeDouble(z4Z) {
  211. var O41 = [arguments];
  212. this.view.setFloat64(this.index, O41[0][0]);
  213. this.index += 8;
  214. }
  215. readFloat() {
  216. var I0l = [arguments];
  217. I0l[5] = this.view.getFloat32(this.index);
  218. this.index += 4;
  219. return I0l[5];
  220. }
  221. writeFloat(y4B) {
  222. var B0v = [arguments];
  223. this.view.setFloat32(this.index, B0v[0][0]);
  224. this.index += 4;
  225. }
  226. readUTF() {
  227. var d6I = [arguments];
  228. d6I[8] = this.readByte();
  229. d6I[7] = this.readByte();
  230. d6I[9] = d6I[8] * 256 + d6I[7];
  231. d6I[1] = new Uint8Array(d6I[9]);
  232. for (d6I[6] = 0; d6I[6] < d6I[9]; d6I[6]++) {
  233. d6I[1][d6I[6]] = this.readByte();
  234. }
  235. return textdecoder.decode(d6I[1]);
  236. }
  237. writeUTF(L3Z) {
  238. var Z75 = [arguments];
  239. Z75[4] = textencoder.encode(Z75[0][0]);
  240. Z75[3] = Z75[4].length;
  241. Z75[5] = Math.floor(Z75[3]/256);
  242. Z75[8] = Z75[3] % 256;
  243. this.writeByte(Z75[5]);
  244. this.writeByte(Z75[8]);
  245. Z75[7] = this;
  246. Z75[4].forEach(I_O);
  247. function I_O(s0Q, H4K, j$o) {
  248. var N0o = [arguments];
  249. Z75[7].writeByte(N0o[0][0]);
  250. }
  251. }
  252. toBase64() {
  253. var P4$ = [arguments];
  254. P4$[4] = "";
  255. P4$[9] = new Uint8Array(this.buffer);
  256. P4$[8] = this.index;
  257. for (P4$[7] = 0; P4$[7] < P4$[8]; P4$[7]++) {
  258. P4$[4] += String.fromCharCode(P4$[9][P4$[7]]);
  259. }
  260. return Gwindow.btoa(P4$[4]);
  261. }
  262. fromBase64(W69, A8Q) {
  263. var o0n = [arguments];
  264. o0n[8] = Gwindow.pako;
  265. o0n[6] = Gwindow.atob(o0n[0][0]);
  266. o0n[9] = o0n[6].length;
  267. o0n[4] = new Uint8Array(o0n[9]);
  268. for (o0n[1] = 0; o0n[1] < o0n[9]; o0n[1]++) {
  269. o0n[4][o0n[1]] = o0n[6].charCodeAt(o0n[1]);
  270. }
  271. if (o0n[0][1] === true) {
  272. o0n[5] = o0n[8].inflate(o0n[4]);
  273. o0n[4] = o0n[5];
  274. }
  275. this.buffer = o0n[4].buffer.slice(
  276. o0n[4].byteOffset,
  277. o0n[4].byteLength + o0n[4].byteOffset
  278. );
  279. this.view = new DataView(this.buffer);
  280. this.index = 0;
  281. }
  282. };
  283.  
  284. if(typeof(scope.originalSend)=='undefined'){scope.originalSend = Gwindow.WebSocket.prototype.send;}
  285. if(typeof(scope.originalXMLOpen)=='undefined'){scope.originalXMLOpen = Gwindow.XMLHttpRequest.prototype.open;}
  286. if(typeof(scope.originalXMLSend)=='undefined'){scope.originalXMLSend = Gwindow.XMLHttpRequest.prototype.send;}
  287. if(typeof(scope.searchrequested)=='undefined'){scope.searchrequested = false;}
  288. if(typeof(scope.originalDrawCircle)=='undefined'){scope.originalDrawCircle = Gwindow.PIXI.Graphics.prototype.drawCircle;}
  289. if(typeof(scope.parentDraw)=='undefined'){scope.parentDraw = 0;}
  290. if(typeof(scope.pixiCircle)=='undefined'){scope.pixiCircle = new Gwindow.PIXI.Graphics();}
  291. if(typeof(scope.container)=='undefined'){scope.container = new Gwindow.PIXI.Container();container.addChild(pixiCircle);}
  292. if(typeof(scope.canvasWidth)=='undefined'){scope.canvasWidth = -1;}
  293.  
  294.  
  295. if(typeof(scope.requestAnimationFrameOriginal)=='undefined'){scope.requestAnimationFrameOriginal = Gwindow.requestAnimationFrame;}
  296.  
  297.  
  298. if(typeof(scope.bonkwss)=='undefined'){scope.bonkwss = 0;}
  299. if(typeof(scope.bonkwssextra)=='undefined'){scope.bonkwssextra = [];}
  300. if(typeof(scope.chatlog)=='undefined'){scope.chatlog = ["ROOM START"];}
  301. if(typeof(scope.wsssendrecievelog)=='undefined'){scope.wsssendrecievelog = [];}
  302. if(typeof(scope.wsssendlog)=='undefined'){scope.wsssendlog = [];}
  303. if(typeof(scope.wssrecievelog)=='undefined'){scope.wssrecievelog = [];}
  304. if(typeof(scope.wsslogpaused)=='undefined'){scope.wsslogpaused = false;}
  305. if(typeof(scope.debuggeropen)=='undefined'){scope.debuggeropen = false;}
  306. if(typeof(scope.debuggercount)=='undefined'){scope.debuggercount = true;}
  307. if(typeof(scope.packetcount)=='undefined'){scope.packetcount = 0;}
  308. if(typeof(scope.requestedmaps)=='undefined'){scope.requestedmaps = [];}
  309. if(typeof(scope.maponclick)=='undefined'){scope.maponclick = 0;}
  310. if(typeof(scope.LZString)=='undefined'){scope.LZString = Gwindow.LZString;}
  311. if(typeof(scope.PSON)=='undefined'){scope.PSON = Gwindow.dcodeIO.PSON;}
  312. if(typeof(scope.bytebuffer)=='undefined'){scope.bytebuffer = Gwindow.dcodeIO.ByteBuffer;}
  313. if(typeof(scope.speech)=='undefined'){scope.speech = new SpeechSynthesisUtterance();speech.pitch = 0.75;}
  314. if(typeof(scope.sayer)=='undefined'){scope.sayer = speechSynthesis;sayer.volume = 0.5;sayer.rate = 1.25;}
  315. if(typeof(scope.pollactive)=='undefined'){scope.pollactive = [false,0,0,[]];}
  316. if(typeof(scope.pollactive2)=='undefined'){scope.pollactive2 = [false,0,[]];}
  317. if(typeof(scope.mode)=='undefined'){scope.mode = '';}
  318. if(typeof(scope.FFA)=='undefined'){scope.FFA = true;}
  319.  
  320. 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]);}
  321. if(typeof(scope.sandboxon)=='undefined'){scope.sandboxon = false;}
  322. if(typeof(scope.sandboxid)=='undefined'){scope.sandboxid = 200;}
  323. if(typeof(scope.playerids)=='undefined'){scope.playerids = {};}
  324. if(typeof(scope.delplayerids)=='undefined'){scope.delplayerids = {};}
  325. if(typeof(scope.myid)=='undefined'){scope.myid = -1;}
  326. if(typeof(scope.hostid)=='undefined'){scope.hostid = -1;}
  327. if(typeof(scope.sandboxplayerids)=='undefined'){scope.sandboxplayerids = {};}
  328. if(typeof(scope.originalMapLoad)=='undefined'){scope.originalMapLoad = Gdocument.getElementById("maploadwindowmapscontainer").appendChild;}
  329. if(typeof(scope.originalLobbyChat)=='undefined'){scope.originalLobbyChat = Gdocument.getElementById("newbonklobby_chat_content").appendChild;}
  330. if(typeof(scope.originalIngameChat)=='undefined'){scope.originalIngameChat = Gdocument.getElementById("ingamechatcontent").appendChild;}
  331. 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];}
  332. if(Gdocument.getElementById("maploadtypedropdowntitlerequested") == null){
  333. scope.clearmaprequests = Gdocument.createElement("div");
  334. clearmaprequests.id = "clearmaprequests";
  335. clearmaprequests.classList.value = "brownButton brownButton_classic buttonShadow";
  336. clearmaprequests.textContent = "Clear";
  337. clearmaprequests.style["position"] = "absolute";
  338. clearmaprequests.style["display"] = "none";
  339. if(typeof(ishost)!='undefined'){
  340. if(ishost && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS"){
  341. clearmaprequests.style["display"] = "block";
  342. }
  343. }
  344. clearmaprequests.style["right"] = "306px";
  345. clearmaprequests.style["top"] = "57px";
  346. clearmaprequests.style["height"] = "23px";
  347. clearmaprequests.style["width"] = "47px";
  348. clearmaprequests.style["line-height"] = "23px";
  349. clearmaprequests.style["font-size"] = "14px";
  350. clearmaprequests.addEventListener("click",function(){
  351. requestedmaps = [];
  352. Gdocument.getElementById("maploadwindowstatustext").style["visibility"] = "inherit";
  353. Gdocument.getElementById("maploadwindowstatustext").textContent = "No Maps";
  354. while(Gdocument.getElementById("maploadwindowmapscontainer").children.length>0){
  355. Gdocument.getElementById("maploadwindowmapscontainer").removeChild(Gdocument.getElementById("maploadwindowmapscontainer").firstChild);
  356. }
  357. });
  358. Gdocument.getElementById("maploadwindow").insertBefore(clearmaprequests,Gdocument.getElementById("maploadwindowsearchinput"));
  359. scope.refreshmaprequests = Gdocument.createElement("div");
  360. refreshmaprequests.id = "refreshmaprequests";
  361. refreshmaprequests.classList.value = "brownButton brownButton_classic buttonShadow";
  362. refreshmaprequests.textContent = "Refresh";
  363. refreshmaprequests.style["position"] = "absolute";
  364. refreshmaprequests.style["display"] = "none";
  365. if(typeof(ishost)!='undefined'){
  366. if(ishost && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS"){
  367. refreshmaprequests.style["display"] = "block";
  368. }
  369. }
  370. refreshmaprequests.style["right"] = "357px";
  371. refreshmaprequests.style["top"] = "57px";
  372. refreshmaprequests.style["height"] = "23px";
  373. refreshmaprequests.style["width"] = "47px";
  374. refreshmaprequests.style["line-height"] = "23px";
  375. refreshmaprequests.style["font-size"] = "14px";
  376. refreshmaprequests.addEventListener("click",function(){
  377. Gdocument.getElementById("maploadtypedropdowntitle").textContent = dropdownrequested.textContent;
  378. Gdocument.getElementById("maploadwindowsearchinput").value = "";
  379. dropdownrequested.style["display"] = "none";
  380. clearmaprequests.style["display"] = "block";
  381. refreshmaprequests.style["display"] = "block";
  382. Gdocument.getElementById("maploadwindowhotnessslider").style["visibility"] = "hidden";
  383. Gdocument.getElementById("maploadwindowsearchoptions").style["visibility"] = "hidden";
  384. searchrequested = true;
  385. Gdocument.getElementById("maploadwindowsearchbutton").click();
  386.  
  387. Gdocument.getElementById("maploadtypedropdowntitle").textContent = "MAP REQUESTS";
  388. });
  389. Gdocument.getElementById("maploadwindow").insertBefore(refreshmaprequests,Gdocument.getElementById("maploadwindowsearchinput"));
  390.  
  391. scope.dropdownrequested = Gdocument.createElement("div");
  392. dropdownrequested.classList = "dropdown-option dropdown_classic";
  393. dropdownrequested.style["display"] = "none";
  394. dropdownrequested.id = "maploadtypedropdowntitlerequested";
  395.  
  396. if(Gdocument.getElementById("maploadtypedropdownoption10").style["display"] == "block"){
  397. dropdownrequested.style["display"] = "block";
  398. }
  399. dropdownrequested.textContent = "MAP REQUESTS";
  400. dropdownrequested.onclick = function(){
  401. Gdocument.getElementById("maploadtypedropdowntitle").textContent = dropdownrequested.textContent;
  402. Gdocument.getElementById("maploadwindowsearchinput").value = "";
  403. dropdownrequested.style["display"] = "none";
  404. clearmaprequests.style["display"] = "block";
  405. refreshmaprequests.style["display"] = "block";
  406. Gdocument.getElementById("maploadwindowhotnessslider").style["visibility"] = "hidden";
  407. Gdocument.getElementById("maploadwindowsearchoptions").style["visibility"] = "hidden";
  408. searchrequested = true;
  409. Gdocument.getElementById("maploadwindowsearchbutton").click();
  410.  
  411. Gdocument.getElementById("maploadtypedropdowntitle").textContent = "MAP REQUESTS";
  412. };
  413. (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});
  414. Gdocument.getElementById("maploadtypedropdown").insertBefore(dropdownrequested,Gdocument.getElementById("maploadtypedropdownoption1"));
  415. Gdocument.getElementById("maploadwindowmapscontainer").__defineGetter__("clientHeight",function(){if(Gdocument.getElementById("maploadtypedropdowntitle").textContent != "MAP REQUESTS"){return Gdocument.getElementById("maploadwindowmapscontainer").getClientRects()[0].height;}else{return 0;}});
  416.  
  417. };
  418.  
  419. function sandboxonclick(){
  420. Gdocument.getElementById("roomlistrefreshbutton").click();
  421. Gdocument.getElementById("roomlistcreatebutton").click();
  422. sandboxon = true;
  423. }
  424. function checkboxclearbuttononclick(){
  425. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  426. var e = true;
  427. for(var i = 0; i<classes.length;i++){
  428. if(classes[i].checked == true){
  429. e = false
  430. }
  431. classes[i].checked = false;
  432. }
  433. if(e){
  434. for(var i = 0; i<classes.length;i++){
  435. classes[i].checked = true;
  436. }
  437. }
  438. }
  439. Gdocument.getElementById("ingamechatcontent").__defineGetter__("childElementCount",function(){return this.children.length/50;});
  440. if(Gdocument.getElementById("classic_mid_sandbox")==null){
  441. Gdocument.getElementById("roomlistrefreshbutton").click();
  442. scope.sandboxbutton = Gdocument.createElement("div");
  443. sandboxbutton.id = "classic_mid_sandbox";
  444. sandboxbutton.classList.value = "brownButton brownButton_classic classic_mid_buttons";
  445. sandboxbutton.textContent = "Sandbox";
  446. sandboxbutton.addEventListener("click",sandboxonclick);
  447. Gdocument.getElementById("classic_mid").insertBefore(sandboxbutton,Gdocument.getElementById("classic_mid_news"));
  448.  
  449. }
  450. if(Gdocument.getElementById("clearallcheckboxes")==null){
  451. scope.checkboxclearbutton = Gdocument.createElement("div");
  452. checkboxclearbutton.id = "clearallcheckboxes";
  453. checkboxclearbutton.classList.value = "brownButton brownButton_classic buttonShadow";
  454. checkboxclearbutton.textContent = "On/Off";
  455. checkboxclearbutton.style["position"] = "absolute";
  456. checkboxclearbutton.style["display"] = "none";
  457. if(typeof(ishost)!='undefined'){
  458. if(ishost && stopquickplay == 0){
  459. checkboxclearbutton.style["display"] = "block";
  460. }
  461. }
  462. checkboxclearbutton.style["right"] = "255px";
  463. checkboxclearbutton.style["top"] = "57px";
  464. checkboxclearbutton.style["height"] = "23px";
  465. checkboxclearbutton.style["width"] = "47px";
  466. checkboxclearbutton.style["line-height"] = "23px";
  467. checkboxclearbutton.style["font-size"] = "13px";
  468. checkboxclearbutton.addEventListener("click",checkboxclearbuttononclick);
  469. Gdocument.getElementById("maploadwindow").insertBefore(checkboxclearbutton,Gdocument.getElementById("maploadwindowsearchinput"));
  470.  
  471. }
  472. scope.holdloadbuttonTimeout = [];
  473. scope.holdloadbutton = function(){
  474. var scrollcount = 0;
  475. var mapwindow = Gdocument.getElementById("maploadwindowmapscontainer");
  476. mapwindow.scroll(0,mapwindow.scrollHeight);
  477. };
  478.  
  479. if(Gdocument.getElementById("mapwindowloadall")==null){
  480. scope.loadall = Gdocument.createElement("div");
  481. loadall.id = "mapwindowloadall";
  482. loadall.classList.value = "brownButton brownButton_classic buttonShadow";
  483. loadall.textContent = "Load";
  484. loadall.style["position"] = "absolute";
  485. loadall.style["display"] = "block";
  486. loadall.style["left"] = "204px";
  487. loadall.style["top"] = "57px";
  488. loadall.style["height"] = "23px";
  489. loadall.style["width"] = "34px";
  490. loadall.style["line-height"] = "23px";
  491. loadall.style["font-size"] = "12px";
  492. var repeat = function(){holdloadbutton();holdloadbuttonTimeout.push(setTimeout(repeat,25));};
  493. loadall.onmousedown = function(){repeat();};
  494. loadall.onmouseup = function(){for(var i = 0; i<holdloadbuttonTimeout.length; i++){clearTimeout(holdloadbuttonTimeout[i]);}};
  495. loadall.onmouseout = function(){for(var i = 0; i<holdloadbuttonTimeout.length; i++){clearTimeout(holdloadbuttonTimeout[i]);}};
  496.  
  497. Gdocument.getElementById("maploadwindow").insertBefore(loadall,Gdocument.getElementById("maploadwindowsearchinput"));
  498.  
  499. }
  500. if(Gdocument.getElementById("BonkCommandsDebuggerContainer")==null){
  501. Gdocument.getElementById("leaveconfirmwindow").style["z-index"]=3;
  502. scope.debuggermenu = Gdocument.createElement("div");
  503. debuggermenu.id = "BonkCommandsDebuggerContainer";
  504. debuggermenu.style["position"] = "absolute";
  505. debuggermenu.style["display"] = "none";
  506. if(typeof(debuggeropen)!='undefined'){
  507. if(debuggeropen){
  508. debuggermenu.style["display"] = "block";
  509. }
  510. }
  511. debuggermenu.style["width"] = Gdocument.getElementById("bonkiocontainer").style["width"];
  512. debuggermenu.style["height"] = Gdocument.getElementById("bonkiocontainer").style["height"];
  513.  
  514. debuggermenu.style["background"] = "rgb(26, 39, 51)";
  515.  
  516. scope.width = parseInt(Gdocument.getElementById("bonkiocontainer").style["width"])-20;
  517. scope.height = parseInt(Gdocument.getElementById("bonkiocontainer").style["height"])-210;
  518.  
  519. scope.logmenu = Gdocument.createElement("div");
  520. logmenu.id = "BonkCommandsWebSocketLog";
  521. logmenu.style["position"] = "absolute";
  522. logmenu.style["width"] = width.toString()+"px";
  523. logmenu.style["height"] = height.toString()+"px";
  524. logmenu.style["top"] = "80px";
  525. logmenu.style["left"] = "10px";
  526. logmenu.style["background"] = "rgb(207, 216, 220)";
  527. scope.logmenutopleft = Gdocument.createElement("div");
  528. logmenutopleft.id = "BonkCommandsWebSocketLog";
  529. logmenutopleft.style["position"] = "absolute";
  530. logmenutopleft.textContent = "Sending";
  531. logmenutopleft.classList = "newbonklobby_boxtop newbonklobby_boxtop_classic";
  532. logmenutopleft.style["width"] = (width/2).toString()+"px";
  533. logmenutopleft.style["height"] = "30px";
  534. logmenutopleft.style["top"] = "-30px";
  535. logmenutopleft.style["background"] = "rgb(0, 150, 136)";
  536. logmenu.appendChild(logmenutopleft);
  537. scope.logmenutopright = Gdocument.createElement("div");
  538. logmenutopright.id = "BonkCommandsWebSocketLog";
  539. logmenutopright.style["position"] = "absolute";
  540. logmenutopright.textContent = "Recieving";
  541. logmenutopright.classList = "newbonklobby_boxtop newbonklobby_boxtop_classic";
  542. logmenutopright.style["width"] = (width/2).toString()+"px";
  543. logmenutopright.style["height"] = "30px";
  544. logmenutopright.style["left"] = (width/2).toString()+"px";
  545. logmenutopright.style["top"] = "-30px";
  546. logmenutopright.style["background"] = "rgb(0, 150, 136)";
  547. logmenu.appendChild(logmenutopright);
  548. scope.logmenutable = Gdocument.createElement("table");
  549. logmenutable.id = "BonkCommandsWebSocketTable";
  550. logmenutable.style["position"] = "absolute";
  551. logmenutable.style["border-spacing"] = "0px";
  552. logmenutable.style["font-size"] = "12px";
  553. logmenutable.style["display"] = "table-cell";
  554. logmenutable.style["width"] = "50%";
  555. logmenutable.style["height"] = "100%";
  556. logmenutable.style["table-layout"] = "fixed";
  557. logmenutable.style["overflow-y"] = "scroll";
  558.  
  559. scope.logmenutable2 = Gdocument.createElement("table");
  560. logmenutable2.id = "BonkCommandsWebSocketTable2";
  561. logmenutable2.style["position"] = "absolute";
  562. logmenutable2.style["width"] = "50%";
  563. logmenutable2.style["left"] = "50%";
  564. logmenutable2.style["font-size"] = "12px";
  565. logmenutable2.style["display"] = "table-cell";
  566. logmenutable2.style["height"] = "100%";
  567. logmenutable2.style["table-layout"] = "fixed";
  568. logmenutable2.style["overflow-y"] = "scroll";
  569. logmenutable2.style["border-spacing"] = "0px";
  570. scope.leftsync = false;
  571. scope.rightsync = false;
  572. logmenutable2.onscroll = function(){
  573. if(!leftsync){
  574. rightsync = true;
  575. logmenutable.scrollTop = this.scrollTop;
  576. }
  577. else{
  578. leftsync = false;
  579. }
  580. };
  581. logmenutable.onscroll = function(){
  582. if(!rightsync){
  583. leftsync = true;
  584. logmenutable2.scrollTop = this.scrollTop;
  585. }
  586. else{
  587. rightsync = false
  588. }
  589. };
  590. logmenu.appendChild(logmenutable);
  591. logmenu.appendChild(logmenutable2);
  592. debuggermenu.appendChild(logmenu);
  593. scope.debuggermenuclose = Gdocument.createElement("div");
  594. debuggermenuclose.id = "debuggerclose";
  595. debuggermenuclose.classList = "windowCloseButton brownButton brownButton_classic buttonShadow";
  596. debuggermenuclose.style["position"] = "absolute";
  597. debuggermenuclose.style["top"] = "40px";
  598. debuggermenuclose.style["right"] = "5px";
  599. debuggermenuclose.onclick = function(){debuggeropen = false;debuggermenu.style["display"] = "none";Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  600. Gdocument.getElementById("ingamechatinputtext").style["display"] = "";};
  601. debuggermenu.appendChild(debuggermenuclose);
  602. scope.debuggerform = Gdocument.createElement("form");
  603. debuggerform.autocomplete = "off";
  604. scope.debuggerinput = Gdocument.createElement("input");
  605. debuggerinput.style["position"] = "absolute";
  606. debuggerinput.style["width"] = width.toString()+"px";
  607. debuggerinput.style["left"] = "10px";
  608. debuggerinput.style["top"] = (height+90).toString()+"px";
  609. debuggerinput.style["font-size"] = "12px";
  610. debuggerinput.style["height"] = "20px";
  611. debuggerform.appendChild(debuggerinput);
  612. scope.debuggersendrecieve = Gdocument.createElement("div");
  613. debuggersendrecieve.style["position"] = "absolute";
  614. debuggersendrecieve.style["width"] = "140px";
  615. debuggersendrecieve.style["left"] = "10px";
  616. debuggersendrecieve.style["top"] = (height+120).toString()+"px";
  617. debuggersendrecieve.style["font-size"] = "15px";
  618. debuggersendrecieve.style["height"] = "20px";
  619. debuggersendrecieve.classList = "brownButton brownButton_classic buttonShadow";
  620. debuggersendrecieve.textContent = "Send";
  621. debuggersendrecieve.value = 0;
  622. debuggersendrecieve.onclick = function(){if(this.value == 0){this.textContent = "Recieve";this.value = 1;}else{this.textContent = "Send";this.value = 0;}};
  623.  
  624. debuggermenu.appendChild(debuggersendrecieve);
  625. scope.debuggerpausebutton = Gdocument.createElement("div");
  626. debuggerpausebutton.style["position"] = "absolute";
  627. debuggerpausebutton.style["width"] = "140px";
  628. debuggerpausebutton.style["left"] = "10px";
  629. debuggerpausebutton.style["top"] = (height+150).toString()+"px";
  630. debuggerpausebutton.style["font-size"] = "15px";
  631. debuggerpausebutton.style["height"] = "20px";
  632. debuggerpausebutton.classList = "brownButton brownButton_classic buttonShadow";
  633. debuggerpausebutton.textContent = "Pause";
  634. debuggerpausebutton.value = 0;
  635. debuggerpausebutton.onclick = function(){if(this.value == 0){this.textContent = "Play";this.value = 1;wsslogpaused = true}else{this.textContent = "Pause";this.value = 0;wsslogpaused = false;}};
  636.  
  637. debuggermenu.appendChild(debuggerpausebutton);
  638. scope.debuggereval = Gdocument.createElement("input");
  639. debuggereval.style["position"] = "absolute";
  640. debuggereval.style["width"] = (width-150).toString()+"px";
  641. debuggereval.style["right"] = "10px";
  642. debuggereval.style["top"] = (height+120).toString()+"px";
  643. debuggereval.style["font-size"] = "12px";
  644. debuggereval.style["height"] = "20px";
  645. debuggereval.addEventListener("keypress",function(e){if(e.repeat){return;}if(e.code == "Enter" && this.value.length>0){if(debuggersendrecieve.value == 0){SEND(this.value);}else{RECIEVE(this.value);}}});
  646. debuggerform.appendChild(debuggereval);
  647. debuggermenu.appendChild(debuggerform);
  648. Gdocument.getElementById("newbonkgamecontainer").appendChild(debuggermenu);
  649.  
  650. }
  651. scope.ISdecode = function(rawdata) {
  652. rawdata_caseflipped = "";
  653. for (i = 0; i < rawdata.length; i++) {
  654. if (i <= 100 && rawdata.charAt(i) === rawdata.charAt(i).toLowerCase()) {
  655. rawdata_caseflipped += rawdata.charAt(i).toUpperCase();
  656. } else if (i <= 100 && rawdata.charAt(i) === rawdata.charAt(i).toUpperCase()) {
  657. rawdata_caseflipped += rawdata.charAt(i).toLowerCase();
  658. } else {
  659. rawdata_caseflipped += rawdata.charAt(i);
  660. }
  661. }
  662.  
  663. data_deLZd = LZString.decompressFromEncodedURIComponent(rawdata_caseflipped);
  664. databuffer = bytebuffer.fromBase64(data_deLZd);
  665. data = ISpsonpair.decode(databuffer.buffer);
  666. return data;
  667. };
  668. scope.ISencode = function(obj) {
  669. data = ISpsonpair.encode(obj);
  670. b64 = data.toBase64();
  671. lzd = LZString.compressToEncodedURIComponent(b64);
  672.  
  673. caseflipped = "";
  674. for (i = 0; i < lzd.length; i++) {
  675. if (i <= 100 && lzd.charAt(i) === lzd.charAt(i).toLowerCase()) {
  676. caseflipped += lzd.charAt(i).toUpperCase();
  677. } else if (i <= 100 && lzd.charAt(i) === lzd.charAt(i).toUpperCase()) {
  678. caseflipped += lzd.charAt(i).toLowerCase();
  679. } else {
  680. caseflipped += lzd.charAt(i);
  681. }
  682. }
  683.  
  684.  
  685. return caseflipped;
  686. };
  687. scope.decodeIS = function(x){
  688. return ISdecode(x);
  689. };
  690. scope.encodeIS = function(x){
  691. return ISencode(x);
  692. };
  693. scope.encodeToDatabase = function (W2A) {
  694. var M3n = [arguments];
  695. M3n[1] = new bytebuffer2;
  696. M3n[9] = M3n[0][0].physics;
  697. M3n[0][0].v = 14;
  698. M3n[1].writeShort(M3n[0][0].v);
  699. M3n[1].writeBoolean(M3n[0][0].s.re);
  700. M3n[1].writeBoolean(M3n[0][0].s.nc);
  701. M3n[1].writeShort(M3n[0][0].s.pq);
  702. M3n[1].writeFloat(M3n[0][0].s.gd);
  703. M3n[1].writeBoolean(M3n[0][0].s.fl);
  704. M3n[1].writeUTF(M3n[0][0].m.rxn);
  705. M3n[1].writeUTF(M3n[0][0].m.rxa);
  706. M3n[1].writeUint(M3n[0][0].m.rxid);
  707. M3n[1].writeShort(M3n[0][0].m.rxdb);
  708. M3n[1].writeUTF(M3n[0][0].m.n);
  709. M3n[1].writeUTF(M3n[0][0].m.a);
  710. M3n[1].writeUint(M3n[0][0].m.vu);
  711. M3n[1].writeUint(M3n[0][0].m.vd);
  712. M3n[1].writeShort(M3n[0][0].m.cr.length);
  713. for (
  714. M3n[84] = 0;
  715. M3n[84] < M3n[0][0].m.cr.length;
  716. M3n[84]++
  717. ) {
  718. M3n[1].writeUTF(M3n[0][0].m.cr[M3n[84]]);
  719. }
  720. M3n[1].writeUTF(M3n[0][0].m.mo);
  721. M3n[1].writeInt(M3n[0][0].m.dbid);
  722. M3n[1].writeBoolean(M3n[0][0].m.pub);
  723. M3n[1].writeInt(M3n[0][0].m.dbv);
  724. M3n[1].writeShort(M3n[9].ppm);
  725. M3n[1].writeShort(M3n[9].bro.length);
  726. for (M3n[17] = 0; M3n[17] < M3n[9].bro.length; M3n[17]++) {
  727. M3n[1].writeShort(M3n[9].bro[M3n[17]]);
  728. }
  729. M3n[1].writeShort(M3n[9].shapes.length);
  730. for (M3n[80] = 0; M3n[80] < M3n[9].shapes.length; M3n[80]++) {
  731. M3n[2] = M3n[9].shapes[M3n[80]];
  732. if (M3n[2].type == "bx") {
  733. M3n[1].writeShort(1);
  734. M3n[1].writeDouble(M3n[2].w);
  735. M3n[1].writeDouble(M3n[2].h);
  736. M3n[1].writeDouble(M3n[2].c[0]);
  737. M3n[1].writeDouble(M3n[2].c[1]);
  738. M3n[1].writeDouble(M3n[2].a);
  739. M3n[1].writeBoolean(M3n[2].sk);
  740. }
  741. if (M3n[2].type == "ci") {
  742. M3n[1].writeShort(2);
  743. M3n[1].writeDouble(M3n[2].r);
  744. M3n[1].writeDouble(M3n[2].c[0]);
  745. M3n[1].writeDouble(M3n[2].c[1]);
  746. M3n[1].writeBoolean(M3n[2].sk);
  747. }
  748. if (M3n[2].type == "po") {
  749. M3n[1].writeShort(3);
  750. M3n[1].writeDouble(M3n[2].s);
  751. M3n[1].writeDouble(M3n[2].a);
  752. M3n[1].writeDouble(M3n[2].c[0]);
  753. M3n[1].writeDouble(M3n[2].c[1]);
  754. M3n[1].writeShort(M3n[2].v.length);
  755. for (M3n[61] = 0; M3n[61] < M3n[2].v.length; M3n[61]++) {
  756. M3n[1].writeDouble(M3n[2].v[M3n[61]][0]);
  757. M3n[1].writeDouble(M3n[2].v[M3n[61]][1]);
  758. }
  759. }
  760. }
  761. M3n[1].writeShort(M3n[9].fixtures.length);
  762. for (M3n[20] = 0; M3n[20] < M3n[9].fixtures.length; M3n[20]++) {
  763. M3n[7] = M3n[9].fixtures[M3n[20]];
  764. M3n[1].writeShort(M3n[7].sh);
  765. M3n[1].writeUTF(M3n[7].n);
  766. if (M3n[7].fr === null) {
  767. M3n[1].writeDouble(Number.MAX_VALUE);
  768. } else {
  769. M3n[1].writeDouble(M3n[7].fr);
  770. }
  771. if (M3n[7].fp === null) {
  772. M3n[1].writeShort(0);
  773. }
  774. if (M3n[7].fp === false) {
  775. M3n[1].writeShort(1);
  776. }
  777. if (M3n[7].fp === true) {
  778. M3n[1].writeShort(2);
  779. }
  780. if (M3n[7].re === null) {
  781. M3n[1].writeDouble(Number.MAX_VALUE);
  782. } else {
  783. M3n[1].writeDouble(M3n[7].re);
  784. }
  785. if (M3n[7].de === null) {
  786. M3n[1].writeDouble(Number.MAX_VALUE);
  787. } else {
  788. M3n[1].writeDouble(M3n[7].de);
  789. }
  790. M3n[1].writeUint(M3n[7].f);
  791. M3n[1].writeBoolean(M3n[7].d);
  792. M3n[1].writeBoolean(M3n[7].np);
  793. M3n[1].writeBoolean(M3n[7].ng);
  794. M3n[1].writeBoolean(M3n[7].ig);
  795. }
  796. M3n[1].writeShort(M3n[9].bodies.length);
  797. for (M3n[37] = 0; M3n[37] < M3n[9].bodies.length; M3n[37]++) {
  798. M3n[4] = M3n[9].bodies[M3n[37]];
  799. M3n[1].writeUTF(M3n[4].type);
  800. M3n[1].writeUTF(M3n[4].n);
  801. M3n[1].writeDouble(M3n[4].p[0]);
  802. M3n[1].writeDouble(M3n[4].p[1]);
  803. M3n[1].writeDouble(M3n[4].a);
  804. M3n[1].writeDouble(M3n[4].fric);
  805. M3n[1].writeBoolean(M3n[4].fricp);
  806. M3n[1].writeDouble(M3n[4].re);
  807. M3n[1].writeDouble(M3n[4].de);
  808. M3n[1].writeDouble(M3n[4].lv[0]);
  809. M3n[1].writeDouble(M3n[4].lv[1]);
  810. M3n[1].writeDouble(M3n[4].av);
  811. M3n[1].writeDouble(M3n[4].ld);
  812. M3n[1].writeDouble(M3n[4].ad);
  813. M3n[1].writeBoolean(M3n[4].fr);
  814. M3n[1].writeBoolean(M3n[4].bu);
  815. M3n[1].writeDouble(M3n[4].cf.x);
  816. M3n[1].writeDouble(M3n[4].cf.y);
  817. M3n[1].writeDouble(M3n[4].cf.ct);
  818. M3n[1].writeBoolean(M3n[4].cf.w);
  819. M3n[1].writeShort(M3n[4].f_c);
  820. M3n[1].writeBoolean(M3n[4].f_1);
  821. M3n[1].writeBoolean(M3n[4].f_2);
  822. M3n[1].writeBoolean(M3n[4].f_3);
  823. M3n[1].writeBoolean(M3n[4].f_4);
  824. M3n[1].writeBoolean(M3n[4].f_p);
  825. M3n[1].writeBoolean(M3n[4].fz.on);
  826. if (M3n[4].fz.on) {
  827. M3n[1].writeDouble(M3n[4].fz.x);
  828. M3n[1].writeDouble(M3n[4].fz.y);
  829. M3n[1].writeBoolean(M3n[4].fz.d);
  830. M3n[1].writeBoolean(M3n[4].fz.p);
  831. M3n[1].writeBoolean(M3n[4].fz.a);
  832. }
  833. M3n[1].writeShort(M3n[4].fx.length);
  834. for (M3n[28] = 0; M3n[28] < M3n[4].fx.length; M3n[28]++) {
  835. M3n[1].writeShort(M3n[4].fx[M3n[28]]);
  836. }
  837. }
  838. M3n[1].writeShort(M3n[0][0].spawns.length);
  839. for (
  840. M3n[30] = 0;
  841. M3n[30] < M3n[0][0].spawns.length;
  842. M3n[30]++
  843. ) {
  844. M3n[6] = M3n[0][0].spawns[M3n[30]];
  845. M3n[1].writeDouble(M3n[6].x);
  846. M3n[1].writeDouble(M3n[6].y);
  847. M3n[1].writeDouble(M3n[6].xv);
  848. M3n[1].writeDouble(M3n[6].yv);
  849. M3n[1].writeShort(M3n[6].priority);
  850. M3n[1].writeBoolean(M3n[6].r);
  851. M3n[1].writeBoolean(M3n[6].f);
  852. M3n[1].writeBoolean(M3n[6].b);
  853. M3n[1].writeBoolean(M3n[6].gr);
  854. M3n[1].writeBoolean(M3n[6].ye);
  855. M3n[1].writeUTF(M3n[6].n);
  856. }
  857. M3n[1].writeShort(M3n[0][0].capZones.length);
  858. for (
  859. M3n[74] = 0;
  860. M3n[74] < M3n[0][0].capZones.length;
  861. M3n[74]++
  862. ) {
  863. M3n[3] = M3n[0][0].capZones[M3n[74]];
  864. M3n[1].writeUTF(M3n[3].n);
  865. M3n[1].writeDouble(M3n[3].l);
  866. M3n[1].writeShort(M3n[3].i);
  867. M3n[1].writeShort(M3n[3].ty);
  868. }
  869. M3n[1].writeShort(M3n[9].joints.length);
  870. for (M3n[89] = 0; M3n[89] < M3n[9].joints.length; M3n[89]++) {
  871. M3n[5] = M3n[9].joints[M3n[89]];
  872. if (M3n[5].type == "rv") {
  873. M3n[1].writeShort(1);
  874. M3n[1].writeDouble(M3n[5].d.la);
  875. M3n[1].writeDouble(M3n[5].d.ua);
  876. M3n[1].writeDouble(M3n[5].d.mmt);
  877. M3n[1].writeDouble(M3n[5].d.ms);
  878. M3n[1].writeBoolean(M3n[5].d.el);
  879. M3n[1].writeBoolean(M3n[5].d.em);
  880. M3n[1].writeDouble(M3n[5].aa[0]);
  881. M3n[1].writeDouble(M3n[5].aa[1]);
  882. }
  883. if (M3n[5].type == "d") {
  884. M3n[1].writeShort(2);
  885. M3n[1].writeDouble(M3n[5].d.fh);
  886. M3n[1].writeDouble(M3n[5].d.dr);
  887. M3n[1].writeDouble(M3n[5].aa[0]);
  888. M3n[1].writeDouble(M3n[5].aa[1]);
  889. M3n[1].writeDouble(M3n[5].ab[0]);
  890. M3n[1].writeDouble(M3n[5].ab[1]);
  891. }
  892. if (M3n[5].type == "lpj") {
  893. M3n[1].writeShort(3);
  894. M3n[1].writeDouble(M3n[5].pax);
  895. M3n[1].writeDouble(M3n[5].pay);
  896. M3n[1].writeDouble(M3n[5].pa);
  897. M3n[1].writeDouble(M3n[5].pf);
  898. M3n[1].writeDouble(M3n[5].pl);
  899. M3n[1].writeDouble(M3n[5].pu);
  900. M3n[1].writeDouble(M3n[5].plen);
  901. M3n[1].writeDouble(M3n[5].pms);
  902. }
  903. if (M3n[5].type == "lsj") {
  904. M3n[1].writeShort(4);
  905. M3n[1].writeDouble(M3n[5].sax);
  906. M3n[1].writeDouble(M3n[5].say);
  907. M3n[1].writeDouble(M3n[5].sf);
  908. M3n[1].writeDouble(M3n[5].slen);
  909. }
  910. M3n[1].writeShort(M3n[5].ba);
  911. M3n[1].writeShort(M3n[5].bb);
  912. M3n[1].writeBoolean(M3n[5].d.cc);
  913. M3n[1].writeDouble(M3n[5].d.bf);
  914. M3n[1].writeBoolean(M3n[5].d.dl);
  915. }
  916. M3n[32] = M3n[1].toBase64();
  917. M3n[77] = LZString.compressToEncodedURIComponent(M3n[32]);
  918. return M3n[77];
  919. };
  920. scope.decodeFromDatabase = function (map) {
  921. var F5W = [arguments];
  922. var b64mapdata = LZString.decompressFromEncodedURIComponent(map);
  923. var binaryReader = new bytebuffer2;
  924. binaryReader.fromBase64(b64mapdata, false);
  925. 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: "", }};
  926. map.physics = map.physics;
  927. map.v = binaryReader.readShort();
  928. if (map.v > 14) {
  929. throw new Error("Future map version, please refresh page");
  930. }
  931. map.s.re = binaryReader.readBoolean();
  932. map.s.nc = binaryReader.readBoolean();
  933. if (map.v >= 3) {
  934. map.s.pq = binaryReader.readShort();
  935. }
  936. if (map.v >= 4 && map.v <= 12) {
  937. map.s.gd = binaryReader.readShort();
  938. } else if (map.v >= 13) {
  939. map.s.gd = binaryReader.readFloat();
  940. }
  941. if (map.v >= 9) {
  942. map.s.fl = binaryReader.readBoolean();
  943. }
  944. map.m.rxn = binaryReader.readUTF();
  945. map.m.rxa = binaryReader.readUTF();
  946. map.m.rxid = binaryReader.readUint();
  947. map.m.rxdb = binaryReader.readShort();
  948. map.m.n = binaryReader.readUTF();
  949. map.m.a = binaryReader.readUTF();
  950. if (map.v >= 10) {
  951. map.m.vu = binaryReader.readUint();
  952. map.m.vd = binaryReader.readUint();
  953. }
  954. if (map.v >= 4) {
  955. F5W[7] = binaryReader.readShort();
  956. for (F5W[83] = 0; F5W[83] < F5W[7]; F5W[83]++) {
  957. map.m.cr.push(binaryReader.readUTF());
  958. }
  959. }
  960. if (map.v >= 5) {
  961. map.m.mo = binaryReader.readUTF();
  962. map.m.dbid = binaryReader.readInt();
  963. }
  964. if (map.v >= 7) {
  965. map.m.pub = binaryReader.readBoolean();
  966. }
  967. if (map.v >= 8) {
  968. map.m.dbv = binaryReader.readInt();
  969. }
  970. map.physics.ppm = binaryReader.readShort();
  971. F5W[4] = binaryReader.readShort();
  972. for (F5W[15] = 0; F5W[15] < F5W[4]; F5W[15]++) {
  973. map.physics.bro[F5W[15]] = binaryReader.readShort();
  974. }
  975. F5W[6] = binaryReader.readShort();
  976. for (F5W[28] = 0; F5W[28] < F5W[6]; F5W[28]++) {
  977. F5W[5] = binaryReader.readShort();
  978. if (F5W[5] == 1) {
  979. map.physics.shapes[F5W[28]] = { type: "bx", w: 10, h: 40, c: [0, 0], a: 0.0, sk: false };
  980. map.physics.shapes[F5W[28]].w = binaryReader.readDouble();
  981. map.physics.shapes[F5W[28]].h = binaryReader.readDouble();
  982. map.physics.shapes[F5W[28]].c = [
  983. binaryReader.readDouble(),
  984. binaryReader.readDouble(),
  985. ];
  986. map.physics.shapes[F5W[28]].a = binaryReader.readDouble();
  987. map.physics.shapes[F5W[28]].sk = binaryReader.readBoolean();
  988. }
  989. if (F5W[5] == 2) {
  990. map.physics.shapes[F5W[28]] = { type: "ci", r: 25, c: [0, 0], sk: false };
  991. map.physics.shapes[F5W[28]].r = binaryReader.readDouble();
  992. map.physics.shapes[F5W[28]].c = [
  993. binaryReader.readDouble(),
  994. binaryReader.readDouble(),
  995. ];
  996. map.physics.shapes[F5W[28]].sk = binaryReader.readBoolean();
  997. }
  998. if (F5W[5] == 3) {
  999. map.physics.shapes[F5W[28]] = { type: "po", v: [], s: 1, a: 0, c: [0, 0] };
  1000. map.physics.shapes[F5W[28]].s = binaryReader.readDouble();
  1001. map.physics.shapes[F5W[28]].a = binaryReader.readDouble();
  1002. map.physics.shapes[F5W[28]].c = [
  1003. binaryReader.readDouble(),
  1004. binaryReader.readDouble(),
  1005. ];
  1006. F5W[74] = binaryReader.readShort();
  1007. map.physics.shapes[F5W[28]].v = [];
  1008. for (F5W[27] = 0; F5W[27] < F5W[74]; F5W[27]++) {
  1009. map.physics.shapes[F5W[28]].v.push([
  1010. binaryReader.readDouble(),
  1011. binaryReader.readDouble(),
  1012. ]);
  1013. }
  1014. }
  1015. }
  1016. F5W[71] = binaryReader.readShort();
  1017. for (F5W[17] = 0; F5W[17] < F5W[71]; F5W[17]++) {
  1018. map.physics.fixtures[F5W[17]] = { sh: 0, n: "Def Fix", fr: 0.3, fp: null, re: 0.8, de: 0.3, f: 0x4f7cac, d: false, np: false, ng: false };
  1019. map.physics.fixtures[F5W[17]].sh = binaryReader.readShort();
  1020. map.physics.fixtures[F5W[17]].n = binaryReader.readUTF();
  1021. map.physics.fixtures[F5W[17]].fr = binaryReader.readDouble();
  1022. if (map.physics.fixtures[F5W[17]].fr == Number.MAX_VALUE) {
  1023. map.physics.fixtures[F5W[17]].fr = null;
  1024. }
  1025. F5W[12] = binaryReader.readShort();
  1026. if (F5W[12] == 0) {
  1027. map.physics.fixtures[F5W[17]].fp = null;
  1028. }
  1029. if (F5W[12] == 1) {
  1030. map.physics.fixtures[F5W[17]].fp = false;
  1031. }
  1032. if (F5W[12] == 2) {
  1033. map.physics.fixtures[F5W[17]].fp = true;
  1034. }
  1035. map.physics.fixtures[F5W[17]].re = binaryReader.readDouble();
  1036. if (map.physics.fixtures[F5W[17]].re == Number.MAX_VALUE) {
  1037. map.physics.fixtures[F5W[17]].re = null;
  1038. }
  1039. map.physics.fixtures[F5W[17]].de = binaryReader.readDouble();
  1040. if (map.physics.fixtures[F5W[17]].de == Number.MAX_VALUE) {
  1041. map.physics.fixtures[F5W[17]].de = null;
  1042. }
  1043. map.physics.fixtures[F5W[17]].f = binaryReader.readUint();
  1044. map.physics.fixtures[F5W[17]].d = binaryReader.readBoolean();
  1045. map.physics.fixtures[F5W[17]].np = binaryReader.readBoolean();
  1046. if (map.v >= 11) {
  1047. map.physics.fixtures[F5W[17]].ng = binaryReader.readBoolean();
  1048. }
  1049. if (map.v >= 12) {
  1050. map.physics.fixtures[F5W[17]].ig = binaryReader.readBoolean();
  1051. }
  1052. }
  1053. F5W[63] = binaryReader.readShort();
  1054. for (F5W[52] = 0; F5W[52] < F5W[63]; F5W[52]++) {
  1055. map.physics.bodies[F5W[52]] ={ 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, fz: { on: false, x: 0, y: 0, d: true, p: true, a: true }};
  1056. map.physics.bodies[F5W[52]].type = binaryReader.readUTF();
  1057. map.physics.bodies[F5W[52]].n = binaryReader.readUTF();
  1058. map.physics.bodies[F5W[52]].p = [binaryReader.readDouble(), binaryReader.readDouble()];
  1059. map.physics.bodies[F5W[52]].a = binaryReader.readDouble();
  1060. map.physics.bodies[F5W[52]].fric = binaryReader.readDouble();
  1061. map.physics.bodies[F5W[52]].fricp = binaryReader.readBoolean();
  1062. map.physics.bodies[F5W[52]].re = binaryReader.readDouble();
  1063. map.physics.bodies[F5W[52]].de = binaryReader.readDouble();
  1064. map.physics.bodies[F5W[52]].lv = [
  1065. binaryReader.readDouble(),
  1066. binaryReader.readDouble(),
  1067. ];
  1068. map.physics.bodies[F5W[52]].av = binaryReader.readDouble();
  1069. map.physics.bodies[F5W[52]].ld = binaryReader.readDouble();
  1070. map.physics.bodies[F5W[52]].ad = binaryReader.readDouble();
  1071. map.physics.bodies[F5W[52]].fr = binaryReader.readBoolean();
  1072. map.physics.bodies[F5W[52]].bu = binaryReader.readBoolean();
  1073. map.physics.bodies[F5W[52]].cf.x = binaryReader.readDouble();
  1074. map.physics.bodies[F5W[52]].cf.y = binaryReader.readDouble();
  1075. map.physics.bodies[F5W[52]].cf.ct = binaryReader.readDouble();
  1076. map.physics.bodies[F5W[52]].cf.w = binaryReader.readBoolean();
  1077. map.physics.bodies[F5W[52]].f_c = binaryReader.readShort();
  1078. map.physics.bodies[F5W[52]].f_1 = binaryReader.readBoolean();
  1079. map.physics.bodies[F5W[52]].f_2 = binaryReader.readBoolean();
  1080. map.physics.bodies[F5W[52]].f_3 = binaryReader.readBoolean();
  1081. map.physics.bodies[F5W[52]].f_4 = binaryReader.readBoolean();
  1082. if (map.v >= 2) {
  1083. map.physics.bodies[F5W[52]].f_p = binaryReader.readBoolean();
  1084. }
  1085. if (map.v >= 14) {
  1086. map.physics.bodies[F5W[52]].fz.on = binaryReader.readBoolean();
  1087. if (map.physics.bodies[F5W[52]].fz.on) {
  1088. map.physics.bodies[F5W[52]].fz.x = binaryReader.readDouble();
  1089. map.physics.bodies[F5W[52]].fz.y = binaryReader.readDouble();
  1090. map.physics.bodies[F5W[52]].fz.d = binaryReader.readBoolean();
  1091. map.physics.bodies[F5W[52]].fz.p = binaryReader.readBoolean();
  1092. map.physics.bodies[F5W[52]].fz.a = binaryReader.readBoolean();
  1093. }
  1094. }
  1095. F5W[88] = binaryReader.readShort();
  1096. for (F5W[65] = 0; F5W[65] < F5W[88]; F5W[65]++) {
  1097. map.physics.bodies[F5W[52]].fx.push(binaryReader.readShort());
  1098. }
  1099. }
  1100. F5W[97] = binaryReader.readShort();
  1101. for (F5W[41] = 0; F5W[41] < F5W[97]; F5W[41]++) {
  1102. map.spawns[F5W[41]] = {"x":400,"y":300,"xv":0,"yv":0,"priority":5,"r":true,"f":true,"b":true,"gr":false,"ye":false,"n":"Spawn"};
  1103. F5W[35] = map.spawns[F5W[41]];
  1104. F5W[35].x = binaryReader.readDouble();
  1105. F5W[35].y = binaryReader.readDouble();
  1106. F5W[35].xv = binaryReader.readDouble();
  1107. F5W[35].yv = binaryReader.readDouble();
  1108. F5W[35].priority = binaryReader.readShort();
  1109. F5W[35].r = binaryReader.readBoolean();
  1110. F5W[35].f = binaryReader.readBoolean();
  1111. F5W[35].b = binaryReader.readBoolean();
  1112. F5W[35].gr = binaryReader.readBoolean();
  1113. F5W[35].ye = binaryReader.readBoolean();
  1114. F5W[35].n = binaryReader.readUTF();
  1115. }
  1116. F5W[16] = binaryReader.readShort();
  1117. for (F5W[25] = 0; F5W[25] < F5W[16]; F5W[25]++) {
  1118. map.capZones[F5W[25]] = {"n":"Cap Zone","ty":1,"l":10,"i":-1};
  1119. map.capZones[F5W[25]].n = binaryReader.readUTF();
  1120. map.capZones[F5W[25]].l = binaryReader.readDouble();
  1121. map.capZones[F5W[25]].i = binaryReader.readShort();
  1122. if (map.v >= 6) {
  1123. map.capZones[F5W[25]].ty = binaryReader.readShort();
  1124. }
  1125. }
  1126. F5W[98] = binaryReader.readShort();
  1127. for (F5W[19] = 0; F5W[19] < F5W[98]; F5W[19]++) {
  1128. F5W[31] = binaryReader.readShort();
  1129. if (F5W[31] == 1) {
  1130. map.physics.joints[F5W[19]] = {"type":"rv","d":{"la":0,"ua":0,"mmt":0,"ms":0,"el":false,"em":false,"cc":false,"bf":0,"dl":true},"aa":[0,0]};
  1131. F5W[20] = map.physics.joints[F5W[19]];
  1132. F5W[20].d.la = binaryReader.readDouble();
  1133. F5W[20].d.ua = binaryReader.readDouble();
  1134. F5W[20].d.mmt = binaryReader.readDouble();
  1135. F5W[20].d.ms = binaryReader.readDouble();
  1136. F5W[20].d.el = binaryReader.readBoolean();
  1137. F5W[20].d.em = binaryReader.readBoolean();
  1138. F5W[20].aa = [binaryReader.readDouble(), binaryReader.readDouble()];
  1139. }
  1140. if (F5W[31] == 2) {
  1141. map.physics.joints[F5W[19]] = {"type":"d","d":{"fh":0,"dr":0,"cc":false,"bf":0,"dl":true},"aa":[0,0],"ab":[0,0]};
  1142. F5W[87] = map.physics.joints[F5W[19]];
  1143. F5W[87].d.fh = binaryReader.readDouble();
  1144. F5W[87].d.dr = binaryReader.readDouble();
  1145. F5W[87].aa = [binaryReader.readDouble(), binaryReader.readDouble()];
  1146. F5W[87].ab = [binaryReader.readDouble(), binaryReader.readDouble()];
  1147. }
  1148. if (F5W[31] == 3) {
  1149. map.physics.joints[F5W[19]] = {"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};
  1150. F5W[90] = map.physics.joints[F5W[19]];
  1151. F5W[90].pax = binaryReader.readDouble();
  1152. F5W[90].pay = binaryReader.readDouble();
  1153. F5W[90].pa = binaryReader.readDouble();
  1154. F5W[90].pf = binaryReader.readDouble();
  1155. F5W[90].pl = binaryReader.readDouble();
  1156. F5W[90].pu = binaryReader.readDouble();
  1157. F5W[90].plen = binaryReader.readDouble();
  1158. F5W[90].pms = binaryReader.readDouble();
  1159. }
  1160. if (F5W[31] == 4) {
  1161. map.physics.joints[F5W[19]] = {"type":"lsj","d":{"cc":false,"bf":0,"dl":true},"sax":0,"say":0,"sf":0,"slen":0};
  1162. F5W[44] = map.physics.joints[F5W[19]];
  1163. F5W[44].sax = binaryReader.readDouble();
  1164. F5W[44].say = binaryReader.readDouble();
  1165. F5W[44].sf = binaryReader.readDouble();
  1166. F5W[44].slen = binaryReader.readDouble();
  1167. }
  1168. map.physics.joints[F5W[19]].ba = binaryReader.readShort();
  1169. map.physics.joints[F5W[19]].bb = binaryReader.readShort();
  1170. map.physics.joints[F5W[19]].d.cc = binaryReader.readBoolean();
  1171. map.physics.joints[F5W[19]].d.bf = binaryReader.readDouble();
  1172. map.physics.joints[F5W[19]].d.dl = binaryReader.readBoolean();
  1173. }
  1174. return map;
  1175. };
  1176. scope.updateWssLog = function(){
  1177. if(!wsslogpaused){
  1178. if(logmenutable.children.length < wsssendrecievelog.length){
  1179. var bottomscroll = logmenutable.clientHeight + logmenutable.scrollTop >= logmenutable.scrollHeight-1;
  1180. while (logmenutable.children.length>1000) {
  1181. logmenutable.removeChild(logmenutable.firstChild);
  1182. logmenutable2.removeChild(logmenutable2.firstChild);
  1183. }
  1184. var loopthro = wsssendrecievelog.slice(packetcount);
  1185. for(var i = 0; i < loopthro.length;i++){
  1186. packetcount++;
  1187. var row = document.createElement("tr");
  1188. var row2 = document.createElement("tr");
  1189.  
  1190. var cell1 = document.createElement("td");
  1191. cell1.style["overflow-x"] = "scroll";
  1192. cell1.style["padding"] = "0px";
  1193. cell1.style["width"] = "100000px";
  1194.  
  1195. var cell2 = document.createElement("td");
  1196. cell2.style["overflow-x"] = "scroll";
  1197. cell2.style["padding"] = "0px";
  1198. cell2.style["width"] = "100000px";
  1199. if(debuggercount){
  1200. cell1.style["background"] = "rgb(178, 185, 189)";
  1201. debuggercount = false;
  1202. }
  1203. else{
  1204. cell2.style["background"] = "rgb(178, 185, 189)";
  1205. debuggercount = true;
  1206. }
  1207. cell1.textContent = loopthro[i][1];
  1208. cell2.textContent = loopthro[i][1];
  1209. if(loopthro[i][0] == 0){
  1210. cell2.style["color"] = "transparent";
  1211. cell1.onclick = function(){debuggerinput.value = this.textContent};
  1212. }
  1213. else{
  1214. cell1.style["color"] = "transparent";
  1215. cell2.onclick = function(){debuggerinput.value = this.textContent};
  1216. }
  1217. row.appendChild(cell1);
  1218. row2.appendChild(cell2);
  1219. logmenutable.appendChild(row);
  1220. logmenutable2.appendChild(row2);
  1221. }
  1222. while (logmenutable.children.length>1000) {
  1223. logmenutable.removeChild(logmenutable.firstChild);
  1224. logmenutable2.removeChild(logmenutable2.firstChild);
  1225. }
  1226. if(bottomscroll){
  1227. logmenutable.scrollTop = logmenutable.scrollHeight;
  1228. logmenutable2.scrollTop = logmenutable.scrollHeight;
  1229. }
  1230. }
  1231. }
  1232. };
  1233. Gdocument.getElementById("maploadwindowmapscontainer").appendChild = function(args){
  1234.  
  1235. var checkbox = Gdocument.createElement("input");
  1236. checkbox.type = "checkbox";
  1237. checkbox.style["position"]="absolute";
  1238. checkbox.style["margin-top"] = "135px";
  1239. checkbox.style["margin-left"] = "140px";
  1240. checkbox.style["scale"] = "2";
  1241. checkbox.style["display"] = "none";
  1242. checkbox.className = "quickplaycheckbox quickplayunchecked";
  1243. if(ishost && stopquickplay==0){
  1244. checkbox.style["display"] = "block";
  1245. checkbox.className = "quickplaycheckbox quickplaychecked";
  1246. }
  1247. checkbox.checked = true;
  1248. checkbox.onclick = function(e){e.stopPropagation();};
  1249. args.appendChild(checkbox);
  1250. originalMapLoad.call(this,args);
  1251. };
  1252. Gdocument.getElementById("newbonklobby_chat_content").appendChild = function(args){
  1253. if(beenKickedTimeStamp+100>Date.now() && args.children.length>0){
  1254. if(args.children[0].textContent.endsWith(" has left the game ") && args.children[0].textContent.startsWith("* ")){
  1255. var kickedorbanned = "banned";
  1256. if(onlykicked){
  1257. kickedorbanned = "kicked";
  1258. }
  1259. args.children[0].textContent = args.children[0].textContent.substring(0,args.children[0].textContent.length-19)+" has been "+kickedorbanned+" from the game ";
  1260. }
  1261. }
  1262. setTimeout(function(){
  1263. if(args.textContent.startsWith("* ") && args.children.length>=5){
  1264. var newarg = args.cloneNode();
  1265. for(var i = 0;i<args.children.length;i++){
  1266. var newarg2 = args.children[i].cloneNode();
  1267. newarg2.textContent = args.children[i].textContent;
  1268. newarg2.style.color = '#ffffffd6';
  1269. newarg2.onclick = args.children[i].onclick;
  1270. newarg2.suggestID = args.children[i].suggestID;
  1271. newarg.appendChild(newarg2);
  1272. }
  1273. Gdocument.getElementById("ingamechatcontent").appendChild(newarg);
  1274. Gdocument.getElementById("ingamechatcontent").scrollTop = Number.MAX_SAFE_INTEGER;
  1275. }},0);
  1276. originalLobbyChat.call(this,args);
  1277. };
  1278. Gdocument.getElementById("ingamechatcontent").appendChild = function(args){
  1279. if(beenKickedTimeStamp+100>Date.now() && args.children.length>0){
  1280. if(args.children[0].textContent.endsWith(" has left the game.") && args.children[0].textContent.startsWith("* ")){
  1281. var kickedorbanned = "banned";
  1282. if(onlykicked){
  1283. kickedorbanned = "kicked";
  1284. }
  1285. args.children[0].textContent = args.children[0].textContent.substring(0,args.children[0].textContent.length-19)+" has been "+kickedorbanned+" from the game.";
  1286. }
  1287. }
  1288. if(recordedTimeStamp+100>Date.now() && args.children.length>0){
  1289. if(args.children[0].textContent.includes("seconds") && args.children[0].textContent.startsWith("* ")){
  1290. args.children[0].textContent = args.children[0].textContent + " - " + playerids[recordedId].userName;
  1291. }
  1292. }
  1293. originalIngameChat.call(this,args);
  1294. };
  1295. Gwindow.XMLHttpRequest.prototype.open = function(_, url) {
  1296. if (url.includes("scripts/map_get") || url.includes("scripts/map_b1_get") || url.includes("scripts/hotmaps/")) {
  1297. this.isSearchMap = true;
  1298. }
  1299. originalXMLOpen.call(this, ...arguments);
  1300. };
  1301. Gwindow.XMLHttpRequest.prototype.send = function(data) {
  1302. if (this.isSearchMap) {
  1303. this.onreadystatechange = function () {
  1304. if (this.readyState == 4 && searchrequested && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS") {
  1305. searchrequested = false;
  1306. var jsonargs = {r:"success",maps:[],more:true};
  1307. for(var i = 0; i<requestedmaps.length; i++){
  1308. var dec = requestedmaps[i][0];
  1309. var undec = requestedmaps[i][1];
  1310. var map = {};
  1311. map.id = dec["m"]["dbid"];
  1312. map.name = dec["m"]["n"];
  1313. map.authorname = dec["m"]["a"];
  1314. map.leveldata = undec;
  1315. map.publisheddate = dec["m"]["date"];
  1316. map.remixauthor = dec["m"]["rxa"];
  1317. map.remixdb = dec["m"]["rxdb"];
  1318. map.remixid = dec["m"]["rxid"];
  1319. map.remixname = dec["m"]["rxn"];
  1320. map.vd = dec["m"]["vd"];
  1321. map.vu = dec["m"]["vu"];
  1322. jsonargs.maps.push(map);
  1323. }
  1324. jsonargs2 = JSON.stringify(jsonargs);
  1325. function stringifyjsonargs(){
  1326. return jsonargs2;
  1327. }
  1328. this.__defineGetter__("responseText", stringifyjsonargs);
  1329. this.__defineGetter__("response", stringifyjsonargs);
  1330. }
  1331. }
  1332. }
  1333. originalXMLSend.call(this, ...arguments);
  1334. };
  1335. scope.STB = function(x){
  1336. if(x == "0"){
  1337. return 0;
  1338. }
  1339. else{
  1340. return 1;
  1341. }
  1342. };
  1343. scope.BTS = function(x){
  1344. if(x == 0){
  1345. return "0";
  1346. }
  1347. else{
  1348. return "1";
  1349. }
  1350. };
  1351. scope.GET_KEYS = function(x){
  1352. var x2 = ((x+64)>>>0).toString(2).substring(1).split("");
  1353. 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])}
  1354. };
  1355. scope.MAKE_KEYS = function(x){
  1356. return x.special*32+x.heavy*16+x.down*8+x.up*4+x.right*2+x.left
  1357. };
  1358.  
  1359. Gwindow.PIXI.Graphics.prototype.drawCircle = function(...args){
  1360. var This = this;
  1361. var Args = [...args];
  1362. setTimeout(function(){
  1363. if(This.parent){
  1364. var childs = This.parent.children;
  1365. var user = 0;
  1366. for(var i = 0;i<childs.length;i++){
  1367. if(childs[i]._text){
  1368. user = childs[i]._text;
  1369. }
  1370. if(i==2 && childs[i]!=This){
  1371. return;
  1372. }
  1373. }
  1374. var keys = Object.keys(playerids);
  1375. for(var i = 0;i<keys.length;i++){
  1376. if(playerids[keys[i]].userName == user){
  1377. playerids[keys[i]].playerData = This.parent;
  1378. if(!playerids[keys[i]].playerData2){
  1379. playerids[keys[i]].playerData2 = {alive:true,radius:12,timeStamp:0,timeStamp2:0,px:0,py:0,pvx:0,pvy:0,xacc:0,yacc:0,xvel:0,yvel:0,balance:0};
  1380. }
  1381. playerids[keys[i]].playerData2.radius = Args[2];
  1382. parentDraw = This.parent;
  1383. while(parentDraw.parent){
  1384. parentDraw = parentDraw.parent;
  1385. }
  1386. }
  1387. }
  1388. }
  1389. },0);
  1390. return originalDrawCircle.call(this,...args);
  1391. };
  1392. Gwindow.requestAnimationFrame = function(...args){
  1393. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  1394. while(parentDraw.parent){
  1395. parentDraw = parentDraw.parent;
  1396. }
  1397. var canv = 0;
  1398. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  1399. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  1400. canv = Gdocument.getElementById("gamerenderer").children[i];
  1401. break;
  1402. }
  1403. }
  1404. var width = parseInt(canv.style["width"]);
  1405. var height = parseInt(canv.style["height"]);
  1406. scale = (parseInt(canv.style["width"])/730);
  1407. var now = Date.now();
  1408. var keys = Object.keys(playerids);
  1409. var addto = {"children":[]};
  1410. for(var i = 0;i<parentDraw.children.length;i++){
  1411. if(parentDraw.children[i].constructor.name == "e"){
  1412. addto = parentDraw.children[i];
  1413. break;
  1414. }
  1415. }
  1416. var newzoom = 1;
  1417. if(autocam){
  1418. var autocamx = 365*scale;
  1419. var autocamy = 250*scale;
  1420. if(FollowCam && playerids[myid].playerData.transform){
  1421. autocamx = playerids[myid].playerData.transform.position.x;
  1422. autocamy = playerids[myid].playerData.transform.position.y;
  1423. }
  1424. var distances = {};
  1425. for(var i = 0;i<keys.length;i++){
  1426. if(playerids[keys[i]].playerData && playerids[keys[i]].playerData2){
  1427. if(playerids[keys[i]].playerData.transform){
  1428. var ypos = playerids[keys[i]].playerData.transform.position.y;
  1429. if(ypos>460*scale && ypos< 500 * scale){
  1430. ypos = scale * 460;
  1431. }
  1432. distances[keys[i]] = [playerids[keys[i]].playerData.transform.position.x-autocamx,ypos-autocamy];
  1433. }
  1434. }
  1435. }
  1436. distances["topleft"] = [autocamx-40,autocamy-40];
  1437. distances["topright"] = [690*scale-autocamx,autocamy-40];
  1438. distances["bottomleft"] = [autocamx-40,460*scale-autocamy];
  1439. distances["bottomright"] = [690*scale-autocamx,460*scale-autocamy];
  1440. var lowestD = [-1,-1];
  1441. var keys2 = Object.keys(distances);
  1442. for(var i = 0;i<keys2.length;i++){
  1443. if(Math.abs(distances[keys2[i]][0]/scale)>lowestD[0]){
  1444. lowestD[0] = Math.abs(distances[keys2[i]][0]/scale);
  1445. }
  1446. if(Math.abs(distances[keys2[i]][1]/scale)>lowestD[1]){
  1447. lowestD[1] = Math.abs(distances[keys2[i]][1]/scale);
  1448. }
  1449. }
  1450. var horizontal = (lowestD[0])/345;
  1451. var vertical = (lowestD[1])/230;
  1452. newzoom = Math.min(Math.abs(1/Math.max(horizontal,vertical)),1);
  1453. newzoom2 = newzoom2 + 0.15*(newzoom-newzoom2);
  1454. }
  1455. zoom2 = zoom2 + 0.15*(zoom-zoom2);
  1456. addto.scale.x = newzoom2 * zoom2;
  1457. addto.scale.y = newzoom2 * zoom2;
  1458. if(holdheavy>0){
  1459. if(holdheavy==1){
  1460. holdheavy = -1;
  1461. }
  1462. else{
  1463. holdheavy-=1;
  1464. }
  1465. }
  1466. if(playerids[myid].playerData?.children){
  1467. for(var i = 0;i<playerids[myid].playerData.children.length;i++){
  1468. if(playerids[myid].playerData.children[i].alpha!=1){
  1469. heavyid = i;
  1470. }
  1471. if(playerids[myid].playerData.children[i].vertextData){
  1472. if(playerids[myid].playerData.children[i].vertextData.length == 0){
  1473. specialid = i;
  1474. }
  1475. }
  1476. }
  1477. }
  1478. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  1479. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  1480. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  1481. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  1482. if(canvasWidth!=width){
  1483. canvasWidth = width;
  1484. pixiCircle.clear();
  1485. pixiCircle.x = parseInt(canv.style["width"])/2;
  1486. pixiCircle.y = parseInt(canv.style["height"])/2;
  1487. pixiCircle.lineStyle(3, 0x8B8000);
  1488. pixiCircle.drawRect(-parseInt(canv.style["width"])/2,-parseInt(canv.style["height"])/2,parseInt(canv.style["width"]),parseInt(canv.style["height"]));
  1489. pixiCircle.lineStyle(3, 0xFF0000);
  1490. pixiCircle.arc(0, 0, 850*scale,Math.atan2(250,-100*Math.sqrt(66)),Math.atan2(250,100*Math.sqrt(66)));
  1491. pixiCircle.lineTo(-100*Math.sqrt(66)*scale,250*scale);
  1492. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  1493. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  1494. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  1495. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  1496. }
  1497.  
  1498. if(!addto.children.includes(container)){
  1499. addto.addChild(container);
  1500. }
  1501. if(keys.length>0){
  1502. if(playerids[myid].playerData && playerids[myid].playerData2){
  1503. if(aimbot || heavybot){
  1504. var targetid = -1;
  1505. var distances = {};
  1506. if(Gdocument.getElementById("ingamecountdown").style["visibility"] == "hidden"){
  1507. if(playerids[myid].playerData.transform){
  1508. var teamok = true;
  1509. if(playerids[myid].team>1){
  1510. teamok = false;
  1511. }
  1512. for(var i = 0;i<keys.length;i++){
  1513. if(playerids[keys[i]].playerData && playerids[keys[i]].playerData2 && keys[i]!=myid){
  1514. if(playerids[keys[i]].playerData.transform && (playerids[keys[i]].team != playerids[myid].team || teamok || FFA)){
  1515. distances[keys[i]] = Math.sqrt((playerids[keys[i]].playerData.transform.position.x-playerids[myid].playerData.transform.position.x)**2+(playerids[keys[i]].playerData.transform.position.y-playerids[myid].playerData.transform.position.y)**2);
  1516. }
  1517. }
  1518. }
  1519. }
  1520. }
  1521. var lowestD = [-1,-1];
  1522. var keys2 = Object.keys(distances);
  1523. for(var i = 0;i<keys2.length;i++){
  1524. if(myid != keys2[i]){
  1525. if(lowestD[1] == -1){
  1526. lowestD[1] = distances[keys2[i]];
  1527. lowestD[0] = keys2[i];
  1528. }
  1529. else if(distances[keys2[i]]<lowestD[1]){
  1530. lowestD[1] = distances[keys2[i]];
  1531. lowestD[0] = keys2[i];
  1532. }
  1533. }
  1534. }
  1535. targetid = lowestD[0];
  1536. if(targetid != -1 && playerids[myid].playerData.transform){
  1537. if(playerids[myid].playerData.children.length >= 7 && playerids[targetid].playerData && playerids[targetid].playerData?.transform && playerids[targetid].playerData2 && playerids[myid].playerData.transform && aimbot){
  1538. var indexE = -1;
  1539. for(var i = 0;i<playerids[myid].playerData.children.length;i++){
  1540. if(playerids[myid].playerData.children[i].constructor.name == "e"){
  1541. indexE = i;
  1542. break;
  1543. }
  1544. }
  1545. if(indexE != -1 && playerids[myid].playerData.children[indexE].visible){
  1546. if(started == 0){
  1547. started = now;
  1548. }
  1549. var scale2=1/(parseInt(canv.style["width"])/730);
  1550. scale2 /= scale/(1 + playerids[myid].playerData2.balance*0.0088)*(playerids[myid].playerData2.radius/12);
  1551. var Dstarted = (Math.min((now-started)/1000,10/3)/(10/3));
  1552. var v = multiplier * (Dstarted*100+15);
  1553. var g = gravity;
  1554. var mypos = playerids[myid].playerData.transform.position;
  1555. var targetpos = playerids[targetid].playerData.transform.position;
  1556. var deltapos = [(targetpos.x-mypos.x)*scale2,(targetpos.y-mypos.y)*scale2];
  1557. var dis = (Math.sqrt(deltapos[0]**2 + deltapos[1]**2))/v*prediction;
  1558. deltapos[0]+=playerids[targetid].playerData2.xvel*scale2*dis+(playerids[targetid].playerData2.xacc*scale2*(dis))**2/2;
  1559. deltapos[1]+=playerids[targetid].playerData2.yvel*scale2*dis+(playerids[targetid].playerData2.yacc*scale2*(dis))**2/2;
  1560. deltapos[1] = -deltapos[1];
  1561. var angle = positive(-Math.atan2(deltapos[1],deltapos[0]));
  1562. var rot = playerids[myid].playerData.children[indexE].transform.rotation;
  1563. rot = positive(rot);
  1564. angle = positive(angle);
  1565.  
  1566. var alpha = deltapos[0];
  1567. var beta = deltapos[1];
  1568. var v_squared = v**2;
  1569. var rootterm = v_squared**2 - g*(g*alpha**2+2*beta*v_squared);
  1570. if(rootterm < 0) {
  1571. } else {
  1572. gamma_first = (v_squared + Math.sqrt(rootterm));
  1573. gamma_second = (v_squared - Math.sqrt(rootterm));
  1574. theta_first = positive(-Math.atan2(gamma_first, g*alpha));
  1575. theta_second = positive(-Math.atan2(gamma_second, g*alpha));
  1576. if(angle_between(angle,theta_first)<angle_between(angle,theta_second)){
  1577. angle = theta_first;
  1578. }
  1579. else{
  1580. angle = theta_second;
  1581. }
  1582. }
  1583. var min = angle_between(angle,rot);
  1584. if(angle_between2(angle,rot)<0){
  1585. fire("keydown",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1586. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"))
  1587. }
  1588. else{
  1589. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1590. fire("keydown",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"))
  1591. }
  1592. if(min<0.05){
  1593. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1594. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1595. }
  1596. }
  1597. else if(started>0){
  1598. started = 0;
  1599. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1600. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1601. }
  1602. }
  1603. }
  1604. if(playerids[myid].playerData.transform && heavybot && mode!="f" && mode!="bs"){
  1605. var myradius = playerids[myid].playerData2.radius / scale;
  1606. var mypos = playerids[myid].playerData.transform.position;
  1607. var breakout = false;
  1608. var collision_happened = false;
  1609. for(var i = 0;i<keys2.length;i++){
  1610. var targetradius = playerids[keys2[i]].playerData2.radius / scale;
  1611. var targetpos = playerids[keys2[i]].playerData.transform.position;
  1612. var deltapos = [(targetpos.x-mypos.x)/scale,(targetpos.y-mypos.y)/scale];
  1613. for(var i2 = 0;i2<100;i2++){
  1614. deltapos2 = [...deltapos];
  1615. var i3 = i2*0.25;
  1616. deltapos2[0]+=((playerids[keys2[i]].playerData2.xvel-playerids[myid].playerData2.xvel)/scale*i3);
  1617. deltapos2[1]+=((playerids[keys2[i]].playerData2.yvel-playerids[myid].playerData2.yvel)/scale*i3);
  1618. var dis = Math.sqrt(deltapos2[0]**2+deltapos2[1]**2);
  1619. if(dis<myradius+targetradius){
  1620. breakout = true;
  1621. holdheavy = 12;
  1622. collision_happened = true;
  1623. break;
  1624. }
  1625. }
  1626. if(breakout){
  1627. break;
  1628. }
  1629. }
  1630. if(holdheavy>0){
  1631. if(collision_happened && holdheavy<12){
  1632. holdheavy += 1;
  1633. }
  1634. if(!heavyheld2){
  1635. heavyheld = playerids[myid].playerData.children[heavyid].alpha>0;
  1636. }
  1637. fire("keydown",{"keyCode":heavy},Gdocument.getElementById("gamerenderer"));
  1638. heavyheld2 = true;
  1639. if(mode == "sp"){
  1640. if(!grappleheld2){
  1641. grappleheld = playerids[myid].playerData.children[specialid].vertexData?.length>0;
  1642. }
  1643. fire("keyup",{"keyCode":special},Gdocument.getElementById("gamerenderer"));
  1644. grappleheld2 = true;
  1645. }
  1646. }
  1647. else if(holdheavy<0){
  1648. holdheavy = 0;
  1649. heavyheld2 = false;
  1650. grappleheld2 = false;
  1651. if(!heavyheld){
  1652. heavyheld = false;
  1653. fire("keyup",{"keyCode":heavy},Gdocument.getElementById("gamerenderer"));
  1654. }
  1655. if(grappleheld && mode == "sp"){
  1656. grappleheld = false;
  1657. fire("keydown",{"keyCode":special},Gdocument.getElementById("gamerenderer"));
  1658. }
  1659. }
  1660. else{
  1661. heavyheld2 = false;
  1662. heavyheld = false;
  1663. grappleheld2 = false;
  1664. grappleheld = false;
  1665. }
  1666. }
  1667.  
  1668. }
  1669. if(FollowCam){
  1670. if(playerids[myid].playerData.transform){
  1671.  
  1672. pixiCircle.visible = true;
  1673.  
  1674. parentDraw.x = -playerids[myid].playerData.x*addto.scale.x+parseInt(width)/2;
  1675. parentDraw.y = -playerids[myid].playerData.y*addto.scale.y+parseInt(height)/2;
  1676. parentDraw.children[0].x = playerids[myid].playerData.x*addto.scale.x-parseInt(width)/2;
  1677. parentDraw.children[0].y = playerids[myid].playerData.y*addto.scale.y-parseInt(height)/2;
  1678. }
  1679. else{
  1680. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  1681. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  1682. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  1683. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  1684. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999){
  1685. pixiCircle.visible = false;
  1686. }
  1687. else{
  1688. pixiCircle.visible = true;
  1689. }
  1690. }
  1691. }
  1692. }
  1693. }
  1694. if(!FollowCam){
  1695. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999){
  1696. pixiCircle.visible = false;
  1697. }
  1698. else{
  1699. pixiCircle.visible = true;
  1700. }
  1701. }
  1702. }
  1703. return requestAnimationFrameOriginal.call(this,...args);
  1704. };
  1705. scope.SENDFUNCTION = function(args){return args;};
  1706. scope.RECIEVEFUNCTION = function(args){return args;};
  1707. scope.EVENTLOOPFUNCTION = function(){};
  1708.  
  1709. Gwindow.WebSocket.prototype.send = function(args) {
  1710. if(this.url.includes(".bonk.io/socket.io/?EIO=3&transport=websocket&sid=")){
  1711. if(typeof(args) == "string" && !bonkwssextra.includes(this)){
  1712. args = SENDFUNCTION(args);
  1713. wsssendlog.push(args);
  1714. wsssendrecievelog.push([0,args]);
  1715. if(!bonkwss){
  1716. bonkwss = this;
  1717. }
  1718. if(args.startsWith('42[26,')){
  1719. var jsonargs = JSON.parse(args.substring(2));
  1720. if(sandboxon){
  1721. if(typeof(sandboxplayerids[jsonargs[1]["targetID"]])!='undefined'){
  1722. var packet = '42[18,'+jsonargs[1]["targetID"]+','+jsonargs[1]["targetTeam"]+']';
  1723. RECIEVE(packet);
  1724. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  1725. }
  1726. }
  1727. }
  1728. if(args.startsWith('42[9,')){
  1729. var jsonargs = JSON.parse(args.substring(2));
  1730. if(sandboxon){
  1731. if(typeof(sandboxplayerids[jsonargs[1]["banshortid"]])!='undefined'){
  1732. if(Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden"){
  1733. var packet = '42[24,'+jsonargs[1]["banshortid"].toString()+','+jsonargs[1]["kickonly"]+']';
  1734. var packet2 = '42[5,'+jsonargs[1]["banshortid"].toString()+',0]';
  1735. RECIEVE(packet);
  1736. RECIEVE(packet2);
  1737. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet,packet2],to:[-1]}]));
  1738. }
  1739. else{
  1740. displayInChat("Cannot delete players while ingame.","#DA0808","#1EBCC1");
  1741. }
  1742. }
  1743. }
  1744. }
  1745. if(args.startsWith('42[1,')){
  1746. return;
  1747. }
  1748.  
  1749. if(args.startsWith('42[4,')){
  1750. var jsonargs = JSON.parse(args.substring(2));
  1751. if(sandboxcopyme && typeof(jsonargs[1]["i"])!="undefined"){
  1752. var jsonkeys = Object.keys(sandboxplayerids);
  1753. var jsonargs2 = jsonargs[1];
  1754. for(var i = 0; i<jsonkeys.length;i++){
  1755. jsonargs2["c"] = playerids[jsonkeys[i]].movecount;
  1756. var packet = '42[7,'+jsonkeys[i].toString()+','+JSON.stringify(jsonargs2)+']';
  1757. RECIEVE(packet);
  1758. }
  1759. jsonargs2["c"] = "CVALUE";
  1760. jsonargs2 = JSON.stringify(jsonargs2).replace('"CVALUE"',"CVALUE");
  1761. SEND("42"+JSON.stringify([4,{"type":"customfakerecieve","from":username,"packet":['42[7,ID,'+jsonargs2+']'],to:[-1]}]));
  1762. }
  1763. playerids[myid].lastmove = Date.now();
  1764. if(ishost && typeof(jsonargs[1]["i"])!="undefined"){
  1765. for(var i = 0;i<disabledkeys.length;i++){
  1766. if(GET_KEYS(jsonargs[1]["i"])[disabledkeys[i]]){
  1767. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden" && !killedids.includes(myid)){
  1768. killedids.push(myid);
  1769. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  1770. SEND('42[25,{"a":{"playersLeft":['+myid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  1771. RECIEVE('42[31,{"a":{"playersLeft":['+myid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  1772. break;
  1773. }
  1774. }
  1775. }
  1776. }
  1777. }
  1778. if(args.startsWith('42[29,')){
  1779. var jsonargs = JSON.parse(args.substring(2));
  1780. playerids[jsonargs[1]["sid"]].playerData2.balance = jsonargs[1]["bal"];
  1781. if(sandboxon){
  1782. if(typeof(sandboxplayerids[jsonargs[1]["sid"]])!='undefined'){
  1783. var packet = '42[36,'+jsonargs[1]["sid"]+','+jsonargs[1]["bal"]+']';
  1784. RECIEVE(packet);
  1785. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  1786. }
  1787. }
  1788. }
  1789. if(args.startsWith('42[12,')){
  1790. playerids = {};
  1791. var jsonargs2 = JSON.parse(args.substring(2));
  1792. var jsonargs = jsonargs2[1];
  1793. 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"],"movecount":0,"ratelimit":{"pm":0,"mode":0,"team":0,"poll":0},"vote":{"poll":-1}};
  1794. myid = 0;
  1795. bonkwss = this;
  1796. hostid = 0;
  1797. }
  1798. if(args.startsWith('42[23,') && recteams){
  1799. var jsonargs = JSON.parse(args.substring(2));
  1800. var map = decodeFromDatabase(jsonargs[1]["m"]);
  1801. var spawns = map["spawns"];
  1802. var teamsneeded = true;
  1803. var excludedindexes = [];
  1804. var ffaspawns = false;
  1805. var ffaforsure = false;
  1806. for(var i = 0; i<spawns.length;i++){
  1807. var currentSpawn = spawns[i];
  1808. if(Math.sqrt(currentSpawn.x**2 + currentSpawn.y**2)>=850 || currentSpawn.y>250){
  1809. excludedindexes.push(i);
  1810. }
  1811. else if(!(currentSpawn.f || currentSpawn.r || currentSpawn.b || currentSpawn.gr || currentSpawn.ye)){
  1812. excludedindexes.push(i);
  1813. }
  1814. else if(currentSpawn.f){
  1815. ffaspawns = true;
  1816. if(!(currentSpawn.r || currentSpawn.b || currentSpawn.gr || currentSpawn.ye)){
  1817. excludedindexes.push(i);
  1818. ffaforsure = true
  1819. }
  1820. }
  1821. }
  1822. if(!ffaspawns && !ffaforsure){
  1823. teamsneeded = true;
  1824. }
  1825. else{
  1826. teamsneeded = false;
  1827. }
  1828. if(teamsneeded){
  1829. var newspawns = [];
  1830. for(var i = 0; i<spawns.length;i++){
  1831. if(!excludedindexes.includes(i)){
  1832. 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"]});
  1833. }
  1834. }
  1835. if(newspawns.length>0){
  1836. var teamletters = ["r","g","b","y"];
  1837. var ratios = {"r":0,"g":0,"b":0,"y":0};
  1838. for(var i = 0; i < newspawns.length;i++){
  1839. for(var i2 = 0; i2<teamletters.length;i2++){
  1840. var ct = teamletters[i2];
  1841. if(newspawns[i]["priority"]!=0){
  1842. ratios[ct]+=(newspawns[i][ct])/newspawns[i]["total"]*newspawns[i]["priority"];
  1843. }
  1844. }
  1845. }
  1846. var highest = ["",0];
  1847. for(var i = 0; i<teamletters.length;i++){
  1848. var ct = teamletters[i];
  1849. if(ratios[ct]>0 && highest[1]<ratios[ct]){
  1850. highest = [ct,ratios[ct]];
  1851. }
  1852. }
  1853. if(highest[0]!=""){
  1854. for(var i = 0; i<teamletters.length;i++){
  1855. var ct = teamletters[i];
  1856. ratios[ct] = ratios[ct]/highest[1];
  1857. }
  1858. }
  1859. var playerids3 = Object.keys(playerids);
  1860. var playerids2 = [];
  1861. for(var i = 0; i<playerids3.length;i++){
  1862. if(playerids[playerids3[i]].team>0){
  1863. playerids2.push(playerids3[i]);
  1864. }
  1865. }
  1866. var pi2l = playerids2.length;
  1867. var ratios2 = {"r":0,"r1":0,"g":0,"g1":0,"b":0,"b1":0,"y":0,"y1":0};
  1868. var items = Object.entries(ratios);
  1869. items.sort(function(a,b){return a[1]-b[1];});
  1870. var items = items.map(function(e){return e[0];});
  1871. var highest2 = ["",0];
  1872. while(pi2l>0){
  1873. var done = false;
  1874. for(var i2 = 0; i2<items.length;i2++){
  1875. var ci = items[i2];
  1876. var ci2 = items[i2]+"1";
  1877. for(var i = 0; i<teamletters.length;i++){
  1878. var ct = teamletters[i];
  1879. if(ratios2[ct]>0 && highest2[1]<ratios2[ct]){
  1880. highest2 = [ct,ratios2[ct]];
  1881. }
  1882. }
  1883. if(highest2[0]!=""){
  1884. for(var i = 0; i<teamletters.length;i++){
  1885. var ct = teamletters[i];
  1886. ratios2[ct+"1"] = ratios2[ct]/highest2[1];
  1887. }
  1888. }
  1889. if(ratios[ci]>0 && ratios[ci]>=ratios2[ci2] && pi2l>0){
  1890. ratios2[ci]+=1;
  1891. pi2l--;
  1892. done = true;
  1893. }
  1894. }
  1895. if(pi2l>0 && !done){
  1896. ratios2[highest2[0]]+=1;
  1897. pi2l--;
  1898. }
  1899. }
  1900. SEND('42[32,{"t":true}]');
  1901. RECIEVE('42[39,true]');
  1902. for(var i = 0; i<ratios2["r"];i++){
  1903. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  1904. SEND('42[26,{"targetID":'+pid+',"targetTeam":2}]');
  1905. RECIEVE('42[18,'+pid+',2]');
  1906. }
  1907. for(var i = 0; i<ratios2["g"];i++){
  1908. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  1909. SEND('42[26,{"targetID":'+pid+',"targetTeam":4}]');
  1910. RECIEVE('42[18,'+pid+',4]');
  1911. }
  1912. for(var i = 0; i<ratios2["b"];i++){
  1913. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  1914. SEND('42[26,{"targetID":'+pid+',"targetTeam":3}]');
  1915. RECIEVE('42[18,'+pid+',3]');
  1916. }
  1917. for(var i = 0; i<ratios2["y"];i++){
  1918. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  1919. SEND('42[26,{"targetID":'+pid+',"targetTeam":5}]');
  1920. RECIEVE('42[18,'+pid+',5]');
  1921. }
  1922. }
  1923. }
  1924. else{
  1925. SEND('42[32,{"t":false}]');
  1926. RECIEVE('42[39,false]');
  1927. }
  1928. }
  1929.  
  1930. if(args.startsWith('42[47,') && stopquickplay == 0 && ishost && document.hidden && !qppaused){
  1931. roundsperqp2++;
  1932. if(roundsperqp2>=roundsperqp){
  1933. if(shuffle){
  1934. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  1935. var available = [];
  1936. var availableindexes = [];
  1937. var notempty = false;
  1938. for(var i = 0; i<e2.length;i++){
  1939. var a = false;
  1940. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  1941. available.push(a);
  1942. if(a){
  1943. availableindexes.push(i);
  1944. notempty = true;
  1945. }
  1946. }
  1947. if(notempty){
  1948.  
  1949. if(availableindexes.length!=1){
  1950. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  1951. }
  1952. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  1953. }
  1954. }
  1955. else{
  1956. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  1957. var available = [];
  1958. var availableindexes = [];
  1959. var notempty = false;
  1960. for(var i = 0; i<e2.length;i++){
  1961. var a = false;
  1962. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  1963. available.push(a);
  1964. if(a){
  1965. availableindexes.push(i);
  1966. notempty = true;
  1967. }
  1968. }
  1969. if(notempty){
  1970. var above = [];
  1971. for(var i = 0;i<availableindexes.length;i++){
  1972. if(availableindexes[i]>quicki){
  1973. above.push(availableindexes[i]);
  1974. }
  1975. }
  1976. if(above.length>0){
  1977. quicki = above[0];
  1978. }
  1979. else{
  1980. quicki = availableindexes[0];
  1981. }
  1982. }
  1983. }
  1984. }
  1985. canceled = false;
  1986. startedinqp = true;
  1987. window.map(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length),0);
  1988. }
  1989. if(args.startsWith('42[32,')){
  1990. var jsonargs = JSON.parse(args.substring(2));
  1991. var keys = Object.keys(playerids);
  1992. if(!jsonargs[1]["t"]){
  1993. FFA = true;
  1994. for(var i = 0;i<keys.length;i++){
  1995. if(playerids[keys[i]].team!=0){
  1996. playerids[keys[i]].team = 1;
  1997. }
  1998. }
  1999. }
  2000. else{
  2001. FFA = false;
  2002. }
  2003. }
  2004. if(args.startsWith('42[5,')){
  2005. var jsonargs = JSON.parse(args.substring(2));
  2006. if(stopquickplay!=1 && startedinqp){
  2007. startedinqp = false;
  2008. jsonargs[1]["gs"]["wl"] = 999;
  2009. if(!instaqp){
  2010. var jsonargs2 = decodeIS(jsonargs[1]["is"]);
  2011. jsonargs2["ftu"] = 60;
  2012. if(jsonargs2["mm"]["rxa"] != ""){
  2013. jsonargs2["mm"]["a"] = jsonargs2["mm"]["rxa"];
  2014. jsonargs2["mm"]["n"] = jsonargs2["mm"]["rxn"];
  2015. }
  2016. jsonargs2 = encodeIS(jsonargs2);
  2017. jsonargs[1]["is"] = jsonargs2;
  2018. var jsonargs3 = decodeFromDatabase(jsonargs[1]["gs"]["map"]);
  2019. if(jsonargs3["m"]["rxa"] != ""){
  2020. jsonargs3["m"]["a"] = jsonargs3["m"]["rxa"];
  2021. jsonargs3["m"]["n"] = jsonargs3["m"]["rxn"];
  2022. }
  2023.  
  2024. jsonargs3 = encodeToDatabase(jsonargs3);
  2025. jsonargs[1]["gs"]["map"] = jsonargs3;
  2026. }
  2027. }
  2028.  
  2029. args = "42"+JSON.stringify(jsonargs);
  2030. }
  2031. }
  2032.  
  2033. }
  2034. else{
  2035. if(args.includes("rport")){
  2036. return;
  2037. }
  2038. }
  2039. if(this.url.includes(".bonk.io/socket.io/?EIO=3&transport=websocket&sid=") && !this.injected){
  2040. this.injected = true;
  2041.  
  2042. var originalRecieve = this.onmessage;
  2043. this.onmessage = function(args){
  2044. if(!bonkwssextra.includes(this)){
  2045. wssrecievelog.push(args.data);
  2046. wsssendrecievelog.push([1,args.data]);
  2047. if(typeof(args.data)=="string"){
  2048. args = {"data":RECIEVEFUNCTION(args.data)};
  2049. if(args.data.startsWith('42[1,')){
  2050. var jsonargs = JSON.parse(args.data.substring(2));
  2051. originalSend.call(this,'42[1,{"id":'+jsonargs[2]+'}]');
  2052. }
  2053. if(args.data.startsWith('42[36,')){
  2054. var jsonargs = JSON.parse(args.data.substring(2));
  2055. playerids[jsonargs[1]].playerData2.balance = jsonargs[2];
  2056. }
  2057. if(args.data.startsWith('42[24,')){
  2058. beenKickedTimeStamp = Date.now();
  2059. onlykicked = JSON.parse(args.data.substring(2))[2];
  2060. }
  2061. if(args.data.startsWith('42[21,')){
  2062. recievedinitdata = true;
  2063. }
  2064. if(args.data.startsWith('42[48,')){
  2065. recievedinitdata = true;
  2066. }
  2067. if(args.data.startsWith('42[16,')){
  2068. var jsonargs = JSON.parse(args.data.substring(2));
  2069. var now = Date.now();
  2070. if(jsonargs[1]=="chat_rate_limit"){
  2071. if(pollactive[1]+100>now){
  2072. pollactive = [false,0,0,[]];
  2073. displayInChat("Your poll failed due to chat rate limit.","#DA0808","#1EBCC1");
  2074. displayInChat("Please try again.","#DA0808","#1EBCC1");
  2075. }
  2076. }
  2077. }
  2078. if(args.data.startsWith('42[6,')){
  2079. var jsonargs = JSON.parse(args.data.substring(2));
  2080. if(typeof(playerids[jsonargs[1]])!='undefined'){
  2081. delplayerids[jsonargs[1]] = playerids[jsonargs[1]];
  2082. delete playerids[jsonargs[1]];
  2083. }
  2084. hostid = jsonargs[2];
  2085. }
  2086. if(args.data.startsWith('42[39,')){
  2087. var jsonargs = JSON.parse(args.data.substring(2));
  2088. var keys = Object.keys(playerids);
  2089. if(!jsonargs[1]){
  2090. FFA = true;
  2091. for(var i = 0;i<keys.length;i++){
  2092. if(playerids[keys[i]].team!=0){
  2093. playerids[keys[i]].team = 1;
  2094. }
  2095. }
  2096. }
  2097. else{
  2098. FFA = false;
  2099. }
  2100. }
  2101. if(args.data.startsWith('42[41,')){
  2102. var jsonargs = JSON.parse(args.data.substring(2));
  2103. hostid = jsonargs[1]["newHost"];
  2104. }
  2105. if(args.data.startsWith('42[20,')){
  2106. var jsonargs = JSON.parse(args.data.substring(2));
  2107. if(echo_list.includes(playerids[jsonargs[1]].userName)){
  2108. chat(flag_manage(echotext.replaceAll("username",playerids[jsonargs[1]].userName).replaceAll("message",jsonargs[2])));
  2109. }
  2110. if(pollactive[0] || pollactive2[0]){
  2111. var chatmessage = jsonargs[2].toUpperCase().trim().replace(")","");
  2112. var lettersindex = letters.indexOf(chatmessage);
  2113. if(ishost){
  2114. if(pollactive[3].length>0 && lettersindex!=-1 && lettersindex<pollactive[3].length){
  2115. playerids[jsonargs[1]].vote.poll = lettersindex;
  2116. }
  2117. }
  2118. else{
  2119. if(pollactive2[2].length>0 && lettersindex!=-1 && lettersindex<pollactive2[2].length){
  2120. playerids[jsonargs[1]].vote.poll = lettersindex;
  2121. }
  2122. }
  2123. }
  2124. }
  2125. if(args.data.startsWith('42[32')){
  2126. SEND('42[4,{"type":"inactive kick counter"}]');
  2127. }
  2128. if(args.data.startsWith('42[18')){
  2129. var jsonargs = JSON.parse(args.data.substring(2));
  2130. playerids[jsonargs[1]].team = jsonargs[2];
  2131. }
  2132. if(args.data.startsWith('42[40,')){
  2133. recordedTimeStamp = Date.now();
  2134. recordedId = JSON.parse(args.data.substring(2))[1];
  2135. }
  2136. if(args.data.startsWith('42[3,')){
  2137. playerids = {};
  2138. var jsonargs = JSON.parse(args.data.substring(2));
  2139. for(var i = 0; i<jsonargs[3].length;i++){
  2140. if(jsonargs[3][i]!=null){
  2141. playerids[i.toString()] = jsonargs[3][i];
  2142. playerids[i.toString()].ratelimit = {"pm":0,"mode":0,"team":0,"poll":0};
  2143. playerids[i.toString()].vote = {"poll":-1};
  2144. }
  2145. }
  2146. if(playerids[jsonargs[1]].userName.startsWith(Gdocument.getElementById("pretty_top_name").textContent)){
  2147. myid = jsonargs[1];
  2148. bonkwss = this;
  2149. }
  2150. else{
  2151. bonkwssextra.push(this);
  2152. }
  2153. hostid = jsonargs[2];
  2154. SEND('42[4,{"type":"commands"}]');
  2155. setTimeout(function(){if(!sandboxon && !recievedinitdata && myid!=0){RECIEVE('42[21,{"map":{"v":13,"s":{"re":false,"nc":false,"pq":1,"gd":25,"fl":false},"physics":{"shapes":[],"fixtures":[],"bodies":[],"bro":[],"joints":[],"ppm":12},"spawns":[],"capZones":[],"m":{"a":"","n":"","dbv":0,"dbid":0,"authid":-1,"date":"","rxid":0,"rxn":"","rxa":"","rxdb":0,"cr":[],"pub":false,"mo":"","vu":0,"vd":0}},"gt":2,"wl":3,"q":false,"tl":false,"tea":false,"ga":"b","mo":"b","bal":[]}]');displayInChat("You have joined a ghost room.","#DA0808","#1EBCC1");}},4000);
  2156.  
  2157. }
  2158. if(args.data.startsWith('42[21,')){
  2159. var jsonargs = JSON.parse(args.data.substring(2));
  2160. mode = jsonargs[1]["mo"];
  2161. FFA = !jsonargs[1]["tea"];
  2162. }
  2163. if(args.data.startsWith('42[48,')){
  2164. var jsonargs = JSON.parse(args.data.substring(2));
  2165. mode = jsonargs[1]["gs"]["mo"];
  2166. FFA = !jsonargs[1]["gs"]["tea"];
  2167. }
  2168. if(args.data.startsWith('42[15,')){
  2169. var jsonargs = JSON.parse(args.data.substring(2));
  2170. dontswitch = false;
  2171. mode = jsonargs[3]["mo"];
  2172. gameStartTimeStamp = Date.now();
  2173. killedids = [];
  2174. Gdocument.getElementById("newbonklobby").style["z-index"] = "unset";
  2175. Gdocument.getElementById("mapeditorcontainer").style["z-index"] = "unset";
  2176. }
  2177. if(args.data.startsWith('42[33,')){
  2178. var jsonargs = JSON.parse(args.data.substring(2));
  2179. var decodedmap = decodeFromDatabase(jsonargs[1]);
  2180. if(decodedmap!=0){
  2181. requestedmaps.push([decodedmap,jsonargs[1]]);
  2182. }
  2183. }
  2184. if(args.data.startsWith('42[7,')){
  2185. var jsonargs2 = JSON.parse(args.data.substring(2));
  2186. var idofpacket = jsonargs2[1];
  2187. jsonargs = jsonargs2[2];
  2188. if(typeof(jsonargs["i"]) == "undefined"){
  2189. if(jsonargs["type"]=="private chat" && jsonargs["to"] == username){
  2190. from = jsonargs["from"];
  2191. if(Object.keys(playerids).includes(idofpacket.toString())){
  2192. from = playerids[idofpacket].userName;
  2193. }
  2194. if(!ignorepmlist.includes(from)){
  2195. if(typeof(jsonargs["message"])=="object" && typeof(jsonargs["password"]) == "object"){
  2196. if(public_key[0]==jsonargs["public key"][0] && public_key[1]==jsonargs["public key"][1]){
  2197. var now = Date.now();
  2198. if(jsonargs["password"].length<=25 && playerids[idofpacket].ratelimit.pm+250<now){
  2199. playerids[idofpacket].ratelimit.pm = now;
  2200. var password = CRYPT_MESSAGE(private_key,jsonargs["password"]);
  2201. var decodedtext = jsonargs["message"].slice(0,400);
  2202. var encodedtext = "";
  2203. for(var i=0;i<decodedtext.length;i++){
  2204. if(password[i%password.length]<1000){
  2205. encodedtext+=String.fromCharCode(password[i%password.length]^decodedtext[i]);
  2206. }
  2207. }
  2208. 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);';
  2209. displayInChat('> '+'<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+from+'</a>'+': ',"#DA0808","#1EBCC1",{sanitize:false},encodedtext);
  2210.  
  2211. Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true;
  2212. Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true;
  2213. Laster_message = lastmessage();
  2214. }
  2215. }
  2216. else{
  2217. SEND("42"+JSON.stringify([4,{"type":"public key correction","from":username,"to":private_chat_public_key[0],"public key":public_key}]));
  2218. }
  2219. }
  2220. }
  2221. }
  2222. if(jsonargs["type"]=="request public key" && jsonargs["to"] == username){
  2223. SEND("42"+JSON.stringify([4,{"type":"public key","from":username,"public key":public_key}]));
  2224. }
  2225. if(jsonargs["type"]=="private chat users" && pmuserstimestamp+1500>Date.now()){
  2226. if(typeof(jsonargs["from"])!='undefined'){
  2227. from = jsonargs["from"];
  2228. if(Object.keys(playerids).includes(idofpacket.toString())){
  2229. from = playerids[idofpacket].userName;
  2230. }
  2231. if(!pmusers.includes(from) && username == jsonargs["to"]){
  2232. pmusers.push(from);
  2233. }
  2234. }
  2235. }
  2236. if(jsonargs["type"]=="request private chat users"){
  2237. if(typeof(jsonargs["from"])!='undefined'){
  2238. from = jsonargs["from"];
  2239. if(Object.keys(playerids).includes(idofpacket.toString())){
  2240. from = playerids[idofpacket].userName;
  2241. }
  2242. SEND("42"+JSON.stringify([4,{"type":"private chat users","from":username,"to":from}]));
  2243. }
  2244. }
  2245. if(jsonargs["type"]=="public key" && request_public_key_time_stamp+1500>Date.now()){
  2246. from = jsonargs["from"];
  2247. if(Object.keys(playerids).includes(idofpacket.toString())){
  2248. from = playerids[idofpacket].userName;
  2249. }
  2250. if(from == private_chat){
  2251. private_chat_public_key = [private_chat,jsonargs["public key"]];
  2252. displayInChat("Private chatting with "+private_chat+".","#DA0808","#1EBCC1");
  2253. }
  2254. }
  2255. if(jsonargs["type"]=="fakerecieve" && hostid == idofpacket && sandboxon && ((jsonargs["to"].includes(myid) && jsonargs["to"][0]!=-1) || (!jsonargs["to"].includes(myid) && jsonargs["to"][0]==-1))){
  2256. for(var i = 0;i<jsonargs["packet"].length;i++){
  2257. if(!jsonargs["packet"][i].startsWith("42[10,")){
  2258. RECIEVE(jsonargs["packet"][i]);
  2259. }
  2260. }
  2261. }
  2262. if(jsonargs["type"]=="customfakerecieve" && hostid == idofpacket && sandboxon && ((jsonargs["to"].includes(myid) && jsonargs["to"][0]!=-1) || (!jsonargs["to"].includes(myid) && jsonargs["to"][0]==-1))){
  2263. for(var i2 = 0;i2<jsonargs["packet"].length;i2++){
  2264. var keys = Object.keys(sandboxplayerids);
  2265. for(var i = 0;i<keys.length;i++){
  2266. if(jsonargs["packet"][i2].startsWith("42[7,")){
  2267. RECIEVE(jsonargs["packet"][i2].replace("ID",keys[i].toString()).replace("CVALUE",playerids[keys[i]].movecount.toString()))
  2268. }
  2269. }
  2270. }
  2271. }
  2272. if(jsonargs["type"]=="commands"){
  2273. playerids[idofpacket].commands = true;
  2274. }
  2275. if(jsonargs["type"]=="sandboxid" && hostid == idofpacket && sandboxon && ((jsonargs["to"].includes(myid) && jsonargs["to"][0]!=-1) || (!jsonargs["to"].includes(myid) && jsonargs["to"][0]==-1))){
  2276. sandboxid = jsonargs["lastid"];
  2277. }
  2278. if(jsonargs["type"]=="sandboxon" && idofpacket == hostid){
  2279. if(!sandboxon){
  2280. displayInChat("This is a sandbox lobby.","#DA0808","#1EBCC1");
  2281. sandboxon = true;
  2282. }
  2283. }
  2284. if(jsonargs["type"]=="vote poll"){
  2285. from = jsonargs["from"];
  2286. if(Object.keys(playerids).includes(idofpacket.toString())){
  2287. from = playerids[idofpacket].userName;
  2288. }
  2289. if(typeof(jsonargs["vote"]) == 'number' && idofpacket!=hostid){
  2290. var now = Date.now();
  2291. if(ishost && pollactive[3].length>1 && pollactive[0]){
  2292. if(jsonargs["vote"]>=0 && jsonargs["vote"]<pollactive[3].length){
  2293. playerids[idofpacket].vote.poll = jsonargs["vote"];
  2294. }
  2295. }
  2296. else if(pollactive2[0] && pollactive2[2].length>1){
  2297. if(jsonargs["vote"]>=0 && jsonargs["vote"]<pollactive2[2].length){
  2298. playerids[idofpacket].vote.poll = jsonargs["vote"];
  2299. }
  2300. }
  2301. }
  2302.  
  2303. }
  2304. if(jsonargs["type"]=="poll end"){
  2305. from = jsonargs["from"];
  2306. if(Object.keys(playerids).includes(idofpacket.toString())){
  2307. from = playerids[idofpacket].userName;
  2308. }
  2309. var now = Date.now();
  2310. if(hostid == idofpacket && playerids[idofpacket].ratelimit.poll+5000<now){
  2311. playerids[idofpacket].ratelimit.poll = now;
  2312. var count = [0,0,0,0];
  2313. var keys = Object.keys(playerids);
  2314. for(var i = 0;i<keys.length;i++){
  2315. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive2[2].length-1){
  2316. count[playerids[keys[i]].vote.poll]++;
  2317. }
  2318. playerids[keys[i]].vote.poll = -1;
  2319. }
  2320. displayInChat("The poll ended.","#DA0808","#1EBCC1");
  2321. for(var i = 0;i<count.length;i++){
  2322. if(count[i]>1){
  2323. displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  2324. }
  2325. if(count[i]==1){
  2326. displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  2327. }
  2328. }
  2329. pollactive2 = [false,0,[]];
  2330. }
  2331.  
  2332. }
  2333. if(jsonargs["type"]=="poll" && idofpacket == hostid){
  2334. from = jsonargs["from"];
  2335. if(Object.keys(playerids).includes(idofpacket.toString())){
  2336. from = playerids[idofpacket].userName;
  2337. }
  2338. if(Array.isArray(jsonargs["poll"])){
  2339. var propperpoll = true;
  2340. var pollifproper = [];
  2341. if(jsonargs["poll"].length>5){
  2342. propperpoll = false;
  2343. }
  2344. else{
  2345. for(var i = 0;i<jsonargs["poll"].length;i++){
  2346. if(typeof(jsonargs["poll"][i]) == 'string'){
  2347. if(jsonargs["poll"][i].length>50){
  2348. propperpoll = false;
  2349. break;
  2350. }
  2351. else{
  2352. pollifproper.push(jsonargs["poll"][i]);
  2353. }
  2354. }
  2355. else{
  2356. propperpoll = false;
  2357. break;
  2358. }
  2359. }
  2360. }
  2361. if(propperpoll){
  2362. var now = Date.now();
  2363. var keys = Object.keys(playerids);
  2364. for(var i = 0;i<keys.length;i++){
  2365. playerids[keys[i]].vote.poll = -1;
  2366. }
  2367. pollactive2 = [true,now,pollifproper];
  2368. playerids[idofpacket].ratelimit.poll = now;
  2369. displayInChat(from+" started a poll:","#DA0808","#1EBCC1");
  2370. for(var i = 0;i<pollifproper.length;i++){
  2371. var code = 'Gwindow.displayInChat("You voted for option '+letters[i]+'.","#DA0808","#1EBCC1",{sanitize:false},"",true);Gwindow.SEND("42"+JSON.stringify([4,{"type":"vote poll","from":Gwindow.username,"vote":'+i+'}]));Gwindow.playerids[Gwindow.myid].vote.poll='+i+';Gwindow.Gdocument.getElementById("newbonklobby_chat_content").children[Gwindow.Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true;Gwindow.Gdocument.getElementById("ingamechatcontent").children[Gwindow.Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true;Gwindow.Laster_message = Gwindow.lastmessage();';
  2372. displayInChat('<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+letters[i]+')</a>',"#DA0808","#1EBCC1",{sanitize:false}," "+pollifproper[i]);
  2373. }
  2374. }
  2375. }
  2376. }
  2377. if(jsonargs["type"]=="request mode" && playerids[idofpacket].ratelimit.mode+1000<Date.now()){
  2378. playerids[idofpacket].ratelimit.mode = Date.now();
  2379. from = jsonargs["from"];
  2380. if(Object.keys(playerids).includes(idofpacket.toString())){
  2381. from = playerids[idofpacket].userName;
  2382. }
  2383. var req_mode = jsonargs["mode"];
  2384. var req_mode2 = "";
  2385. if(req_mode){
  2386. if(req_mode == "b"){
  2387. req_mode2 = "Classic";
  2388. }
  2389. else if(req_mode == "sp"){
  2390. req_mode2 = "Grapple";
  2391. }
  2392. else if(req_mode == "ar"){
  2393. req_mode2 = "Arrows";
  2394. }
  2395. else if(req_mode == "ard"){
  2396. req_mode2 = "Death Arrows";
  2397. }
  2398. }
  2399. if(req_mode2){
  2400. var code = 'if(!Gwindow.ishost){Gwindow.displayInChat("You must be host to change the mode.","#DA0808","#1EBCC1",{sanitize:false},"",true)}else{Gwindow.changemode("'+req_mode+'")}';
  2401. displayInChat('> '+playerids[idofpacket].userName+' requests [<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+req_mode2+'</a>]',"#DA0808","#1EBCC1",{sanitize:false}," mode.");
  2402. }
  2403.  
  2404. }
  2405. if(jsonargs["type"]=="public key correction" && private_chat_public_key[0] == private_chat){
  2406. from = jsonargs["from"];
  2407. if(Object.keys(playerids).includes(idofpacket.toString())){
  2408. from = playerids[idofpacket].userName;
  2409. }
  2410. if(from == private_chat){
  2411. private_chat_public_key = [private_chat,jsonargs["public key"]];
  2412. var text = pmlastmessage;
  2413. var password = [];
  2414. for(var i = 0;i<10;i++){
  2415. password.push(Math.floor(Math.random()*100+50));
  2416. }
  2417. var text2 = [];
  2418. for(var i = 0;i<text.length ;i++){
  2419. text2.push(password[i%password.length]^text.slice(0,400).charCodeAt(i));
  2420. }
  2421. cc
  2422. }
  2423. }
  2424.  
  2425. }
  2426. else{
  2427. var now = Date.now();
  2428. playerids[idofpacket.toString()].movecount+=1;
  2429. if(playerids[idofpacket.toString()]){
  2430. playerids[idofpacket.toString()].lastmove = now;
  2431. }
  2432. if(Math.abs(gameStartTimeStamp - (now-1000*jsonargs["f"]/30))>250){
  2433. gameStartTimeStamp = now-1000*jsonargs["f"]/30;
  2434. }
  2435. if(ishost){
  2436. for(var i = 0;i<disabledkeys.length;i++){
  2437. var get_keys_var = GET_KEYS(jsonargs["i"]);
  2438. if(get_keys_var[disabledkeys[i]]){
  2439. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden" && !killedids.includes(idofpacket)){
  2440. killedids.push(idofpacket);
  2441. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  2442. SEND('42[25,{"a":{"playersLeft":['+idofpacket.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  2443. RECIEVE('42[31,{"a":{"playersLeft":['+idofpacket.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  2444. break;
  2445. }
  2446. }
  2447. }
  2448. }
  2449. }
  2450. }
  2451.  
  2452. if(args.data.startsWith('42[4,')){
  2453. var jsonargs = JSON.parse(args.data.substring(2));
  2454. playerids[jsonargs[1]] = {"peerID":jsonargs[2],"userName":jsonargs[3],"guest":jsonargs[4],"level":jsonargs[5],"team":jsonargs[6],"avatar":jsonargs[7],"movecount":0,"ratelimit":{"pm":0,"mode":0,"team":0,"poll":0},"vote":{"poll":-1}};
  2455. if(sandboxon){
  2456. var sandboxkeys = Object.keys(sandboxplayerids);
  2457. if(sandboxkeys.includes(jsonargs[1].toString())){
  2458. delete sandboxplayerids[jsonargs[1]];
  2459. }
  2460. if(jsonargs[2]=="sandbox"){
  2461. sandboxplayerids[jsonargs[1]] = jsonargs[3];
  2462. if(jsonargs[1]>sandboxid){
  2463. sandboxid = parseInt(jsonargs[1])+1;
  2464. }
  2465. }
  2466. else{
  2467. if(ishost){
  2468. SEND('42[4,{"type":"sandboxon"}]');
  2469. var sandboxkeys = Object.keys(sandboxplayerids);
  2470. var packets = [];
  2471. for(var i = 0;i<sandboxkeys.length;i++){
  2472. var p = playerids[sandboxkeys[i]];
  2473. var packet = '42'+JSON.stringify([4,sandboxkeys[i],p.peerID,p.userName,p.guest,p.level,p.team,p.avatar]);
  2474. packets.push(packet);
  2475. }
  2476. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":packets,to:[jsonargs[1]]}]));
  2477. SEND("42"+JSON.stringify([4,{"type":"sandboxid","from":username,"lastid":sandboxid,to:[jsonargs[1]]}]));
  2478. setTimeout(function(){if(!playerids[jsonargs[1]]?.commands){SEND('42[9,{"banshortid":'+jsonargs[1].toString()+',"kickonly":true}]');}},1500);
  2479. }
  2480. }
  2481. }
  2482. if(ishost){
  2483. if(jointext!=""){
  2484. chat(flag_manage(jointext.replaceAll("username",jsonargs[3])));
  2485. }
  2486. if(freejoin){
  2487. var count = 0;
  2488. var keys = Object.keys(playerids);
  2489. for(var i = 0; i<keys.length;i++){
  2490. if(playerids[keys[i]].team!=0){
  2491. count++;
  2492. }
  2493. }
  2494. if(count <= 2 && jsonargs[6]!=0){
  2495. setTimeout(function(){
  2496. Gdocument.getElementById("newbonklobby_editorbutton").click();
  2497. Gdocument.getElementById("mapeditor_close").click();
  2498. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  2499. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  2500. if(transitioning == true){
  2501. canceled = true;
  2502. }
  2503. },150);
  2504. }
  2505. }
  2506. }
  2507.  
  2508. }
  2509. if(args.data.startsWith('42[5,')){
  2510. var jsonargs = JSON.parse(args.data.substring(2));
  2511. if(typeof(playerids[jsonargs[1]])!='undefined'){
  2512. delplayerids[jsonargs[1]] = playerids[jsonargs[1]];
  2513. delete playerids[jsonargs[1]];
  2514. }
  2515. if(sandboxon && typeof(sandboxplayerids[jsonargs[1]])!='undefined'){
  2516. delete sandboxplayerids[jsonargs[1]];
  2517. }
  2518. }
  2519. }}
  2520. return originalRecieve.call(this,args);
  2521. };
  2522.  
  2523. var originalClose = this.onclose;
  2524. this.onclose = function () {
  2525. if(bonkwssextra.includes(this)){
  2526. bonkwssextra.splice(bonkwssextra.indexOf(this),1)
  2527. }
  2528. else{
  2529. window.bonkwss = 0;
  2530. }
  2531. return originalClose.call(this);
  2532. }
  2533.  
  2534. }
  2535. return originalSend.call(this,args);
  2536. };
  2537.  
  2538. scope.SEND = function(args){
  2539. if(bonkwss!=0){
  2540. bonkwss.send(args);
  2541. }
  2542. };
  2543. scope.RECIEVE = function(args){
  2544. if(bonkwss!=0){
  2545. bonkwss.onmessage({data:args});
  2546. }
  2547. };
  2548.  
  2549.  
  2550.  
  2551. scope.dontswitch = false;
  2552. scope.username = 0;
  2553. scope.timedelay = 1400;
  2554. scope.ishost = false;
  2555. scope.checkboxhidden = true;
  2556. scope.quicki=0;
  2557. scope.defaultmode = "d";
  2558. scope.recmodebool = false;
  2559. scope.shuffle = false;
  2560. scope.startedinqp = false;
  2561. scope.instaqp = false;
  2562. scope.freejoin = false;
  2563. scope.recordedTimeStamp = 0;
  2564. scope.recordedId = 0;
  2565. scope.smartteams = false;
  2566. scope.beenKickedTimeStamp = 0;
  2567. scope.stopquickplay = 1;
  2568. scope.currentFrame = 0;
  2569. scope.text2speech = false;
  2570. scope.gameStartTimeStamp = 0;
  2571. scope.canceled = false;
  2572. scope.wintext = "";
  2573. scope.banned = [];
  2574. scope.transitioning = false;
  2575. scope.echo_list = [];
  2576. scope.echoAppend = "";
  2577. scope.message = "";
  2578. scope.private_chat = "";
  2579. scope.private_chat_public_key = ["",[0,0]];
  2580. scope.disabledkeys = [];
  2581. scope.actuallyhost = false;
  2582. scope.pmusers = [];
  2583. scope.pmlastmessage = "";
  2584. scope.pmuserstimestamp = 0;
  2585. scope.ignorepmlist = [];
  2586. scope.scroll = false;
  2587. scope.elem = Gdocument.getElementById("maploadwindowmapscontainer");
  2588. scope.npermissions = 1;
  2589. scope.space_flag = false;
  2590. scope.rcaps_flag = false;
  2591. scope.number_flag = false;
  2592. scope.reverse_flag = false;
  2593. scope.request_public_key_time_stamp = 0;
  2594. scope.sandboxcopyme = false;
  2595. scope.recteams = false;
  2596. scope.chatheight = 128;
  2597. scope.onlykicked = false;
  2598. scope.killedids = [];
  2599. scope.jointext = "";
  2600. scope.afkkill = -1;
  2601. scope.tournament_mode = "";
  2602. scope.tournament_scores = [];
  2603. scope.tournament_in_and_out = {"in":[],"out":[]};
  2604. scope.echotext = "message";
  2605. scope.nextafter = 0;
  2606. scope.nextafterbuffer = -1;
  2607. scope.roundsperqp = 1;
  2608. scope.roundsperqp2 = 0;
  2609. scope.autorecord = false;
  2610. scope.poll = [];
  2611. scope.letters = ["A","B","C","D","E"];
  2612. scope.qppaused = false;
  2613. scope.FollowCam = false;
  2614. scope.autocam = false;
  2615. scope.gravity = 20;
  2616. scope.multiplier = 3.75;
  2617. scope.aimbot = false;
  2618. scope.recievedinitdata = false;
  2619. scope.heavybot = false;
  2620. scope.zoom = 1;
  2621.  
  2622. scope.prediction = 750;
  2623. scope.started = 0;
  2624. scope.holdheavy = 0;
  2625. scope.grappleheld = false;
  2626. scope.grappleheld2 = false;
  2627. scope.heavyheld = false;
  2628. scope.heavyheld2 = false;
  2629. scope.heavyid = 3;
  2630. scope.specialid = 0;
  2631. scope.keyCodes = {"BACK_SPACE":8,"TAB":9,"SHIFT":16,"ALT":18,"LEFT ARROW":37,"RIGHT ARROW":39,"DOWN ARROW":40,"UP ARROW":38,"CONTROL":17,"SPACE":32};
  2632. scope.leftRight = [37,39];
  2633. scope.heavy = 88;
  2634. scope.special = 90;
  2635. scope.newzoom2 = 1;
  2636. scope.zoom2 = 1;
  2637. scope.positive = function(angle){
  2638. if(angle<0){
  2639. angle += 2*Math.PI;
  2640. }
  2641. return angle%(Math.PI*2);
  2642. };
  2643. scope.angle_between = function(angle,angle2){
  2644. return Math.min(Math.abs(positive(angle)-positive(angle2)),Math.PI*2-Math.abs(positive(angle)-positive(angle2)));
  2645. };
  2646. scope.angle_between2 = function(angle,angle2){
  2647. if(angle_between(angle,angle2+Math.PI/2)<Math.PI/2){
  2648. return 1;
  2649. }
  2650. return -1;
  2651. };
  2652.  
  2653. scope.help = ["All the commands are:","/help","/?","/advhelp [command]","/space","/rcaps","/number","/speech","/followcam","/autocam","/zoom [in/out/reset]","/xray","/aimbot","/heavybot","/echo [username]","/clearecho","/remove [username]","/echotext [text]","/chatw [username]","/msg [text]","/ignorepm [username]","/pmusers","/pollstat","/lobby","/score","/team [letter]","/mode [mode]","/scroll","/hidechat","/showchat","/notify","/stopnotify","/support","Host commands are:","/startqp","/stopqp","/pauseqp","/next","/nextafter [seconds]","/previous","/shuffle","/instaqp","/freejoin","/recmode","/recteam","/defaultmode [mode]","/start","/balanceA [number]","/moveA [letter]","/moveT [letter] [letter]","/rounds [number]","/roundsperqp [number]","/disablekeys [keys]","/jointext [text]","/wintext [text]","/autorecord","/afkkill [number]","/ban [username]","/kill [username]","/resetpoll","/addoption [text]","/deloption [letter]","/startpoll [seconds]","/endpoll","Sandbox commands are:","/addplayer [number]","/addname [text]","/delplayer [number]","/copyme","Debugging commands are:","/eval [code]","/debugger","Hotkeys are:","Alt L","Alt B","Alt C","Alt I","Alt <","Alt >","Alt N","Alt V","Alt G","Alt H","Alt J","Host hotkeys are:","Alt S","Alt P","Alt T","Alt E","Alt K","Alt M","Alt Q","Alt A","Alt D","Alt F","Alt R"];
  2654.  
  2655. scope.adv_help = {"help":"Shows all command names.",
  2656. "?":"Shows all command names.",
  2657. "advhelp":"Shows a command in detail.",
  2658. "space":"Toggles space. When space is on, whatever you type will be spaced apart.",
  2659. "rcaps":"Toggles rcaps. When rcaps is on, each letter will randomly get capitalized.",
  2660. "number":"Toggles number. When number is on, 'a' becomes 4, 'e' becomes 3, 's' becomes 5, 'o' becomes 0, 'l' and 'i' become 1.",
  2661. "speech":"Turns on text to speech for the chat.",
  2662. "echo":"Echoes a username. It copies the username's chat messages.",
  2663. "echotext":"Sets a message when someone who is echoed chats. \"message\" will get replaced by the person's message. \"username\" will get replaced by the person's username.",
  2664. "remove":"Removes username from echo list. You will not echo that username anymore.",
  2665. "clearecho":"Clears echo list. You will not echo anyone anymore.",
  2666. "chatw":"It private chats with username. Type /msg to message that username.",
  2667. "msg":"Messages with what username you are chatting with. Type /chatw to chat with a username.",
  2668. "ignorepm":"Ignores the username's private chat messages. To unignore, type '/ignorepm [username]'.",
  2669. "pmusers":"Dispays who you can private chat with.",
  2670. "pollstat":"Displays the current poll and its votes.",
  2671. "eval":"Evaluates code. Only use this if you are experienced in javascript.",
  2672. "debugger":"Opens debugger.",
  2673. "lobby":"Makes lobby visible when you are ingame. Type '/lobby' again to close lobby.",
  2674. "score":"Displays the current score while ingame. Type '/score' again to hide the score.",
  2675. "team":"Joins a specific team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  2676. "scroll":"Toggles a scrollbar in ingame chat.",
  2677. "followcam":"Enables follow camera. Your character will be centered on the screen.",
  2678. "autocam":"Zooms in/out enough for you to see everyone on the screen.",
  2679. "zoom":"Zooms in, out, or resets zoom.",
  2680. "xray":"Removes all shapes that don't have a shadow. This means all non-physics shapes will be hidden.",
  2681. "aimbot":"Toggles aimbot. Aimbot will aim for you in arrows or death arrows mode.",
  2682. "heavybot":"Enables heavy bot. Heavy bot will heavy right before collision. Turn this off when player collision is off, because heavy bot will still function.",
  2683. "hidechat":"Hides ingame chat. Type '/showchat' to show it again.",
  2684. "showchat":"Shows ingame chat. '/hidechat' hides the chat.",
  2685. "notify":"You will be notified if a person types @username",
  2686. "stopnotify":"You will not be notified if a person types @username",
  2687. "support":"Displays many ways to support LEGENDBOSS123.",
  2688. "startqp":"Starts cycling maps in your map menu.",
  2689. "stopqp":"Stops cycling maps in your map menu.",
  2690. "pauseqp":"Only pauses or unpauses the quickplay cycle due to round end. '/next', '/previous' still work. Type 'pauseqp' to unpause quickplay.",
  2691. "next":"Skips the map. Usable only with '/startqp'.",
  2692. "nextafter":"Skips the map if no one is able to win/draw within a certain amount of time.",
  2693. "previous":"Goes to previous map. Usable only with '/startqp'.",
  2694. "shuffle":"Makes quickplay play random maps instead of in order.",
  2695. "freejoin":"Toggles freejoin. If freejoin is on, starts the game instantly if there are 1 or less players currently playing.",
  2696. "recmode":"In quickplay, it switches mode to recommended mode, according to editor.",
  2697. "recteam":"In quickplay, it sorts people into teams when teams are necessary.",
  2698. "defaultmode":"Switches mode to defaultmode if there is no recmode.",
  2699. "start":"Starts game instantly.",
  2700. "instaqp":"Rounds will instantly start without a countdown.",
  2701. "balanceA":"Balances everyone with balance number.",
  2702. "moveA":"Sets everyones team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  2703. "moveT":"Sets everyone in one team to another team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  2704. "rounds":"Sets rounds to win.",
  2705. "roundsperqp":"After that many rounds, the map will change. Normally, the map will change after 1 round.",
  2706. "autorecord":"After a round ends, automatically records the last 15 seconds.",
  2707. "mode":"If host, switches mode. Otherwise, it requests the host to switch mode, as long as the host has this mod.",
  2708. "disablekeys":"If anyone presses a disabled key, they get killed. Key options: left right up down heavy special.",
  2709. "jointext":"Chats the jointext whenever someone joins. \"username\" will get replaced by the joining person's username.",
  2710. "wintext":"Chats the wintext whenever someone wins. \"username\" will get replaced by the winning person's username.",
  2711. "afkkill":"If a person stays afk for that many seconds, they get automatically killed.",
  2712. "ban":"Bans username from lobby. If they rejoin, it automatically bans.",
  2713. "kill":"Kills the person ingame.",
  2714. "resetpoll":"Clears the poll.",
  2715. "addoption":"Adds the option to the poll. You can only have 4 maximum options. Type '/deloption [letter]' to remove an option.",
  2716. "deloption":"Removes the option with that letter.",
  2717. "startpoll":"Starts a poll that lasts for at least 10 seconds. Type '/endpoll' to end it early.",
  2718. "endpoll":"Ends the poll early if the poll lasted for at least 10 seconds.",
  2719. "addplayer":"In sandbox, it adds players.",
  2720. "addname":"Adds a bot with a specific name. If that name already exists, it will copy the skin of that player to the bot.",
  2721. "delplayer":"In sandbox, it deletes players.",
  2722. "copyme":"In sandbox, it makes each player copy your movements.",
  2723. "Alt L":"Makes lobby visible when you are ingame. Press Alt L again to close lobby.",
  2724. "Alt C":"Hides ingame chat. Press Alt C again to show ingame chat.",
  2725. "Alt S":"Starts game instantly.",
  2726. "Alt T":"Toggles teams.",
  2727. "Alt N":"Enables follow camera. Your character will be centered on the screen.",
  2728. "Alt G":"Zooms in.",
  2729. "Alt H":"Resets zoom.",
  2730. "Alt J":"Zooms out.",
  2731. "Alt Y":"Enables xray. Removes all shapes that don't have a shadow. This means all non-physics shapes will be hidden.",
  2732. "Alt E":"Toggles editor.",
  2733. "Alt K":"Exits ingame and returns to lobby.",
  2734. "Alt M":"Switches modes.",
  2735. "Alt V":"Toggles autocam. Autocam zooms in/out enough for you to see everyone on the screen.",
  2736. "Alt Q":"Toggles quickplay.",
  2737. "Alt B":"Displays the current score while ingame. Press Alt B again to hide the score.",
  2738. "Alt A":"Skips the map if quickplay is on.",
  2739. "Alt D":"Goes to previous map if quickplay is on.",
  2740. "Alt F":"Toggles freejoin. If freejoin is on, starts the game instantly if there are 1 or less players currently playing.",
  2741. "Alt O":"Enables heavy bot. Heavy bot will heavy right before collision. Turn this off when player collision is off, because heavy bot will still function.",
  2742. "Alt U":"Toggles aimbot. Aimbot will aim for you in arrows or death arrows mode.",
  2743. "Alt P":"Only pauses or unpauses the quickplay cycle due to round end. '/next', '/previous' still work. Type 'pauseqp' to unpause quickplay.",
  2744. "Alt R":"In quickplay, it switches mode to recommended mode, according to editor.",
  2745. "Alt I":"Opens debugger.",
  2746. "Alt <":"Lowers ingame chat height.",
  2747. "Alt >":"Highers ingame chat height."
  2748. };
  2749. scope.displayadvhelp = function(command){
  2750. displayInChat(adv_help[command],"#009398","#DA0808",{sanitize:true},"",true);
  2751. };
  2752. scope.changemode = function(mode){
  2753. SEND('42[20,{"ga":"b","mo":"'+mode+'"}]');
  2754. RECIEVE('42[26,"b","'+mode+'"]');
  2755. };
  2756. Gdocument.getElementById("ingamechatcontent").style["pointer-events"]="all";
  2757. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  2758. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  2759. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  2760.  
  2761. document.getElementById('adboxverticalCurse').style["display"] = "none";
  2762. document.getElementById('adboxverticalleftCurse').style["display"] = "none";
  2763. elem.onclick=function(e){
  2764. if(stopquickplay==0 && ishost == true && e.isTrusted == true){
  2765. quicki = (Array.from(e.target.parentElement.parentNode.children).indexOf(e.target.parentNode)-1)%(Gdocument.getElementById("maploadwindowmapscontainer").children.length);
  2766. }
  2767. };
  2768. scope.urlify = function(text) {
  2769. if(!Gdocument.getElementById('bl_Menu')){
  2770. return text.replace(/(?:https?:\/\/)?(?:[A-Za-z0-9-ßàÁâãóôþüúðæåïçèõöÿýòäœêëìíøùîûñé]+)(?:\.[A-Za-z0-9-ßàÁâãóôþüúðæåïçèõöÿýòäœêëìíøùîûñé]+)+(?:\/(?:[A-Za-z0-9-._~:/?#\[\]@!$&'()*+,;=]|%[0-9a-fA-F]{2})*)?(?:\?(?:[^=]+=[^&](?:&[^=]+=[^&])*)?)?/g, function(url) {
  2771. if(url.startsWith('https://') || url.startsWith('http://')){return '<a href="' + url + '" target="_blank" style = "color:orange">' + url + '</a>';}
  2772. else{return '<a href="https://' + url + '" target="_blank" style = "color:orange">' + url + '</a>';}
  2773. })}return text;
  2774. };
  2775.  
  2776. scope.fire = function(type,options,d = Gdocument){
  2777. var event= document.createEvent("HTMLEvents");
  2778. event.initEvent(type,true,false);
  2779. for(var p in options){
  2780. event[p]=options[p];
  2781. }
  2782. d.dispatchEvent(event);
  2783. };
  2784.  
  2785. scope.chat = function(message){
  2786. SEND('42[10,{"message":'+JSON.stringify(message)+'}]');
  2787. };
  2788. scope.chat2 = function(message,enteragain=false){
  2789. mess = Gdocument.getElementById("newbonklobby_chat_input").value;
  2790. mess2 = Gdocument.getElementById("ingamechatinputtext").value;
  2791. Gdocument.getElementById("newbonklobby_chat_input").value = message;
  2792. Gdocument.getElementById("ingamechatinputtext").value = message;
  2793. fire("keydown",{keyCode:13});
  2794. if(!enteragain){
  2795. fire("keydown",{keyCode:13});
  2796. }
  2797. Gdocument.getElementById("newbonklobby_chat_input").value = mess;
  2798. Gdocument.getElementById("ingamechatinputtext").value = mess2;
  2799. };
  2800. scope.displayInChat = function(message, LobbyColor, InGameColor, options, message2, BringDown) {
  2801. options = options ?? {};
  2802. BringDown = BringDown ?? false;
  2803. message2 = message2 ?? "";
  2804. LobbyColor = LobbyColor ?? "#8800FF";
  2805. InGameColor = InGameColor ?? "#AA88FF";
  2806. let A = Gdocument.createElement("div");
  2807. let B = Gdocument.createElement("span");
  2808. B.className = "newbonklobby_chat_status";
  2809. B.style.color = LobbyColor;
  2810. A.appendChild(B);
  2811. B.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  2812. B.innerHTML+=urlify(message2.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;'));
  2813. let C = Gdocument.createElement("div");
  2814. let D = Gdocument.createElement("span");
  2815. D.style.color = InGameColor;
  2816. C.appendChild(D);
  2817. D.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  2818. D.innerHTML+=urlify(message2.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;'));
  2819. let a = BringDown;
  2820. if(Gdocument.getElementById("newbonklobby_chat_content").clientHeight + Gdocument.getElementById("newbonklobby_chat_content").scrollTop >= Gdocument.getElementById("newbonklobby_chat_content").scrollHeight-1) {
  2821. a = true;
  2822. }
  2823. A.style["parsed"] = true;
  2824. C.style["parsed"] = true;
  2825. Gdocument.getElementById("newbonklobby_chat_content").appendChild(A);
  2826. Gdocument.getElementById("ingamechatcontent").appendChild(C);
  2827. if (a) { Gdocument.getElementById("newbonklobby_chat_content").scrollTop = Number.MAX_SAFE_INTEGER;};
  2828. Gdocument.getElementById("ingamechatcontent").scrollTop = Number.MAX_SAFE_INTEGER;
  2829. if(Gdocument.getElementById("newbonklobby_chat_input").style["pointer-events"]!="auto" && !Gdocument.getElementById("ingamechatinputtext").classList.value.includes("ingamechatinputtextbg")){
  2830. chat2("");
  2831. }
  2832. };
  2833.  
  2834. scope.lobby = function(){
  2835. if (Gdocument.getElementById("newbonklobby").style["display"]=="none"){
  2836.  
  2837. Gdocument.getElementById("newbonklobby_editorbutton").click();
  2838. Gdocument.getElementById("mapeditor_close").click();
  2839. if(Gdocument.getElementById("newbonklobby_playerbox_elementcontainer").children.length+Gdocument.getElementById("newbonklobby_specbox_elementcontainer").children.length-3>0){
  2840. Gdocument.getElementById("newbonklobby").style["z-index"]=1;
  2841. Gdocument.getElementById("maploadwindowcontainer").style["z-index"]=1;
  2842. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=1;
  2843. Gdocument.getElementById("pretty_top").style["z-index"]=3;
  2844. Gdocument.getElementById("settingsContainer").style["z-index"]=3;
  2845. Gdocument.getElementById("leaveconfirmwindow").style["z-index"]=3;
  2846. Gdocument.getElementById("hostleaveconfirmwindow").style["z-index"]=3;
  2847. debuggermenu.style["z-index"] = 2;
  2848. }
  2849. else{
  2850. Gdocument.getElementById("newbonklobby").style["opacity"]=0;
  2851. Gdocument.getElementById("newbonklobby").style["display"]="none";
  2852. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
  2853.  
  2854. }
  2855.  
  2856. }
  2857. else if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  2858. Gdocument.getElementById("newbonklobby").style["opacity"]=0;
  2859. Gdocument.getElementById("newbonklobby").style["display"]="none";
  2860. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
  2861.  
  2862. }
  2863. };
  2864.  
  2865. scope.lastmessage = function(){
  2866. if(Gdocument.getElementById("newbonklobby_chat_content").children.length!=0){
  2867. var lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  2868. var lm2 = "";
  2869. for(var i = 0; i<lm.length;i++){
  2870. lm2+=" "+lm[i].textContent.trim();
  2871. }
  2872. lm2 = lm2.trim();
  2873. if(lm2.startsWith("*")){
  2874. return lm2;
  2875. }
  2876. }
  2877. if(Gdocument.getElementById("ingamechatcontent").children.length!=0){
  2878. var lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  2879. var lm2 = "";
  2880. for(var i = 0; i<lm.length;i++){
  2881. lm2+=" "+lm[i].textContent.trim();
  2882. }
  2883. return lm2.trim();
  2884. }
  2885. return "";
  2886.  
  2887. };
  2888. scope.map = function(e,t=timedelay){
  2889. if(e<0){
  2890. displayInChat("There is no previous map.","#DA0808","#1EBCC1");
  2891. quicki = 0;
  2892. return;
  2893. }
  2894. if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
  2895. displayInChat("Click the maps button.","#DA0808","#1EBCC1");
  2896. return;
  2897. }
  2898.  
  2899. setTimeout(function(){if(!canceled){
  2900. startedinqp = true;
  2901. if(roundsperqp2>=roundsperqp){
  2902. roundsperqp2 = 0;
  2903. }
  2904. gameStartTimeStamp = Date.now();
  2905. Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
  2906. Gdocument.getElementById("newbonklobby_editorbutton").click();
  2907. if(recmodebool && ishost){
  2908. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  2909. if(mode == "" && defaultmode!="d"){
  2910. mode = defaultmode;
  2911. }
  2912. if(mode != ""){
  2913. RECIEVE('42[26,"b","'+mode+'"]');
  2914. }
  2915. }
  2916. var displayblock = Gdocument.getElementById("newbonklobby").style["display"] == "block";
  2917. Gdocument.getElementById("mapeditorcontainer").style["display"] = "none";
  2918. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  2919. if(displayblock){
  2920. Gdocument.getElementById("newbonklobby").style["display"] = "block";
  2921. }
  2922. Gdocument.getElementById("mapeditor_midbox_testbutton").click();}
  2923. canceled = false;
  2924. transitioning = false;
  2925. },t);
  2926.  
  2927. };
  2928.  
  2929. scope.gotonextmap = function(e){
  2930. if(e<0){
  2931. displayInChat("There is no previous map.","#DA0808","#1EBCC1");
  2932. quicki = 0;
  2933. return;
  2934. }
  2935. if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
  2936. displayInChat("Click the maps button.","#DA0808","#1EBCC1");
  2937. return;
  2938. }
  2939. Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
  2940. Gdocument.getElementById("newbonklobby_editorbutton").click();
  2941. if(recmodebool && ishost){
  2942. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  2943. if(mode == "" && defaultmode!="d"){
  2944. mode = defaultmode;
  2945. }
  2946. if(mode != ""){
  2947. RECIEVE('42[26,"b","'+mode+'"]');
  2948. }
  2949. }
  2950. startedinqp = true;
  2951. if(roundsperqp2>=roundsperqp){
  2952. roundsperqp2 = 0;
  2953. }
  2954. gameStartTimeStamp = Date.now();
  2955. var displayblock = Gdocument.getElementById("newbonklobby").style["display"] == "block";
  2956. Gdocument.getElementById("mapeditorcontainer").style["display"] = "none";
  2957. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  2958. if(displayblock){
  2959. Gdocument.getElementById("newbonklobby").style["display"] = "block";
  2960. }
  2961. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  2962. Gdocument.getElementById("newbonklobby").style["visibility"] = "visible";
  2963. };
  2964. scope.commandhandle = function(chat_val){
  2965. if (chat_val.substring(1,6)=="echo " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  2966. if (chat_val.substring(6).replace(/^\s+|\s+$/g, '')==username){
  2967. displayInChat("You cannot echo yourself.","#DA0808","#1EBCC1");
  2968. return "";
  2969. }
  2970. else if (echo_list.indexOf(chat_val.substring(6).replace(/^\s+|\s+$/g, ''))===-1) {
  2971.  
  2972. echo_list.push(chat_val.substring(6).replace(/^\s+|\s+$/g, ''));
  2973. displayInChat(chat_val.substring(6).replace(/^\s+|\s+$/g, '') + " is being echoed.","#DA0808","#1EBCC1");
  2974. return "";
  2975. }
  2976. else{
  2977. displayInChat(chat_val.substring(6).replace(/^\s+|\s+$/g, '') + " is already being echoed.","#DA0808","#1EBCC1");
  2978. return "";
  2979. }
  2980. }
  2981. else if (chat_val.substring(1,8)=="remove " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  2982. if (echo_list.indexOf(chat_val.substring(7).replace(/^\s+|\s+$/g, ''))!==-1){
  2983. echo_list.splice(echo_list.indexOf(chat_val.substring(7).replace(/^\s+|\s+$/g, '')),1);
  2984. displayInChat(chat_val.substring(7).replace(/^\s+|\s+$/g, '')+" is not being echoed.","#DA0808","#1EBCC1");
  2985. return "";
  2986. }
  2987. else{
  2988. displayInChat("You cannot remove someone that you didn't echo.","#DA0808","#1EBCC1");
  2989. return "";
  2990. }
  2991.  
  2992. }
  2993. else if (chat_val.substring(1,10)=="echotext " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  2994. echotext = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  2995. displayInChat("Set echotext as: "+echotext,"#DA0808","#1EBCC1");
  2996. displayInChat("Type '/echotext' to reset echotext.","#DA0808","#1EBCC1");
  2997. return "";
  2998.  
  2999. }
  3000. else if (chat_val.substring(1,9)=="echotext"){
  3001. echotext = "message";
  3002. displayInChat("Reset echotext.","#DA0808","#1EBCC1");
  3003. return "";
  3004.  
  3005. }
  3006. else if (chat_val.substring(1,10)=="clearecho"){
  3007. echo_list = [];
  3008. displayInChat("Cleared the echo list.","#DA0808","#1EBCC1");
  3009. return "";
  3010. }
  3011. else if (chat_val.substring(1,6)=="space"){
  3012. if(space_flag == true){
  3013. displayInChat("Space is now off.","#DA0808","#1EBCC1");
  3014. space_flag = false;
  3015. }
  3016. else{
  3017. displayInChat("Space is now on.","#DA0808","#1EBCC1");
  3018. space_flag = true;
  3019. }
  3020. return "";
  3021. }
  3022. else if (chat_val.substring(1,6)=="rcaps"){
  3023. if(rcaps_flag == true){
  3024. displayInChat("Rcaps is now off.","#DA0808","#1EBCC1");
  3025. rcaps_flag = false;
  3026. }
  3027. else{
  3028. displayInChat("Rcaps is now on.","#DA0808","#1EBCC1");
  3029. rcaps_flag = true;
  3030. }
  3031.  
  3032. return "";
  3033. }
  3034. else if (chat_val.substring(1,7)=="number"){
  3035. if(number_flag == true){
  3036. displayInChat("Number is now off.","#DA0808","#1EBCC1");
  3037. number_flag = false;
  3038. }
  3039. else{
  3040. displayInChat("Number is now on.","#DA0808","#1EBCC1");
  3041. number_flag = true;
  3042. }
  3043.  
  3044. return "";
  3045. }
  3046. else if (chat_val.substring(1,8)=="reverse"){
  3047. if(reverse_flag == true){
  3048. displayInChat("Reverse is now off.","#DA0808","#1EBCC1");
  3049. reverse_flag = false;
  3050. }
  3051. else{
  3052. displayInChat("Reverse is now on.","#DA0808","#1EBCC1");
  3053. reverse_flag = true;
  3054. }
  3055.  
  3056. return "";
  3057. }
  3058. else if (chat_val.substring(1,7)=="speech"){
  3059. if(text2speech == true){
  3060. displayInChat("Text to speech is now off.","#DA0808","#1EBCC1");
  3061. text2speech = false;
  3062. }
  3063. else{
  3064. displayInChat("Text to speech is now on.","#DA0808","#1EBCC1");
  3065. text2speech = true;
  3066. }
  3067.  
  3068. return "";
  3069. }
  3070. else if (chat_val.substring(1,6)=="eval " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  3071. var ev = "";
  3072. try{
  3073. ev = eval(chat_val.substring(6).replace(/^\s+|\s+$/g, ''));
  3074. }
  3075. catch(e){
  3076. displayInChat(e.message,"#DA0808","#1EBCC1");
  3077. }
  3078. try{
  3079. displayInChat(ev.toString(),"#DA0808","#1EBCC1");
  3080. }
  3081. catch{
  3082. }
  3083.  
  3084. return "";
  3085.  
  3086. }
  3087. else if (chat_val.substring(1,10)=="followcam"){
  3088. if(FollowCam == true){
  3089. displayInChat("Follow Camera is now off.","#DA0808","#1EBCC1");
  3090. FollowCam = false;
  3091. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  3092. var addto = {"children":[]};
  3093. for(var i = 0;i<parentDraw.children.length;i++){
  3094. if(parentDraw.children[i].constructor.name == "e"){
  3095. addto = parentDraw.children[i];
  3096. break;
  3097. }
  3098. }
  3099. var canv = 0;
  3100. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  3101. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  3102. canv = Gdocument.getElementById("gamerenderer").children[i];
  3103. break;
  3104. }
  3105. }
  3106. var width = parseInt(canv.style["width"]);
  3107. var height = parseInt(canv.style["height"]);
  3108. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  3109. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  3110. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  3111. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  3112. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999){
  3113. pixiCircle.visible = false;
  3114. }
  3115. else{
  3116. pixiCircle.visible = true;
  3117. }
  3118. }
  3119. }
  3120. else{
  3121. displayInChat("Follow Camera is now on.","#DA0808","#1EBCC1");
  3122. FollowCam = true;
  3123. }
  3124.  
  3125. return "";
  3126. }
  3127. else if (chat_val.substring(1,8)=="autocam"){
  3128. if(autocam == true){
  3129. displayInChat("Auto Cam is now off.","#DA0808","#1EBCC1");
  3130. autocam = false
  3131. }
  3132. else{
  3133. displayInChat("Auto Cam is now on.","#DA0808","#1EBCC1");
  3134. autocam = true;
  3135. }
  3136.  
  3137. return "";
  3138. }
  3139. else if (chat_val.substring(1,7)=="aimbot"){
  3140. if(aimbot == true){
  3141. displayInChat("Aimbot is now off.","#DA0808","#1EBCC1");
  3142. aimbot = false;
  3143. }
  3144. else{
  3145. displayInChat("Aimbot is now on.","#DA0808","#1EBCC1");
  3146. aimbot = true;
  3147. var keykeys = Object.keys(keyCodes);
  3148. var keyslist = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[1].children).slice(1);
  3149. var keyslist2 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[2].children).slice(1);
  3150. for(var i = 0;i<keyslist.length;i++){
  3151. if(keykeys.includes(keyslist[i].textContent)){
  3152. leftRight[0] = keyCodes[keyslist[i].textContent];
  3153. break;
  3154. }
  3155. else{
  3156. leftRight[0] = keyslist[i].textContent.charCodeAt(0);
  3157. break
  3158. }
  3159. }
  3160. for(var i = 0;i<keyslist2.length;i++){
  3161. if(keykeys.includes(keyslist2[i].textContent)){
  3162. leftRight[1] = keyCodes[keyslist2[i].textContent];
  3163. break;
  3164. }
  3165. else{
  3166. leftRight[1] = keyslist2[i].textContent.charCodeAt(0);
  3167. }
  3168. }
  3169. }
  3170.  
  3171. return "";
  3172. }
  3173. else if (chat_val.substring(1,9)=="heavybot"){
  3174. if(heavybot == true){
  3175. displayInChat("Heavy bot is now off.","#DA0808","#1EBCC1");
  3176. heavybot = false;
  3177. }
  3178. else{
  3179. displayInChat("Heavy bot is now on.","#DA0808","#1EBCC1");
  3180. heavybot = true;
  3181. var keykeys = Object.keys(keyCodes);
  3182. var keyslist = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[5].children).slice(1);
  3183. for(var i = 0;i<keyslist.length;i++){
  3184. if(keykeys.includes(keyslist[i].textContent)){
  3185. heavy = keyCodes[keyslist[i].textContent];
  3186. break;
  3187. }
  3188. else{
  3189. heavy = keyslist[i].textContent.charCodeAt(0);
  3190. break
  3191. }
  3192. }
  3193. var keyslist2 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[6].children).slice(1);
  3194. for(var i = 0;i<keyslist2.length;i++){
  3195. if(keykeys.includes(keyslist2[i].textContent)){
  3196. special = keyCodes[keyslist2[i].textContent];
  3197. break;
  3198. }
  3199. else{
  3200. special = keyslist2[i].textContent.charCodeAt(0);
  3201. break
  3202. }
  3203. }
  3204. }
  3205.  
  3206. return "";
  3207. }
  3208. else if (chat_val.substring(1,5)=="xray"){
  3209. Gdocument.getElementById("pretty_top_settings").click();
  3210. Gdocument.getElementById("settings_close").click();
  3211. if(Gdocument.getElementById("settings_graphicsquality").value==1){
  3212. displayInChat("You must have medium or high quality enabled to use this feature.","#DA0808","#1EBCC1");
  3213. return "";
  3214. }
  3215.  
  3216.  
  3217. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  3218. var addto = {"children":[]};
  3219. for(var i = 0;i<parentDraw.children.length;i++){
  3220. if(parentDraw.children[i].constructor.name == "e"){
  3221. addto = parentDraw.children[i];
  3222. break;
  3223. }
  3224. }
  3225. var addto2 = {"children":[]};
  3226. for(var i = 0;i<addto.children.length;i++){
  3227. if(addto.children[i].constructor.name == "e"){
  3228. addto2 = addto.children[i];
  3229. break;
  3230. }
  3231. }
  3232. var checkxray = addto2.children[0];
  3233. var addto3 = addto2.children[0].children;
  3234. if(addto3.length==1){
  3235. checkxray = checkxray.children[0];
  3236. addto3 = addto3[0].children;
  3237. }
  3238. var xrayon = false;
  3239. if(checkxray.xrayon){
  3240. checkxray.xrayon = false;
  3241. xrayon = false;
  3242. }
  3243. else{
  3244. checkxray.xrayon = true;
  3245. xrayon = true;
  3246. }
  3247. if(xrayon){
  3248. displayInChat("Xray is now on.","#DA0808","#1EBCC1");
  3249. for(var i = 0;i<addto3.length;i++){
  3250. if(addto3[i].children.length>0){
  3251. for(var i3 = 0;i3<addto3[i].children.length;i3++){
  3252. addto3[i].children[i3].visible = false;
  3253. if(addto3[i].children[i3].children.length>0){
  3254. addto3[i].children[i3].visible = true;
  3255. }
  3256. }
  3257. }
  3258. }
  3259.  
  3260. }
  3261. else{
  3262. displayInChat("Xray is now off.","#DA0808","#1EBCC1");
  3263. for(var i = 0;i<addto3.length;i++){
  3264. for(var i2 = 0;i2<addto3[i].children.length;i2++){
  3265. addto3[i].children[i2].visible = true;
  3266. }
  3267. }
  3268. }
  3269. }
  3270.  
  3271. return "";
  3272. }
  3273. else if (chat_val.substring(1,6)=="zoom "){
  3274. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  3275. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  3276. var addto = 0;
  3277. for(var i = 0;i<parentDraw.children.length;i++){
  3278. if(parentDraw.children[i].constructor.name == "e"){
  3279. addto = parentDraw.children[i];
  3280. break;
  3281. }
  3282. }
  3283. var canv = 0;
  3284. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  3285. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  3286. canv = Gdocument.getElementById("gamerenderer").children[i];
  3287. break;
  3288. }
  3289. }
  3290. var width = parseInt(canv.style["width"]);
  3291. var height = parseInt(canv.style["height"]);
  3292. if(addto){
  3293. if(text == "in"){
  3294. zoom *= 1.1;
  3295. }
  3296. else if(text == "out"){
  3297. zoom /= 1.1;
  3298. }
  3299. else if(text == "reset"){
  3300. zoom = 1;
  3301. }
  3302. else{
  3303. displayInChat("Options for zooming:","#DA0808","#1EBCC1");
  3304. displayInChat("in","#DA0808","#1EBCC1");
  3305. displayInChat("out","#DA0808","#1EBCC1");
  3306. displayInChat("reset","#DA0808","#1EBCC1");
  3307. return "";
  3308. }
  3309. addto.scale.x=zoom;
  3310. addto.scale.y=zoom;
  3311. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  3312. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  3313. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  3314. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  3315. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999 && !FollowCam){
  3316. pixiCircle.visible = false;
  3317. }
  3318. else{
  3319. pixiCircle.visible = true;
  3320. }
  3321. }
  3322. }
  3323. return "";
  3324. }
  3325. else if (chat_val.substring(1,9)=="hidechat"){
  3326. Gdocument.getElementById("ingamechatcontent").style["max-height"]="0px";
  3327. return "";
  3328. }
  3329. else if (chat_val.substring(1,9)=="showchat"){
  3330. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  3331. return "";
  3332. }
  3333. else if (chat_val.substring(1,6)=="score"){
  3334. var element = Gdocument.getElementById("ingamewinner_scores");
  3335. element.style["visibility"] = "visible";
  3336. if(element.style["opacity"]<1){
  3337. element.style["opacity"] = 1;
  3338. }
  3339. else{
  3340. element.style["opacity"] = 0;
  3341. }
  3342. return "";
  3343. }
  3344.  
  3345. else if (chat_val.substring(1,7)=="scroll"){
  3346. if(scroll==false){
  3347. scroll = true;
  3348. Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="scroll";
  3349. Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
  3350. }
  3351. else if(scroll==true){
  3352. scroll = false;
  3353. Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="hidden";
  3354. Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
  3355. }
  3356.  
  3357. return "";
  3358. }
  3359.  
  3360. else if (chat_val.substring(1,7)=="chatw "){
  3361. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '');
  3362.  
  3363. if(username == text){
  3364. displayInChat("You cannot private chat with yourself.","#DA0808","#1EBCC1");
  3365. return "";
  3366. }
  3367. private_chat = text;
  3368.  
  3369. SEND("42"+JSON.stringify([4,{"type":"request public key","from":username,"to":private_chat}]));
  3370. request_public_key_time_stamp = Date.now();
  3371. 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);
  3372. return "";
  3373. }
  3374.  
  3375. else if (chat_val.substring(1,5)=="msg " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  3376. if(private_chat_public_key[1][0] != 0 && private_chat_public_key[1][1] != 0 && private_chat_public_key[0] == private_chat){
  3377. var text = chat_val.substring(5).replace(/^\s+|\s+$/g, '');
  3378. var password = [];
  3379. for(var i = 0;i<10;i++){
  3380. password.push(Math.floor(Math.random()*100+50));
  3381. }
  3382. var text2 = [];
  3383. for(var i = 0;i<text.slice(0,400).length ;i++){
  3384. text2.push(password[i%password.length]^text.slice(0,400).charCodeAt(i));
  3385. }
  3386. pmlastmessage = text.slice(0,400);
  3387. 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)}]));
  3388. displayInChat("> "+username+": ","#DA0808","#1EBCC1",{sanitize:false},text,false);
  3389. Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true;
  3390. Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true;
  3391. Laster_message = lastmessage();
  3392.  
  3393. }
  3394. return "";
  3395. }
  3396. else if (chat_val.substring(1,10)=="ignorepm " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  3397. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  3398. if(ignorepmlist.includes(text)){
  3399. var index = ignorepmlist.indexOf(text);
  3400. ignorepmlist.splice(index,1);
  3401. displayInChat("You are not ignoring private messages from "+text+".","#DA0808","#1EBCC1");
  3402.  
  3403. }
  3404. else{
  3405. ignorepmlist.push(text);
  3406. displayInChat("You are now ignoring private messages from "+text+".","#DA0808","#1EBCC1");
  3407. }
  3408. return "";
  3409. }
  3410. else if (chat_val.substring(1,8)=="pmusers"){
  3411. pmusers = [];
  3412. SEND("42"+JSON.stringify([4,{"type":"request private chat users","from":username}]));
  3413. pmuserstimestamp = Date.now();
  3414. setTimeout(function(){if(pmusers.length == 0){displayInChat("You cannot private chat with anyone.","#DA0808","#1EBCC1");
  3415. }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);
  3416. return "";
  3417. }
  3418. else if (chat_val.substring(1,6)=="lobby"){
  3419. lobby();
  3420. return "";
  3421. }
  3422. else if (chat_val.substring(1,9)=="debugger"){
  3423. if(Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"] == "none"){
  3424. debuggeropen = true;
  3425. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="block";
  3426. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="none";
  3427. Gdocument.getElementById("ingamechatinputtext").style["display"] = "none";
  3428. }
  3429. else{
  3430. debuggeropen = false;
  3431. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="none";
  3432. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  3433. Gdocument.getElementById("ingamechatinputtext").style["display"] = "";
  3434. }
  3435. return "";
  3436. }
  3437. else if (chat_val.substring(1,6)=="team " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  3438. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  3439. if(text == "r"){Gdocument.getElementById("newbonklobby_redbutton").click();}
  3440. else if(text == "g"){Gdocument.getElementById("newbonklobby_greenbutton").click();}
  3441. else if(text == "y"){Gdocument.getElementById("newbonklobby_yellowbutton").click();}
  3442. else if(text == "b"){Gdocument.getElementById("newbonklobby_bluebutton").click();}
  3443. else if(text == "s"){Gdocument.getElementById("newbonklobby_specbutton").click();}
  3444. else if(text == "f"){Gdocument.getElementById("newbonklobby_ffabutton").click();}
  3445. return "";
  3446. }
  3447. else if (chat_val.substring(1,7)=="notify"){
  3448. npermissions = 1;
  3449. return "";
  3450. }
  3451. else if (chat_val.substring(1,11)=="stopnotify"){
  3452. npermissions = 0;
  3453. return "";
  3454. }
  3455. else if (chat_val.substring(1,8)=="support"){
  3456. displayInChat("Thanks everyone for helping me make this mod - LEGENDBOSS123","#0000FF","#FFFFFF");
  3457. displayInChat("mastery3","#0000FF","#FFFFFF");
  3458. displayInChat("UnmatchedBracket aka Left Paren","#0000FF","#FFFFFF");
  3459. displayInChat("iNeonz","#0000FF","#FFFFFF");
  3460. return "";
  3461. }
  3462. else if (chat_val.substring(1,9)=="pollstat"){
  3463. if(pollactive[0] || pollactive2[0]){
  3464. var count = [0,0,0,0];
  3465. var keys = Object.keys(playerids);
  3466. for(var i = 0;i<keys.length;i++){
  3467. if(ishost){
  3468. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive[3].length-1){
  3469. count[playerids[keys[i]].vote.poll]++;
  3470. }
  3471. }
  3472. else{
  3473. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive2[2].length-1){
  3474. count[playerids[keys[i]].vote.poll]++;
  3475. }
  3476. }
  3477. }
  3478. for(var i = 0;i<count.length;i++){
  3479. if(count[i]>1){
  3480. displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  3481. }
  3482. if(count[i]==1){
  3483. displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  3484. }
  3485. }
  3486. if(ishost){
  3487. displayInChat("The poll will end in: "+((pollactive[2]-Date.now())/1000).toString()+" seconds.","#DA0808","#1EBCC1");
  3488. }
  3489. displayInChat("The poll is:","#DA0808","#1EBCC1");
  3490. if(ishost){
  3491. for(var i = 0;i<pollactive[3].length;i++){
  3492. displayInChat(letters[i]+") "+pollactive[3][i],"#DA0808","#1EBCC1");
  3493. }
  3494. }
  3495. else{
  3496. for(var i = 0;i<pollactive2[2].length;i++){
  3497. displayInChat(letters[i]+") "+pollactive2[2][i],"#DA0808","#1EBCC1");
  3498. }
  3499. }
  3500. }
  3501. else{
  3502. displayInChat("No poll has been started.","#DA0808","#1EBCC1");
  3503. if(ishost){
  3504. displayInChat("Type '/startpoll [seconds]' to start a poll.","#DA0808","#1EBCC1");
  3505. if(poll.length>0){
  3506. displayInChat("The poll is:","#DA0808","#1EBCC1");
  3507. for(var i = 0;i<poll.length;i++){
  3508. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  3509. }
  3510. }
  3511. }
  3512. }
  3513. return "";
  3514. }
  3515. else if (chat_val.substring(1,5)=="help" || chat_val.substring(1,2)=="?"){
  3516. for(var i = 0;i<help.length;i++){
  3517. if(help[i].startsWith("/")){
  3518. var splitted = help[i].substring(1).split(" ");
  3519. var command = splitted[0];
  3520. var rest = "";
  3521. if(splitted.length>1){
  3522. rest = " "+splitted.slice(1).join(" ");
  3523. }
  3524. displayInChat("/"+'<a onclick = \'Gwindow.displayadvhelp("'+command+'");\' style = "color:green;" href = "javascript:void(0);">'+command+'</a>'+rest,"#DA0808","#1EBCC1",{sanitize:false},"",false);
  3525. }
  3526. else if(help[i].startsWith("Alt ")){
  3527. displayInChat('<a onclick = \'Gwindow.displayadvhelp("'+help[i]+'");\' style = "color:green;" href = "javascript:void(0);">'+help[i]+'</a>',"#DA0808","#1EBCC1",{sanitize:false},"",false);
  3528. }
  3529. else{
  3530. displayInChat(help[i],"#DA0808","#1EBCC1");
  3531. }
  3532.  
  3533. }
  3534. return "";
  3535. }
  3536. else if (chat_val.substring(1,9)=="advhelp " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  3537. var text = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  3538. if(typeof(adv_help[text])!='undefined'){
  3539. displayInChat(adv_help[text],"#DA0808","#1EBCC1");
  3540. }
  3541. return "";
  3542. }
  3543. else if (chat_val.substring(1,6)=="mode " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  3544. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  3545. var mode = "";
  3546. var text2 = text;
  3547. if(text == "arrows"){
  3548. text2 = "Arrows";
  3549. mode = "ar";
  3550. }
  3551. else if(text == "death arrows"){
  3552. mode = "ard";
  3553. text2 = "Death Arrows";
  3554. }
  3555. else if(text == "grapple"){
  3556. mode = "sp";
  3557. text2 = "Grapple";
  3558. }
  3559. else if(text == "classic"){
  3560. mode = "b";
  3561. text2 = "Classic";
  3562. }
  3563. else{
  3564. displayInChat("Mode options:","#DA0808","#1EBCC1");
  3565. displayInChat("classic","#DA0808","#1EBCC1");
  3566. displayInChat("arrows","#DA0808","#1EBCC1");
  3567. displayInChat("death arrows","#DA0808","#1EBCC1");
  3568. displayInChat("grapple","#DA0808","#1EBCC1");
  3569. }
  3570. if(mode != ""){
  3571. if(ishost){
  3572. SEND('42[20,{"ga":"b","mo":"'+mode+'"}]');
  3573. RECIEVE('42[26,"b","'+mode+'"]');
  3574. displayInChat("Changed mode to "+text+".","#DA0808","#1EBCC1");
  3575. }
  3576. else{
  3577. if(playerids[myid].ratelimit.mode+1000<Date.now()){
  3578. playerids[myid].ratelimit.mode=Date.now();
  3579. SEND("42"+JSON.stringify([4,{"type":"request mode","from":username,"mode":mode}]));
  3580. var code = 'if(!Gwindow.ishost){Gwindow.displayInChat("You must be host to change the mode.","#DA0808","#1EBCC1",{sanitize:false},"",true)}else{Gwindow.changemode("'+mode+'")}';
  3581. displayInChat('> '+username+' requests [<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+text2+'</a>]',"#DA0808","#1EBCC1",{sanitize:false}," mode.");
  3582.  
  3583. }
  3584. else{
  3585. displayInChat("You are requesting modes too quickly.","#DA0808","#1EBCC1");
  3586. }
  3587. }
  3588. }
  3589. return "";
  3590.  
  3591. }
  3592. else if(ishost){
  3593. if (chat_val.substring(1,11)=="nextafter " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  3594. var text = parseFloat(chat_val.substring(11).replace(/^\s+|\s+$/g, ''));
  3595. if(isNaN(text)){
  3596. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  3597. return "";
  3598. }
  3599. else if(text<=0){
  3600. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  3601. return "";
  3602. }
  3603. nextafter = text;
  3604. displayInChat("Set next after to: " + text.toString()+" seconds.","#DA0808","#1EBCC1");
  3605. displayInChat("Type '/nextafter' to reset next after.","#DA0808","#1EBCC1");
  3606. return "";
  3607.  
  3608. }
  3609. else if (chat_val.substring(1,10)=="nextafter"){
  3610. nextafter = 0;
  3611. displayInChat("Reset next after.","#DA0808","#1EBCC1");
  3612. return "";
  3613.  
  3614. }
  3615. else if (chat_val.substring(1,5)=="next" && stopquickplay == 0){
  3616. roundsperqp2 = 0;
  3617. if(shuffle){
  3618. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  3619. var available = [];
  3620. var availableindexes = [];
  3621. var notempty = false;
  3622. for(var i = 0; i<e.length;i++){
  3623. var a = false;
  3624. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  3625. available.push(a);
  3626. if(a){
  3627. availableindexes.push(i);
  3628. notempty = true;
  3629. }
  3630. }
  3631. if(notempty){
  3632.  
  3633. if(availableindexes.length!=1){
  3634. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  3635. }
  3636. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  3637. }
  3638. }
  3639. else{
  3640. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  3641. var available = [];
  3642. var availableindexes = [];
  3643. var notempty = false;
  3644. for(var i = 0; i<e.length;i++){
  3645. var a = false;
  3646. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  3647. available.push(a);
  3648. if(a){
  3649. availableindexes.push(i);
  3650. notempty = true;
  3651. }
  3652. }
  3653. if(notempty){
  3654. var above = [];
  3655. for(var i = 0;i<availableindexes.length;i++){
  3656. if(availableindexes[i]>quicki){
  3657. above.push(availableindexes[i]);
  3658. }
  3659. }
  3660. if(above.length>0){
  3661. quicki = above[0];
  3662. }
  3663. else{
  3664. quicki = availableindexes[0];
  3665. }
  3666. }
  3667. }
  3668. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  3669. displayInChat("Switched to next map.","#DA0808","#1EBCC1");
  3670. return "";
  3671.  
  3672. }
  3673. else if (chat_val.substring(1,9)=="freejoin"){
  3674. if(freejoin == false){
  3675. freejoin = true;
  3676. displayInChat("Freejoin is now on.","#DA0808","#1EBCC1");
  3677.  
  3678. }
  3679. else{
  3680. freejoin = false;
  3681. displayInChat("Freejoin is now off.","#DA0808","#1EBCC1");
  3682. }
  3683.  
  3684. return "";
  3685.  
  3686. }
  3687. else if (chat_val.substring(1,8)=="instaqp"){
  3688. if(instaqp == false){
  3689. instaqp = true;
  3690. displayInChat("Instaqp is now on.","#DA0808","#1EBCC1");
  3691.  
  3692. }
  3693. else{
  3694. instaqp = false;
  3695. displayInChat("Instaqp is now off.","#DA0808","#1EBCC1");
  3696. }
  3697.  
  3698. return "";
  3699.  
  3700. }
  3701.  
  3702. else if (chat_val.substring(1,9)=="previous" && stopquickplay == 0){
  3703. roundsperqp2 = 0;
  3704. if(shuffle){
  3705. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  3706. var available = [];
  3707. var availableindexes = [];
  3708. var notempty = false;
  3709. for(var i = 0; i<e.length;i++){
  3710. var a = false;
  3711. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  3712. available.push(a);
  3713. if(a){
  3714. availableindexes.push(i);
  3715. notempty = true;
  3716. }
  3717. }
  3718. if(notempty){
  3719.  
  3720. if(availableindexes.length!=1){
  3721. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  3722. }
  3723. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  3724. }
  3725. }
  3726. else{
  3727. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  3728. var available = [];
  3729. var availableindexes = [];
  3730. var notempty = false;
  3731. for(var i = 0; i<e.length;i++){
  3732. var a = false;
  3733. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  3734. available.push(a);
  3735. if(a){
  3736. availableindexes.push(i);
  3737. notempty = true;
  3738. }
  3739. }
  3740. if(notempty){
  3741. var above = [];
  3742. for(var i = 0;i<availableindexes.length;i++){
  3743. if(availableindexes[i]<quicki){
  3744. above.push(availableindexes[i]);
  3745. }
  3746. }
  3747. if(above.length>0){
  3748. quicki = above[above.length-1];
  3749. }
  3750. else{
  3751. quicki = availableindexes[availableindexes.length-1];
  3752. }
  3753. }
  3754. }
  3755. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  3756.  
  3757. displayInChat("Switched to previous map.","#DA0808","#1EBCC1");
  3758. return "";
  3759. }
  3760. else if (chat_val.substring(1,6)=="start" && chat_val.length == 6){
  3761. if(Gdocument.getElementById("mapeditorcontainer").style["display"]!="block"){
  3762. Gdocument.getElementById("newbonklobby_editorbutton").click();
  3763. }
  3764. if(recmodebool && ishost){
  3765. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  3766. if(mode == "" && defaultmode!="d"){
  3767. mode = defaultmode;
  3768. }
  3769. if(mode != ""){
  3770. RECIEVE('42[26,"b","'+mode+'"]');
  3771. }
  3772. }
  3773. Gdocument.getElementById("mapeditor_close").click();
  3774. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  3775. roundsperqp2 = 0;
  3776. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  3777.  
  3778. return "";
  3779. }
  3780.  
  3781. else if (chat_val.substring(1,8)=="startqp" && stopquickplay == 1){
  3782. stopquickplay = 0;
  3783. quicki = 0;
  3784. qppaused = false;
  3785. displayInChat("Enabled quickplay.","#DA0808","#1EBCC1");
  3786. return "";
  3787. }
  3788. else if (chat_val.substring(1,7)=="stopqp" && stopquickplay == 0){
  3789. stopquickplay = 1;
  3790. quicki = 0;
  3791. qppaused = false;
  3792. displayInChat("Disabled quickplay.","#DA0808","#1EBCC1");
  3793. return "";
  3794. }
  3795. else if (chat_val.substring(1,8)=="pauseqp" && stopquickplay == 0){
  3796. if(qppaused == false){
  3797. qppaused = true;
  3798. displayInChat("Paused quickplay.","#DA0808","#1EBCC1");
  3799. }
  3800. else{
  3801. qppaused = false;
  3802. displayInChat("Unpaused quickplay.","#DA0808","#1EBCC1");
  3803. }
  3804. return "";
  3805. }
  3806.  
  3807. else if (chat_val.substring(1,5)=="ban " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  3808. banned.push(chat_val.substring(5).replace(/^\s+|\s+$/g, ''));
  3809. displayInChat("Banned "+chat_val.substring(5).replace(/^\s+|\s+$/g, '')+".","#DA0808","#1EBCC1");
  3810. return "/kick '" + chat_val.substring(5).replace(/^\s+|\s+$/g, '') + "'";
  3811. }
  3812. else if (chat_val.substring(1,6)=="kill " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  3813. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  3814. var keys = Object.keys(playerids);
  3815. var killid = undefined;
  3816. for(var i = 0; i<keys.length; i++){
  3817. if(playerids[keys[i]].userName == text){
  3818. killid = keys[i];
  3819. }
  3820. }
  3821. if(typeof(killid)!="undefined" && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden" && !killedids.includes(killid)){
  3822. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  3823. killedids.push(killid);
  3824. SEND('42[25,{"a":{"playersLeft":['+killid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  3825. RECIEVE('42[31,{"a":{"playersLeft":['+killid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  3826. }
  3827. return "";
  3828. }
  3829. else if (chat_val.substring(1,10)=="balanceA " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  3830. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  3831. if(!isNaN(parseInt(text))){
  3832. if(parseInt(text)>=-100 && parseInt(text)<=100){
  3833. var keys = Object.keys(playerids);
  3834. for(var i = 0; i<keys.length;i++){
  3835. SEND('42[29,{"sid":'+keys[i]+',"bal":'+text+'}]');
  3836. RECIEVE('42[36,'+keys[i]+','+text+']');
  3837. }
  3838. }
  3839. }
  3840. return "";
  3841.  
  3842. }
  3843. else if (chat_val.substring(1,10)=="resetpoll"){
  3844. poll = [];
  3845. displayInChat("The poll has been reset.","#DA0808","#1EBCC1");
  3846. return "";
  3847. }
  3848. else if (chat_val.substring(1,11)=="addoption " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  3849. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  3850. if(text.length>50){
  3851. displayInChat("Your option is greater than 50 characters.","#DA0808","#1EBCC1");
  3852. return "";
  3853. }
  3854. if(poll.includes(text)){
  3855. displayInChat("This option already exists.","#DA0808","#1EBCC1");
  3856. }
  3857. else if(poll.length>=4){
  3858. displayInChat("Your poll already has the max 4 amounts of options.","#DA0808","#1EBCC1");
  3859. displayInChat("Type '/deloption [letter]' to remove a option.","#DA0808","#1EBCC1");
  3860. displayInChat("The poll is:","#DA0808","#1EBCC1");
  3861. for(var i = 0;i<poll.length;i++){
  3862. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  3863. }
  3864. }
  3865. else{
  3866. poll.push(text);
  3867. displayInChat("The poll is now:","#DA0808","#1EBCC1");
  3868. for(var i = 0;i<poll.length;i++){
  3869. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  3870. }
  3871. }
  3872. return "";
  3873. }
  3874. else if (chat_val.substring(1,11)=="deloption " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  3875. var text = letters.indexOf(chat_val.substring(11).replace(/^\s+|\s+$/g, ''));
  3876. if(text==-1 || text>=poll.length){
  3877. if(poll.length>0){
  3878. displayInChat("Available options are:","#DA0808","#1EBCC1");
  3879. for(var i = 0;i<poll.length;i++){
  3880. displayInChat(letters[i],"#DA0808","#1EBCC1");
  3881. }
  3882. }
  3883. else{
  3884. displayInChat("Your poll is empty.","#DA0808","#1EBCC1");
  3885. displayInChat("Type '/addoption [text]' to add an option.","#DA0808","#1EBCC1");
  3886. }
  3887. }
  3888. else{
  3889. poll.splice(text,1);
  3890. displayInChat("The poll is now:","#DA0808","#1EBCC1");
  3891. for(var i = 0;i<poll.length;i++){
  3892. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  3893. }
  3894. }
  3895. return "";
  3896. }
  3897. else if (chat_val.substring(1,11)=="startpoll " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  3898. var text = parseFloat(chat_val.substring(11).replace(/^\s+|\s+$/g, ''));
  3899. if(isNaN(text)){
  3900. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  3901. return "";
  3902. }
  3903. else if(text<=0){
  3904. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  3905. return "";
  3906. }
  3907. else if(text<10){
  3908. displayInChat("Your poll has to last for at least 10 seconds.","#DA0808","#1EBCC1");
  3909. return "";
  3910. }
  3911. if(pollactive[0]){
  3912. displayInChat("There is already an ongoing poll.","#DA0808","#1EBCC1");
  3913. displayInChat("Type '/endpoll' to end the poll.","#DA0808","#1EBCC1");
  3914. return "";
  3915. }
  3916. if(poll.length<2){
  3917. displayInChat("Your poll needs at least 2 options.","#DA0808","#1EBCC1");
  3918. displayInChat("Type '/addoption' to add to the poll.","#DA0808","#1EBCC1");
  3919. return "";
  3920. }
  3921. var now = Date.now();
  3922. pollactive = [true,now,now+text*1000,[...poll]];
  3923. playerids[myid].ratelimit.poll = now;
  3924. var chatpoll = [...poll];
  3925. chatpoll.push("Cancel vote.");
  3926. pollactive[3].push("Cancel vote.");
  3927. for(var i = 0;i<chatpoll.length;i++){
  3928. chatpoll[i] = letters[i]+") "+chatpoll[i];
  3929. }
  3930. chat(chatpoll.join("     "));
  3931. setTimeout(function(){
  3932. if(pollactive[0]){
  3933. SEND("42"+JSON.stringify([4,{"type":"poll","from":username,"poll":pollactive[3]}]));
  3934. var keys = Object.keys(playerids);
  3935. for(var i = 0;i<keys.length;i++){
  3936. playerids[keys[i]].vote.poll = -1;
  3937. }
  3938. displayInChat("The poll will end in: " + text.toString()+" seconds.","#DA0808","#1EBCC1");
  3939. displayInChat("Type '/endpoll' to end the poll early.","#DA0808","#1EBCC1");
  3940. }
  3941. },200);
  3942. return "";
  3943. }
  3944. else if (chat_val.substring(1,8)=="endpoll"){
  3945. if(pollactive[0]){
  3946. if(playerids[myid].ratelimit.poll+10000>Date.now()){
  3947. displayInChat("Your poll has to be at least 10 seconds.","#DA0808","#1EBCC1");
  3948. displayInChat("There are "+((playerids[myid].ratelimit.poll+10000-Date.now())/1000).toString()+" seconds left until you can end the poll early.","#DA0808","#1EBCC1");
  3949. return "";
  3950. }
  3951. playerids[myid].ratelimit.poll = Date.now();
  3952. SEND("42"+JSON.stringify([4,{"type":"poll end","from":username}]));
  3953. displayInChat("The poll ended.","#DA0808","#1EBCC1");
  3954. var count = [0,0,0,0];
  3955. var keys = Object.keys(playerids);
  3956. for(var i = 0;i<keys.length;i++){
  3957. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive[3].length-1){
  3958. count[playerids[keys[i]].vote.poll]++;
  3959. }
  3960. playerids[keys[i]].vote.poll = -1;
  3961. }
  3962. for(var i = 0;i<count.length;i++){
  3963. if(count[i]>1){
  3964. displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  3965. }
  3966. if(count[i]==1){
  3967. displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  3968. }
  3969. }
  3970. displayInChat("The poll was:","#DA0808","#1EBCC1");
  3971. for(var i = 0;i<pollactive[3].length;i++){
  3972. displayInChat(letters[i]+") "+pollactive[3][i],"#DA0808","#1EBCC1");
  3973. }
  3974. pollactive = [false,0,0,[]];
  3975. }
  3976. else{
  3977. displayInChat("No poll has been started","#DA0808","#1EBCC1");
  3978. displayInChat("Type '/startpoll [seconds]' to start a poll.","#DA0808","#1EBCC1");
  3979. }
  3980. return "";
  3981. }
  3982. else if (chat_val.substring(1,7)=="moveA " && chat_val.replace(/^\s+|\s+$/g, '').length>=8){
  3983. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '');
  3984. var keys = Object.keys(playerids);
  3985. var t = -1;
  3986. if(text == "f"){
  3987. t = 1;
  3988. }
  3989. else if(text == "b"){
  3990. t = 3;
  3991. }
  3992. else if(text == "g"){
  3993. t = 4;
  3994. }
  3995. else if(text == "r"){
  3996. t = 2;
  3997. }
  3998. else if(text == "y"){
  3999. t = 5;
  4000. }
  4001. else if(text == "s"){
  4002. t = 0;
  4003. }
  4004. if(t == -1){
  4005. displayInChat("The format for this command is:","#DA0808","#1EBCC1");
  4006. displayInChat("/moveA [letter]","#DA0808","#1EBCC1");
  4007. displayInChat("For example: '/moveA r' would move everyone to red team.","#DA0808","#1EBCC1");
  4008. return "";
  4009. }
  4010. for(var i = 0;i<keys.length;i++){
  4011. SEND('42[26,{"targetID":'+keys[i].toString()+',"targetTeam":'+t.toString()+'}]');
  4012. RECIEVE('42[18,'+keys[i].toString()+','+t.toString()+']');
  4013. }
  4014. return "";
  4015. }
  4016. else if (chat_val.substring(1,7)=="moveT " && chat_val.replace(/^\s+|\s+$/g, '').length>=8){
  4017. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '').split(" ").filter(function(i){if(i==""){return false}else{return true}});
  4018. if(text.length == 2){
  4019. var firstteam = -1;
  4020. var secondteam = -1;
  4021. for(var i = 0;i<2;i++){
  4022. var t = -1;
  4023. if(text[i] == "f"){
  4024. t = 1;
  4025. }
  4026. else if(text[i] == "b"){
  4027. t = 3;
  4028. }
  4029. else if(text[i] == "g"){
  4030. t = 4;
  4031. }
  4032. else if(text[i] == "r"){
  4033. t = 2;
  4034. }
  4035. else if(text[i] == "y"){
  4036. t = 5;
  4037. }
  4038. else if(text[i] == "s"){
  4039. t = 0;
  4040. }
  4041. if(t==-1){
  4042. displayInChat("The format for this command is:","#DA0808","#1EBCC1");
  4043. displayInChat("/moveT [letter] [letter]","#DA0808","#1EBCC1");
  4044. displayInChat("For example: '/moveT s r' would move everyone in spectate to red team.","#DA0808","#1EBCC1");
  4045. return "";
  4046. }
  4047. else{
  4048. if(i == 0){
  4049. firstteam = t;
  4050. }
  4051. else{
  4052. secondteam = t;
  4053. }
  4054. }
  4055. }
  4056. var keys = Object.keys(playerids);
  4057. for(var i = 0;i<keys.length;i++){
  4058. if(playerids[keys[i]].team == firstteam){
  4059. SEND('42[26,{"targetID":'+keys[i].toString()+',"targetTeam":'+secondteam.toString()+'}]');
  4060. RECIEVE('42[18,'+keys[i].toString()+','+secondteam.toString()+']');
  4061. }
  4062. }
  4063. }
  4064. else{
  4065. displayInChat("The format for this command is:","#DA0808","#1EBCC1");
  4066. displayInChat("/moveT [team] [team]","#DA0808","#1EBCC1");
  4067. displayInChat("For example: '/moveT s r' would move everyone in spectate to red team.","#DA0808","#1EBCC1");
  4068. return "";
  4069. }
  4070. return "";
  4071. }
  4072. if (chat_val.substring(1,13)=="roundsperqp " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  4073. var text = parseInt(chat_val.substring(13).replace(/^\s+|\s+$/g, ''));
  4074. if(isNaN(text)){
  4075. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  4076. return "";
  4077. }
  4078. else if(text<=0){
  4079. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  4080. return "";
  4081. }
  4082. roundsperqp = text;
  4083. roundsperqp2 = 0;
  4084. displayInChat("Set rounds per quickplay to: " + text.toString(),"#DA0808","#1EBCC1");
  4085. displayInChat("Type '/roundsperqp' to reset rounds per quickplay.","#DA0808","#1EBCC1");
  4086. return "";
  4087.  
  4088. }
  4089. else if (chat_val.substring(1,12)=="roundsperqp"){
  4090. roundsperqp = 1;
  4091. roundsperqp2 = 0;
  4092. displayInChat("Reset rounds per quickplay.","#DA0808","#1EBCC1");
  4093. return "";
  4094.  
  4095. }
  4096. else if (chat_val.substring(1,8)=="rounds " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  4097. var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '');
  4098. if(!isNaN(parseInt(text))){
  4099. text = parseInt(text).toString();
  4100. SEND('42[21,{"w":'+text+'}]');
  4101. RECIEVE('42[27,'+text+']');
  4102. }
  4103. return "";
  4104.  
  4105. }
  4106. else if (chat_val.substring(1,13)=="disablekeys " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  4107. var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '');
  4108. var keys = text.split(" ");
  4109. var disabledkeys2 = [];
  4110. var possiblekeys = ["left","right","up","down","heavy","special"];
  4111. for(var i = 0; i<keys.length; i++){
  4112. if(keys[i]!="" && !disabledkeys2.includes(keys[i])){
  4113. if(possiblekeys.includes(keys[i])){
  4114. disabledkeys2.push(keys[i]);
  4115. }
  4116. else{
  4117. displayInChat("Key options: " + possiblekeys.join(" ") + ".","#DA0808","#1EBCC1");
  4118. return "";
  4119. }
  4120. }
  4121. }
  4122. disabledkeys = disabledkeys2;
  4123. displayInChat("Set disabled keys to: " + disabledkeys.join(" ") + ".","#DA0808","#1EBCC1");
  4124. displayInChat("Type '/disablekeys' to reset disabled keys.","#DA0808","#1EBCC1");
  4125. return "";
  4126.  
  4127. }
  4128. else if (chat_val.substring(1,12)=="disablekeys"){
  4129. displayInChat("Reset disabled keys.","#DA0808","#1EBCC1");
  4130. disabledkeys = [];
  4131. return "";
  4132.  
  4133. }
  4134. else if (chat_val.substring(1,10)=="jointext " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  4135. jointext = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  4136. displayInChat("Set jointext to: " + jointext,"#DA0808","#1EBCC1");
  4137. displayInChat("Type '/jointext' to reset jointext.","#DA0808","#1EBCC1");
  4138. return "";
  4139.  
  4140. }
  4141. else if (chat_val.substring(1,9)=="jointext"){
  4142. jointext = "";
  4143. displayInChat("Reset jointext.","#DA0808","#1EBCC1");
  4144. return "";
  4145.  
  4146. }
  4147. else if (chat_val.substring(1,9)=="wintext " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  4148. wintext = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  4149. displayInChat("Set wintext to: " + wintext,"#DA0808","#1EBCC1");
  4150. displayInChat("Type '/wintext' to reset wintext.","#DA0808","#1EBCC1");
  4151. return "";
  4152.  
  4153. }
  4154. else if (chat_val.substring(1,8)=="wintext"){
  4155. wintext = "";
  4156. displayInChat("Reset wintext.","#DA0808","#1EBCC1");
  4157. return "";
  4158.  
  4159. }
  4160. else if (chat_val.substring(1,11)=="autorecord"){
  4161. if(autorecord){
  4162. autorecord = false;
  4163. displayInChat("Autorecord is now off.","#DA0808","#1EBCC1");
  4164. }
  4165. else{
  4166. autorecord = true;
  4167. displayInChat("Autorecord is now on.","#DA0808","#1EBCC1");
  4168. }
  4169. return "";
  4170.  
  4171. }
  4172. else if (chat_val.substring(1,9)=="afkkill " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  4173. var text = parseFloat(chat_val.substring(9).replace(/^\s+|\s+$/g, ''));
  4174. if(!isNaN(text)){
  4175. if(text>0){
  4176. displayInChat("Set afk kill to: " + text.toString()+" seconds.","#DA0808","#1EBCC1");
  4177. displayInChat("Type '/afkkill' to reset afk kill.","#DA0808","#1EBCC1");
  4178. var keys = Object.keys(playerids);
  4179. var now = Date.now();
  4180. for(var i = 0;i<keys.length;i++){
  4181. playerids[keys[i]].lastmove = now;
  4182. }
  4183. afkkill = text;
  4184. }
  4185. else{
  4186. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  4187. }
  4188. }
  4189. else{
  4190. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  4191. }
  4192. return "";
  4193.  
  4194. }
  4195. else if (chat_val.substring(1,9)=="afkkill"){
  4196. afkkill = -1;
  4197. displayInChat("Reset afk kill.","#DA0808","#1EBCC1");
  4198. return "";
  4199.  
  4200. }
  4201. else if (chat_val.substring(1,13)=="defaultmode " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  4202. var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '');
  4203. if(text == "default"){
  4204. defaultmode = "";
  4205. displayInChat("Changed default mode to default.","#DA0808","#1EBCC1");
  4206. }
  4207. else if(text == "arrows"){
  4208. defaultmode = "ar";
  4209. displayInChat("Changed default mode to arrows.","#DA0808","#1EBCC1");
  4210. }
  4211. else if(text == "death arrows"){
  4212. defaultmode = "ard";
  4213. displayInChat("Changed default mode to death arrows.","#DA0808","#1EBCC1");
  4214. }
  4215. else if(text == "grapple"){
  4216. defaultmode = "sp";
  4217. displayInChat("Changed default mode to grapple.","#DA0808","#1EBCC1");
  4218. }
  4219. else if(text == "classic"){
  4220. defaultmode = "b";
  4221. displayInChat("Changed default mode to classic.","#DA0808","#1EBCC1");
  4222.  
  4223. }
  4224. else{
  4225. displayInChat("Default mode options:","#DA0808","#1EBCC1");
  4226. displayInChat("default","#DA0808","#1EBCC1");
  4227. displayInChat("classic","#DA0808","#1EBCC1");
  4228. displayInChat("arrows","#DA0808","#1EBCC1");
  4229. displayInChat("death arrows","#DA0808","#1EBCC1");
  4230. displayInChat("grapple","#DA0808","#1EBCC1");
  4231. }
  4232. return "";
  4233.  
  4234. }
  4235. else if (chat_val.substring(1,8)=="recmode"){
  4236. if(recmodebool == true){
  4237. recmodebool = false;
  4238. displayInChat("Recmode is now off.","#DA0808","#1EBCC1");
  4239.  
  4240. }
  4241. else{
  4242. recmodebool = true;
  4243. displayInChat("Recmode is now on.","#DA0808","#1EBCC1");
  4244.  
  4245. }
  4246.  
  4247. return "";
  4248.  
  4249. }
  4250. else if (chat_val.substring(1,8)=="recteam"){
  4251. if(recteams == true){
  4252. recteams = false;
  4253. displayInChat("Recteam is now off.","#DA0808","#1EBCC1");
  4254.  
  4255. }
  4256. else{
  4257. recteams = true;
  4258. displayInChat("Recteam is now on.","#DA0808","#1EBCC1");
  4259.  
  4260. }
  4261. return "";
  4262. }
  4263. else if (chat_val.substring(1,8)=="shuffle"){
  4264. if(shuffle == true){
  4265. shuffle = false;
  4266. displayInChat("Shuffle is now off.","#DA0808","#1EBCC1");
  4267.  
  4268. }
  4269. else{
  4270. shuffle = true;
  4271. displayInChat("Shuffle is now on.","#DA0808","#1EBCC1");
  4272.  
  4273. }
  4274.  
  4275. return "";
  4276.  
  4277. }
  4278. else if(sandboxon){
  4279. if (chat_val.substring(1,11)=="addplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  4280. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  4281. if(!isNaN(parseInt(text))){
  4282. var text2 = parseInt(text);
  4283. if(text2>0){
  4284. for(var i = 0;i<text2;i++){
  4285. while(playerids[sandboxid]){
  4286. sandboxid+=1;
  4287. }
  4288. var color = Math.floor(Math.random() * 16777215).toString();
  4289. var packet = '42'+JSON.stringify([4,sandboxid,"sandbox",sandboxid.toString(),true,0,0,{"layers":[],"bc":color}]);
  4290. RECIEVE(packet);
  4291. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  4292. sandboxplayerids[sandboxid] = sandboxid.toString();
  4293. sandboxid+=1;
  4294. }
  4295.  
  4296. }
  4297. }
  4298. return "";
  4299.  
  4300. }
  4301. if (chat_val.substring(1,9)=="addname " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  4302. var text = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  4303. while(playerids[sandboxid]){
  4304. sandboxid+=1;
  4305. }
  4306. var keys = Object.keys(playerids);
  4307. var addon = "";
  4308. var escape = false;
  4309. var keysi = -1;
  4310. while(!escape){
  4311. escape = true;
  4312. for(var i = 0;i<keys.length;i++){
  4313. if(playerids[keys[i]].userName == text+addon){
  4314. addon+="‎";
  4315. var escape = false;
  4316. }
  4317. if(playerids[keys[i]].userName == text){
  4318. keysi = keys[i];
  4319. }
  4320. }
  4321. }
  4322. if(keysi!=-1){
  4323. var packet = '42'+JSON.stringify([4,sandboxid,"sandbox",text+addon,playerids[keysi].guest,playerids[keysi].level,0,playerids[keysi].avatar]);
  4324. RECIEVE(packet);
  4325. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  4326. }
  4327. else{
  4328. var color = Math.floor(Math.random() * 16777215).toString();
  4329. var packet = '42'+JSON.stringify([4,sandboxid,"sandbox",text+addon,true,0,1,{"layers":[],"bc":color}]);
  4330. RECIEVE(packet);
  4331. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  4332. }
  4333. sandboxplayerids[sandboxid] = sandboxid.toString();
  4334. sandboxid+=1;
  4335. return "";
  4336.  
  4337. }
  4338. else if (chat_val.substring(1,11)=="delplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  4339. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  4340. if(!isNaN(parseInt(text))){
  4341. var text2 = parseInt(text);
  4342. if(text2>0){
  4343. if(Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden"){
  4344. var jsonkeys = Object.keys(sandboxplayerids).reverse();
  4345. var packets = [];
  4346. for(var i = 0;i<text2 && i<jsonkeys.length;i++){
  4347. var packet = '42[5,'+jsonkeys[i]+',0]';
  4348. RECIEVE(packet);
  4349. packets.push(packet);
  4350. delete sandboxplayerids[jsonkeys[i]];
  4351. }
  4352. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":packets,to:[-1]}]));
  4353. }
  4354. else{
  4355. displayInChat("Cannot delete players while ingame.","#DA0808","#1EBCC1");
  4356. }
  4357.  
  4358. }
  4359. }
  4360. return "";
  4361. }
  4362. else if (chat_val.substring(1,7)=="copyme"){
  4363. if(sandboxcopyme == true){
  4364. displayInChat("Copyme is now off.","#DA0808","#1EBCC1");
  4365. sandboxcopyme = false;
  4366. }
  4367. else{
  4368. displayInChat("Copyme is now on.","#DA0808","#1EBCC1");
  4369. sandboxcopyme = true;
  4370. }
  4371.  
  4372. return "";
  4373. }
  4374. }
  4375. }
  4376. return chat_val;
  4377. };
  4378.  
  4379. scope.flag_manage = function(t){
  4380. var text = t;
  4381. if(reverse_flag == true){
  4382. text = text.split("").reverse().join("")
  4383. }
  4384. if(rcaps_flag == true){
  4385. text = text.split('');
  4386. for(var i = 0; i<text.length;i++){
  4387. if(Math.floor(Math.random()*2)){
  4388. text[i] = text[i].toUpperCase();
  4389. }
  4390. else{
  4391. text[i] = text[i].toLowerCase();
  4392. }
  4393. }
  4394. text = text.join('');
  4395. }
  4396. if(space_flag == true){
  4397. text = text.split('').join(' ')
  4398. }
  4399. if(number_flag == true){
  4400. text = text.replace(/[t|T][Oo]+/g,"2");
  4401. text = text.replace(/[f|F][o|O][r|R]/g,"4");
  4402. text = text.replace(/[a|A][t|T][e|E]/g,"8");
  4403. text = text.replace(/[e|E]/g,"3");
  4404. text = text.replace(/[a|A]/g,"4");
  4405. text = text.replace(/[o|O]/g,"0");
  4406. text = text.replace(/[s|S]/g,"5");
  4407. text = text.replace(/[i|I|l|L]/g,"1");
  4408. }
  4409. return text;
  4410. };
  4411. Gdocument.getElementById("newbonklobby_chat_input").onkeydown = function(e){
  4412. if(e.keyCode==13){
  4413.  
  4414. var chat_val = Gdocument.getElementById("newbonklobby_chat_input").value;
  4415.  
  4416. if (chat_val!="" && chat_val[0]=="/"){
  4417.  
  4418. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  4419. chat2(commandhandle(chat_val));
  4420. }
  4421. else{
  4422. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  4423. chat2(flag_manage(chat_val));
  4424. }
  4425.  
  4426. }
  4427. };
  4428. Gdocument.getElementById("ingamechatinputtext").onkeydown = function(e){
  4429. if(e.keyCode==13){
  4430.  
  4431. var chat_val = Gdocument.getElementById("ingamechatinputtext").value;
  4432.  
  4433. if (chat_val!="" && chat_val[0]=="/"){
  4434.  
  4435. Gdocument.getElementById("ingamechatinputtext").value = "";
  4436. chat2(commandhandle(chat_val));
  4437. }
  4438. else{
  4439. Gdocument.getElementById("ingamechatinputtext").value = "";
  4440. chat2(flag_manage(chat_val));
  4441. }
  4442. }
  4443. };
  4444. scope.Last_message = "";
  4445. scope.Laster_message = "";
  4446. scope.new_message = false;
  4447. scope.changed_chat = false;
  4448. scope.injectedBonkCommandsScript = setInterval(timeout123,60);
  4449.  
  4450. scope.hotkeys = function(e){
  4451. var keycode = e.code;
  4452. if(e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  4453. if(keycode == "Period"){
  4454. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]!="0px"){
  4455. chatheight+=5;
  4456. if(chatheight>600){chatheight = 600;}
  4457. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  4458. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  4459. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  4460. }
  4461. e.preventDefault();
  4462. }
  4463. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  4464. if(keycode == "KeyG"){
  4465. var addto = 0;
  4466. for(var i = 0;i<parentDraw.children.length;i++){
  4467. if(parentDraw.children[i].constructor.name == "e"){
  4468. addto = parentDraw.children[i];
  4469. break;
  4470. }
  4471. }
  4472. var canv = 0;
  4473. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  4474. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  4475. canv = Gdocument.getElementById("gamerenderer").children[i];
  4476. break;
  4477. }
  4478. }
  4479. var width = parseInt(canv.style["width"]);
  4480. var height = parseInt(canv.style["height"]);
  4481. if(addto){
  4482. zoom *= 1.1;
  4483. }
  4484. addto.scale.x = zoom;
  4485. addto.scale.y = zoom;
  4486. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  4487. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  4488. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  4489. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  4490. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999 && !FollowCam){
  4491. pixiCircle.visible = false;
  4492. }
  4493. else{
  4494. pixiCircle.visible = true;
  4495. }
  4496. e.preventDefault();
  4497. }
  4498. if(keycode == "KeyH"){
  4499. var addto = 0;
  4500. for(var i = 0;i<parentDraw.children.length;i++){
  4501. if(parentDraw.children[i].constructor.name == "e"){
  4502. addto = parentDraw.children[i];
  4503. break;
  4504. }
  4505. }
  4506. var canv = 0;
  4507. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  4508. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  4509. canv = Gdocument.getElementById("gamerenderer").children[i];
  4510. break;
  4511. }
  4512. }
  4513. var width = parseInt(canv.style["width"]);
  4514. var height = parseInt(canv.style["height"]);
  4515. if(addto){
  4516. zoom = 1;
  4517. }
  4518. addto.scale.x = zoom;
  4519. addto.scale.y = zoom;
  4520. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  4521. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  4522. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  4523. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  4524. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999 && !FollowCam){
  4525. pixiCircle.visible = false;
  4526. }
  4527. else{
  4528. pixiCircle.visible = true;
  4529. }
  4530. e.preventDefault();
  4531. }
  4532. if(keycode == "KeyJ"){
  4533. var addto = 0;
  4534. for(var i = 0;i<parentDraw.children.length;i++){
  4535. if(parentDraw.children[i].constructor.name == "e"){
  4536. addto = parentDraw.children[i];
  4537. break;
  4538. }
  4539. }
  4540. var canv = 0;
  4541. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  4542. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  4543. canv = Gdocument.getElementById("gamerenderer").children[i];
  4544. break;
  4545. }
  4546. }
  4547. var width = parseInt(canv.style["width"]);
  4548. var height = parseInt(canv.style["height"]);
  4549. if(addto){
  4550. zoom /= 1.1;
  4551. }
  4552. addto.scale.x = zoom;
  4553. addto.scale.y = zoom;
  4554. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  4555. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  4556. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  4557. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  4558. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999 && !FollowCam){
  4559. pixiCircle.visible = false;
  4560. }
  4561. else{
  4562. pixiCircle.visible = true;
  4563. }
  4564. e.preventDefault();
  4565. }
  4566. }
  4567. if(keycode == "Comma"){
  4568. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]!="0px"){
  4569. chatheight-=5;
  4570. if(chatheight<100){chatheight = 100;}
  4571. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  4572. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  4573. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  4574. }
  4575. e.preventDefault();
  4576. }
  4577. }
  4578. if(e.repeat){return;}
  4579. if(e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  4580. if(ishost){
  4581. if(keycode == "KeyE"){
  4582. if(Gdocument.getElementById("newbonklobby").style["display"] == "block"){
  4583. Gdocument.getElementById("newbonklobby_editorbutton").click();
  4584. }
  4585. else if(Gdocument.getElementById("mapeditorcontainer").style["display"] == "block"){
  4586. Gdocument.getElementById("mapeditor_close").click();
  4587. }
  4588. e.preventDefault();
  4589.  
  4590. }
  4591. else if(keycode == "KeyT"){
  4592. Gdocument.getElementById("newbonklobby_teamsbutton").click();
  4593. e.preventDefault();
  4594. }
  4595. else if(keycode == "KeyM"){
  4596. Gdocument.getElementById("newbonklobby_modebutton").click();
  4597. e.preventDefault();
  4598. }
  4599. else if(keycode == "KeyK"){
  4600. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  4601. Gdocument.getElementById("pretty_top_exit").click();
  4602. }
  4603. e.preventDefault();
  4604. }
  4605. else if(keycode == "KeyS"){
  4606. if(Gdocument.getElementById("mapeditorcontainer").style["display"]!="block"){
  4607. Gdocument.getElementById("newbonklobby_editorbutton").click();
  4608. }
  4609. if(recmodebool && ishost){
  4610. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  4611. if(mode == "" && defaultmode!="d"){
  4612. mode = defaultmode;
  4613. }
  4614. if(mode != ""){
  4615. RECIEVE('42[26,"b","'+mode+'"]');
  4616. }
  4617. }
  4618. Gdocument.getElementById("mapeditor_close").click();
  4619. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  4620. roundsperqp2 = 0;
  4621. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  4622. e.preventDefault();
  4623. }
  4624. else if(keycode == "KeyD"){
  4625. roundsperqp2 = 0;
  4626. if(stopquickplay == 0){
  4627. if(shuffle){
  4628. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4629. var available = [];
  4630. var availableindexes = [];
  4631. var notempty = false;
  4632. for(var i = 0; i<e2.length;i++){
  4633. var a = false;
  4634. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4635. available.push(a);
  4636. if(a){
  4637. availableindexes.push(i);
  4638. notempty = true;
  4639. }
  4640. }
  4641. if(notempty){
  4642.  
  4643. if(availableindexes.length!=1){
  4644. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  4645. }
  4646. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  4647. }
  4648. }
  4649. else{
  4650. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4651. var available = [];
  4652. var availableindexes = [];
  4653. var notempty = false;
  4654. for(var i = 0; i<e2.length;i++){
  4655. var a = false;
  4656. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4657. available.push(a);
  4658. if(a){
  4659. availableindexes.push(i);
  4660. notempty = true;
  4661. }
  4662. }
  4663. if(notempty){
  4664. var above = [];
  4665. for(var i = 0;i<availableindexes.length;i++){
  4666. if(availableindexes[i]>quicki){
  4667. above.push(availableindexes[i]);
  4668. }
  4669. }
  4670. if(above.length>0){
  4671. quicki = above[0];
  4672. }
  4673. else{
  4674. quicki = availableindexes[0];
  4675. }
  4676. }
  4677. }
  4678. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  4679. }
  4680. e.preventDefault();
  4681. }
  4682. else if(keycode == "KeyA"){
  4683. if(stopquickplay == 0){
  4684. roundsperqp2 = 0;
  4685. if(shuffle){
  4686. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4687. var available = [];
  4688. var availableindexes = [];
  4689. var notempty = false;
  4690. for(var i = 0; i<e2.length;i++){
  4691. var a = false;
  4692. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4693. available.push(a);
  4694. if(a){
  4695. availableindexes.push(i);
  4696. notempty = true;
  4697. }
  4698. }
  4699. if(notempty){
  4700.  
  4701. if(availableindexes.length!=1){
  4702. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  4703. }
  4704. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  4705. }
  4706. }
  4707. else{
  4708. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4709. var available = [];
  4710. var availableindexes = [];
  4711. var notempty = false;
  4712. for(var i = 0; i<e2.length;i++){
  4713. var a = false;
  4714. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4715. available.push(a);
  4716. if(a){
  4717. availableindexes.push(i);
  4718. notempty = true;
  4719. }
  4720. }
  4721. if(notempty){
  4722. var above = [];
  4723. for(var i = 0;i<availableindexes.length;i++){
  4724. if(availableindexes[i]<quicki){
  4725. above.push(availableindexes[i]);
  4726. }
  4727. }
  4728. if(above.length>0){
  4729. quicki = above[above.length-1];
  4730. }
  4731. else{
  4732. quicki = availableindexes[availableindexes.length-1];
  4733. }
  4734. }
  4735. }
  4736. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  4737. }
  4738. e.preventDefault();
  4739. }
  4740. else if(keycode == "KeyQ"){
  4741. if(stopquickplay == 1){
  4742. stopquickplay = 0;
  4743. quicki = 0;
  4744. qppaused = false;
  4745. displayInChat("Enabled quickplay.","#DA0808","#1EBCC1");
  4746. }
  4747. else{
  4748. stopquickplay = 1;
  4749. quicki = 0;
  4750. qppaused = false;
  4751. displayInChat("Disabled quickplay.","#DA0808","#1EBCC1");
  4752. }
  4753. e.preventDefault();
  4754. }
  4755. else if(keycode == "KeyP" && stopquickplay==0){
  4756. if(qppaused == true){
  4757. qppaused = false;
  4758. displayInChat("Unpaused quickplay.","#DA0808","#1EBCC1");
  4759. }
  4760. else{
  4761. qppaused = true;
  4762. displayInChat("Paused quickplay.","#DA0808","#1EBCC1");
  4763. }
  4764. e.preventDefault();
  4765. }
  4766. else if(keycode == "KeyR"){
  4767. if(recmodebool == true){
  4768. recmodebool = false;
  4769. displayInChat("Recmode is now off.","#DA0808","#1EBCC1");
  4770.  
  4771. }
  4772. else{
  4773. recmodebool = true;
  4774. displayInChat("Recmode is now on.","#DA0808","#1EBCC1");
  4775.  
  4776. }
  4777. }
  4778. else if(keycode == "KeyF"){
  4779. if(freejoin == false){
  4780. freejoin = true;
  4781. displayInChat("Freejoin is now on.","#DA0808","#1EBCC1");
  4782.  
  4783. }
  4784. else{
  4785. freejoin = false;
  4786. displayInChat("Freejoin is now off.","#DA0808","#1EBCC1");
  4787. }
  4788. e.preventDefault();
  4789. }
  4790. }
  4791. else{
  4792. if(keycode == "KeyE"){
  4793. e.preventDefault();
  4794. }
  4795. else if(keycode == "KeyT"){
  4796. e.preventDefault();
  4797. }
  4798. else if(keycode == "KeyM"){
  4799. e.preventDefault();
  4800. }
  4801. else if(keycode == "KeyK"){
  4802. e.preventDefault();
  4803. }
  4804. else if(keycode == "KeyS"){
  4805. e.preventDefault();
  4806. }
  4807. else if(keycode == "KeyD"){
  4808. e.preventDefault();
  4809. }
  4810. else if(keycode == "KeyA"){
  4811. e.preventDefault();
  4812. }
  4813. else if(keycode == "KeyQ"){
  4814. e.preventDefault();
  4815. }
  4816. else if(keycode == "KeyP"){
  4817. e.preventDefault();
  4818. }
  4819. else if(keycode == "KeyF"){
  4820. e.preventDefault();
  4821. }
  4822. else if(keycode == "KeyR"){
  4823. e.preventDefault();
  4824. }
  4825.  
  4826. }
  4827. if(keycode == "KeyL"){
  4828. lobby();
  4829. e.preventDefault();
  4830. }
  4831. if(keycode == "KeyC"){
  4832. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  4833. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]=="0px"){
  4834. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  4835. }
  4836. else{
  4837. Gdocument.getElementById("ingamechatcontent").style["max-height"]="0px";
  4838. }
  4839. }
  4840. e.preventDefault();
  4841. }
  4842. if(keycode == "KeyI"){
  4843. if(Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"] == "none"){
  4844. debuggeropen = true;
  4845. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="block";
  4846. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="none";
  4847. Gdocument.getElementById("ingamechatinputtext").style["display"] = "none";
  4848. }
  4849. else{
  4850. debuggeropen = false;
  4851. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="none";
  4852. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  4853. Gdocument.getElementById("ingamechatinputtext").style["display"] = "";
  4854. }
  4855. e.preventDefault();
  4856. }
  4857. if(keycode == "KeyB"){
  4858. var element = Gdocument.getElementById("ingamewinner_scores");
  4859. element.style["visibility"] = "visible";
  4860. if(element.style["opacity"]<1){
  4861. element.style["opacity"] = 1;
  4862. }
  4863. else{
  4864. element.style["opacity"] = 0;
  4865. }
  4866. e.preventDefault();
  4867. }
  4868. if(keycode == "KeyY"){
  4869. Gdocument.getElementById("pretty_top_settings").click();
  4870. Gdocument.getElementById("settings_close").click();
  4871. if(Gdocument.getElementById("settings_graphicsquality").value==1){
  4872. displayInChat("You must have medium or high quality enabled to use this feature.","#DA0808","#1EBCC1");
  4873. return "";
  4874. }
  4875.  
  4876.  
  4877. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  4878. var addto = {"children":[]};
  4879. for(var i = 0;i<parentDraw.children.length;i++){
  4880. if(parentDraw.children[i].constructor.name == "e"){
  4881. addto = parentDraw.children[i];
  4882. break;
  4883. }
  4884. }
  4885. var addto2 = {"children":[]};
  4886. for(var i = 0;i<addto.children.length;i++){
  4887. if(addto.children[i].constructor.name == "e"){
  4888. addto2 = addto.children[i];
  4889. break;
  4890. }
  4891. }
  4892. var checkxray = addto2.children[0];
  4893. var addto3 = addto2.children[0].children;
  4894. if(addto3.length==1){
  4895. checkxray = checkxray.children[0];
  4896. addto3 = addto3[0].children;
  4897. }
  4898. var xrayon = false;
  4899. if(checkxray.xrayon){
  4900. checkxray.xrayon = false;
  4901. xrayon = false;
  4902. }
  4903. else{
  4904. checkxray.xrayon = true;
  4905. xrayon = true;
  4906. }
  4907. if(xrayon){
  4908. displayInChat("Xray is now on.","#DA0808","#1EBCC1");
  4909. for(var i = 0;i<addto3.length;i++){
  4910. if(addto3[i].children.length>0){
  4911. for(var i3 = 0;i3<addto3[i].children.length;i3++){
  4912. addto3[i].children[i3].visible = false;
  4913. if(addto3[i].children[i3].children.length>0){
  4914. addto3[i].children[i3].visible = true;
  4915. }
  4916. }
  4917. }
  4918. }
  4919.  
  4920. }
  4921. else{
  4922. displayInChat("Xray is now off.","#DA0808","#1EBCC1");
  4923. for(var i = 0;i<addto3.length;i++){
  4924. for(var i2 = 0;i2<addto3[i].children.length;i2++){
  4925. addto3[i].children[i2].visible = true;
  4926. }
  4927. }
  4928. }
  4929. }
  4930. e.preventDefault();
  4931. }
  4932. if(keycode == "KeyN"){
  4933. if(FollowCam == true){
  4934. displayInChat("Follow Camera is now off.","#DA0808","#1EBCC1");
  4935. FollowCam = false;
  4936. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  4937. var addto = {"children":[]};
  4938. for(var i = 0;i<parentDraw.children.length;i++){
  4939. if(parentDraw.children[i].constructor.name == "e"){
  4940. addto = parentDraw.children[i];
  4941. break;
  4942. }
  4943. }
  4944. var canv = 0;
  4945. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  4946. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  4947. canv = Gdocument.getElementById("gamerenderer").children[i];
  4948. break;
  4949. }
  4950. }
  4951. var width = parseInt(canv.style["width"]);
  4952. var height = parseInt(canv.style["height"]);
  4953. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  4954. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  4955. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  4956. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  4957. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999){
  4958. pixiCircle.visible = false;
  4959. }
  4960. else{
  4961. pixiCircle.visible = true;
  4962. }
  4963. }
  4964. }
  4965. else{
  4966. displayInChat("Follow Camera is now on.","#DA0808","#1EBCC1");
  4967. FollowCam = true;
  4968. }
  4969. e.preventDefault();
  4970. }
  4971. if(keycode == "KeyV"){
  4972. if(autocam == true){
  4973. displayInChat("Auto Cam is now off.","#DA0808","#1EBCC1");
  4974. autocam = false
  4975. }
  4976. else{
  4977. displayInChat("Auto Cam is now on.","#DA0808","#1EBCC1");
  4978. autocam = true;
  4979. }
  4980. e.preventDefault();
  4981. }
  4982. if(keycode == "KeyO"){
  4983. if(heavybot == true){
  4984. displayInChat("Heavy bot is now off.","#DA0808","#1EBCC1");
  4985. heavybot = false;
  4986. }
  4987. else{
  4988. displayInChat("Heavy bot is now on.","#DA0808","#1EBCC1");
  4989. heavybot = true;
  4990. var keykeys = Object.keys(keyCodes);
  4991. var keyslist = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[5].children).slice(1);
  4992. for(var i = 0;i<keyslist.length;i++){
  4993. if(keykeys.includes(keyslist[i].textContent)){
  4994. heavy = keyCodes[keyslist[i].textContent];
  4995. break;
  4996. }
  4997. else{
  4998. heavy = keyslist[i].textContent.charCodeAt(0);
  4999. break
  5000. }
  5001. }
  5002. var keyslist2 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[6].children).slice(1);
  5003. for(var i = 0;i<keyslist2.length;i++){
  5004. if(keykeys.includes(keyslist2[i].textContent)){
  5005. special = keyCodes[keyslist2[i].textContent];
  5006. break;
  5007. }
  5008. else{
  5009. special = keyslist2[i].textContent.charCodeAt(0);
  5010. break
  5011. }
  5012. }
  5013. }
  5014. e.preventDefault();
  5015. }
  5016. if(keycode == "KeyU"){
  5017. if(aimbot == true){
  5018. displayInChat("Aimbot is now off.","#DA0808","#1EBCC1");
  5019. aimbot = false;
  5020. }
  5021. else{
  5022. displayInChat("Aimbot is now on.","#DA0808","#1EBCC1");
  5023. aimbot = true;
  5024. var keykeys = Object.keys(keyCodes);
  5025. var keyslist = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[1].children).slice(1);
  5026. var keyslist2 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[2].children).slice(1);
  5027. for(var i = 0;i<keyslist.length;i++){
  5028. if(keykeys.includes(keyslist[i].textContent)){
  5029. leftRight[0] = keyCodes[keyslist[i].textContent];
  5030. break;
  5031. }
  5032. else{
  5033. leftRight[0] = keyslist[i].textContent.charCodeAt(0);
  5034. break
  5035. }
  5036. }
  5037. for(var i = 0;i<keyslist2.length;i++){
  5038. if(keykeys.includes(keyslist2[i].textContent)){
  5039. leftRight[1] = keyCodes[keyslist2[i].textContent];
  5040. break;
  5041. }
  5042. else{
  5043. leftRight[1] = keyslist2[i].textContent.charCodeAt(0);
  5044. }
  5045. }
  5046. }
  5047. e.preventDefault();
  5048. }
  5049. }
  5050. if(!e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  5051. if(keycode == "Slash" && !(Gdocument.getElementById("gmeditor")?.style["transform"] == "scale(1)")){
  5052. 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"]==""){
  5053. Gdocument.getElementById("newbonklobby_chat_input").value = "/";
  5054. if(Gdocument.getElementById("newbonklobby_chat_input").style["pointer-events"] == "none"){
  5055. fire("keydown",{keyCode:13});
  5056. }
  5057. else{
  5058. Gdocument.getElementById("newbonklobby_chat_input").focus();
  5059. }
  5060. e.preventDefault();
  5061.  
  5062. }
  5063. else if(Gdocument.getElementById("ingamechatinputtext").style["visibility"]=="visible" && Gdocument.getElementById("ingamechatinputtext").style["display"]=="" && Gdocument.getElementById("mapeditorcontainer").style["display"]!="block" && Gdocument.getElementById("ingamechatinputtext").value == ""){
  5064. Gdocument.getElementById("ingamechatinputtext").value = "/";
  5065. if(!Gdocument.getElementById("ingamechatinputtext").classList.value.includes("ingamechatinputtextbg")){
  5066. fire("keydown",{keyCode:13});
  5067. }
  5068. else{
  5069. Gdocument.getElementById("ingamechatinputtext").focus();
  5070. }
  5071. e.preventDefault();
  5072.  
  5073. }
  5074. }
  5075. }
  5076. };
  5077.  
  5078. Gdocument.onkeydown = hotkeys;
  5079.  
  5080. Gwindow.addEventListener('resize',function(e){
  5081. debuggermenu.style["width"] = Gdocument.getElementById("bonkiocontainer").style["width"];
  5082. debuggermenu.style["height"] = Gdocument.getElementById("bonkiocontainer").style["height"];
  5083. scope.width = parseInt(Gdocument.getElementById("bonkiocontainer").style["width"])-20;
  5084. scope.height = parseInt(Gdocument.getElementById("bonkiocontainer").style["height"])-210;
  5085. logmenu.style["width"] = width.toString()+"px";
  5086. logmenu.style["height"] = height.toString()+"px";
  5087. logmenutopleft.style["width"] = (width/2).toString()+"px";
  5088. logmenutopright.style["width"] = (width/2).toString()+"px";
  5089. logmenutopright.style["left"] = (width/2).toString()+"px";
  5090. debuggerinput.style["width"] = width.toString()+"px";
  5091. debuggerinput.style["top"] = (height+90).toString()+"px";
  5092. debuggersendrecieve.style["top"] = (height+120).toString()+"px";
  5093. debuggerpausebutton.style["top"] = (height+150).toString()+"px";
  5094. debuggereval.style["width"] = (width-150).toString()+"px";
  5095. debuggereval.style["top"] = (height+120).toString()+"px";},true);
  5096.  
  5097.  
  5098. function timeout123() {
  5099. updateWssLog();
  5100. EVENTLOOPFUNCTION();
  5101. var now = Date.now();
  5102. var keys = Object.keys(playerids);
  5103. for(var i = 0;i<keys.length;i++){
  5104.  
  5105. if(playerids[keys[i]].playerData){
  5106. if(playerids[keys[i]].playerData2){
  5107. if(playerids[keys[i]].playerData.transform){
  5108. playerids[keys[i]].playerData2.alive = true;
  5109. if(playerids[keys[i]].playerData2.timeStamp == 0){
  5110. playerids[keys[i]].playerData2.px = playerids[keys[i]].playerData.transform.position.x;
  5111. playerids[keys[i]].playerData2.py = playerids[keys[i]].playerData.transform.position.y;
  5112. playerids[keys[i]].playerData2.timeStamp = now;
  5113. }
  5114. else{
  5115. playerids[keys[i]].playerData2.xvel = (playerids[keys[i]].playerData2.px - playerids[keys[i]].playerData.transform.position.x)/(playerids[keys[i]].playerData2.timeStamp-now);
  5116. playerids[keys[i]].playerData2.yvel = (playerids[keys[i]].playerData2.py - playerids[keys[i]].playerData.transform.position.y)/(playerids[keys[i]].playerData2.timeStamp-now);
  5117. playerids[keys[i]].playerData2.px = playerids[keys[i]].playerData.transform.position.x;
  5118. playerids[keys[i]].playerData2.py = playerids[keys[i]].playerData.transform.position.y;
  5119. playerids[keys[i]].playerData2.timeStamp = now;
  5120. }
  5121. if(playerids[keys[i]].playerData2.timeStamp2 == 0){
  5122. playerids[keys[i]].playerData2.pvx = playerids[keys[i]].playerData2.xvel;
  5123. playerids[keys[i]].playerData2.pvy = playerids[keys[i]].playerData2.yvel;
  5124. playerids[keys[i]].playerData2.timeStamp2 = now;
  5125. }
  5126. else{
  5127. playerids[keys[i]].playerData2.xacc = (playerids[keys[i]].playerData2.pvx - playerids[keys[i]].playerData2.xvel)/((playerids[keys[i]].playerData2.timeStamp2-now));
  5128. playerids[keys[i]].playerData2.yacc = (playerids[keys[i]].playerData2.pvy - playerids[keys[i]].playerData2.yvel)/((playerids[keys[i]].playerData2.timeStamp2-now));
  5129. playerids[keys[i]].playerData2.pvx = playerids[keys[i]].playerData2.xvel;
  5130. playerids[keys[i]].playerData2.pvy = playerids[keys[i]].playerData2.yvel;
  5131. playerids[keys[i]].playerData2.timeStamp2 = now;
  5132. }
  5133. }
  5134. else{
  5135. if(playerids[keys[i]].playerData2.alive){
  5136.  
  5137. }
  5138. playerids[keys[i]].playerData2.alive = false;
  5139. }
  5140. }
  5141. else{
  5142. playerids[keys[i]].playerData2 = {alive:true,radius:12,timeStamp:0,timeStamp2:0,px:0,py:0,pvx:0,pvy:0,xacc:0,yacc:0,xvel:0,yvel:0,balance:0};
  5143. }
  5144. }
  5145. }
  5146. for(var i = 0;i<keys.length;i++){
  5147. if(!playerids[keys[i]].playerData2){
  5148. playerids[keys[i]].playerData2 = {alive:true,radius:12,timeStamp:0,timeStamp2:0,px:0,py:0,pvx:0,pvy:0,xacc:0,yacc:0,xvel:0,yvel:0,balance:0};
  5149. }
  5150. }
  5151. if(Gdocument.getElementById("redefineControls_table").children[0].children.length<=1 && keys.length>0){
  5152. Gdocument.getElementById("pretty_top_settings").click();
  5153. Gdocument.getElementById("settings_close").click();
  5154. }
  5155. if(pollactive[0] && pollactive[2]<now && ishost){
  5156. playerids[myid].ratelimit.poll = Date.now();
  5157. SEND("42"+JSON.stringify([4,{"type":"poll end","from":username}]));
  5158. var count = [0,0,0,0];
  5159. var keys = Object.keys(playerids);
  5160. for(var i = 0;i<keys.length;i++){
  5161. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive[3].length-1){
  5162. count[playerids[keys[i]].vote.poll]++;
  5163. }
  5164. playerids[keys[i]].vote.poll = -1;
  5165. }
  5166. displayInChat("The poll ended due to time.","#DA0808","#1EBCC1");
  5167. for(var i = 0;i<count.length;i++){
  5168. if(count[i]>1){
  5169. displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  5170. }
  5171. if(count[i]==1){
  5172. displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  5173. }
  5174. }
  5175. displayInChat("The poll was:","#DA0808","#1EBCC1");
  5176. for(var i = 0;i<pollactive[3].length;i++){
  5177. displayInChat(letters[i]+") "+pollactive[3][i],"#DA0808","#1EBCC1");
  5178. }
  5179. pollactive = [false,0,0,[]];
  5180. }
  5181. if(!ishost && sandboxcopyme){
  5182. sandboxcopyme = false;
  5183. }
  5184. if(afkkill>0 && ishost){
  5185. var keys = Object.keys(playerids);
  5186. currentFrame = Math.floor((now - gameStartTimeStamp)/1000*30);
  5187. for(var i = 0; i<keys.length;i++){
  5188. if(typeof(playerids[keys[i]].lastmove)=="undefined"){
  5189. playerids[keys[i]].lastmove = now;
  5190. }
  5191. else{
  5192. if(playerids[keys[i]].playerData2?.alive && now-playerids[keys[i]].lastmove>=afkkill*1000 && now-gameStartTimeStamp>=afkkill*1000 && !killedids.includes(keys[i])){
  5193. killedids.push(keys[i]);
  5194. SEND('42[25,{"a":{"playersLeft":['+keys[i]+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  5195. RECIEVE('42[31,{"a":{"playersLeft":['+keys[i]+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  5196. break;
  5197. }
  5198. }
  5199. }
  5200. }
  5201. if(ishost && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS"){
  5202. clearmaprequests.style["display"] = "block";
  5203. refreshmaprequests.style["display"] = "block";
  5204. }
  5205. else{
  5206. clearmaprequests.style["display"] = "none";
  5207. refreshmaprequests.style["display"] = "none";
  5208. }
  5209. if(Gdocument.getElementById("gamerenderer").style["visibility"]=="hidden"){
  5210. Gdocument.getElementById("ingamewinner_scores").style["visibility"] = "unset";
  5211. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  5212. }
  5213. if(Gdocument.getElementById("maploadwindowmapscontainer").children.length>0 && maponclick == 0){
  5214. maponclick = Gdocument.getElementById("maploadwindowmapscontainer").children[0].onclick;
  5215. }
  5216. if((Gdocument.getElementById("sm_connectingContainer").style["visibility"] == "hidden" || Gdocument.getElementById("sm_connectingContainer").style["visibility"] == "") && (Gdocument.getElementById("roomlistcreatewindowcontainer").style["visibility"] == "hidden" || Gdocument.getElementById("roomlistcreatewindowcontainer").style["visibility"] == "")){
  5217. var chatbox = Gdocument.getElementById("newbonklobby_chat_content");
  5218. while (chatbox.firstChild) {
  5219. chatbox.removeChild(chatbox.firstChild);
  5220. }
  5221. rcaps_flag = false;
  5222. space_flag = false;
  5223. number_flag = false;
  5224. reverse_flag = false;
  5225. echo_list = [];
  5226. scroll = false;
  5227. FollowCam = false;
  5228. autocam = false;
  5229. aimbot = false;
  5230. recievedinitdata = false;
  5231. zoom = 1;
  5232. zoom2 = 1;
  5233. newzoom = 1;
  5234. newzoom2 = 1;
  5235. FFA = true;
  5236. mode = "b";
  5237. heavybot = false;
  5238. stopquickplay = 1;
  5239. roundsperqp = 1;
  5240. roundsperqp2 = 0;
  5241. checkboxhidden = false;
  5242. freejoin = false;
  5243. shuffle = false;
  5244. defaultmode = "";
  5245. recmodebool = false;
  5246. recteams = false;
  5247. autorecord = false;
  5248. pollactive = [false,0,0,[]];
  5249. pollactive2 = [false,0,[]];
  5250. afkkill = -1;
  5251. nextafter = 0;
  5252. jointext = "";
  5253. ishost = false;
  5254. parentDraw = 0;
  5255. sandboxplayerids = {};
  5256. sandboxcopyme = false;
  5257. wintext = "";
  5258. sandboxon = false;
  5259. sandboxid = 200;
  5260. disabledkeys = [];
  5261. myid = -1;
  5262. if(!bonkwss){
  5263. playerids = {};
  5264. }
  5265. qppaused = false;
  5266. nextafterbuffer = -1;
  5267. hostid = -1;
  5268. if(chatlog[chatlog.length-1]!="ROOM END"){
  5269. chatlog.push("ROOM END");
  5270. }
  5271. }
  5272. else{
  5273. if(chatlog[chatlog.length-1]=="ROOM END"){
  5274. chatlog.push("ROOM START");
  5275. }
  5276. }
  5277.  
  5278. if(Gdocument.getElementById("newbonklobby").style["display"]=="block"){
  5279. Gdocument.getElementById("ingamechatinputtext").style["visibility"]="hidden";
  5280. }
  5281. else{
  5282. Gdocument.getElementById("ingamechatinputtext").style["visibility"]="visible";
  5283.  
  5284. }
  5285. if(Gdocument.getElementsByClassName('newbonklobby_settings_button brownButton brownButton_classic buttonShadow brownButtonDisabled').length == 0){
  5286. ishost = true;
  5287. }
  5288. else{
  5289. ishost = actuallyhost;
  5290. }
  5291.  
  5292. if(Gdocument.getElementById("pretty_top_name")!=null){
  5293. username = Gdocument.getElementById("pretty_top_name").textContent;
  5294. if(myid!=-1){
  5295. username = playerids[myid].userName;
  5296. }
  5297. }
  5298. try{
  5299. Last_message = lastmessage()
  5300. } catch{
  5301. Last_message = "";
  5302. }
  5303. if (Laster_message != Last_message){
  5304. Laster_message = Last_message;
  5305. if(changed_chat==false){
  5306. new_message = true;
  5307. }
  5308. else{
  5309. changed_chat = false;
  5310. }
  5311. }
  5312. if(new_message){
  5313. chatlog.push(Last_message);
  5314. var lm = "";
  5315. try{
  5316. lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  5317. if(typeof(lm[0].parentElement.style["parsed"]) == 'undefined'){
  5318. if (lm[0].className == "newbonklobby_chat_msg_colorbox"){
  5319. lm[2].innerHTML = urlify(lm[2].innerHTML);
  5320. Laster_message = lastmessage();
  5321. lm[0].parentElement.style["parsed"] = true;
  5322. }
  5323. if (lm[0].className == "newbonklobby_chat_status"){
  5324. lm[0].innerHTML = urlify(lm[0].innerHTML);
  5325. Laster_message = lastmessage();
  5326. lm[0].parentElement.style["parsed"] = true;
  5327. }
  5328. }
  5329. }
  5330. catch{
  5331. lm = "";
  5332. }
  5333.  
  5334. if(Last_message.indexOf("@"+username)!=-1 && npermissions == 1){
  5335. if(Notification.requestPermission()){
  5336. var n = new Notification(Last_message);
  5337. }
  5338. }
  5339.  
  5340. try{
  5341. lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  5342. if(typeof(lm[0].parentElement.style["parsed"])=='undefined'){
  5343. if(lm[0].className == "ingamechatname"){
  5344. lm[1].innerHTML = urlify(lm[1].innerHTML);
  5345. Laster_message = lastmessage();
  5346. lm[0].parentElement.style["parsed"] = true;
  5347. }
  5348. if(lm[0].className == ""){
  5349. lm[0].innerHTML = urlify(lm[0].innerHTML);
  5350. Laster_message = lastmessage();
  5351. lm[0].parentElement.style["parsed"] = true;
  5352. }
  5353. }
  5354. }
  5355. catch{
  5356. lm = "";
  5357. }
  5358. if(text2speech){
  5359. if(!sayer.speaking){
  5360. if(Last_message.includes(": ")){
  5361. speech.text = Last_message.substring(0,Last_message.indexOf(":")).toLowerCase();
  5362. speech.rate = 2.25;
  5363. sayer.speak(speech);
  5364. speech.text = Last_message.substring(Last_message.indexOf(": ")+3).toLowerCase();
  5365. speech.rate = 1.25;
  5366. sayer.speak(speech);
  5367. }
  5368. else{
  5369. speech.text = Last_message.toLowerCase();
  5370. sayer.speak(speech);
  5371. }
  5372. }
  5373. }
  5374. }
  5375. if (ishost==true && new_message){
  5376. for(i=0;i<banned.length;i++){
  5377. if(Last_message.startsWith("* "+banned[i]+" has joined the game")){
  5378. chat2("/kick '"+banned[i]+"'");
  5379. }
  5380. }
  5381. }
  5382. if(Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden" && ishost){
  5383. roundsperqp2 = 0;
  5384. }
  5385. if(Gdocument.getElementById("ingamewinner").style["visibility"]=="inherit" && ishost){
  5386. if(Gdocument.getElementById("ingamewinner").style["parsed"] != true){
  5387. if(stopquickplay!=1){
  5388. roundsperqp2++;
  5389. }
  5390. if(autorecord){
  5391. Gdocument.getElementById("pretty_top_replay").click();
  5392. }
  5393. }
  5394. if(Gdocument.getElementById("ingamewinner").style["parsed"] != true && wintext!="" && Gdocument.getElementById("ingamewinner_bottom").textContent!="DRAW"){
  5395. chat(flag_manage(wintext.replaceAll("username",Gdocument.getElementById("ingamewinner_top").textContent)));
  5396. }
  5397. Gdocument.getElementById("ingamewinner").style["parsed"] = true;
  5398. }
  5399. else{
  5400. Gdocument.getElementById("ingamewinner").style["parsed"] = false;
  5401. }
  5402. if(ishost && stopquickplay == 0){
  5403. if(checkboxhidden){
  5404. checkboxhidden = false;
  5405. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  5406. for(var i = 0; i<classes.length;i++){
  5407. classes[i].style["display"] = "block";
  5408. classes[i].className = "quickplaycheckbox quickplaychecked";
  5409. }
  5410. Gdocument.getElementById('clearallcheckboxes').style["display"] = "block";
  5411.  
  5412. }
  5413. if(nextafter>0 && gameStartTimeStamp+nextafter*1000<=now && Gdocument.getElementById("gamerenderer").style["visibility"] != "hidden" && dontswitch == false && Gdocument.getElementById("ingamewinner").style["visibility"]!="inherit" && !qppaused){
  5414. roundsperqp2 = 0;
  5415. if(shuffle){
  5416. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  5417. var available = [];
  5418. var availableindexes = [];
  5419. var notempty = false;
  5420. for(var i = 0; i<e.length;i++){
  5421. var a = false;
  5422. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  5423. available.push(a);
  5424. if(a){
  5425. availableindexes.push(i);
  5426. notempty = true;
  5427. }
  5428. }
  5429. if(notempty){
  5430. if(availableindexes.length!=1){
  5431. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  5432. }
  5433. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  5434. }
  5435. }
  5436. else{
  5437. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  5438. var available = [];
  5439. var availableindexes = [];
  5440. var notempty = false;
  5441. for(var i = 0; i<e.length;i++){
  5442. var a = false;
  5443. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  5444. available.push(a);
  5445. if(a){
  5446. availableindexes.push(i);
  5447. notempty = true;
  5448. }
  5449. }
  5450. if(notempty){
  5451. var above = [];
  5452. for(var i = 0;i<availableindexes.length;i++){
  5453. if(availableindexes[i]>quicki){
  5454. above.push(availableindexes[i]);
  5455. }
  5456. }
  5457. if(above.length>0){
  5458. quicki = above[0];
  5459. }
  5460. else{
  5461. quicki = availableindexes[0];
  5462. }
  5463. }
  5464. }
  5465. startedinqp = true;
  5466. dontswitch = true;
  5467. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  5468. }
  5469. if(Gdocument.getElementById("ingamewinner").style["visibility"]=="inherit" && dontswitch == false && !document.hidden && !qppaused){
  5470. if(roundsperqp2>=roundsperqp){
  5471. if(shuffle){
  5472. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  5473. var available = [];
  5474. var availableindexes = [];
  5475. var notempty = false;
  5476. for(var i = 0; i<e.length;i++){
  5477. var a = false;
  5478. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  5479. available.push(a);
  5480. if(a){
  5481. availableindexes.push(i);
  5482. notempty = true;
  5483. }
  5484. }
  5485. if(notempty){
  5486.  
  5487. if(availableindexes.length!=1){
  5488. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  5489. }
  5490. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  5491. }
  5492. }
  5493. else{
  5494. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  5495. var available = [];
  5496. var availableindexes = [];
  5497. var notempty = false;
  5498. for(var i = 0; i<e.length;i++){
  5499. var a = false;
  5500. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  5501. available.push(a);
  5502. if(a){
  5503. availableindexes.push(i);
  5504. notempty = true;
  5505. }
  5506. }
  5507. if(notempty){
  5508. var above = [];
  5509. for(var i = 0;i<availableindexes.length;i++){
  5510. if(availableindexes[i]>quicki){
  5511. above.push(availableindexes[i]);
  5512. }
  5513. }
  5514. if(above.length>0){
  5515. quicki = above[0];
  5516. }
  5517. else{
  5518. quicki = availableindexes[0];
  5519. }
  5520. }
  5521. }
  5522. }
  5523. transitioning = true;
  5524. startedinqp = true;
  5525. map(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  5526. dontswitch = true;
  5527. setTimeout(function(){Gdocument.getElementById("ingamewinner").style["visibility"]="hidden"; dontswitch = false;},timedelay);
  5528. }
  5529. }
  5530. else{
  5531. if(!checkboxhidden){
  5532. checkboxhidden = true;
  5533. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  5534. for(var i = 0; i<classes.length;i++){
  5535. classes[i].style["display"] = "none";
  5536. classes[i].className = "quickplaycheckbox quickplayunchecked";
  5537. }
  5538. Gdocument.getElementById('clearallcheckboxes').style["display"] = "none";
  5539. }
  5540. }
  5541. new_message = false;
  5542. };
  5543. });