Bonk Commands

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

当前为 2023-04-29 提交的版本,查看 最新版本

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