Bonk Commands

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

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

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

QingJ © 2025

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