Bonk Commands

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

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

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

QingJ © 2025

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