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.1
  5. // @description Adds lots of commands to bonk.io. Type /? or /help in bonk chat to get started.
  6. // @author LEGENDBOSS123 + left paren + mastery3
  7. // @match https://bonk.io/*
  8. // @run-at document-idle
  9. // @grant none
  10. // @unwrap
  11. // ==/UserScript==
  12. function BonkCommandsScriptInjector(f){
  13. if(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":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1486. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"))
  1487. }
  1488. else{
  1489. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1490. fire("keydown",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"))
  1491. }
  1492. if(min<0.05){
  1493. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1494. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1495. }
  1496. }
  1497. else if(started>0){
  1498. started = 0;
  1499. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1500. fire("keyup",{"keyCode":leftRight[1]},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.keyCodes = {"BACK_SPACE":8,"TAB":9,"SHIFT":16,"ALT":18,"LEFT ARROW":37,"RIGHT ARROW":39,"DOWN ARROW":40,"UP ARROW":38,"CONTROL":17,"SPACE":32};
  2315. scope.leftRight = [37,39];
  2316. scope.positive = function(angle){
  2317. if(angle<0){
  2318. angle += 2*Math.PI;
  2319. }
  2320. return angle%(Math.PI*2);
  2321. };
  2322. scope.angle_between = function(angle,angle2){
  2323. return Math.min(Math.abs(positive(angle)-positive(angle2)),Math.PI*2-Math.abs(positive(angle)-positive(angle2)));
  2324. };
  2325. scope.angle_between2 = function(angle,angle2){
  2326. if(angle_between(angle,angle2+Math.PI/2)<Math.PI/2){
  2327. return 1;
  2328. }
  2329. return -1;
  2330. };
  2331.  
  2332. 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"];
  2333.  
  2334. scope.adv_help = {"help":"Shows all command names.",
  2335. "?":"Shows all command names.",
  2336. "advhelp":"Shows a command in detail.",
  2337. "space":"Toggles space. When space is on, whatever you type will be spaced apart.",
  2338. "rcaps":"Toggles rcaps. When rcaps is on, each letter will randomly get capitalized.",
  2339. "number":"Toggles number. When number is on, 'a' becomes 4, 'e' becomes 3, 's' becomes 5, 'o' becomes 0, 'l' and 'i' become 1.",
  2340. "speech":"Turns on text to speech for the chat.",
  2341. "echo":"Echoes a username. It copies the username's chat messages.",
  2342. "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.",
  2343. "remove":"Removes username from echo list. You will not echo that username anymore.",
  2344. "clearecho":"Clears echo list. You will not echo anyone anymore.",
  2345. "chatw":"It private chats with username. Type /msg to message that username.",
  2346. "msg":"Messages with what username you are chatting with. Type /chatw to chat with a username.",
  2347. "ignorepm":"Ignores the username's private chat messages. To unignore, type '/ignorepm [username]'.",
  2348. "pmusers":"Dispays who you can private chat with.",
  2349. "pollstat":"Displays the current poll and its votes.",
  2350. "eval":"Evaluates code. Only use this if you are experienced in javascript.",
  2351. "debugger":"Opens debugger.",
  2352. "lobby":"Makes lobby visible when you are ingame. Type '/lobby' again to close lobby.",
  2353. "score":"Displays the current score while ingame. Type '/score' again to hide the score.",
  2354. "team":"Joins a specific team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  2355. "scroll":"Toggles a scrollbar in ingame chat.",
  2356. "followcam":"Enables follow camera. Your character will be centered on the screen.",
  2357. "zoom":"Zooms in, out, or resets zoom.",
  2358. "xray":"Removes all shapes that don't have a shadow. This means all non-physics shapes will be hidden.",
  2359. "aimbot":"Toggles aimbot. Aimbot will aim for you in arrows or death arrows mode.",
  2360. "hidechat":"Hides ingame chat. Type '/showchat' to show it again.",
  2361. "showchat":"Shows ingame chat. '/hidechat' hides the chat.",
  2362. "notify":"You will be notified if a person types @username",
  2363. "stopnotify":"You will not be notified if a person types @username",
  2364. "support":"Displays many ways to support LEGENDBOSS123.",
  2365. "startqp":"Starts cycling maps in your map menu.",
  2366. "stopqp":"Stops cycling maps in your map menu.",
  2367. "pauseqp":"Only pauses the quickplay cycle due to round end. '/next', '/previous' still work. Type 'pauseqp' to unpause quickplay.",
  2368. "next":"Skips the map. Usable only with '/startqp'.",
  2369. "nextafter":"Skips the map if no one is able to win/draw within a certain amount of time.",
  2370. "previous":"Goes to previous map. Usable only with '/startqp'.",
  2371. "shuffle":"Makes quickplay play random maps instead of in order.",
  2372. "freejoin":"Toggles freejoin. If freejoin is on, starts the game instantly if there are 1 or less players currently playing.",
  2373. "recmode":"In quickplay, it switches mode to recommended mode, according to editor.",
  2374. "recteam":"In quickplay, it sorts people into teams when teams are necessary.",
  2375. "defaultmode":"Switches mode to defaultmode if there is no recmode.",
  2376. "start":"Starts game instantly.",
  2377. "instaqp":"Rounds will instantly start without a countdown.",
  2378. "balanceA":"Balances everyone with balance number.",
  2379. "moveA":"Sets everyones team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  2380. "rounds":"Sets rounds to win.",
  2381. "roundsperqp":"After that many rounds, the map will change. Normally, the map will change after 1 round.",
  2382. "autorecord":"After a round ends, automatically records the last 15 seconds.",
  2383. "mode":"If host, switches mode. Otherwise, it requests the host to switch mode, as long as the host has this mod.",
  2384. "disablekeys":"If anyone presses a disabled key, they get killed. Key options: left right up down heavy special.",
  2385. "jointext":"Chats the jointext whenever someone joins. \"username\" will get replaced by the joining person's username.",
  2386. "wintext":"Chats the wintext whenever someone wins. \"username\" will get replaced by the winning person's username.",
  2387. "afkkill":"If a person stays afk for that many seconds, they get automatically killed.",
  2388. "ban":"Bans username from lobby. If they rejoin, it automatically bans.",
  2389. "kill":"Kills the person ingame.",
  2390. "resetpoll":"Clears the poll.",
  2391. "addoption":"Adds the option to the poll. You can only have 4 maximum options. Type '/deloption [letter]' to remove an option.",
  2392. "deloption":"Removes the option with that letter.",
  2393. "startpoll":"Starts a poll that lasts for at least 10 seconds. Type '/endpoll' to end it early.",
  2394. "endpoll":"Ends the poll early if the poll lasted for at least 10 seconds.",
  2395. "addplayer":"In sandbox, it adds players.",
  2396. "delplayer":"In sandbox, it deletes players.",
  2397. "copyme":"In sandbox, it makes each player copy your movements.",
  2398. "Alt L":"Makes lobby visible when you are ingame. Press Alt L again to close lobby.",
  2399. "Alt C":"Hides ingame chat. Press Alt C again to show ingame chat.",
  2400. "Alt S":"Starts game instantly.",
  2401. "Alt T":"Toggles teams.",
  2402. "Alt N":"Enables follow camera. Your character will be centered on the screen.",
  2403. "Alt G":"Zooms in.",
  2404. "Alt H":"Resets zoom.",
  2405. "Alt J":"Zooms out.",
  2406. "Alt Y":"Enables xray. Removes all shapes that don't have a shadow. This means all non-physics shapes will be hidden.",
  2407. "Alt E":"Toggles editor.",
  2408. "Alt K":"Exits ingame and returns to lobby.",
  2409. "Alt M":"Switches modes.",
  2410. "Alt Q":"Toggles quickplay.",
  2411. "Alt B":"Displays the current score while ingame. Press Alt B again to hide the score.",
  2412. "Alt A":"Skips the map if quickplay is on.",
  2413. "Alt D":"Goes to previous map if quickplay is on.",
  2414. "Alt F":"Toggles freejoin. If freejoin is on, starts the game instantly if there are 1 or less players currently playing.",
  2415. "Alt R":"In quickplay, it switches mode to recommended mode, according to editor.",
  2416. "Alt I":"Opens debugger.",
  2417. "Alt <":"Lowers ingame chat height.",
  2418. "Alt >":"Highers ingame chat height."
  2419. };
  2420. scope.displayadvhelp = function(command){
  2421. displayInChat(adv_help[command],"#009398","#DA0808",{sanitize:true},"",true);
  2422. };
  2423. scope.changemode = function(mode){
  2424. SEND('42[20,{"ga":"b","mo":"'+mode+'"}]');
  2425. RECIEVE('42[26,"b","'+mode+'"]');
  2426. };
  2427. Gdocument.getElementById("ingamechatcontent").style["pointer-events"]="all";
  2428. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  2429. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  2430. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  2431.  
  2432. document.getElementById('adboxverticalCurse').style["display"] = "none";
  2433. document.getElementById('adboxverticalleftCurse').style["display"] = "none";
  2434. elem.onclick=function(e){
  2435. if(stopquickplay==0 && ishost == true && e.isTrusted == true){
  2436. quicki = (Array.from(e.target.parentElement.parentNode.children).indexOf(e.target.parentNode)-1)%(Gdocument.getElementById("maploadwindowmapscontainer").children.length);
  2437. }
  2438. };
  2439. scope.urlify = function(text) {
  2440. if(!Gdocument.getElementById('bl_Menu')){
  2441. return text.replace(/(?:https?:\/\/)?(?:[A-Za-z0-9-ßàÁâãóôþüúðæåïçèõöÿýòäœêëìíøùîûñé]+)(?:\.[A-Za-z0-9-ßàÁâãóôþüúðæåïçèõöÿýòäœêëìíøùîûñé]+)+(?:\/(?:[A-Za-z0-9-._~:/?#\[\]@!$&'()*+,;=]|%[0-9a-fA-F]{2})*)?(?:\?(?:[^=]+=[^&](?:&[^=]+=[^&])*)?)?/g, function(url) {
  2442. if(url.startsWith('https://') || url.startsWith('http://')){return '<a href="' + url + '" target="_blank" style = "color:orange">' + url + '</a>';}
  2443. else{return '<a href="https://' + url + '" target="_blank" style = "color:orange">' + url + '</a>';}
  2444. })}return text;
  2445. };
  2446.  
  2447. scope.fire = function(type,options,d = Gdocument){
  2448. var event= document.createEvent("HTMLEvents");
  2449. event.initEvent(type,true,false);
  2450. for(var p in options){
  2451. event[p]=options[p];
  2452. }
  2453. d.dispatchEvent(event);
  2454. };
  2455.  
  2456. scope.chat = function(message){
  2457. SEND('42[10,{"message":'+JSON.stringify(message)+'}]');
  2458. };
  2459. scope.chat2 = function(message,enteragain=false){
  2460. mess = Gdocument.getElementById("newbonklobby_chat_input").value;
  2461. mess2 = Gdocument.getElementById("ingamechatinputtext").value;
  2462. Gdocument.getElementById("newbonklobby_chat_input").value = message;
  2463. Gdocument.getElementById("ingamechatinputtext").value = message;
  2464. fire("keydown",{keyCode:13});
  2465. if(!enteragain){
  2466. fire("keydown",{keyCode:13});
  2467. }
  2468. Gdocument.getElementById("newbonklobby_chat_input").value = mess;
  2469. Gdocument.getElementById("ingamechatinputtext").value = mess2;
  2470. };
  2471. scope.displayInChat = function(message, LobbyColor, InGameColor, options, message2, BringDown) {
  2472. options = options ?? {};
  2473. BringDown = BringDown ?? false;
  2474. message2 = message2 ?? "";
  2475. LobbyColor = LobbyColor ?? "#8800FF";
  2476. InGameColor = InGameColor ?? "#AA88FF";
  2477. let A = Gdocument.createElement("div");
  2478. let B = Gdocument.createElement("span");
  2479. B.className = "newbonklobby_chat_status";
  2480. B.style.color = LobbyColor;
  2481. A.appendChild(B);
  2482. B.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  2483. B.innerHTML+=urlify(message2.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;'));
  2484. let C = Gdocument.createElement("div");
  2485. let D = Gdocument.createElement("span");
  2486. D.style.color = InGameColor;
  2487. C.appendChild(D);
  2488. D.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  2489. D.innerHTML+=urlify(message2.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;'));
  2490. let a = BringDown;
  2491. if(Gdocument.getElementById("newbonklobby_chat_content").clientHeight + Gdocument.getElementById("newbonklobby_chat_content").scrollTop >= Gdocument.getElementById("newbonklobby_chat_content").scrollHeight-1) {
  2492. a = true;
  2493. }
  2494. A.style["parsed"] = true;
  2495. C.style["parsed"] = true;
  2496. Gdocument.getElementById("newbonklobby_chat_content").appendChild(A);
  2497. Gdocument.getElementById("ingamechatcontent").appendChild(C);
  2498. if (a) { Gdocument.getElementById("newbonklobby_chat_content").scrollTop = Number.MAX_SAFE_INTEGER;};
  2499. Gdocument.getElementById("ingamechatcontent").scrollTop = Number.MAX_SAFE_INTEGER;
  2500. chat2("");
  2501. };
  2502.  
  2503. scope.lobby = function(){
  2504. if (Gdocument.getElementById("newbonklobby").style["display"]=="none"){
  2505.  
  2506. Gdocument.getElementById("newbonklobby_editorbutton").click();
  2507. Gdocument.getElementById("mapeditor_close").click();
  2508. if(Gdocument.getElementById("newbonklobby_playerbox_elementcontainer").children.length+Gdocument.getElementById("newbonklobby_specbox_elementcontainer").children.length-3>0){
  2509. Gdocument.getElementById("newbonklobby").style["z-index"]=1;
  2510. Gdocument.getElementById("maploadwindowcontainer").style["z-index"]=1;
  2511. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=1;
  2512. Gdocument.getElementById("pretty_top").style["z-index"]=3;
  2513. Gdocument.getElementById("settingsContainer").style["z-index"]=3;
  2514. Gdocument.getElementById("leaveconfirmwindow").style["z-index"]=3;
  2515. Gdocument.getElementById("hostleaveconfirmwindow").style["z-index"]=3;
  2516. debuggermenu.style["z-index"] = 2;
  2517. }
  2518. else{
  2519. Gdocument.getElementById("newbonklobby").style["opacity"]=0;
  2520. Gdocument.getElementById("newbonklobby").style["display"]="none";
  2521. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
  2522.  
  2523. }
  2524.  
  2525. }
  2526. else if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  2527. Gdocument.getElementById("newbonklobby").style["opacity"]=0;
  2528. Gdocument.getElementById("newbonklobby").style["display"]="none";
  2529. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
  2530.  
  2531. }
  2532. };
  2533.  
  2534. scope.lastmessage = function(){
  2535. if(Gdocument.getElementById("newbonklobby_chat_content").children.length!=0){
  2536. var lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  2537. var lm2 = "";
  2538. for(var i = 0; i<lm.length;i++){
  2539. lm2+=" "+lm[i].textContent.trim();
  2540. }
  2541. lm2 = lm2.trim();
  2542. if(lm2.startsWith("*")){
  2543. return lm2;
  2544. }
  2545. }
  2546. if(Gdocument.getElementById("ingamechatcontent").children.length!=0){
  2547. var lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  2548. var lm2 = "";
  2549. for(var i = 0; i<lm.length;i++){
  2550. lm2+=" "+lm[i].textContent.trim();
  2551. }
  2552. return lm2.trim();
  2553. }
  2554. return "";
  2555.  
  2556. };
  2557. scope.map = function(e,t=timedelay){
  2558. if(e<0){
  2559. displayInChat("There is no previous map.","#DA0808","#1EBCC1");
  2560. quicki = 0;
  2561. return;
  2562. }
  2563. if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
  2564. displayInChat("Click the maps button.","#DA0808","#1EBCC1");
  2565. return;
  2566. }
  2567.  
  2568. setTimeout(function(){if(!canceled){
  2569. startedinqp = true;
  2570. if(roundsperqp2>=roundsperqp){
  2571. roundsperqp2 = 0;
  2572. }
  2573. gameStartTimeStamp = Date.now();
  2574. Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
  2575. Gdocument.getElementById("newbonklobby_editorbutton").click();
  2576. if(recmodebool && ishost){
  2577. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  2578. if(mode == "" && defaultmode!="d"){
  2579. mode = defaultmode;
  2580. }
  2581. if(mode != ""){
  2582. RECIEVE('42[26,"b","'+mode+'"]');
  2583. }
  2584. }
  2585. var displayblock = Gdocument.getElementById("newbonklobby").style["display"] == "block";
  2586. Gdocument.getElementById("mapeditorcontainer").style["display"] = "none";
  2587. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  2588. if(displayblock){
  2589. Gdocument.getElementById("newbonklobby").style["display"] = "block";
  2590. }
  2591. Gdocument.getElementById("mapeditor_midbox_testbutton").click();}
  2592. canceled = false;
  2593. transitioning = false;
  2594. },t);
  2595.  
  2596. };
  2597.  
  2598. scope.gotonextmap = function(e){
  2599. if(e<0){
  2600. displayInChat("There is no previous map.","#DA0808","#1EBCC1");
  2601. quicki = 0;
  2602. return;
  2603. }
  2604. if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
  2605. displayInChat("Click the maps button.","#DA0808","#1EBCC1");
  2606. return;
  2607. }
  2608. Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
  2609. Gdocument.getElementById("newbonklobby_editorbutton").click();
  2610. if(recmodebool && ishost){
  2611. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  2612. if(mode == "" && defaultmode!="d"){
  2613. mode = defaultmode;
  2614. }
  2615. if(mode != ""){
  2616. RECIEVE('42[26,"b","'+mode+'"]');
  2617. }
  2618. }
  2619. startedinqp = true;
  2620. if(roundsperqp2>=roundsperqp){
  2621. roundsperqp2 = 0;
  2622. }
  2623. gameStartTimeStamp = Date.now();
  2624. var displayblock = Gdocument.getElementById("newbonklobby").style["display"] == "block";
  2625. Gdocument.getElementById("mapeditorcontainer").style["display"] = "none";
  2626. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  2627. if(displayblock){
  2628. Gdocument.getElementById("newbonklobby").style["display"] = "block";
  2629. }
  2630. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  2631. Gdocument.getElementById("newbonklobby").style["visibility"] = "visible";
  2632. };
  2633. scope.commandhandle = function(chat_val){
  2634. if (chat_val.substring(1,6)=="echo " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  2635. if (chat_val.substring(6).replace(/^\s+|\s+$/g, '')==username){
  2636. displayInChat("You cannot echo yourself.","#DA0808","#1EBCC1");
  2637. return "";
  2638. }
  2639. else if (echo_list.indexOf(chat_val.substring(6).replace(/^\s+|\s+$/g, ''))===-1) {
  2640.  
  2641. echo_list.push(chat_val.substring(6).replace(/^\s+|\s+$/g, ''));
  2642. displayInChat(chat_val.substring(6).replace(/^\s+|\s+$/g, '') + " is being echoed.","#DA0808","#1EBCC1");
  2643. return "";
  2644. }
  2645. else{
  2646. displayInChat(chat_val.substring(6).replace(/^\s+|\s+$/g, '') + " is already being echoed.","#DA0808","#1EBCC1");
  2647. return "";
  2648. }
  2649. }
  2650. else if (chat_val.substring(1,8)=="remove " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  2651. if (echo_list.indexOf(chat_val.substring(7).replace(/^\s+|\s+$/g, ''))!==-1){
  2652. echo_list.splice(echo_list.indexOf(chat_val.substring(7).replace(/^\s+|\s+$/g, '')),1);
  2653. displayInChat(chat_val.substring(7).replace(/^\s+|\s+$/g, '')+" is not being echoed.","#DA0808","#1EBCC1");
  2654. return "";
  2655. }
  2656. else{
  2657. displayInChat("You cannot remove someone that you didn't echo.","#DA0808","#1EBCC1");
  2658. return "";
  2659. }
  2660.  
  2661. }
  2662. else if (chat_val.substring(1,10)=="echotext " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  2663. echotext = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  2664. displayInChat("Set echotext as: "+echotext,"#DA0808","#1EBCC1");
  2665. displayInChat("Type '/echotext' to reset echotext.","#DA0808","#1EBCC1");
  2666. return "";
  2667.  
  2668. }
  2669. else if (chat_val.substring(1,9)=="echotext"){
  2670. echotext = "message";
  2671. displayInChat("Reset echotext.","#DA0808","#1EBCC1");
  2672. return "";
  2673.  
  2674. }
  2675. else if (chat_val.substring(1,10)=="clearecho"){
  2676. echo_list = [];
  2677. displayInChat("Cleared the echo list.","#DA0808","#1EBCC1");
  2678. return "";
  2679. }
  2680. else if (chat_val.substring(1,6)=="space"){
  2681. if(space_flag == true){
  2682. displayInChat("Space is now off.","#DA0808","#1EBCC1");
  2683. space_flag = false;
  2684. }
  2685. else{
  2686. displayInChat("Space is now on.","#DA0808","#1EBCC1");
  2687. space_flag = true;
  2688. }
  2689. return "";
  2690. }
  2691. else if (chat_val.substring(1,6)=="rcaps"){
  2692. if(rcaps_flag == true){
  2693. displayInChat("Rcaps is now off.","#DA0808","#1EBCC1");
  2694. rcaps_flag = false;
  2695. }
  2696. else{
  2697. displayInChat("Rcaps is now on.","#DA0808","#1EBCC1");
  2698. rcaps_flag = true;
  2699. }
  2700.  
  2701. return "";
  2702. }
  2703. else if (chat_val.substring(1,7)=="number"){
  2704. if(number_flag == true){
  2705. displayInChat("Number is now off.","#DA0808","#1EBCC1");
  2706. number_flag = false;
  2707. }
  2708. else{
  2709. displayInChat("Number is now on.","#DA0808","#1EBCC1");
  2710. number_flag = true;
  2711. }
  2712.  
  2713. return "";
  2714. }
  2715. else if (chat_val.substring(1,8)=="reverse"){
  2716. if(reverse_flag == true){
  2717. displayInChat("Reverse is now off.","#DA0808","#1EBCC1");
  2718. reverse_flag = false;
  2719. }
  2720. else{
  2721. displayInChat("Reverse is now on.","#DA0808","#1EBCC1");
  2722. reverse_flag = true;
  2723. }
  2724.  
  2725. return "";
  2726. }
  2727. else if (chat_val.substring(1,7)=="speech"){
  2728. if(text2speech == true){
  2729. displayInChat("Text to speech is now off.","#DA0808","#1EBCC1");
  2730. text2speech = false;
  2731. }
  2732. else{
  2733. displayInChat("Text to speech is now on.","#DA0808","#1EBCC1");
  2734. text2speech = true;
  2735. }
  2736.  
  2737. return "";
  2738. }
  2739. else if (chat_val.substring(1,6)=="eval " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  2740. var ev = "";
  2741. try{
  2742. ev = eval(chat_val.substring(6).replace(/^\s+|\s+$/g, ''));
  2743. }
  2744. catch(e){
  2745. displayInChat(e.message,"#DA0808","#1EBCC1");
  2746. }
  2747. try{
  2748. displayInChat(ev.toString(),"#DA0808","#1EBCC1");
  2749. }
  2750. catch{
  2751. }
  2752.  
  2753. return "";
  2754.  
  2755. }
  2756. else if (chat_val.substring(1,10)=="followcam"){
  2757. if(FollowCam == true){
  2758. displayInChat("Follow Camera is now off.","#DA0808","#1EBCC1");
  2759. FollowCam = false;
  2760. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  2761. var addto = {"children":[]};
  2762. for(var i = 0;i<parentDraw.children.length;i++){
  2763. if(parentDraw.children[i].constructor.name == "e"){
  2764. addto = parentDraw.children[i];
  2765. break;
  2766. }
  2767. }
  2768. var canv = 0;
  2769. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  2770. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  2771. canv = Gdocument.getElementById("gamerenderer").children[i];
  2772. break;
  2773. }
  2774. }
  2775. var width = parseInt(canv.style["width"]);
  2776. var height = parseInt(canv.style["height"]);
  2777. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  2778. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  2779. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  2780. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  2781. if(addto.scale.x>=0.95 && addto.scale.y>=0.95){
  2782. pixiCircle.visible = false;
  2783. }
  2784. else{
  2785. pixiCircle.visible = true;
  2786. }
  2787. }
  2788. }
  2789. else{
  2790. displayInChat("Follow Camera is now on.","#DA0808","#1EBCC1");
  2791. FollowCam = true;
  2792. }
  2793.  
  2794. return "";
  2795. }
  2796. else if (chat_val.substring(1,7)=="aimbot"){
  2797. if(aimbot == true){
  2798. displayInChat("Aimbot is now off.","#DA0808","#1EBCC1");
  2799. aimbot = false;
  2800. }
  2801. else{
  2802. displayInChat("Aimbot is now on.","#DA0808","#1EBCC1");
  2803. aimbot = true;
  2804. var keykeys = Object.keys(keyCodes);
  2805. var keyslist = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[1].children).slice(1);
  2806. var keyslist2 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[2].children).slice(1);
  2807. for(var i = 0;i<keyslist.length;i++){
  2808. if(keykeys.includes(keyslist[i].textContent)){
  2809. leftRight[0] = keyCodes[keyslist[i].textContent];
  2810. break;
  2811. }
  2812. else{
  2813. leftRight[0] = keyslist[i].textContent.charCodeAt(0);
  2814. break
  2815. }
  2816. }
  2817. for(var i = 0;i<keyslist2.length;i++){
  2818. if(keykeys.includes(keyslist2[i].textContent)){
  2819. leftRight[1] = keyCodes[keyslist2[i].textContent];
  2820. break;
  2821. }
  2822. else{
  2823. leftRight[1] = keyslist2[i].textContent.charCodeAt(0);
  2824. }
  2825. }
  2826. }
  2827.  
  2828. return "";
  2829. }
  2830. else if (chat_val.substring(1,5)=="xray"){
  2831. Gdocument.getElementById("pretty_top_settings").click();
  2832. Gdocument.getElementById("settings_close").click();
  2833. if(Gdocument.getElementById("settings_graphicsquality").value==1){
  2834. displayInChat("You must have medium or high quality enabled to use this feature.","#DA0808","#1EBCC1");
  2835. return "";
  2836. }
  2837.  
  2838.  
  2839. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  2840. var addto = {"children":[]};
  2841. for(var i = 0;i<parentDraw.children.length;i++){
  2842. if(parentDraw.children[i].constructor.name == "e"){
  2843. addto = parentDraw.children[i];
  2844. break;
  2845. }
  2846. }
  2847. var addto2 = {"children":[]};
  2848. for(var i = 0;i<addto.children.length;i++){
  2849. if(addto.children[i].constructor.name == "e"){
  2850. addto2 = addto.children[i];
  2851. break;
  2852. }
  2853. }
  2854. var checkxray = addto2.children[0];
  2855. var addto3 = addto2.children[0].children;
  2856. if(addto3.length==1){
  2857. checkxray = checkxray.children[0];
  2858. addto3 = addto3[0].children;
  2859. }
  2860. var xrayon = false;
  2861. if(checkxray.xrayon){
  2862. checkxray.xrayon = false;
  2863. xrayon = false;
  2864. }
  2865. else{
  2866. checkxray.xrayon = true;
  2867. xrayon = true;
  2868. }
  2869. if(xrayon){
  2870. displayInChat("Xray is now on.","#DA0808","#1EBCC1");
  2871. for(var i = 0;i<addto3.length;i++){
  2872. if(addto3[i].children.length>0){
  2873. for(var i3 = 0;i3<addto3[i].children.length;i3++){
  2874. addto3[i].children[i3].visible = false;
  2875. if(addto3[i].children[i3].children.length>0){
  2876. addto3[i].children[i3].visible = true;
  2877. }
  2878. }
  2879. }
  2880. }
  2881.  
  2882. }
  2883. else{
  2884. displayInChat("Xray is now off.","#DA0808","#1EBCC1");
  2885. for(var i = 0;i<addto3.length;i++){
  2886. for(var i2 = 0;i2<addto3[i].children.length;i2++){
  2887. addto3[i].children[i2].visible = true;
  2888. }
  2889. }
  2890. }
  2891. }
  2892.  
  2893. return "";
  2894. }
  2895. else if (chat_val.substring(1,6)=="zoom "){
  2896. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  2897. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  2898. var addto = 0;
  2899. for(var i = 0;i<parentDraw.children.length;i++){
  2900. if(parentDraw.children[i].constructor.name == "e"){
  2901. addto = parentDraw.children[i];
  2902. break;
  2903. }
  2904. }
  2905. var canv = 0;
  2906. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  2907. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  2908. canv = Gdocument.getElementById("gamerenderer").children[i];
  2909. break;
  2910. }
  2911. }
  2912. var width = parseInt(canv.style["width"]);
  2913. var height = parseInt(canv.style["height"]);
  2914. if(addto){
  2915. if(text == "in"){
  2916. addto.scale.x *= 1.1;
  2917. addto.scale.y *= 1.1;
  2918. }
  2919. else if(text == "out"){
  2920. addto.scale.x /= 1.1;
  2921. addto.scale.y /= 1.1;
  2922. }
  2923. else if(text == "reset"){
  2924. addto.scale.x = 1;
  2925. addto.scale.y = 1;
  2926. }
  2927. else{
  2928. displayInChat("Options for zooming:","#DA0808","#1EBCC1");
  2929. displayInChat("in","#DA0808","#1EBCC1");
  2930. displayInChat("out","#DA0808","#1EBCC1");
  2931. displayInChat("reset","#DA0808","#1EBCC1");
  2932. return "";
  2933. }
  2934. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  2935. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  2936. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  2937. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  2938. if(addto.scale.x>=0.95 && addto.scale.y>=0.95 && !FollowCam){
  2939. pixiCircle.visible = false;
  2940. }
  2941. else{
  2942. pixiCircle.visible = true;
  2943. }
  2944. }
  2945. }
  2946. return "";
  2947. }
  2948. else if (chat_val.substring(1,9)=="hidechat"){
  2949. Gdocument.getElementById("ingamechatcontent").style["max-height"]="0px";
  2950. return "";
  2951. }
  2952. else if (chat_val.substring(1,9)=="showchat"){
  2953. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  2954. return "";
  2955. }
  2956. else if (chat_val.substring(1,6)=="score"){
  2957. var element = Gdocument.getElementById("ingamewinner_scores");
  2958. element.style["visibility"] = "visible";
  2959. if(element.style["opacity"]<1){
  2960. element.style["opacity"] = 1;
  2961. }
  2962. else{
  2963. element.style["opacity"] = 0;
  2964. }
  2965. return "";
  2966. }
  2967.  
  2968. else if (chat_val.substring(1,7)=="scroll"){
  2969. if(scroll==false){
  2970. scroll = true;
  2971. Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="scroll";
  2972. Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
  2973. }
  2974. else if(scroll==true){
  2975. scroll = false;
  2976. Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="hidden";
  2977. Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
  2978. }
  2979.  
  2980. return "";
  2981. }
  2982.  
  2983. else if (chat_val.substring(1,7)=="chatw "){
  2984. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '');
  2985.  
  2986. if(username == text){
  2987. displayInChat("You cannot private chat with yourself.","#DA0808","#1EBCC1");
  2988. return "";
  2989. }
  2990. private_chat = text;
  2991.  
  2992. SEND("42"+JSON.stringify([4,{"type":"request public key","from":username,"to":private_chat}]));
  2993. request_public_key_time_stamp = Date.now();
  2994. 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);
  2995. return "";
  2996. }
  2997.  
  2998. else if (chat_val.substring(1,5)=="msg " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  2999. if(private_chat_public_key[1][0] != 0 && private_chat_public_key[1][1] != 0 && private_chat_public_key[0] == private_chat){
  3000. var text = chat_val.substring(5).replace(/^\s+|\s+$/g, '');
  3001. var password = [];
  3002. for(var i = 0;i<10;i++){
  3003. password.push(Math.floor(Math.random()*100+50));
  3004. }
  3005. var text2 = [];
  3006. for(var i = 0;i<text.slice(0,400).length ;i++){
  3007. text2.push(password[i%password.length]^text.slice(0,400).charCodeAt(i));
  3008. }
  3009. pmlastmessage = text.slice(0,400);
  3010. 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)}]));
  3011. displayInChat("> "+username+": ","#DA0808","#1EBCC1",{sanitize:false},text,false);
  3012. Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true;
  3013. Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true;
  3014. Laster_message = lastmessage();
  3015.  
  3016. }
  3017. return "";
  3018. }
  3019. else if (chat_val.substring(1,10)=="ignorepm " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  3020. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  3021. if(ignorepmlist.includes(text)){
  3022. var index = ignorepmlist.indexOf(text);
  3023. ignorepmlist.splice(index,1);
  3024. displayInChat("You are not ignoring private messages from "+text+".","#DA0808","#1EBCC1");
  3025.  
  3026. }
  3027. else{
  3028. ignorepmlist.push(text);
  3029. displayInChat("You are now ignoring private messages from "+text+".","#DA0808","#1EBCC1");
  3030. }
  3031. return "";
  3032. }
  3033. else if (chat_val.substring(1,8)=="pmusers"){
  3034. pmusers = [];
  3035. SEND("42"+JSON.stringify([4,{"type":"request private chat users","from":username}]));
  3036. pmuserstimestamp = Date.now();
  3037. setTimeout(function(){if(pmusers.length == 0){displayInChat("You cannot private chat with anyone.","#DA0808","#1EBCC1");
  3038. }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);
  3039. return "";
  3040. }
  3041. else if (chat_val.substring(1,6)=="lobby"){
  3042. lobby();
  3043. return "";
  3044. }
  3045. else if (chat_val.substring(1,9)=="debugger"){
  3046. if(Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"] == "none"){
  3047. debuggeropen = true;
  3048. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="block";
  3049. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="none";
  3050. Gdocument.getElementById("ingamechatinputtext").style["display"] = "none";
  3051. }
  3052. else{
  3053. debuggeropen = false;
  3054. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="none";
  3055. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  3056. Gdocument.getElementById("ingamechatinputtext").style["display"] = "";
  3057. }
  3058. return "";
  3059. }
  3060. else if (chat_val.substring(1,6)=="team " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  3061. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  3062. if(text == "r"){Gdocument.getElementById("newbonklobby_redbutton").click();}
  3063. else if(text == "g"){Gdocument.getElementById("newbonklobby_greenbutton").click();}
  3064. else if(text == "y"){Gdocument.getElementById("newbonklobby_yellowbutton").click();}
  3065. else if(text == "b"){Gdocument.getElementById("newbonklobby_bluebutton").click();}
  3066. else if(text == "s"){Gdocument.getElementById("newbonklobby_specbutton").click();}
  3067. else if(text == "f"){Gdocument.getElementById("newbonklobby_ffabutton").click();}
  3068. return "";
  3069. }
  3070. else if (chat_val.substring(1,7)=="notify"){
  3071.  
  3072. npermissions = 1;
  3073. return "";
  3074. }
  3075. else if (chat_val.substring(1,11)=="stopnotify"){
  3076.  
  3077. npermissions = 0;
  3078. return "";
  3079. }
  3080. else if (chat_val.substring(1,8)=="support"){
  3081. displayInChat("Thanks everyone for helping me make this mod - LEGENDBOSS123","#0000FF","#FFFFFF");
  3082. displayInChat("Join the giveaway here for a chance of winning an OP lvl 223 account:","#DA0808","#1EBCC1");
  3083. displayInChat("","#DA0808","#1EBCC1",{},"https://newskit.social/giveaways/BonkCommands-Giveaway-Account");
  3084. displayInChat("Get Bonk Commands Premium here:","#DA0808","#1EBCC1");
  3085. displayInChat("","#DA0808","#1EBCC1",{},"https://myshop.rocks/products/LEGENDBOSS123_BonkCommandsPremium");
  3086. npermissions = 0;
  3087. return "";
  3088. }
  3089. else if (chat_val.substring(1,9)=="pollstat"){
  3090. if(pollactive[0] || pollactive2[0]){
  3091. var count = [0,0,0,0];
  3092. var keys = Object.keys(playerids);
  3093. for(var i = 0;i<keys.length;i++){
  3094. if(ishost){
  3095. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive[3].length-1){
  3096. count[playerids[keys[i]].vote.poll]++;
  3097. }
  3098. }
  3099. else{
  3100. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive2[2].length-1){
  3101. count[playerids[keys[i]].vote.poll]++;
  3102. }
  3103. }
  3104. }
  3105. for(var i = 0;i<count.length;i++){
  3106. if(count[i]>1){
  3107. displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  3108. }
  3109. if(count[i]==1){
  3110. displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  3111. }
  3112. }
  3113. if(ishost){
  3114. displayInChat("The poll will end in: "+((pollactive[2]-Date.now())/1000).toString()+" seconds.","#DA0808","#1EBCC1");
  3115. }
  3116. displayInChat("The poll is:","#DA0808","#1EBCC1");
  3117. if(ishost){
  3118. for(var i = 0;i<pollactive[3].length;i++){
  3119. displayInChat(letters[i]+") "+pollactive[3][i],"#DA0808","#1EBCC1");
  3120. }
  3121. }
  3122. else{
  3123. for(var i = 0;i<pollactive2[2].length;i++){
  3124. displayInChat(letters[i]+") "+pollactive2[2][i],"#DA0808","#1EBCC1");
  3125. }
  3126. }
  3127. }
  3128. else{
  3129. displayInChat("No poll has been started.","#DA0808","#1EBCC1");
  3130. if(ishost){
  3131. displayInChat("Type '/startpoll [seconds]' to start a poll.","#DA0808","#1EBCC1");
  3132. if(poll.length>0){
  3133. displayInChat("The poll is:","#DA0808","#1EBCC1");
  3134. for(var i = 0;i<poll.length;i++){
  3135. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  3136. }
  3137. }
  3138. }
  3139. }
  3140. return "";
  3141. }
  3142. else if (chat_val.substring(1,5)=="help" || chat_val.substring(1,2)=="?"){
  3143. for(var i = 0;i<help.length;i++){
  3144. if(help[i].startsWith("/")){
  3145. var splitted = help[i].substring(1).split(" ");
  3146. var command = splitted[0];
  3147. var rest = "";
  3148. if(splitted.length>1){
  3149. rest = " "+splitted.slice(1).join(" ");
  3150. }
  3151. displayInChat("/"+'<a onclick = \'Gwindow.displayadvhelp("'+command+'");\' style = "color:green;" href = "javascript:void(0);">'+command+'</a>'+rest,"#DA0808","#1EBCC1",{sanitize:false},"",false);
  3152. }
  3153. else if(help[i].startsWith("Alt ")){
  3154. displayInChat('<a onclick = \'Gwindow.displayadvhelp("'+help[i]+'");\' style = "color:green;" href = "javascript:void(0);">'+help[i]+'</a>',"#DA0808","#1EBCC1",{sanitize:false},"",false);
  3155. }
  3156. else{
  3157. displayInChat(help[i],"#DA0808","#1EBCC1");
  3158. }
  3159.  
  3160. }
  3161. return "";
  3162. }
  3163. else if (chat_val.substring(1,9)=="advhelp " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  3164. var text = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  3165. if(typeof(adv_help[text])!='undefined'){
  3166. displayInChat(adv_help[text],"#DA0808","#1EBCC1");
  3167. }
  3168. return "";
  3169. }
  3170. else if (chat_val.substring(1,6)=="mode " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  3171. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  3172. var mode = "";
  3173. var text2 = text;
  3174. if(text == "arrows"){
  3175. text2 = "Arrows";
  3176. mode = "ar";
  3177. }
  3178. else if(text == "death arrows"){
  3179. mode = "ard";
  3180. text2 = "Death Arrows";
  3181. }
  3182. else if(text == "grapple"){
  3183. mode = "sp";
  3184. text2 = "Grapple";
  3185. }
  3186. else if(text == "classic"){
  3187. mode = "b";
  3188. text2 = "Classic";
  3189. }
  3190. else{
  3191. displayInChat("Mode options:","#DA0808","#1EBCC1");
  3192. displayInChat("classic","#DA0808","#1EBCC1");
  3193. displayInChat("arrows","#DA0808","#1EBCC1");
  3194. displayInChat("death arrows","#DA0808","#1EBCC1");
  3195. displayInChat("grapple","#DA0808","#1EBCC1");
  3196. }
  3197. if(mode != ""){
  3198. if(ishost){
  3199. SEND('42[20,{"ga":"b","mo":"'+mode+'"}]');
  3200. RECIEVE('42[26,"b","'+mode+'"]');
  3201. displayInChat("Changed mode to "+text+".","#DA0808","#1EBCC1");
  3202. }
  3203. else{
  3204. if(playerids[myid].ratelimit.mode+1000<Date.now()){
  3205. playerids[myid].ratelimit.mode=Date.now();
  3206. SEND("42"+JSON.stringify([4,{"type":"request mode","from":username,"mode":mode}]));
  3207. var code = 'if(!Gwindow.ishost){Gwindow.displayInChat("You must be host to change the mode.","#DA0808","#1EBCC1",{sanitize:false},"",true)}else{Gwindow.changemode("'+mode+'")}';
  3208. displayInChat('> '+username+' requests [<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+text2+'</a>]',"#DA0808","#1EBCC1",{sanitize:false}," mode.");
  3209.  
  3210. }
  3211. else{
  3212. displayInChat("You are requesting modes too quickly.","#DA0808","#1EBCC1");
  3213. }
  3214. }
  3215. }
  3216. return "";
  3217.  
  3218. }
  3219. else if(ishost){
  3220. if (chat_val.substring(1,11)=="nextafter " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  3221. var text = parseFloat(chat_val.substring(11).replace(/^\s+|\s+$/g, ''));
  3222. if(isNaN(text)){
  3223. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  3224. return "";
  3225. }
  3226. else if(text<=0){
  3227. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  3228. return "";
  3229. }
  3230. nextafter = text;
  3231. displayInChat("Set next after to: " + text.toString()+" seconds.","#DA0808","#1EBCC1");
  3232. displayInChat("Type '/nextafter' to reset next after.","#DA0808","#1EBCC1");
  3233. return "";
  3234.  
  3235. }
  3236. else if (chat_val.substring(1,10)=="nextafter"){
  3237. nextafter = 0;
  3238. displayInChat("Reset next after.","#DA0808","#1EBCC1");
  3239. return "";
  3240.  
  3241. }
  3242. else if (chat_val.substring(1,5)=="next" && stopquickplay == 0){
  3243. roundsperqp2 = 0;
  3244. if(shuffle){
  3245. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  3246. var available = [];
  3247. var availableindexes = [];
  3248. var notempty = false;
  3249. for(var i = 0; i<e.length;i++){
  3250. var a = false;
  3251. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  3252. available.push(a);
  3253. if(a){
  3254. availableindexes.push(i);
  3255. notempty = true;
  3256. }
  3257. }
  3258. if(notempty){
  3259.  
  3260. if(availableindexes.length!=1){
  3261. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  3262. }
  3263. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  3264. }
  3265. }
  3266. else{
  3267. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  3268. var available = [];
  3269. var availableindexes = [];
  3270. var notempty = false;
  3271. for(var i = 0; i<e.length;i++){
  3272. var a = false;
  3273. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  3274. available.push(a);
  3275. if(a){
  3276. availableindexes.push(i);
  3277. notempty = true;
  3278. }
  3279. }
  3280. if(notempty){
  3281. var above = [];
  3282. for(var i = 0;i<availableindexes.length;i++){
  3283. if(availableindexes[i]>quicki){
  3284. above.push(availableindexes[i]);
  3285. }
  3286. }
  3287. if(above.length>0){
  3288. quicki = above[0];
  3289. }
  3290. else{
  3291. quicki = availableindexes[0];
  3292. }
  3293. }
  3294. }
  3295. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  3296. displayInChat("Switched to next map.","#DA0808","#1EBCC1");
  3297. return "";
  3298.  
  3299. }
  3300. else if (chat_val.substring(1,9)=="freejoin"){
  3301. if(freejoin == false){
  3302. freejoin = true;
  3303. displayInChat("Freejoin is now on.","#DA0808","#1EBCC1");
  3304.  
  3305. }
  3306. else{
  3307. freejoin = false;
  3308. displayInChat("Freejoin is now off.","#DA0808","#1EBCC1");
  3309. }
  3310.  
  3311. return "";
  3312.  
  3313. }
  3314. else if (chat_val.substring(1,8)=="instaqp"){
  3315. if(instaqp == false){
  3316. instaqp = true;
  3317. displayInChat("Instaqp is now on.","#DA0808","#1EBCC1");
  3318.  
  3319. }
  3320. else{
  3321. instaqp = false;
  3322. displayInChat("Instaqp is now off.","#DA0808","#1EBCC1");
  3323. }
  3324.  
  3325. return "";
  3326.  
  3327. }
  3328.  
  3329. else if (chat_val.substring(1,9)=="previous" && stopquickplay == 0){
  3330. roundsperqp2 = 0;
  3331. if(shuffle){
  3332. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  3333. var available = [];
  3334. var availableindexes = [];
  3335. var notempty = false;
  3336. for(var i = 0; i<e.length;i++){
  3337. var a = false;
  3338. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  3339. available.push(a);
  3340. if(a){
  3341. availableindexes.push(i);
  3342. notempty = true;
  3343. }
  3344. }
  3345. if(notempty){
  3346.  
  3347. if(availableindexes.length!=1){
  3348. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  3349. }
  3350. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  3351. }
  3352. }
  3353. else{
  3354. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  3355. var available = [];
  3356. var availableindexes = [];
  3357. var notempty = false;
  3358. for(var i = 0; i<e.length;i++){
  3359. var a = false;
  3360. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  3361. available.push(a);
  3362. if(a){
  3363. availableindexes.push(i);
  3364. notempty = true;
  3365. }
  3366. }
  3367. if(notempty){
  3368. var above = [];
  3369. for(var i = 0;i<availableindexes.length;i++){
  3370. if(availableindexes[i]<quicki){
  3371. above.push(availableindexes[i]);
  3372. }
  3373. }
  3374. if(above.length>0){
  3375. quicki = above[above.length-1];
  3376. }
  3377. else{
  3378. quicki = availableindexes[availableindexes.length-1];
  3379. }
  3380. }
  3381. }
  3382. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  3383.  
  3384. displayInChat("Switched to previous map.","#DA0808","#1EBCC1");
  3385. return "";
  3386. }
  3387. else if (chat_val.substring(1,6)=="start" && chat_val.length == 6){
  3388. Gdocument.getElementById("newbonklobby_editorbutton").click();
  3389. if(recmodebool && ishost){
  3390. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  3391. if(mode == "" && defaultmode!="d"){
  3392. mode = defaultmode;
  3393. }
  3394. if(mode != ""){
  3395. RECIEVE('42[26,"b","'+mode+'"]');
  3396. }
  3397. }
  3398. Gdocument.getElementById("mapeditor_close").click();
  3399. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  3400. roundsperqp2 = 0;
  3401. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  3402.  
  3403. return "";
  3404. }
  3405.  
  3406. else if (chat_val.substring(1,8)=="startqp" && stopquickplay == 1){
  3407. stopquickplay = 0;
  3408. quicki = 0;
  3409. qppaused = false;
  3410. displayInChat("Enabled quickplay.","#DA0808","#1EBCC1");
  3411. return "";
  3412. }
  3413. else if (chat_val.substring(1,7)=="stopqp" && stopquickplay == 0){
  3414. stopquickplay = 1;
  3415. quicki = 0;
  3416. qppaused = false;
  3417. displayInChat("Disabled quickplay.","#DA0808","#1EBCC1");
  3418. return "";
  3419. }
  3420. else if (chat_val.substring(1,8)=="pauseqp" && stopquickplay == 0){
  3421. if(qppaused == false){
  3422. qppaused = true;
  3423. displayInChat("Paused quickplay.","#DA0808","#1EBCC1");
  3424. }
  3425. else{
  3426. qppaused = false;
  3427. displayInChat("Unpaused quickplay.","#DA0808","#1EBCC1");
  3428. }
  3429. return "";
  3430. }
  3431.  
  3432. else if (chat_val.substring(1,5)=="ban " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  3433. banned.push(chat_val.substring(5).replace(/^\s+|\s+$/g, ''));
  3434. displayInChat("Banned "+chat_val.substring(5).replace(/^\s+|\s+$/g, '')+".","#DA0808","#1EBCC1");
  3435. return "/kick '" + chat_val.substring(5).replace(/^\s+|\s+$/g, '') + "'";
  3436. }
  3437. else if (chat_val.substring(1,6)=="kill " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  3438. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  3439. var keys = Object.keys(playerids);
  3440. var killid = undefined;
  3441. for(var i = 0; i<keys.length; i++){
  3442. if(playerids[keys[i]].userName == text){
  3443. killid = keys[i];
  3444. }
  3445. }
  3446. if(typeof(killid)!="undefined" && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden" && !killedids.includes(killid)){
  3447. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  3448. killedids.push(killid);
  3449. SEND('42[25,{"a":{"playersLeft":['+killid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  3450. RECIEVE('42[31,{"a":{"playersLeft":['+killid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  3451. }
  3452. return "";
  3453. }
  3454. else if (chat_val.substring(1,10)=="balanceA " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  3455. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  3456. if(!isNaN(parseInt(text))){
  3457. if(parseInt(text)>=-100 && parseInt(text)<=100){
  3458. var keys = Object.keys(playerids);
  3459. for(var i = 0; i<keys.length;i++){
  3460. SEND('42[29,{"sid":'+keys[i]+',"bal":'+text+'}]');
  3461. RECIEVE('42[36,'+keys[i]+','+text+']');
  3462. }
  3463. }
  3464. }
  3465. return "";
  3466.  
  3467. }
  3468. else if (chat_val.substring(1,10)=="resetpoll"){
  3469. poll = [];
  3470. displayInChat("The poll has been reset.","#DA0808","#1EBCC1");
  3471. return "";
  3472. }
  3473. else if (chat_val.substring(1,11)=="addoption " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  3474. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  3475. if(text.length>50){
  3476. displayInChat("Your option is greater than 50 characters.","#DA0808","#1EBCC1");
  3477. return "";
  3478. }
  3479. if(poll.includes(text)){
  3480. displayInChat("This option already exists.","#DA0808","#1EBCC1");
  3481. }
  3482. else if(poll.length>=4){
  3483. displayInChat("Your poll already has the max 4 amounts of options.","#DA0808","#1EBCC1");
  3484. displayInChat("Type '/deloption [letter]' to remove a option.","#DA0808","#1EBCC1");
  3485. displayInChat("The poll is:","#DA0808","#1EBCC1");
  3486. for(var i = 0;i<poll.length;i++){
  3487. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  3488. }
  3489. }
  3490. else{
  3491. poll.push(text);
  3492. displayInChat("The poll is now:","#DA0808","#1EBCC1");
  3493. for(var i = 0;i<poll.length;i++){
  3494. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  3495. }
  3496. }
  3497. return "";
  3498. }
  3499. else if (chat_val.substring(1,11)=="deloption " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  3500. var text = letters.indexOf(chat_val.substring(11).replace(/^\s+|\s+$/g, ''));
  3501. if(text==-1 || text>=poll.length){
  3502. if(poll.length>0){
  3503. displayInChat("Available options are:","#DA0808","#1EBCC1");
  3504. for(var i = 0;i<poll.length;i++){
  3505. displayInChat(letters[i],"#DA0808","#1EBCC1");
  3506. }
  3507. }
  3508. else{
  3509. displayInChat("Your poll is empty.","#DA0808","#1EBCC1");
  3510. displayInChat("Type '/addoption [text]' to add an option.","#DA0808","#1EBCC1");
  3511. }
  3512. }
  3513. else{
  3514. poll.splice(text,1);
  3515. displayInChat("The poll is now:","#DA0808","#1EBCC1");
  3516. for(var i = 0;i<poll.length;i++){
  3517. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  3518. }
  3519. }
  3520. return "";
  3521. }
  3522. else if (chat_val.substring(1,11)=="startpoll " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  3523. var text = parseFloat(chat_val.substring(11).replace(/^\s+|\s+$/g, ''));
  3524. if(isNaN(text)){
  3525. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  3526. return "";
  3527. }
  3528. else if(text<=0){
  3529. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  3530. return "";
  3531. }
  3532. else if(text<10){
  3533. displayInChat("Your poll has to last for at least 10 seconds.","#DA0808","#1EBCC1");
  3534. return "";
  3535. }
  3536. if(pollactive[0]){
  3537. displayInChat("There is already an ongoing poll.","#DA0808","#1EBCC1");
  3538. displayInChat("Type '/endpoll' to end the poll.","#DA0808","#1EBCC1");
  3539. return "";
  3540. }
  3541. if(poll.length<2){
  3542. displayInChat("Your poll needs at least 2 options.","#DA0808","#1EBCC1");
  3543. displayInChat("Type '/addoption' to add to the poll.","#DA0808","#1EBCC1");
  3544. return "";
  3545. }
  3546. var now = Date.now();
  3547. pollactive = [true,now,now+text*1000,[...poll]];
  3548. playerids[myid].ratelimit.poll = now;
  3549. var chatpoll = [...poll];
  3550. chatpoll.push("Cancel vote.");
  3551. pollactive[3].push("Cancel vote.");
  3552. for(var i = 0;i<chatpoll.length;i++){
  3553. chatpoll[i] = letters[i]+") "+chatpoll[i];
  3554. }
  3555. chat(chatpoll.join("     "));
  3556. setTimeout(function(){
  3557. if(pollactive[0]){
  3558. SEND("42"+JSON.stringify([4,{"type":"poll","from":username,"poll":pollactive[3]}]));
  3559. var keys = Object.keys(playerids);
  3560. for(var i = 0;i<keys.length;i++){
  3561. playerids[keys[i]].vote.poll = -1;
  3562. }
  3563. displayInChat("The poll will end in: " + text.toString()+" seconds.","#DA0808","#1EBCC1");
  3564. displayInChat("Type '/endpoll' to end the poll early.","#DA0808","#1EBCC1");
  3565. }
  3566. },200);
  3567. return "";
  3568. }
  3569. else if (chat_val.substring(1,8)=="endpoll"){
  3570. if(pollactive[0]){
  3571. if(playerids[myid].ratelimit.poll+10000>Date.now()){
  3572. displayInChat("Your poll has to be at least 10 seconds.","#DA0808","#1EBCC1");
  3573. displayInChat("There are "+((playerids[myid].ratelimit.poll+10000-Date.now())/1000).toString()+" seconds left until you can end the poll early.","#DA0808","#1EBCC1");
  3574. return "";
  3575. }
  3576. playerids[myid].ratelimit.poll = Date.now();
  3577. SEND("42"+JSON.stringify([4,{"type":"poll end","from":username}]));
  3578. displayInChat("The poll ended.","#DA0808","#1EBCC1");
  3579. var count = [0,0,0,0];
  3580. var keys = Object.keys(playerids);
  3581. for(var i = 0;i<keys.length;i++){
  3582. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive[3].length-1){
  3583. count[playerids[keys[i]].vote.poll]++;
  3584. }
  3585. playerids[keys[i]].vote.poll = -1;
  3586. }
  3587. for(var i = 0;i<count.length;i++){
  3588. if(count[i]>1){
  3589. displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  3590. }
  3591. if(count[i]==1){
  3592. displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  3593. }
  3594. }
  3595. displayInChat("The poll was:","#DA0808","#1EBCC1");
  3596. for(var i = 0;i<pollactive[3].length;i++){
  3597. displayInChat(letters[i]+") "+pollactive[3][i],"#DA0808","#1EBCC1");
  3598. }
  3599. pollactive = [false,0,0,[]];
  3600. }
  3601. else{
  3602. displayInChat("No poll has been started","#DA0808","#1EBCC1");
  3603. displayInChat("Type '/startpoll [seconds]' to start a poll.","#DA0808","#1EBCC1");
  3604. }
  3605. return "";
  3606. }
  3607. else if (chat_val.substring(1,7)=="moveA " && chat_val.replace(/^\s+|\s+$/g, '').length>=8){
  3608. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '');
  3609. var keys = Object.keys(playerids);
  3610. if(text == "f"){
  3611. for(var i = 0; i<keys.length;i++){
  3612. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":1}]')
  3613. }
  3614. }
  3615. else if(text == "b"){
  3616. for(var i = 0; i<keys.length;i++){
  3617. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":3}]')
  3618. }
  3619. }
  3620. else if(text == "g"){
  3621. for(var i = 0; i<keys.length;i++){
  3622. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":4}]')
  3623. }
  3624. }
  3625. else if(text == "r"){
  3626. for(var i = 0; i<keys.length;i++){
  3627. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":2}]')
  3628. }
  3629. }
  3630. else if(text == "y"){
  3631. for(var i = 0; i<keys.length;i++){
  3632. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":5}]')
  3633. }
  3634. }
  3635. else if(text == "s"){
  3636. for(var i = 0; i<keys.length;i++){
  3637. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":0}]')
  3638. }
  3639. }
  3640. return "";
  3641. }
  3642. if (chat_val.substring(1,13)=="roundsperqp " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  3643. var text = parseInt(chat_val.substring(13).replace(/^\s+|\s+$/g, ''));
  3644. if(isNaN(text)){
  3645. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  3646. return "";
  3647. }
  3648. else if(text<=0){
  3649. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  3650. return "";
  3651. }
  3652. roundsperqp = text;
  3653. roundsperqp2 = 0;
  3654. displayInChat("Set rounds per quickplay to: " + text.toString(),"#DA0808","#1EBCC1");
  3655. displayInChat("Type '/roundsperqp' to reset rounds per quickplay.","#DA0808","#1EBCC1");
  3656. return "";
  3657.  
  3658. }
  3659. else if (chat_val.substring(1,12)=="roundsperqp"){
  3660. roundsperqp = 1;
  3661. roundsperqp2 = 0;
  3662. displayInChat("Reset rounds per quickplay.","#DA0808","#1EBCC1");
  3663. return "";
  3664.  
  3665. }
  3666. else if (chat_val.substring(1,8)=="rounds " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  3667. var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '');
  3668. if(!isNaN(parseInt(text))){
  3669. text = parseInt(text).toString();
  3670. SEND('42[21,{"w":'+text+'}]');
  3671. RECIEVE('42[27,'+text+']');
  3672. }
  3673. return "";
  3674.  
  3675. }
  3676. else if (chat_val.substring(1,13)=="disablekeys " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  3677. var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '');
  3678. var keys = text.split(" ");
  3679. var disabledkeys2 = [];
  3680. var possiblekeys = ["left","right","up","down","heavy","special"];
  3681. for(var i = 0; i<keys.length; i++){
  3682. if(keys[i]!="" && !disabledkeys2.includes(keys[i])){
  3683. if(possiblekeys.includes(keys[i])){
  3684. disabledkeys2.push(keys[i]);
  3685. }
  3686. else{
  3687. displayInChat("Key options: " + possiblekeys.join(" ") + ".","#DA0808","#1EBCC1");
  3688. return "";
  3689. }
  3690. }
  3691. }
  3692. disabledkeys = disabledkeys2;
  3693. displayInChat("Set disabled keys to: " + disabledkeys.join(" ") + ".","#DA0808","#1EBCC1");
  3694. displayInChat("Type '/disablekeys' to reset disabled keys.","#DA0808","#1EBCC1");
  3695. return "";
  3696.  
  3697. }
  3698. else if (chat_val.substring(1,12)=="disablekeys"){
  3699. displayInChat("Reset disabled keys.","#DA0808","#1EBCC1");
  3700. disabledkeys = [];
  3701. return "";
  3702.  
  3703. }
  3704. else if (chat_val.substring(1,10)=="jointext " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  3705. jointext = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  3706. displayInChat("Set jointext to: " + jointext,"#DA0808","#1EBCC1");
  3707. displayInChat("Type '/jointext' to reset jointext.","#DA0808","#1EBCC1");
  3708. return "";
  3709.  
  3710. }
  3711. else if (chat_val.substring(1,9)=="jointext"){
  3712. jointext = "";
  3713. displayInChat("Reset jointext.","#DA0808","#1EBCC1");
  3714. return "";
  3715.  
  3716. }
  3717. else if (chat_val.substring(1,9)=="wintext " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  3718. wintext = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  3719. displayInChat("Set wintext to: " + wintext,"#DA0808","#1EBCC1");
  3720. displayInChat("Type '/wintext' to reset wintext.","#DA0808","#1EBCC1");
  3721. return "";
  3722.  
  3723. }
  3724. else if (chat_val.substring(1,8)=="wintext"){
  3725. wintext = "";
  3726. displayInChat("Reset wintext.","#DA0808","#1EBCC1");
  3727. return "";
  3728.  
  3729. }
  3730. else if (chat_val.substring(1,11)=="autorecord"){
  3731. if(autorecord){
  3732. autorecord = false;
  3733. displayInChat("Autorecord is now off.","#DA0808","#1EBCC1");
  3734. }
  3735. else{
  3736. autorecord = true;
  3737. displayInChat("Autorecord is now on.","#DA0808","#1EBCC1");
  3738. }
  3739. return "";
  3740.  
  3741. }
  3742. else if (chat_val.substring(1,9)=="afkkill " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  3743. var text = parseFloat(chat_val.substring(9).replace(/^\s+|\s+$/g, ''));
  3744. if(!isNaN(text)){
  3745. if(text>0){
  3746. displayInChat("Set afk kill to: " + text.toString()+" seconds.","#DA0808","#1EBCC1");
  3747. displayInChat("Type '/afkkill' to reset afk kill.","#DA0808","#1EBCC1");
  3748. var keys = Object.keys(playerids);
  3749. var now = Date.now();
  3750. for(var i = 0;i<keys.length;i++){
  3751. playerids[keys[i]].lastmove = now;
  3752. }
  3753. afkkill = text;
  3754. }
  3755. else{
  3756. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  3757. }
  3758. }
  3759. else{
  3760. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  3761. }
  3762. return "";
  3763.  
  3764. }
  3765. else if (chat_val.substring(1,9)=="afkkill"){
  3766. afkkill = -1;
  3767. displayInChat("Reset afk kill.","#DA0808","#1EBCC1");
  3768. return "";
  3769.  
  3770. }
  3771. else if (chat_val.substring(1,13)=="defaultmode " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  3772. var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '');
  3773. if(text == "default"){
  3774. defaultmode = "";
  3775. displayInChat("Changed default mode to default.","#DA0808","#1EBCC1");
  3776. }
  3777. else if(text == "arrows"){
  3778. defaultmode = "ar";
  3779. displayInChat("Changed default mode to arrows.","#DA0808","#1EBCC1");
  3780. }
  3781. else if(text == "death arrows"){
  3782. defaultmode = "ard";
  3783. displayInChat("Changed default mode to death arrows.","#DA0808","#1EBCC1");
  3784. }
  3785. else if(text == "grapple"){
  3786. defaultmode = "sp";
  3787. displayInChat("Changed default mode to grapple.","#DA0808","#1EBCC1");
  3788. }
  3789. else if(text == "classic"){
  3790. defaultmode = "b";
  3791. displayInChat("Changed default mode to classic.","#DA0808","#1EBCC1");
  3792.  
  3793. }
  3794. else{
  3795. displayInChat("Default mode options:","#DA0808","#1EBCC1");
  3796. displayInChat("default","#DA0808","#1EBCC1");
  3797. displayInChat("classic","#DA0808","#1EBCC1");
  3798. displayInChat("arrows","#DA0808","#1EBCC1");
  3799. displayInChat("death arrows","#DA0808","#1EBCC1");
  3800. displayInChat("grapple","#DA0808","#1EBCC1");
  3801. }
  3802. return "";
  3803.  
  3804. }
  3805. else if (chat_val.substring(1,8)=="recmode"){
  3806. if(recmodebool == true){
  3807. recmodebool = false;
  3808. displayInChat("Recmode is now off.","#DA0808","#1EBCC1");
  3809.  
  3810. }
  3811. else{
  3812. recmodebool = true;
  3813. displayInChat("Recmode is now on.","#DA0808","#1EBCC1");
  3814.  
  3815. }
  3816.  
  3817. return "";
  3818.  
  3819. }
  3820. else if (chat_val.substring(1,8)=="recteam"){
  3821. if(recteams == true){
  3822. recteams = false;
  3823. displayInChat("Recteam is now off.","#DA0808","#1EBCC1");
  3824.  
  3825. }
  3826. else{
  3827. recteams = true;
  3828. displayInChat("Recteam is now on.","#DA0808","#1EBCC1");
  3829.  
  3830. }
  3831. return "";
  3832. }
  3833. else if (chat_val.substring(1,8)=="shuffle"){
  3834. if(shuffle == true){
  3835. shuffle = false;
  3836. displayInChat("Shuffle is now off.","#DA0808","#1EBCC1");
  3837.  
  3838. }
  3839. else{
  3840. shuffle = true;
  3841. displayInChat("Shuffle is now on.","#DA0808","#1EBCC1");
  3842.  
  3843. }
  3844.  
  3845. return "";
  3846.  
  3847. }
  3848. else if(sandboxon){
  3849. if (chat_val.substring(1,11)=="addplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  3850. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  3851. if(!isNaN(parseInt(text))){
  3852. var text2 = parseInt(text);
  3853. if(text2>0){
  3854. for(var i = 0;i<text2;i++){
  3855. RECIEVE('42[4,'+sandboxid+',"0123456789abcdef","'+sandboxid.toString()+'",true,0,1,{"layers":[],"bc":'+Math.floor(Math.random() * 16777215).toString()+'}]');
  3856. sandboxplayerids[sandboxid] = sandboxid.toString();
  3857. sandboxid+=1;
  3858. }
  3859.  
  3860. }
  3861. }
  3862. return "";
  3863.  
  3864. }
  3865. else if (chat_val.substring(1,11)=="delplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  3866. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  3867. if(!isNaN(parseInt(text))){
  3868. var text2 = parseInt(text);
  3869. if(text2>0){
  3870. if(Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden"){
  3871. var jsonkeys = Object.keys(sandboxplayerids).reverse();
  3872. for(var i = 0;i<text2 && i<jsonkeys.length;i++){
  3873. RECIEVE('42[5,'+jsonkeys[i]+',0]');
  3874. delete sandboxplayerids[jsonkeys[i]];
  3875. }
  3876. }
  3877. else{
  3878. displayInChat("Cannot delete players while ingame.","#DA0808","#1EBCC1");
  3879. }
  3880.  
  3881. }
  3882. }
  3883. return "";
  3884. }
  3885. else if (chat_val.substring(1,7)=="copyme"){
  3886. if(sandboxcopyme == true){
  3887. displayInChat("Copyme is now off.","#DA0808","#1EBCC1");
  3888. sandboxcopyme = false;
  3889. }
  3890. else{
  3891. displayInChat("Copyme is now on.","#DA0808","#1EBCC1");
  3892. sandboxcopyme = true;
  3893. }
  3894.  
  3895. return "";
  3896. }
  3897. }
  3898. }
  3899. return chat_val;
  3900. };
  3901.  
  3902. scope.flag_manage = function(t){
  3903. var text = t;
  3904. if(reverse_flag == true){
  3905. text = text.split("").reverse().join("")
  3906. }
  3907. if(rcaps_flag == true){
  3908. text = text.split('');
  3909. for(var i = 0; i<text.length;i++){
  3910. if(Math.floor(Math.random()*2)){
  3911. text[i] = text[i].toUpperCase();
  3912. }
  3913. else{
  3914. text[i] = text[i].toLowerCase();
  3915. }
  3916. }
  3917. text = text.join('');
  3918. }
  3919. if(space_flag == true){
  3920. text = text.split('').join(' ')
  3921. }
  3922. if(number_flag == true){
  3923. text = text.replace(/[t|T][Oo]+/g,"2");
  3924. text = text.replace(/[f|F][o|O][r|R]/g,"4");
  3925. text = text.replace(/[a|A][t|T][e|E]/g,"8");
  3926. text = text.replace(/[e|E]/g,"3");
  3927. text = text.replace(/[a|A]/g,"4");
  3928. text = text.replace(/[o|O]/g,"0");
  3929. text = text.replace(/[s|S]/g,"5");
  3930. text = text.replace(/[i|I|l|L]/g,"1");
  3931. }
  3932. return text;
  3933. };
  3934. Gdocument.getElementById("newbonklobby_chat_input").onkeydown = function(e){
  3935. if(e.keyCode==13){
  3936.  
  3937. var chat_val = Gdocument.getElementById("newbonklobby_chat_input").value;
  3938.  
  3939. if (chat_val!="" && chat_val[0]=="/"){
  3940.  
  3941. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  3942. chat2(commandhandle(chat_val));
  3943. }
  3944. else{
  3945. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  3946. chat2(flag_manage(chat_val));
  3947. }
  3948.  
  3949. }
  3950. };
  3951. Gdocument.getElementById("ingamechatinputtext").onkeydown = function(e){
  3952. if(e.keyCode==13){
  3953.  
  3954. var chat_val = Gdocument.getElementById("ingamechatinputtext").value;
  3955.  
  3956. if (chat_val!="" && chat_val[0]=="/"){
  3957.  
  3958. Gdocument.getElementById("ingamechatinputtext").value = "";
  3959. chat2(commandhandle(chat_val));
  3960. }
  3961. else{
  3962. Gdocument.getElementById("ingamechatinputtext").value = "";
  3963. chat2(flag_manage(chat_val));
  3964. }
  3965. }
  3966. };
  3967. scope.Last_message = "";
  3968. scope.Laster_message = "";
  3969. scope.new_message = false;
  3970. scope.changed_chat = false;
  3971. scope.injectedBonkCommandsScript = setInterval(timeout123,60);
  3972.  
  3973. scope.hotkeys = function(e){
  3974. var keycode = e.code;
  3975. if(e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  3976. if(keycode == "Period"){
  3977. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]!="0px"){
  3978. chatheight+=5;
  3979. if(chatheight>600){chatheight = 600;}
  3980. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  3981. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  3982. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  3983. }
  3984. e.preventDefault();
  3985. }
  3986. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  3987. if(keycode == "KeyG"){
  3988. var addto = 0;
  3989. for(var i = 0;i<parentDraw.children.length;i++){
  3990. if(parentDraw.children[i].constructor.name == "e"){
  3991. addto = parentDraw.children[i];
  3992. break;
  3993. }
  3994. }
  3995. var canv = 0;
  3996. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  3997. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  3998. canv = Gdocument.getElementById("gamerenderer").children[i];
  3999. break;
  4000. }
  4001. }
  4002. var width = parseInt(canv.style["width"]);
  4003. var height = parseInt(canv.style["height"]);
  4004. if(addto){
  4005. addto.scale.x *= 1.1;
  4006. addto.scale.y *= 1.1;
  4007. }
  4008. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  4009. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  4010. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  4011. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  4012. if(addto.scale.x>=0.95 && addto.scale.y>=0.95 && !FollowCam){
  4013. pixiCircle.visible = false;
  4014. }
  4015. else{
  4016. pixiCircle.visible = true;
  4017. }
  4018. e.preventDefault();
  4019. }
  4020. if(keycode == "KeyH"){
  4021. var addto = 0;
  4022. for(var i = 0;i<parentDraw.children.length;i++){
  4023. if(parentDraw.children[i].constructor.name == "e"){
  4024. addto = parentDraw.children[i];
  4025. break;
  4026. }
  4027. }
  4028. var canv = 0;
  4029. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  4030. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  4031. canv = Gdocument.getElementById("gamerenderer").children[i];
  4032. break;
  4033. }
  4034. }
  4035. var width = parseInt(canv.style["width"]);
  4036. var height = parseInt(canv.style["height"]);
  4037. if(addto){
  4038. addto.scale.x = 1;
  4039. addto.scale.y = 1;
  4040. }
  4041. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  4042. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  4043. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  4044. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  4045. if(addto.scale.x>=0.95 && addto.scale.y>=0.95 && !FollowCam){
  4046. pixiCircle.visible = false;
  4047. }
  4048. else{
  4049. pixiCircle.visible = true;
  4050. }
  4051. e.preventDefault();
  4052. }
  4053. if(keycode == "KeyJ"){
  4054. var addto = 0;
  4055. for(var i = 0;i<parentDraw.children.length;i++){
  4056. if(parentDraw.children[i].constructor.name == "e"){
  4057. addto = parentDraw.children[i];
  4058. break;
  4059. }
  4060. }
  4061. var canv = 0;
  4062. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  4063. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  4064. canv = Gdocument.getElementById("gamerenderer").children[i];
  4065. break;
  4066. }
  4067. }
  4068. var width = parseInt(canv.style["width"]);
  4069. var height = parseInt(canv.style["height"]);
  4070. if(addto){
  4071. addto.scale.x /= 1.1;
  4072. addto.scale.y /= 1.1;
  4073. }
  4074. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  4075. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  4076. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  4077. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  4078. if(addto.scale.x>=0.95 && addto.scale.y>=0.95 && !FollowCam){
  4079. pixiCircle.visible = false;
  4080. }
  4081. else{
  4082. pixiCircle.visible = true;
  4083. }
  4084. e.preventDefault();
  4085. }
  4086. }
  4087. if(keycode == "Comma"){
  4088. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]!="0px"){
  4089. chatheight-=5;
  4090. if(chatheight<100){chatheight = 100;}
  4091. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  4092. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  4093. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  4094. }
  4095. e.preventDefault();
  4096. }
  4097. }
  4098. if(e.repeat){return;}
  4099. if(e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  4100. if(ishost){
  4101. if(keycode == "KeyE"){
  4102. if(Gdocument.getElementById("newbonklobby").style["display"] == "block"){
  4103. Gdocument.getElementById("newbonklobby_editorbutton").click();
  4104. }
  4105. else if(Gdocument.getElementById("mapeditorcontainer").style["display"] == "block"){
  4106. Gdocument.getElementById("mapeditor_close").click();
  4107. }
  4108. e.preventDefault();
  4109.  
  4110. }
  4111. else if(keycode == "KeyT"){
  4112. Gdocument.getElementById("newbonklobby_teamsbutton").click();
  4113. e.preventDefault();
  4114. }
  4115. else if(keycode == "KeyM"){
  4116. Gdocument.getElementById("newbonklobby_modebutton").click();
  4117. e.preventDefault();
  4118. }
  4119. else if(keycode == "KeyK"){
  4120. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  4121. Gdocument.getElementById("pretty_top_exit").click();
  4122. }
  4123. e.preventDefault();
  4124. }
  4125. else if(keycode == "KeyS"){
  4126. Gdocument.getElementById("newbonklobby_editorbutton").click();
  4127. if(recmodebool && ishost){
  4128. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  4129. if(mode == "" && defaultmode!="d"){
  4130. mode = defaultmode;
  4131. }
  4132. if(mode != ""){
  4133. RECIEVE('42[26,"b","'+mode+'"]');
  4134. }
  4135. }
  4136. Gdocument.getElementById("mapeditor_close").click();
  4137. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  4138. roundsperqp2 = 0;
  4139. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  4140. e.preventDefault();
  4141. }
  4142. else if(keycode == "KeyD"){
  4143. roundsperqp2 = 0;
  4144. if(stopquickplay == 0){
  4145. if(shuffle){
  4146. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4147. var available = [];
  4148. var availableindexes = [];
  4149. var notempty = false;
  4150. for(var i = 0; i<e2.length;i++){
  4151. var a = false;
  4152. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4153. available.push(a);
  4154. if(a){
  4155. availableindexes.push(i);
  4156. notempty = true;
  4157. }
  4158. }
  4159. if(notempty){
  4160.  
  4161. if(availableindexes.length!=1){
  4162. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  4163. }
  4164. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  4165. }
  4166. }
  4167. else{
  4168. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4169. var available = [];
  4170. var availableindexes = [];
  4171. var notempty = false;
  4172. for(var i = 0; i<e2.length;i++){
  4173. var a = false;
  4174. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4175. available.push(a);
  4176. if(a){
  4177. availableindexes.push(i);
  4178. notempty = true;
  4179. }
  4180. }
  4181. if(notempty){
  4182. var above = [];
  4183. for(var i = 0;i<availableindexes.length;i++){
  4184. if(availableindexes[i]>quicki){
  4185. above.push(availableindexes[i]);
  4186. }
  4187. }
  4188. if(above.length>0){
  4189. quicki = above[0];
  4190. }
  4191. else{
  4192. quicki = availableindexes[0];
  4193. }
  4194. }
  4195. }
  4196. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  4197. }
  4198. e.preventDefault();
  4199. }
  4200. else if(keycode == "KeyA"){
  4201. if(stopquickplay == 0){
  4202. roundsperqp2 = 0;
  4203. if(shuffle){
  4204. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4205. var available = [];
  4206. var availableindexes = [];
  4207. var notempty = false;
  4208. for(var i = 0; i<e2.length;i++){
  4209. var a = false;
  4210. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4211. available.push(a);
  4212. if(a){
  4213. availableindexes.push(i);
  4214. notempty = true;
  4215. }
  4216. }
  4217. if(notempty){
  4218.  
  4219. if(availableindexes.length!=1){
  4220. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  4221. }
  4222. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  4223. }
  4224. }
  4225. else{
  4226. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4227. var available = [];
  4228. var availableindexes = [];
  4229. var notempty = false;
  4230. for(var i = 0; i<e2.length;i++){
  4231. var a = false;
  4232. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4233. available.push(a);
  4234. if(a){
  4235. availableindexes.push(i);
  4236. notempty = true;
  4237. }
  4238. }
  4239. if(notempty){
  4240. var above = [];
  4241. for(var i = 0;i<availableindexes.length;i++){
  4242. if(availableindexes[i]<quicki){
  4243. above.push(availableindexes[i]);
  4244. }
  4245. }
  4246. if(above.length>0){
  4247. quicki = above[above.length-1];
  4248. }
  4249. else{
  4250. quicki = availableindexes[availableindexes.length-1];
  4251. }
  4252. }
  4253. }
  4254. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  4255. }
  4256. e.preventDefault();
  4257. }
  4258. else if(keycode == "KeyQ"){
  4259. if(stopquickplay == 1){
  4260. stopquickplay = 0;
  4261. quicki = 0;
  4262. qppaused = false;
  4263. displayInChat("Enabled quickplay.","#DA0808","#1EBCC1");
  4264. }
  4265. else{
  4266. stopquickplay = 1;
  4267. quicki = 0;
  4268. qppaused = false;
  4269. displayInChat("Disabled quickplay.","#DA0808","#1EBCC1");
  4270. }
  4271. e.preventDefault();
  4272. }
  4273. else if(keycode == "KeyP" && stopquickplay==0){
  4274. if(qppaused == true){
  4275. qppaused = false;
  4276. displayInChat("Unpaused quickplay.","#DA0808","#1EBCC1");
  4277. }
  4278. else{
  4279. qppaused = true;
  4280. displayInChat("Paused quickplay.","#DA0808","#1EBCC1");
  4281. }
  4282. e.preventDefault();
  4283. }
  4284. else if(keycode == "KeyR"){
  4285. if(recmodebool == true){
  4286. recmodebool = false;
  4287. displayInChat("Recmode is now off.","#DA0808","#1EBCC1");
  4288.  
  4289. }
  4290. else{
  4291. recmodebool = true;
  4292. displayInChat("Recmode is now on.","#DA0808","#1EBCC1");
  4293.  
  4294. }
  4295. }
  4296. else if(keycode == "KeyF"){
  4297. if(freejoin == false){
  4298. freejoin = true;
  4299. displayInChat("Freejoin is now on.","#DA0808","#1EBCC1");
  4300.  
  4301. }
  4302. else{
  4303. freejoin = false;
  4304. displayInChat("Freejoin is now off.","#DA0808","#1EBCC1");
  4305. }
  4306. e.preventDefault();
  4307. }
  4308. }
  4309. else{
  4310. if(keycode == "KeyE"){
  4311. e.preventDefault();
  4312. }
  4313. else if(keycode == "KeyT"){
  4314. e.preventDefault();
  4315. }
  4316. else if(keycode == "KeyM"){
  4317. e.preventDefault();
  4318. }
  4319. else if(keycode == "KeyK"){
  4320. e.preventDefault();
  4321. }
  4322. else if(keycode == "KeyS"){
  4323. e.preventDefault();
  4324. }
  4325. else if(keycode == "KeyD"){
  4326. e.preventDefault();
  4327. }
  4328. else if(keycode == "KeyA"){
  4329. e.preventDefault();
  4330. }
  4331. else if(keycode == "KeyQ"){
  4332. e.preventDefault();
  4333. }
  4334. else if(keycode == "KeyP"){
  4335. e.preventDefault();
  4336. }
  4337. else if(keycode == "KeyF"){
  4338. e.preventDefault();
  4339. }
  4340. else if(keycode == "KeyR"){
  4341. e.preventDefault();
  4342. }
  4343.  
  4344. }
  4345. if(keycode == "KeyL"){
  4346. lobby();
  4347. e.preventDefault();
  4348. }
  4349. if(keycode == "KeyC"){
  4350. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  4351. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]=="0px"){
  4352. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  4353. }
  4354. else{
  4355. Gdocument.getElementById("ingamechatcontent").style["max-height"]="0px";
  4356. }
  4357. }
  4358. e.preventDefault();
  4359. }
  4360. if(keycode == "KeyI"){
  4361. if(Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"] == "none"){
  4362. debuggeropen = true;
  4363. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="block";
  4364. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="none";
  4365. Gdocument.getElementById("ingamechatinputtext").style["display"] = "none";
  4366. }
  4367. else{
  4368. debuggeropen = false;
  4369. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="none";
  4370. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  4371. Gdocument.getElementById("ingamechatinputtext").style["display"] = "";
  4372. }
  4373. e.preventDefault();
  4374. }
  4375. if(keycode == "KeyB"){
  4376. var element = Gdocument.getElementById("ingamewinner_scores");
  4377. element.style["visibility"] = "visible";
  4378. if(element.style["opacity"]<1){
  4379. element.style["opacity"] = 1;
  4380. }
  4381. else{
  4382. element.style["opacity"] = 0;
  4383. }
  4384. e.preventDefault();
  4385. }
  4386. if(keycode == "KeyY"){
  4387. Gdocument.getElementById("pretty_top_settings").click();
  4388. Gdocument.getElementById("settings_close").click();
  4389. if(Gdocument.getElementById("settings_graphicsquality").value==1){
  4390. displayInChat("You must have medium or high quality enabled to use this feature.","#DA0808","#1EBCC1");
  4391. return "";
  4392. }
  4393.  
  4394.  
  4395. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  4396. var addto = {"children":[]};
  4397. for(var i = 0;i<parentDraw.children.length;i++){
  4398. if(parentDraw.children[i].constructor.name == "e"){
  4399. addto = parentDraw.children[i];
  4400. break;
  4401. }
  4402. }
  4403. var addto2 = {"children":[]};
  4404. for(var i = 0;i<addto.children.length;i++){
  4405. if(addto.children[i].constructor.name == "e"){
  4406. addto2 = addto.children[i];
  4407. break;
  4408. }
  4409. }
  4410. var checkxray = addto2.children[0];
  4411. var addto3 = addto2.children[0].children;
  4412. if(addto3.length==1){
  4413. checkxray = checkxray.children[0];
  4414. addto3 = addto3[0].children;
  4415. }
  4416. var xrayon = false;
  4417. if(checkxray.xrayon){
  4418. checkxray.xrayon = false;
  4419. xrayon = false;
  4420. }
  4421. else{
  4422. checkxray.xrayon = true;
  4423. xrayon = true;
  4424. }
  4425. if(xrayon){
  4426. displayInChat("Xray is now on.","#DA0808","#1EBCC1");
  4427. for(var i = 0;i<addto3.length;i++){
  4428. if(addto3[i].children.length>0){
  4429. for(var i3 = 0;i3<addto3[i].children.length;i3++){
  4430. addto3[i].children[i3].visible = false;
  4431. if(addto3[i].children[i3].children.length>0){
  4432. addto3[i].children[i3].visible = true;
  4433. }
  4434. }
  4435. }
  4436. }
  4437.  
  4438. }
  4439. else{
  4440. displayInChat("Xray is now off.","#DA0808","#1EBCC1");
  4441. for(var i = 0;i<addto3.length;i++){
  4442. for(var i2 = 0;i2<addto3[i].children.length;i2++){
  4443. addto3[i].children[i2].visible = true;
  4444. }
  4445. }
  4446. }
  4447. }
  4448. e.preventDefault();
  4449. }
  4450. if(keycode == "KeyN"){
  4451. if(FollowCam == true){
  4452. displayInChat("Follow Camera is now off.","#DA0808","#1EBCC1");
  4453. FollowCam = false;
  4454. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  4455. var addto = {"children":[]};
  4456. for(var i = 0;i<parentDraw.children.length;i++){
  4457. if(parentDraw.children[i].constructor.name == "e"){
  4458. addto = parentDraw.children[i];
  4459. break;
  4460. }
  4461. }
  4462. var canv = 0;
  4463. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  4464. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  4465. canv = Gdocument.getElementById("gamerenderer").children[i];
  4466. break;
  4467. }
  4468. }
  4469. var width = parseInt(canv.style["width"]);
  4470. var height = parseInt(canv.style["height"]);
  4471. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  4472. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  4473. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  4474. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  4475. if(addto.scale.x>=0.95 && addto.scale.y>=0.95){
  4476. pixiCircle.visible = false;
  4477. }
  4478. else{
  4479. pixiCircle.visible = true;
  4480. }
  4481. }
  4482. }
  4483. else{
  4484. displayInChat("Follow Camera is now on.","#DA0808","#1EBCC1");
  4485. FollowCam = true;
  4486. }
  4487. e.preventDefault();
  4488. }
  4489. if(keycode == "KeyU"){
  4490. if(aimbot == true){
  4491. displayInChat("Aimbot is now off.","#DA0808","#1EBCC1");
  4492. aimbot = false;
  4493. }
  4494. else{
  4495. displayInChat("Aimbot is now on.","#DA0808","#1EBCC1");
  4496. aimbot = true;
  4497. var keykeys = Object.keys(keyCodes);
  4498. var keyslist = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[1].children).slice(1);
  4499. var keyslist2 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[2].children).slice(1);
  4500. for(var i = 0;i<keyslist.length;i++){
  4501. if(keykeys.includes(keyslist[i].textContent)){
  4502. leftRight[0] = keyCodes[keyslist[i].textContent];
  4503. break;
  4504. }
  4505. else{
  4506. leftRight[0] = keyslist[i].textContent.charCodeAt(0);
  4507. break
  4508. }
  4509. }
  4510. for(var i = 0;i<keyslist2.length;i++){
  4511. if(keykeys.includes(keyslist2[i].textContent)){
  4512. leftRight[1] = keyCodes[keyslist2[i].textContent];
  4513. break;
  4514. }
  4515. else{
  4516. leftRight[1] = keyslist2[i].textContent.charCodeAt(0);
  4517. }
  4518. }
  4519. }
  4520. e.preventDefault();
  4521. }
  4522. }
  4523. if(!e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  4524. if(keycode == "Slash" && !(Gdocument.getElementById("gmeditor")?.style["transform"] == "scale(1)")){
  4525. 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"]==""){
  4526. Gdocument.getElementById("newbonklobby_chat_input").value = "/";
  4527. if(Gdocument.getElementById("newbonklobby_chat_input").style["pointer-events"] == "none"){
  4528. fire("keydown",{keyCode:13});
  4529. }
  4530. else{
  4531. Gdocument.getElementById("newbonklobby_chat_input").focus();
  4532. }
  4533. e.preventDefault();
  4534.  
  4535. }
  4536. else if(Gdocument.getElementById("ingamechatinputtext").style["visibility"]=="visible" && Gdocument.getElementById("ingamechatinputtext").style["display"]=="" && Gdocument.getElementById("mapeditorcontainer").style["display"]!="block" && Gdocument.getElementById("ingamechatinputtext").value == ""){
  4537. Gdocument.getElementById("ingamechatinputtext").value = "/";
  4538. if(!Gdocument.getElementById("ingamechatinputtext").classList.value.includes("ingamechatinputtextbg")){
  4539. fire("keydown",{keyCode:13});
  4540. }
  4541. else{
  4542. Gdocument.getElementById("ingamechatinputtext").focus();
  4543. }
  4544. e.preventDefault();
  4545.  
  4546. }
  4547. }
  4548. }
  4549. };
  4550.  
  4551. Gdocument.onkeydown = hotkeys;
  4552.  
  4553. Gwindow.addEventListener('resize',function(e){
  4554. debuggermenu.style["width"] = Gdocument.getElementById("bonkiocontainer").style["width"];
  4555. debuggermenu.style["height"] = Gdocument.getElementById("bonkiocontainer").style["height"];
  4556. scope.width = parseInt(Gdocument.getElementById("bonkiocontainer").style["width"])-20;
  4557. scope.height = parseInt(Gdocument.getElementById("bonkiocontainer").style["height"])-210;
  4558. logmenu.style["width"] = width.toString()+"px";
  4559. logmenu.style["height"] = height.toString()+"px";
  4560. logmenutopleft.style["width"] = (width/2).toString()+"px";
  4561. logmenutopright.style["width"] = (width/2).toString()+"px";
  4562. logmenutopright.style["left"] = (width/2).toString()+"px";
  4563. debuggerinput.style["width"] = width.toString()+"px";
  4564. debuggerinput.style["top"] = (height+90).toString()+"px";
  4565. debuggersendrecieve.style["top"] = (height+120).toString()+"px";
  4566. debuggerpausebutton.style["top"] = (height+150).toString()+"px";
  4567. debuggereval.style["width"] = (width-150).toString()+"px";
  4568. debuggereval.style["top"] = (height+120).toString()+"px";},true);
  4569.  
  4570.  
  4571. function timeout123() {
  4572. updateWssLog();
  4573. EVENTLOOPFUNCTION();
  4574. var now = Date.now();
  4575. var keys = Object.keys(playerids);
  4576. for(var i = 0;i<keys.length;i++){
  4577. if(playerids[keys[i]].playerData){
  4578. if(playerids[keys[i]].playerData2){
  4579. if(playerids[keys[i]].playerData.transform){
  4580. if(playerids[keys[i]].playerData2.timeStamp == 0){
  4581. playerids[keys[i]].playerData2.px = playerids[keys[i]].playerData.transform.position.x;
  4582. playerids[keys[i]].playerData2.py = playerids[keys[i]].playerData.transform.position.y;
  4583. playerids[keys[i]].playerData2.timeStamp = now;
  4584. }
  4585. else{
  4586. playerids[keys[i]].playerData2.xvel = (playerids[keys[i]].playerData2.px - playerids[keys[i]].playerData.transform.position.x)/(playerids[keys[i]].playerData2.timeStamp-now);
  4587. playerids[keys[i]].playerData2.yvel = (playerids[keys[i]].playerData2.py - playerids[keys[i]].playerData.transform.position.y)/(playerids[keys[i]].playerData2.timeStamp-now);
  4588. playerids[keys[i]].playerData2.px = playerids[keys[i]].playerData.transform.position.x;
  4589. playerids[keys[i]].playerData2.py = playerids[keys[i]].playerData.transform.position.y;
  4590. playerids[keys[i]].playerData2.timeStamp = now;
  4591. }
  4592. if(playerids[keys[i]].playerData2.timeStamp2 == 0){
  4593. playerids[keys[i]].playerData2.pvx = playerids[keys[i]].playerData2.xvel;
  4594. playerids[keys[i]].playerData2.pvx = playerids[keys[i]].playerData2.yvel;
  4595. playerids[keys[i]].playerData2.timeStamp2 = now;
  4596. }
  4597. else{
  4598. playerids[keys[i]].playerData2.xacc = (playerids[keys[i]].playerData2.pvx - playerids[keys[i]].playerData2.xvel)/((playerids[keys[i]].playerData2.timeStamp2-now)**2);
  4599. playerids[keys[i]].playerData2.yacc = (playerids[keys[i]].playerData2.pvy - playerids[keys[i]].playerData2.yvel)/((playerids[keys[i]].playerData2.timeStamp2-now)**2);
  4600. playerids[keys[i]].playerData2.pvx = playerids[keys[i]].playerData2.xvel;
  4601. playerids[keys[i]].playerData2.pvx = playerids[keys[i]].playerData2.yvel;
  4602. playerids[keys[i]].playerData2.timeStamp2 = now;
  4603. }
  4604. }
  4605. else{
  4606. if(playerids[keys[i]].playerData2.alive){
  4607. }
  4608. playerids[keys[i]].playerData2.alive = false;
  4609. }
  4610. }
  4611. else{
  4612. 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};
  4613. }
  4614. }
  4615. }
  4616. if(pollactive[0] && pollactive[2]<now && ishost){
  4617. playerids[myid].ratelimit.poll = Date.now();
  4618. SEND("42"+JSON.stringify([4,{"type":"poll end","from":username}]));
  4619. var count = [0,0,0,0];
  4620. var keys = Object.keys(playerids);
  4621. for(var i = 0;i<keys.length;i++){
  4622. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive[3].length-1){
  4623. count[playerids[keys[i]].vote.poll]++;
  4624. }
  4625. playerids[keys[i]].vote.poll = -1;
  4626. }
  4627. displayInChat("The poll ended due to time.","#DA0808","#1EBCC1");
  4628. for(var i = 0;i<count.length;i++){
  4629. if(count[i]>1){
  4630. displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  4631. }
  4632. if(count[i]==1){
  4633. displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  4634. }
  4635. }
  4636. displayInChat("The poll was:","#DA0808","#1EBCC1");
  4637. for(var i = 0;i<pollactive[3].length;i++){
  4638. displayInChat(letters[i]+") "+pollactive[3][i],"#DA0808","#1EBCC1");
  4639. }
  4640. pollactive = [false,0,0,[]];
  4641. }
  4642. if(afkkill>0 && ishost){
  4643. var keys = Object.keys(playerids);
  4644. currentFrame = Math.floor((now - gameStartTimeStamp)/1000*30);
  4645. for(var i = 0; i<keys.length;i++){
  4646. if(typeof(playerids[keys[i]].lastmove)=="undefined"){
  4647. playerids[keys[i]].lastmove = now;
  4648. }
  4649. else{
  4650. if(playerids[keys[i]].playerData2?.alive && now-playerids[keys[i]].lastmove>=afkkill*1000 && now-gameStartTimeStamp>=afkkill*1000 && !killedids.includes(keys[i])){
  4651. killedids.push(keys[i]);
  4652. SEND('42[25,{"a":{"playersLeft":['+keys[i]+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  4653. RECIEVE('42[31,{"a":{"playersLeft":['+keys[i]+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  4654. break;
  4655. }
  4656. }
  4657. }
  4658. }
  4659. if(ishost && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS"){
  4660. clearmaprequests.style["display"] = "block";
  4661. refreshmaprequests.style["display"] = "block";
  4662. }
  4663. else{
  4664. clearmaprequests.style["display"] = "none";
  4665. refreshmaprequests.style["display"] = "none";
  4666. }
  4667. if(Gdocument.getElementById("gamerenderer").style["visibility"]=="hidden"){
  4668. Gdocument.getElementById("ingamewinner_scores").style["visibility"] = "unset";;
  4669. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  4670. }
  4671. if(Gdocument.getElementById("maploadwindowmapscontainer").children.length>0 && maponclick == 0){
  4672. maponclick = Gdocument.getElementById("maploadwindowmapscontainer").children[0].onclick;
  4673. }
  4674. if(Gdocument.getElementById("sm_connectingContainer").style["visibility"] == "hidden"){
  4675. var chatbox = Gdocument.getElementById("newbonklobby_chat_content");
  4676. while (chatbox.firstChild) {
  4677. chatbox.removeChild(chatbox.firstChild);
  4678. }
  4679. rcaps_flag = false;
  4680. space_flag = false;
  4681. number_flag = false;
  4682. reverse_flag = false;
  4683. echo_list = [];
  4684. scroll = false;
  4685. FollowCam = false;
  4686. aimbot = false;
  4687. stopquickplay = 1;
  4688. roundsperqp = 1;
  4689. roundsperqp2 = 0;
  4690. checkboxhidden = false;
  4691. freejoin = false;
  4692. shuffle = false;
  4693. defaultmode = "";
  4694. recmodebool = false;
  4695. recteams = false;
  4696. autorecord = false;
  4697. pollactive = [false,0,0,[]];
  4698. pollactive2 = [false,0,[]];
  4699. afkkill = -1;
  4700. nextafter = 0;
  4701. jointext = "";
  4702. ishost = false;
  4703. parentDraw = 0;
  4704. sandboxplayerids = {};
  4705. sandboxcopyme = false;
  4706. wintext = "";
  4707. sandboxon = false;
  4708. sandboxid = 1;
  4709. disabledkeys = [];
  4710. myid = -1;
  4711. if(!bonkwss){
  4712. playerids = {};
  4713. }
  4714. qppaused = false;
  4715. nextafterbuffer = -1;
  4716. hostid = -1;
  4717. if(chatlog[chatlog.length-1]!="ROOM END"){
  4718. chatlog.push("ROOM END");
  4719. }
  4720. }
  4721. else{
  4722. if(chatlog[chatlog.length-1]=="ROOM END"){
  4723. chatlog.push("ROOM START");
  4724. }
  4725. }
  4726.  
  4727. if(Gdocument.getElementById("newbonklobby").style["display"]=="block"){
  4728. Gdocument.getElementById("ingamechatinputtext").style["visibility"]="hidden";
  4729. }
  4730. else{
  4731. Gdocument.getElementById("ingamechatinputtext").style["visibility"]="visible";
  4732.  
  4733. }
  4734. mode = Gdocument.getElementById("newbonklobby_modetext").textContent;
  4735. 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
  4736. >0){
  4737. ishost = true;
  4738. }
  4739. else{
  4740. ishost = actuallyhost;
  4741. }
  4742.  
  4743. if(Gdocument.getElementById("pretty_top_name")!=null){
  4744. username = Gdocument.getElementById("pretty_top_name").textContent;
  4745. if(myid!=-1){
  4746. username = playerids[myid].userName;
  4747. }
  4748. }
  4749. try{
  4750. Last_message = lastmessage()
  4751. } catch{
  4752. Last_message = "";
  4753. }
  4754. if (Laster_message != Last_message){
  4755. Laster_message = Last_message;
  4756. if(changed_chat==false){
  4757. new_message = true;
  4758. }
  4759. else{
  4760. changed_chat = false;
  4761. }
  4762. }
  4763. if(new_message){
  4764. chatlog.push(Last_message);
  4765. var lm = "";
  4766. try{
  4767. lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  4768. if(typeof(lm[0].parentElement.style["parsed"]) == 'undefined'){
  4769. if (lm[0].className == "newbonklobby_chat_msg_colorbox"){
  4770. lm[2].innerHTML = urlify(lm[2].innerHTML);
  4771. Laster_message = lastmessage();
  4772. lm[0].parentElement.style["parsed"] = true;
  4773. }
  4774. if (lm[0].className == "newbonklobby_chat_status"){
  4775. lm[0].innerHTML = urlify(lm[0].innerHTML);
  4776. Laster_message = lastmessage();
  4777. lm[0].parentElement.style["parsed"] = true;
  4778. }
  4779. }
  4780. }
  4781. catch{
  4782. lm = "";
  4783. }
  4784.  
  4785. if(Last_message.indexOf("@"+username)!=-1 && npermissions == 1){
  4786. if(Notification.requestPermission()){
  4787. var n = new Notification(Last_message);
  4788. }
  4789. }
  4790.  
  4791. try{
  4792. lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  4793. if(typeof(lm[0].parentElement.style["parsed"])=='undefined'){
  4794. if(lm[0].className == "ingamechatname"){
  4795. lm[1].innerHTML = urlify(lm[1].innerHTML);
  4796. Laster_message = lastmessage();
  4797. lm[0].parentElement.style["parsed"] = true;
  4798. }
  4799. if(lm[0].className == ""){
  4800. lm[0].innerHTML = urlify(lm[0].innerHTML);
  4801. Laster_message = lastmessage();
  4802. lm[0].parentElement.style["parsed"] = true;
  4803. }
  4804. }
  4805. }
  4806. catch{
  4807. lm = "";
  4808. }
  4809. if(text2speech){
  4810. if(!sayer.speaking){
  4811. if(Last_message.includes(": ")){
  4812. speech.text = Last_message.substring(0,Last_message.indexOf(":")).toLowerCase();
  4813. speech.rate = 2.25;
  4814. sayer.speak(speech);
  4815. speech.text = Last_message.substring(Last_message.indexOf(": ")+3).toLowerCase();
  4816. speech.rate = 1.25;
  4817. sayer.speak(speech);
  4818. }
  4819. else{
  4820. speech.text = Last_message.toLowerCase();
  4821. sayer.speak(speech);
  4822. }
  4823. }
  4824. }
  4825. }
  4826. if (ishost==true && new_message){
  4827. for(i=0;i<banned.length;i++){
  4828. if(Last_message.startsWith("* "+banned[i]+" has joined the game")){
  4829. chat2("/kick '"+banned[i]+"'");
  4830. }
  4831. }
  4832. }
  4833. if(Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden" && ishost){
  4834. roundsperqp2 = 0;
  4835. }
  4836. if(Gdocument.getElementById("ingamewinner").style["visibility"]=="inherit" && ishost){
  4837. if(Gdocument.getElementById("ingamewinner").style["parsed"] != true){
  4838. if(stopquickplay!=1){
  4839. roundsperqp2++;
  4840. }
  4841. if(autorecord){
  4842. Gdocument.getElementById("pretty_top_replay").click();
  4843. }
  4844. }
  4845. if(Gdocument.getElementById("ingamewinner").style["parsed"] != true && wintext!="" && Gdocument.getElementById("ingamewinner_bottom").textContent!="DRAW"){
  4846. chat(flag_manage(wintext.replaceAll("username",Gdocument.getElementById("ingamewinner_top").textContent)));
  4847. }
  4848. Gdocument.getElementById("ingamewinner").style["parsed"] = true;
  4849. }
  4850. else{
  4851. Gdocument.getElementById("ingamewinner").style["parsed"] = false;
  4852. }
  4853. if(ishost && stopquickplay == 0){
  4854. if(checkboxhidden){
  4855. checkboxhidden = false;
  4856. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  4857. for(var i = 0; i<classes.length;i++){
  4858. classes[i].style["display"] = "block";
  4859. classes[i].className = "quickplaycheckbox quickplaychecked";
  4860. }
  4861. Gdocument.getElementById('clearallcheckboxes').style["display"] = "block";
  4862.  
  4863. }
  4864. if(nextafter>0 && gameStartTimeStamp+nextafter*1000<=now && Gdocument.getElementById("gamerenderer").style["visibility"] != "hidden" && dontswitch == false && Gdocument.getElementById("ingamewinner").style["visibility"]!="inherit" && !qppaused){
  4865. roundsperqp2 = 0;
  4866. if(shuffle){
  4867. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4868. var available = [];
  4869. var availableindexes = [];
  4870. var notempty = false;
  4871. for(var i = 0; i<e.length;i++){
  4872. var a = false;
  4873. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4874. available.push(a);
  4875. if(a){
  4876. availableindexes.push(i);
  4877. notempty = true;
  4878. }
  4879. }
  4880. if(notempty){
  4881. if(availableindexes.length!=1){
  4882. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  4883. }
  4884. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  4885. }
  4886. }
  4887. else{
  4888. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4889. var available = [];
  4890. var availableindexes = [];
  4891. var notempty = false;
  4892. for(var i = 0; i<e.length;i++){
  4893. var a = false;
  4894. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4895. available.push(a);
  4896. if(a){
  4897. availableindexes.push(i);
  4898. notempty = true;
  4899. }
  4900. }
  4901. if(notempty){
  4902. var above = [];
  4903. for(var i = 0;i<availableindexes.length;i++){
  4904. if(availableindexes[i]>quicki){
  4905. above.push(availableindexes[i]);
  4906. }
  4907. }
  4908. if(above.length>0){
  4909. quicki = above[0];
  4910. }
  4911. else{
  4912. quicki = availableindexes[0];
  4913. }
  4914. }
  4915. }
  4916. startedinqp = true;
  4917. dontswitch = true;
  4918. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  4919. }
  4920. if(Gdocument.getElementById("ingamewinner").style["visibility"]=="inherit" && dontswitch == false && !document.hidden && !qppaused){
  4921. if(roundsperqp2>=roundsperqp){
  4922. if(shuffle){
  4923. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4924. var available = [];
  4925. var availableindexes = [];
  4926. var notempty = false;
  4927. for(var i = 0; i<e.length;i++){
  4928. var a = false;
  4929. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4930. available.push(a);
  4931. if(a){
  4932. availableindexes.push(i);
  4933. notempty = true;
  4934. }
  4935. }
  4936. if(notempty){
  4937.  
  4938. if(availableindexes.length!=1){
  4939. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  4940. }
  4941. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  4942. }
  4943. }
  4944. else{
  4945. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4946. var available = [];
  4947. var availableindexes = [];
  4948. var notempty = false;
  4949. for(var i = 0; i<e.length;i++){
  4950. var a = false;
  4951. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4952. available.push(a);
  4953. if(a){
  4954. availableindexes.push(i);
  4955. notempty = true;
  4956. }
  4957. }
  4958. if(notempty){
  4959. var above = [];
  4960. for(var i = 0;i<availableindexes.length;i++){
  4961. if(availableindexes[i]>quicki){
  4962. above.push(availableindexes[i]);
  4963. }
  4964. }
  4965. if(above.length>0){
  4966. quicki = above[0];
  4967. }
  4968. else{
  4969. quicki = availableindexes[0];
  4970. }
  4971. }
  4972. }
  4973. }
  4974. transitioning = true;
  4975. startedinqp = true;
  4976. map(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  4977. dontswitch = true;
  4978. setTimeout(function(){Gdocument.getElementById("ingamewinner").style["visibility"]="hidden"; dontswitch = false;},timedelay);
  4979. }
  4980. }
  4981. else{
  4982. if(!checkboxhidden){
  4983. checkboxhidden = true;
  4984. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  4985. for(var i = 0; i<classes.length;i++){
  4986. classes[i].style["display"] = "none";
  4987. classes[i].className = "quickplaycheckbox quickplayunchecked";
  4988. }
  4989. Gdocument.getElementById('clearallcheckboxes').style["display"] = "none";
  4990. }
  4991. }
  4992. new_message = false;
  4993. };
  4994. });