Bonk Commands

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

当前为 2023-03-22 提交的版本,查看 最新版本

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