Bonk Commands

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

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

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

QingJ © 2025

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