Bonk Commands

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

当前为 2023-03-25 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Bonk Commands
  3. // @namespace https://gf.qytechs.cn/en/scripts/451341-bonk-commands
  4. // @version 14.2
  5. // @description Adds lots of commands to bonk.io. Type /? or /help in bonk chat to get started.
  6. // @author LEGENDBOSS123 + left paren + mastery3
  7. // @match https://bonk.io/*
  8. // @run-at document-idle
  9. // @grant none
  10. // @unwrap
  11. // ==/UserScript==
  12. function BonkCommandsScriptInjector(f){
  13. if(window.location == window.parent.location){
  14. if(document.readyState == "complete"){f();}
  15. else{document.addEventListener('readystatechange',function(){setTimeout(f,1500);});}
  16. }
  17. }
  18.  
  19. BonkCommandsScriptInjector(function(){
  20. var scope = window;
  21. scope.scope = scope;
  22. scope.Gwindow = document.getElementById("maingameframe").contentWindow;
  23. scope.Gdocument = document.getElementById("maingameframe").contentDocument;
  24. Gwindow.Gwindow = window;
  25. Gwindow.Gdocument = document;
  26.  
  27. scope.link2pastebin = "https://pastebin.com/2b8XqqYu";
  28. scope.link2greasyfork = "https://gf.qytechs.cn/en/scripts/451341-bonk-commands";
  29.  
  30. if(typeof(scope.injectedBonkCommandsScript)=='undefined'){
  31. scope.injectedBonkCommandsScript = true;
  32. }
  33. else{
  34. clearInterval(injectedBonkCommandsScript);
  35. }
  36. scope.GENERATE_COPRIME_NUMBER = function(mini = 0,maxi = 0,coprimewith = 0,choices = []){
  37. if(choices.length == 0){
  38. for(var i = mini;i<maxi+1;i++){
  39. choices.push(i);
  40. }
  41. }
  42. firstTry = choices[Math.floor(Math.random()*choices.length)];
  43. for(var i = 2; i<firstTry+1;i++){
  44. if(firstTry%i == 0 && coprimewith%i == 0){
  45. choices.splice(choices.indexOf(firstTry),1);
  46. if(choices.length == 0){
  47. return 0;
  48. }
  49. return GENERATE_COPRIME_NUMBER(mini,maxi,coprimewith,choices);
  50. }
  51. }
  52. return firstTry;
  53. };
  54. scope.GENERATE_PRIME_NUMBER = function(mini = 0,maxi = 0,choices = []){
  55. if(choices.length == 0){
  56. for(var i = mini;i<maxi+1;i++){
  57. choices.push(i);
  58. }
  59. }
  60. firstTry = choices[Math.floor(Math.random()*choices.length)];
  61. for(var i = 2; i<Math.floor(Math.sqrt(firstTry)+1);i++){
  62. if(i!=firstTry){
  63. if(firstTry%i == 0){
  64. choices.splice(choices.indexOf(firstTry),1);
  65. if(choices.length == 0){
  66. return 0;
  67. }
  68. return GENERATE_PRIME_NUMBER(mini,maxi,choices);
  69. }
  70. }
  71. }
  72. return firstTry;
  73. };
  74. scope.SHUFFLE_LIST = function(x){
  75. var nl = x.slice();
  76. for(var i = nl.length - 1;i>0;i--){
  77. var r = Math.floor(Math.random()*(i+1));
  78. var t = nl[i];
  79. nl[i] = nl[r];
  80. nl[r] = t;
  81. }
  82. return nl;
  83. };
  84. scope.GENERATE_KEYS = function(){
  85. interval = [];
  86. for(var i = 100;i<301;i++){
  87. interval.push(i);
  88. }
  89. random_prime = [GENERATE_PRIME_NUMBER(0,0,choices = interval),0];
  90. interval.splice(interval.indexOf(random_prime[0]),1);
  91. random_prime[1] = GENERATE_PRIME_NUMBER(0,0,choices = interval);
  92.  
  93. n = random_prime[0]*random_prime[1];
  94. n2 = (random_prime[0]-1)*(random_prime[1]-1);
  95.  
  96. e = GENERATE_COPRIME_NUMBER(2,n2-1,n2);
  97. d = 0;
  98. redo = true;
  99. for(var i = 0;i<1000000;i++){
  100. if((e*i-1)%n2 == 0 && i!=e){
  101. d = i;
  102. redo = false;
  103. break;
  104. }
  105. }
  106. if(redo){
  107. return GENERATE_KEYS();
  108. }
  109. else{
  110. return [[n,e],[n,d]];
  111. }
  112.  
  113. };
  114. scope.CRYPT_NUMBER = function(key, data){
  115.  
  116. result = 1;
  117.  
  118. for(var i = 0;i<key[1];i++){
  119. result*=data;
  120. result = result%key[0];
  121. }
  122. return result%key[0];
  123.  
  124. };
  125.  
  126. scope.CRYPT_MESSAGE = function(key,data){
  127. var resulttext = [];
  128. for(var i = 0;i<data.length;i++){
  129. resulttext.push(CRYPT_NUMBER(key,data[i]));
  130. }
  131. return resulttext;
  132.  
  133. };
  134. if(typeof(scope.textdecoder)=='undefined'){scope.textdecoder = new Gwindow.TextDecoder;}
  135. if(typeof(scope.textencoder)=='undefined'){scope.textencoder = new Gwindow.TextEncoder;}
  136.  
  137. class bytebuffer2 {
  138. constructor() {
  139. var g1d = [arguments];
  140. this.index = 0;
  141. this.buffer = new ArrayBuffer(100*1024);
  142. this.view = new DataView(this.buffer);
  143. this.implicitClassAliasArray = [];
  144. this.implicitStringArray = [];
  145. this.bodgeCaptureZoneDataIdentifierArray = [];
  146. }
  147. readByte() {
  148. var N0H = [arguments];
  149. N0H[4] = this.view.getUint8(this.index);
  150. this.index += 1;
  151. return N0H[4];
  152. }
  153. writeByte(z0w) {
  154. var v8$ = [arguments];
  155. this.view.setUint8(this.index, v8$[0][0]);
  156. this.index += 1;
  157. }
  158. readInt() {
  159. var A71 = [arguments];
  160. A71[6] = this.view.getInt32(this.index);
  161. this.index += 4;
  162. return A71[6];
  163. }
  164. writeInt(W6i) {
  165. var p5u = [arguments];
  166. this.view.setInt32(this.index, p5u[0][0]);
  167. this.index += 4;
  168. }
  169. readShort() {
  170. var R1R = [arguments];
  171. R1R[9] = this.view.getInt16(this.index);
  172. this.index += 2;
  173. return R1R[9];
  174. }
  175. writeShort(H8B) {
  176. var d_3 = [arguments];
  177. this.view.setInt16(this.index, d_3[0][0]);
  178. this.index += 2;
  179. }
  180. readUint() {
  181. var W2$ = [arguments];
  182. W2$[8] = this.view.getUint32(this.index);
  183. this.index += 4;
  184. return W2$[8];
  185. }
  186. writeUint(B2X) {
  187. var f8B = [arguments];
  188. this.view.setUint32(this.index, f8B[0][0]);
  189. this.index += 4;
  190. }
  191. readBoolean() {
  192. var h6P = [arguments];
  193. h6P[6] = this.readByte();
  194. return h6P[6] == 1;
  195. }
  196. writeBoolean(Y3I) {
  197. var l79 = [arguments];
  198. if (l79[0][0]) {
  199. this.writeByte(1);
  200. } else {
  201. this.writeByte(0);
  202. }
  203. }
  204. readDouble() {
  205. var V60 = [arguments];
  206. V60[4] = this.view.getFloat64(this.index);
  207. this.index += 8;
  208. return V60[4];
  209. }
  210. writeDouble(z4Z) {
  211. var O41 = [arguments];
  212. this.view.setFloat64(this.index, O41[0][0]);
  213. this.index += 8;
  214. }
  215. readFloat() {
  216. var I0l = [arguments];
  217. I0l[5] = this.view.getFloat32(this.index);
  218. this.index += 4;
  219. return I0l[5];
  220. }
  221. writeFloat(y4B) {
  222. var B0v = [arguments];
  223. this.view.setFloat32(this.index, B0v[0][0]);
  224. this.index += 4;
  225. }
  226. readUTF() {
  227. var d6I = [arguments];
  228. d6I[8] = this.readByte();
  229. d6I[7] = this.readByte();
  230. d6I[9] = d6I[8] * 256 + d6I[7];
  231. d6I[1] = new Uint8Array(d6I[9]);
  232. for (d6I[6] = 0; d6I[6] < d6I[9]; d6I[6]++) {
  233. d6I[1][d6I[6]] = this.readByte();
  234. }
  235. return textdecoder.decode(d6I[1]);
  236. }
  237. writeUTF(L3Z) {
  238. var Z75 = [arguments];
  239. Z75[4] = textencoder.encode(Z75[0][0]);
  240. Z75[3] = Z75[4].length;
  241. Z75[5] = Math.floor(Z75[3]/256);
  242. Z75[8] = Z75[3] % 256;
  243. this.writeByte(Z75[5]);
  244. this.writeByte(Z75[8]);
  245. Z75[7] = this;
  246. Z75[4].forEach(I_O);
  247. function I_O(s0Q, H4K, j$o) {
  248. var N0o = [arguments];
  249. Z75[7].writeByte(N0o[0][0]);
  250. }
  251. }
  252. toBase64() {
  253. var P4$ = [arguments];
  254. P4$[4] = "";
  255. P4$[9] = new Uint8Array(this.buffer);
  256. P4$[8] = this.index;
  257. for (P4$[7] = 0; P4$[7] < P4$[8]; P4$[7]++) {
  258. P4$[4] += String.fromCharCode(P4$[9][P4$[7]]);
  259. }
  260. return Gwindow.btoa(P4$[4]);
  261. }
  262. fromBase64(W69, A8Q) {
  263. var o0n = [arguments];
  264. o0n[8] = Gwindow.pako;
  265. o0n[6] = Gwindow.atob(o0n[0][0]);
  266. o0n[9] = o0n[6].length;
  267. o0n[4] = new Uint8Array(o0n[9]);
  268. for (o0n[1] = 0; o0n[1] < o0n[9]; o0n[1]++) {
  269. o0n[4][o0n[1]] = o0n[6].charCodeAt(o0n[1]);
  270. }
  271. if (o0n[0][1] === true) {
  272. o0n[5] = o0n[8].inflate(o0n[4]);
  273. o0n[4] = o0n[5];
  274. }
  275. this.buffer = o0n[4].buffer.slice(
  276. o0n[4].byteOffset,
  277. o0n[4].byteLength + o0n[4].byteOffset
  278. );
  279. this.view = new DataView(this.buffer);
  280. this.index = 0;
  281. }
  282. };
  283.  
  284. if(typeof(scope.originalSend)=='undefined'){scope.originalSend = Gwindow.WebSocket.prototype.send;}
  285. if(typeof(scope.originalXMLOpen)=='undefined'){scope.originalXMLOpen = Gwindow.XMLHttpRequest.prototype.open;}
  286. if(typeof(scope.originalXMLSend)=='undefined'){scope.originalXMLSend = Gwindow.XMLHttpRequest.prototype.send;}
  287. if(typeof(scope.searchrequested)=='undefined'){scope.searchrequested = false;}
  288. if(typeof(scope.originalDrawCircle)=='undefined'){scope.originalDrawCircle = Gwindow.PIXI.Graphics.prototype.drawCircle;}
  289. if(typeof(scope.parentDraw)=='undefined'){scope.parentDraw = 0;}
  290. if(typeof(scope.pixiCircle)=='undefined'){scope.pixiCircle = new Gwindow.PIXI.Graphics();}
  291. if(typeof(scope.container)=='undefined'){scope.container = new Gwindow.PIXI.Container();container.addChild(pixiCircle);}
  292. if(typeof(scope.canvasWidth)=='undefined'){scope.canvasWidth = -1;}
  293.  
  294.  
  295. if(typeof(scope.requestAnimationFrameOriginal)=='undefined'){scope.requestAnimationFrameOriginal = Gwindow.requestAnimationFrame;}
  296.  
  297.  
  298. if(typeof(scope.bonkwss)=='undefined'){scope.bonkwss = 0;}
  299. if(typeof(scope.bonkwssextra)=='undefined'){scope.bonkwssextra = [];}
  300. if(typeof(scope.chatlog)=='undefined'){scope.chatlog = ["ROOM START"];}
  301. if(typeof(scope.wsssendrecievelog)=='undefined'){scope.wsssendrecievelog = [];}
  302. if(typeof(scope.wsssendlog)=='undefined'){scope.wsssendlog = [];}
  303. if(typeof(scope.wssrecievelog)=='undefined'){scope.wssrecievelog = [];}
  304. if(typeof(scope.wsslogpaused)=='undefined'){scope.wsslogpaused = false;}
  305. if(typeof(scope.debuggeropen)=='undefined'){scope.debuggeropen = false;}
  306. if(typeof(scope.debuggercount)=='undefined'){scope.debuggercount = true;}
  307. if(typeof(scope.packetcount)=='undefined'){scope.packetcount = 0;}
  308. if(typeof(scope.requestedmaps)=='undefined'){scope.requestedmaps = [];}
  309. if(typeof(scope.maponclick)=='undefined'){scope.maponclick = 0;}
  310. if(typeof(scope.LZString)=='undefined'){scope.LZString = Gwindow.LZString;}
  311. if(typeof(scope.PSON)=='undefined'){scope.PSON = Gwindow.dcodeIO.PSON;}
  312. if(typeof(scope.bytebuffer)=='undefined'){scope.bytebuffer = Gwindow.dcodeIO.ByteBuffer;}
  313. if(typeof(scope.speech)=='undefined'){scope.speech = new SpeechSynthesisUtterance();speech.pitch = 0.75;}
  314. if(typeof(scope.sayer)=='undefined'){scope.sayer = speechSynthesis;sayer.volume = 0.5;sayer.rate = 1.25;}
  315. if(typeof(scope.pollactive)=='undefined'){scope.pollactive = [false,0,0,[]];}
  316. if(typeof(scope.pollactive2)=='undefined'){scope.pollactive2 = [false,0,[]];}
  317. if(typeof(scope.mode)=='undefined'){scope.mode = '';}
  318.  
  319. 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]);}
  320. if(typeof(scope.sandboxon)=='undefined'){scope.sandboxon = false;}
  321. if(typeof(scope.sandboxid)=='undefined'){scope.sandboxid = 1;}
  322. if(typeof(scope.playerids)=='undefined'){scope.playerids = {};}
  323. if(typeof(scope.delplayerids)=='undefined'){scope.delplayerids = {};}
  324. if(typeof(scope.myid)=='undefined'){scope.myid = -1;}
  325. if(typeof(scope.hostid)=='undefined'){scope.hostid = -1;}
  326. if(typeof(scope.sandboxplayerids)=='undefined'){scope.sandboxplayerids = {};}
  327. if(typeof(scope.originalMapLoad)=='undefined'){scope.originalMapLoad = Gdocument.getElementById("maploadwindowmapscontainer").appendChild;}
  328. if(typeof(scope.originalLobbyChat)=='undefined'){scope.originalLobbyChat = Gdocument.getElementById("newbonklobby_chat_content").appendChild;}
  329. if(typeof(scope.originalIngameChat)=='undefined'){scope.originalIngameChat = Gdocument.getElementById("ingamechatcontent").appendChild;}
  330. 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];}
  331. if(Gdocument.getElementById("maploadtypedropdowntitlerequested") == null){
  332. scope.clearmaprequests = Gdocument.createElement("div");
  333. clearmaprequests.id = "clearmaprequests";
  334. clearmaprequests.classList.value = "brownButton brownButton_classic buttonShadow";
  335. clearmaprequests.textContent = "Clear";
  336. clearmaprequests.style["position"] = "absolute";
  337. clearmaprequests.style["display"] = "none";
  338. if(typeof(ishost)!='undefined'){
  339. if(ishost && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS"){
  340. clearmaprequests.style["display"] = "block";
  341. }
  342. }
  343. clearmaprequests.style["right"] = "306px";
  344. clearmaprequests.style["top"] = "57px";
  345. clearmaprequests.style["height"] = "23px";
  346. clearmaprequests.style["width"] = "47px";
  347. clearmaprequests.style["line-height"] = "23px";
  348. clearmaprequests.style["font-size"] = "14px";
  349. clearmaprequests.addEventListener("click",function(){
  350. requestedmaps = [];
  351. Gdocument.getElementById("maploadwindowstatustext").style["visibility"] = "inherit";
  352. Gdocument.getElementById("maploadwindowstatustext").textContent = "No Maps";
  353. while(Gdocument.getElementById("maploadwindowmapscontainer").children.length>0){
  354. Gdocument.getElementById("maploadwindowmapscontainer").removeChild(Gdocument.getElementById("maploadwindowmapscontainer").firstChild);
  355. }
  356. });
  357. Gdocument.getElementById("maploadwindow").insertBefore(clearmaprequests,Gdocument.getElementById("maploadwindowsearchinput"));
  358. scope.refreshmaprequests = Gdocument.createElement("div");
  359. refreshmaprequests.id = "refreshmaprequests";
  360. refreshmaprequests.classList.value = "brownButton brownButton_classic buttonShadow";
  361. refreshmaprequests.textContent = "Refresh";
  362. refreshmaprequests.style["position"] = "absolute";
  363. refreshmaprequests.style["display"] = "none";
  364. if(typeof(ishost)!='undefined'){
  365. if(ishost && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS"){
  366. refreshmaprequests.style["display"] = "block";
  367. }
  368. }
  369. refreshmaprequests.style["right"] = "357px";
  370. refreshmaprequests.style["top"] = "57px";
  371. refreshmaprequests.style["height"] = "23px";
  372. refreshmaprequests.style["width"] = "47px";
  373. refreshmaprequests.style["line-height"] = "23px";
  374. refreshmaprequests.style["font-size"] = "14px";
  375. refreshmaprequests.addEventListener("click",function(){
  376. Gdocument.getElementById("maploadtypedropdowntitle").textContent = dropdownrequested.textContent;
  377. Gdocument.getElementById("maploadwindowsearchinput").value = "";
  378. dropdownrequested.style["display"] = "none";
  379. clearmaprequests.style["display"] = "block";
  380. refreshmaprequests.style["display"] = "block";
  381. Gdocument.getElementById("maploadwindowhotnessslider").style["visibility"] = "hidden";
  382. Gdocument.getElementById("maploadwindowsearchoptions").style["visibility"] = "hidden";
  383. searchrequested = true;
  384. Gdocument.getElementById("maploadwindowsearchbutton").click();
  385.  
  386. Gdocument.getElementById("maploadtypedropdowntitle").textContent = "MAP REQUESTS";
  387. });
  388. Gdocument.getElementById("maploadwindow").insertBefore(refreshmaprequests,Gdocument.getElementById("maploadwindowsearchinput"));
  389.  
  390. scope.dropdownrequested = Gdocument.createElement("div");
  391. dropdownrequested.classList = "dropdown-option dropdown_classic";
  392. dropdownrequested.style["display"] = "none";
  393. dropdownrequested.id = "maploadtypedropdowntitlerequested";
  394.  
  395. if(Gdocument.getElementById("maploadtypedropdownoption10").style["display"] == "block"){
  396. dropdownrequested.style["display"] = "block";
  397. }
  398. dropdownrequested.textContent = "MAP REQUESTS";
  399. dropdownrequested.onclick = function(){
  400. Gdocument.getElementById("maploadtypedropdowntitle").textContent = dropdownrequested.textContent;
  401. Gdocument.getElementById("maploadwindowsearchinput").value = "";
  402. dropdownrequested.style["display"] = "none";
  403. clearmaprequests.style["display"] = "block";
  404. refreshmaprequests.style["display"] = "block";
  405. Gdocument.getElementById("maploadwindowhotnessslider").style["visibility"] = "hidden";
  406. Gdocument.getElementById("maploadwindowsearchoptions").style["visibility"] = "hidden";
  407. searchrequested = true;
  408. Gdocument.getElementById("maploadwindowsearchbutton").click();
  409.  
  410. Gdocument.getElementById("maploadtypedropdowntitle").textContent = "MAP REQUESTS";
  411. };
  412. (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});
  413. Gdocument.getElementById("maploadtypedropdown").insertBefore(dropdownrequested,Gdocument.getElementById("maploadtypedropdownoption1"));
  414. Gdocument.getElementById("maploadwindowmapscontainer").__defineGetter__("clientHeight",function(){if(Gdocument.getElementById("maploadtypedropdowntitle").textContent != "MAP REQUESTS"){return Gdocument.getElementById("maploadwindowmapscontainer").getClientRects()[0].height;}else{return 0;}});
  415.  
  416. };
  417.  
  418. function sandboxonclick(){
  419. Gdocument.getElementById("roomlistcreatewindowmaxplayers").value = 1;
  420. Gdocument.getElementById("roomlistcreatewindowunlistedcheckbox").checked = true;
  421. Gdocument.getElementById("roomlistcreatecreatebutton").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. var canv = 0;
  1436. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  1437. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  1438. canv = Gdocument.getElementById("gamerenderer").children[i];
  1439. break;
  1440. }
  1441. }
  1442. var width = parseInt(canv.style["width"]);
  1443. var height = parseInt(canv.style["height"]);
  1444. var scale = (parseInt(canv.style["width"])/730);
  1445. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  1446. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  1447. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  1448. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  1449. if(canvasWidth!=width){
  1450. canvasWidth = width;
  1451. pixiCircle.clear();
  1452. pixiCircle.x = parseInt(canv.style["width"])/2;
  1453. pixiCircle.y = parseInt(canv.style["height"])/2;
  1454. pixiCircle.lineStyle(3, 0x8B8000);
  1455. pixiCircle.drawRect(-parseInt(canv.style["width"])/2,-parseInt(canv.style["height"])/2,parseInt(canv.style["width"]),parseInt(canv.style["height"]));
  1456. pixiCircle.lineStyle(3, 0xFF0000);
  1457. pixiCircle.arc(0, 0, 850*scale,Math.atan2(250,-100*Math.sqrt(66)),Math.atan2(250,100*Math.sqrt(66)));
  1458. pixiCircle.lineTo(-100*Math.sqrt(66)*scale,250*scale);
  1459. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  1460. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  1461. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  1462. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  1463. }
  1464.  
  1465. if(!addto.children.includes(container)){
  1466. addto.addChild(container);
  1467. }
  1468. if(keys.length>0){
  1469. if(playerids[myid].playerData && playerids[myid].playerData2){
  1470. if(aimbot || heavybot){
  1471. var targetid = -1;
  1472. var distances = {};
  1473. if(playerids[myid].playerData.transform){
  1474. var teamok = true;
  1475. if(playerids[myid].team>1){
  1476. teamok = false;
  1477. }
  1478. for(var i = 0;i<keys.length;i++){
  1479. if(playerids[keys[i]].playerData && playerids[keys[i]].playerData2 && keys[i]!=myid){
  1480. if(playerids[keys[i]].playerData.transform && (playerids[keys[i]].team != playerids[myid].team || teamok)){
  1481. 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);
  1482. }
  1483. }
  1484. }
  1485. }
  1486. var lowestD = [-1,-1];
  1487. var keys2 = Object.keys(distances);
  1488. for(var i = 0;i<keys2.length;i++){
  1489. if(myid != keys2[i]){
  1490. if(lowestD[1] == -1){
  1491. lowestD[1] = distances[keys2[i]];
  1492. lowestD[0] = keys2[i];
  1493. }
  1494. else if(distances[keys2[i]]<lowestD[1]){
  1495. lowestD[1] = distances[keys2[i]];
  1496. lowestD[0] = keys2[i];
  1497. }
  1498. }
  1499. }
  1500. targetid = lowestD[0];
  1501. if(targetid != -1 && playerids[myid].playerData.transform){
  1502. if(playerids[myid].playerData.children.length >= 7 && playerids[targetid].playerData && playerids[targetid].playerData?.transform && playerids[targetid].playerData2 && playerids[myid].playerData.transform && aimbot){
  1503. var indexE = -1;
  1504. for(var i = 0;i<playerids[myid].playerData.children.length;i++){
  1505. if(playerids[myid].playerData.children[i].constructor.name == "e"){
  1506. indexE = i;
  1507. break;
  1508. }
  1509. }
  1510. if(indexE != -1 && playerids[myid].playerData.children[indexE].visible){
  1511. if(started == 0){
  1512. started = now;
  1513. }
  1514. var scale=1/(parseInt(canv.style["width"])/730);
  1515. scale /= scale*1/(1 + playerids[myid].playerData2.balance*0.0088)*(playerids[myid].playerData2.radius/12);
  1516. var Dstarted = (Math.min((now-started)/1000,10/3)/(10/3));
  1517. var v = multiplier * (Dstarted*100+15);
  1518. var g = gravity;
  1519. var mypos = playerids[myid].playerData.transform.position;
  1520. var targetpos = playerids[targetid].playerData.transform.position;
  1521. var deltapos = [(targetpos.x-mypos.x)*scale,(targetpos.y-mypos.y)*scale];
  1522. var dis = (Math.sqrt(deltapos[0]**2 + deltapos[1]**2))/v*prediction;
  1523. deltapos[0]+=playerids[targetid].playerData2.xvel*scale*dis+(playerids[targetid].playerData2.xacc*scale*(dis))**2/2;
  1524. deltapos[1]+=playerids[targetid].playerData2.yvel*scale*dis+(playerids[targetid].playerData2.yacc*scale*(dis))**2/2;
  1525. deltapos[1] = -deltapos[1];
  1526. var angle = positive(-Math.atan2(deltapos[1],deltapos[0]));
  1527. var rot = playerids[myid].playerData.children[indexE].transform.rotation;
  1528. rot = positive(rot);
  1529. angle = positive(angle);
  1530.  
  1531. var alpha = deltapos[0];
  1532. var beta = deltapos[1];
  1533. var v_squared = v**2;
  1534. var rootterm = v_squared**2 - g*(g*alpha**2+2*beta*v_squared);
  1535. if(rootterm < 0) {
  1536. } else {
  1537. gamma_first = (v_squared + Math.sqrt(rootterm));
  1538. gamma_second = (v_squared - Math.sqrt(rootterm));
  1539. theta_first = positive(-Math.atan2(gamma_first, g*alpha));
  1540. theta_second = positive(-Math.atan2(gamma_second, g*alpha));
  1541. if(angle_between(angle,theta_first)<angle_between(angle,theta_second)){
  1542. angle = theta_first;
  1543. }
  1544. else{
  1545. angle = theta_second;
  1546. }
  1547. }
  1548. var min = angle_between(angle,rot);
  1549. if(angle_between2(angle,rot)<0){
  1550. fire("keydown",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1551. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"))
  1552. }
  1553. else{
  1554. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1555. fire("keydown",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"))
  1556. }
  1557. if(min<0.05){
  1558. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1559. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1560. }
  1561. }
  1562. else if(started>0){
  1563. started = 0;
  1564. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1565. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1566. }
  1567. }
  1568. }
  1569. if(playerids[myid].playerData.transform && heavybot && mode!="f"){
  1570. var scale=1/(parseInt(canv.style["width"])/730);
  1571. var myradius = playerids[myid].playerData2.radius * scale;
  1572. var mypos = playerids[myid].playerData.transform.position;
  1573. var breakout = false;
  1574. var collision_happened = false;
  1575. for(var i = 0;i<keys2.length;i++){
  1576. var targetradius = playerids[keys2[i]].playerData2.radius * scale;
  1577. var targetpos = playerids[keys2[i]].playerData.transform.position;
  1578. var deltapos = [(targetpos.x-mypos.x)*scale,(targetpos.y-mypos.y)*scale];
  1579. for(var i2 = 0;i2<4;i2++){
  1580. deltapos2 = [...deltapos];
  1581. deltapos2[0]+=(playerids[targetid].playerData2.xvel-playerids[myid].playerData2.xvel)*scale*i2*3;
  1582. deltapos2[1]+=(playerids[targetid].playerData2.yvel-playerids[myid].playerData2.yvel)*scale*i2*3;
  1583. var dis = Math.sqrt(deltapos2[0]**2+deltapos2[1]**2);
  1584. if(dis<myradius+targetradius){
  1585. holdheavy = 10;
  1586. breakout = true;
  1587. collision_happened = true;
  1588. break;
  1589. }
  1590. }
  1591. if(breakout){
  1592. break;
  1593. }
  1594. }
  1595. if(holdheavy>0){
  1596. if(collision_happened){
  1597. holdheavy = 10;
  1598. }
  1599. if(!heavyheld2){
  1600. heavyheld = playerids[myid].playerData.children[3].alpha>0;
  1601. }
  1602. fire("keydown",{"keyCode":heavy},Gdocument.getElementById("gamerenderer"));
  1603. heavyheld2 = true;
  1604. if(mode == "sp"){
  1605. if(!grappleheld2){
  1606. grappleheld = playerids[myid].playerData.children[0].vertexData?.length>0;
  1607. }
  1608. fire("keyup",{"keyCode":special},Gdocument.getElementById("gamerenderer"));
  1609. grappleheld2 = true;
  1610. }
  1611. }
  1612. else if(holdheavy<0){
  1613. holdheavy = 0;
  1614. heavyheld2 = false;
  1615. grappleheld2 = false;
  1616. if(!heavyheld){
  1617. heavyheld = false;
  1618. fire("keyup",{"keyCode":heavy},Gdocument.getElementById("gamerenderer"));
  1619. }
  1620. if(grappleheld && mode == "sp"){
  1621. grappleheld = false;
  1622. fire("keydown",{"keyCode":special},Gdocument.getElementById("gamerenderer"));
  1623. }
  1624. }
  1625. }
  1626.  
  1627. }
  1628. if(FollowCam){
  1629. if(playerids[myid].playerData.transform){
  1630.  
  1631. pixiCircle.visible = true;
  1632.  
  1633. parentDraw.x = -playerids[myid].playerData.x*addto.scale.x+parseInt(width)/2;
  1634. parentDraw.y = -playerids[myid].playerData.y*addto.scale.y+parseInt(height)/2;
  1635. parentDraw.children[0].x = playerids[myid].playerData.x*addto.scale.x-parseInt(width)/2;
  1636. parentDraw.children[0].y = playerids[myid].playerData.y*addto.scale.y-parseInt(height)/2;
  1637. }
  1638. else{
  1639. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  1640. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  1641. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  1642. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  1643. if(addto.scale.x>=0.95 && addto.scale.y>=0.95){
  1644. pixiCircle.visible = false;
  1645. }
  1646. else{
  1647. pixiCircle.visible = true;
  1648. }
  1649. }
  1650. }
  1651. }
  1652. }
  1653. if(!FollowCam){
  1654. if(addto.scale.x>=0.95 && addto.scale.y>=0.95){
  1655. pixiCircle.visible = false;
  1656. }
  1657. else{
  1658. pixiCircle.visible = true;
  1659. }
  1660. }
  1661. }
  1662. return requestAnimationFrameOriginal.call(this,...args);
  1663. };
  1664. scope.SENDFUNCTION = function(args){return args;};
  1665. scope.RECIEVEFUNCTION = function(args){return args;};
  1666. scope.EVENTLOOPFUNCTION = function(){};
  1667.  
  1668. Gwindow.WebSocket.prototype.send = function(args) {
  1669. if(this.url.includes(".bonk.io/socket.io/?EIO=3&transport=websocket&sid=")){
  1670. if(typeof(args) == "string" && !bonkwssextra.includes(this)){
  1671. args = SENDFUNCTION(args);
  1672. wsssendlog.push(args);
  1673. wsssendrecievelog.push([0,args]);
  1674. if(!bonkwss){
  1675. bonkwss = this;
  1676. }
  1677. if(args.startsWith('42[26,')){
  1678. if(sandboxon){
  1679. var jsonargs = JSON.parse(args.substring(2))[1];
  1680. if(typeof(sandboxplayerids[jsonargs["targetID"]])!='undefined'){
  1681. RECIEVE('42[18,'+jsonargs["targetID"]+','+jsonargs["targetTeam"]+']');
  1682.  
  1683. }
  1684. }
  1685. }
  1686. if(args.startsWith('42[1,')){
  1687. return;
  1688. }
  1689.  
  1690. if(args.startsWith('42[4,')){
  1691. var jsonargs = JSON.parse(args.substring(2));
  1692. if(sandboxcopyme && typeof(jsonargs[1]["i"])!="undefined"){
  1693. var jsonkeys = Object.keys(sandboxplayerids);
  1694. for(var i = 0; i<jsonkeys.length;i++){
  1695. RECIEVE('42[7,'+jsonkeys[i].toString()+','+JSON.stringify(jsonargs[1])+']');
  1696. }
  1697. }
  1698. playerids[myid].lastmove = Date.now();
  1699. if(ishost && typeof(jsonargs[1]["i"])!="undefined"){
  1700. for(var i = 0;i<disabledkeys.length;i++){
  1701. if(GET_KEYS(jsonargs[1]["i"])[disabledkeys[i]]){
  1702. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden" && !killedids.includes(myid)){
  1703. killedids.push(myid);
  1704. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  1705. SEND('42[25,{"a":{"playersLeft":['+myid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  1706. RECIEVE('42[31,{"a":{"playersLeft":['+myid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  1707. break;
  1708. }
  1709. }
  1710. }
  1711. }
  1712. args = "42"+JSON.stringify(jsonargs);
  1713. }
  1714. if(args.startsWith('42[29,')){
  1715. var jsonargs = JSON.parse(args.substring(2));
  1716. playerids[jsonargs[1]["sid"]].playerData2.balance = jsonargs[1]["bal"];
  1717. }
  1718. if(args.startsWith('42[12,')){
  1719. playerids = {};
  1720. var jsonargs2 = JSON.parse(args.substring(2));
  1721. var jsonargs = jsonargs2[1];
  1722. 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}};
  1723. myid = 0;
  1724. bonkwss = this;
  1725. hostid = 0;
  1726. }
  1727. if(args.startsWith('42[23,') && recteams){
  1728. var jsonargs = JSON.parse(args.substring(2));
  1729. var map = decodeFromDatabase(jsonargs[1]["m"]);
  1730. var spawns = map["spawns"];
  1731. var teamsneeded = true;
  1732. var excludedindexes = [];
  1733. var ffaspawns = false;
  1734. var ffaforsure = false;
  1735. for(var i = 0; i<spawns.length;i++){
  1736. var currentSpawn = spawns[i];
  1737. if(Math.sqrt(currentSpawn.x**2 + currentSpawn.y**2)>=850 || currentSpawn.y>250){
  1738. excludedindexes.push(i);
  1739. }
  1740. else if(!(currentSpawn.f || currentSpawn.r || currentSpawn.b || currentSpawn.gr || currentSpawn.ye)){
  1741. excludedindexes.push(i);
  1742. }
  1743. else if(currentSpawn.f){
  1744. ffaspawns = true;
  1745. if(!(currentSpawn.r || currentSpawn.b || currentSpawn.gr || currentSpawn.ye)){
  1746. excludedindexes.push(i);
  1747. ffaforsure = true
  1748. }
  1749. }
  1750. }
  1751. if(!ffaspawns && !ffaforsure){
  1752. teamsneeded = true;
  1753. }
  1754. else{
  1755. teamsneeded = false;
  1756. }
  1757. if(teamsneeded){
  1758. var newspawns = [];
  1759. for(var i = 0; i<spawns.length;i++){
  1760. if(!excludedindexes.includes(i)){
  1761. 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"]});
  1762. }
  1763. }
  1764. if(newspawns.length>0){
  1765. var teamletters = ["r","g","b","y"];
  1766. var ratios = {"r":0,"g":0,"b":0,"y":0};
  1767. for(var i = 0; i < newspawns.length;i++){
  1768. for(var i2 = 0; i2<teamletters.length;i2++){
  1769. var ct = teamletters[i2];
  1770. if(newspawns[i]["priority"]!=0){
  1771. ratios[ct]+=(newspawns[i][ct])/newspawns[i]["total"]*newspawns[i]["priority"];
  1772. }
  1773. }
  1774. }
  1775. var highest = ["",0];
  1776. for(var i = 0; i<teamletters.length;i++){
  1777. var ct = teamletters[i];
  1778. if(ratios[ct]>0 && highest[1]<ratios[ct]){
  1779. highest = [ct,ratios[ct]];
  1780. }
  1781. }
  1782. if(highest[0]!=""){
  1783. for(var i = 0; i<teamletters.length;i++){
  1784. var ct = teamletters[i];
  1785. ratios[ct] = ratios[ct]/highest[1];
  1786. }
  1787. }
  1788. var playerids3 = Object.keys(playerids);
  1789. var playerids2 = [];
  1790. for(var i = 0; i<playerids3.length;i++){
  1791. if(playerids[playerids3[i]].team>0){
  1792. playerids2.push(playerids3[i]);
  1793. }
  1794. }
  1795. var pi2l = playerids2.length;
  1796. var ratios2 = {"r":0,"r1":0,"g":0,"g1":0,"b":0,"b1":0,"y":0,"y1":0};
  1797. var items = Object.entries(ratios);
  1798. items.sort(function(a,b){return a[1]-b[1];});
  1799. var items = items.map(function(e){return e[0];});
  1800. var highest2 = ["",0];
  1801. while(pi2l>0){
  1802. var done = false;
  1803. for(var i2 = 0; i2<items.length;i2++){
  1804. var ci = items[i2];
  1805. var ci2 = items[i2]+"1";
  1806. for(var i = 0; i<teamletters.length;i++){
  1807. var ct = teamletters[i];
  1808. if(ratios2[ct]>0 && highest2[1]<ratios2[ct]){
  1809. highest2 = [ct,ratios2[ct]];
  1810. }
  1811. }
  1812. if(highest2[0]!=""){
  1813. for(var i = 0; i<teamletters.length;i++){
  1814. var ct = teamletters[i];
  1815. ratios2[ct+"1"] = ratios2[ct]/highest2[1];
  1816. }
  1817. }
  1818. if(ratios[ci]>0 && ratios[ci]>=ratios2[ci2] && pi2l>0){
  1819. ratios2[ci]+=1;
  1820. pi2l--;
  1821. done = true;
  1822. }
  1823. }
  1824. if(pi2l>0 && !done){
  1825. ratios2[highest2[0]]+=1;
  1826. pi2l--;
  1827. }
  1828. }
  1829. SEND('42[32,{"t":true}]');
  1830. RECIEVE('42[39,true]');
  1831. for(var i = 0; i<ratios2["r"];i++){
  1832. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  1833. SEND('42[26,{"targetID":'+pid+',"targetTeam":2}]');
  1834. RECIEVE('42[18,'+pid+',2]');
  1835. }
  1836. for(var i = 0; i<ratios2["g"];i++){
  1837. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  1838. SEND('42[26,{"targetID":'+pid+',"targetTeam":4}]');
  1839. RECIEVE('42[18,'+pid+',4]');
  1840. }
  1841. for(var i = 0; i<ratios2["b"];i++){
  1842. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  1843. SEND('42[26,{"targetID":'+pid+',"targetTeam":3}]');
  1844. RECIEVE('42[18,'+pid+',3]');
  1845. }
  1846. for(var i = 0; i<ratios2["y"];i++){
  1847. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  1848. SEND('42[26,{"targetID":'+pid+',"targetTeam":5}]');
  1849. RECIEVE('42[18,'+pid+',5]');
  1850. }
  1851. }
  1852. }
  1853. else{
  1854. SEND('42[32,{"t":false}]');
  1855. RECIEVE('42[39,false]');
  1856. }
  1857. }
  1858.  
  1859. if(args.startsWith('42[47,') && stopquickplay == 0 && ishost && document.hidden && !qppaused){
  1860. roundsperqp2++;
  1861. if(roundsperqp2>=roundsperqp){
  1862. if(shuffle){
  1863. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  1864. var available = [];
  1865. var availableindexes = [];
  1866. var notempty = false;
  1867. for(var i = 0; i<e2.length;i++){
  1868. var a = false;
  1869. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  1870. available.push(a);
  1871. if(a){
  1872. availableindexes.push(i);
  1873. notempty = true;
  1874. }
  1875. }
  1876. if(notempty){
  1877.  
  1878. if(availableindexes.length!=1){
  1879. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  1880. }
  1881. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  1882. }
  1883. }
  1884. else{
  1885. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  1886. var available = [];
  1887. var availableindexes = [];
  1888. var notempty = false;
  1889. for(var i = 0; i<e2.length;i++){
  1890. var a = false;
  1891. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  1892. available.push(a);
  1893. if(a){
  1894. availableindexes.push(i);
  1895. notempty = true;
  1896. }
  1897. }
  1898. if(notempty){
  1899. var above = [];
  1900. for(var i = 0;i<availableindexes.length;i++){
  1901. if(availableindexes[i]>quicki){
  1902. above.push(availableindexes[i]);
  1903. }
  1904. }
  1905. if(above.length>0){
  1906. quicki = above[0];
  1907. }
  1908. else{
  1909. quicki = availableindexes[0];
  1910. }
  1911. }
  1912. }
  1913. }
  1914. canceled = false;
  1915. startedinqp = true;
  1916. window.map(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length),0);
  1917. }
  1918.  
  1919. if(args.startsWith('42[5,')){
  1920. var jsonargs = JSON.parse(args.substring(2));
  1921. if(stopquickplay!=1 && startedinqp){
  1922. startedinqp = false;
  1923. jsonargs[1]["gs"]["wl"] = 999;
  1924. if(!instaqp){
  1925. var jsonargs2 = decodeIS(jsonargs[1]["is"]);
  1926. jsonargs2["ftu"] = 60;
  1927. if(jsonargs2["mm"]["rxa"] != ""){
  1928. jsonargs2["mm"]["a"] = jsonargs2["mm"]["rxa"];
  1929. jsonargs2["mm"]["n"] = jsonargs2["mm"]["rxn"];
  1930. }
  1931. jsonargs2 = encodeIS(jsonargs2);
  1932. jsonargs[1]["is"] = jsonargs2;
  1933. var jsonargs3 = decodeFromDatabase(jsonargs[1]["gs"]["map"]);
  1934. if(jsonargs3["m"]["rxa"] != ""){
  1935. jsonargs3["m"]["a"] = jsonargs3["m"]["rxa"];
  1936. jsonargs3["m"]["n"] = jsonargs3["m"]["rxn"];
  1937. }
  1938.  
  1939. jsonargs3 = encodeToDatabase(jsonargs3);
  1940. jsonargs[1]["gs"]["map"] = jsonargs3;
  1941. }
  1942. }
  1943.  
  1944. args = "42"+JSON.stringify(jsonargs);
  1945. }
  1946. }
  1947.  
  1948. }
  1949. else{
  1950. if(args.includes("rport")){
  1951. return;
  1952. }
  1953. }
  1954. if(this.url.includes(".bonk.io/socket.io/?EIO=3&transport=websocket&sid=") && !this.injected){
  1955. this.injected = true;
  1956.  
  1957. var originalRecieve = this.onmessage;
  1958. this.onmessage = function(args){
  1959. if(!bonkwssextra.includes(this)){
  1960. wssrecievelog.push(args.data);
  1961. wsssendrecievelog.push([1,args.data]);
  1962. if(typeof(args.data)=="string"){
  1963. args = {"data":RECIEVEFUNCTION(args.data)};
  1964. if(args.data.startsWith('42[1,')){
  1965. var jsonargs = JSON.parse(args.data.substring(2));
  1966. originalSend.call(this,'42[1,{"id":'+jsonargs[2]+'}]');
  1967. }
  1968. if(args.data.startsWith('42[36,')){
  1969. var jsonargs = JSON.parse(args.data.substring(2));
  1970. playerids[jsonargs[1]].playerData2.balance = jsonargs[2];
  1971. }
  1972. if(args.data.startsWith('42[24,')){
  1973. beenKickedTimeStamp = Date.now();
  1974. onlykicked = JSON.parse(args.data.substring(2))[2];
  1975. }
  1976. if(args.data.startsWith('42[16,')){
  1977. var jsonargs = JSON.parse(args.data.substring(2));
  1978. var now = Date.now();
  1979. if(jsonargs[1]=="chat_rate_limit"){
  1980. if(pollactive[1]+100>now){
  1981. pollactive = [false,0,0,[]];
  1982. displayInChat("Your poll failed due to chat rate limit.","#DA0808","#1EBCC1");
  1983. displayInChat("Please try again.","#DA0808","#1EBCC1");
  1984. }
  1985. }
  1986. }
  1987. if(args.data.startsWith('42[6,')){
  1988. var jsonargs = JSON.parse(args.data.substring(2));
  1989. if(typeof(playerids[jsonargs[1]])!='undefined'){
  1990. delplayerids[jsonargs[1]] = playerids[jsonargs[1]];
  1991. delete playerids[jsonargs[1]];
  1992. }
  1993. hostid = jsonargs[2];
  1994. }
  1995. if(args.data.startsWith('42[41,')){
  1996. var jsonargs = JSON.parse(args.data.substring(2));
  1997. hostid = jsonargs[1]["newHost"];
  1998. }
  1999. if(args.data.startsWith('42[20,')){
  2000. var jsonargs = JSON.parse(args.data.substring(2));
  2001. if(echo_list.includes(playerids[jsonargs[1]].userName)){
  2002. chat(flag_manage(echotext.replaceAll("username",playerids[jsonargs[1]].userName).replaceAll("message",jsonargs[2])));
  2003. }
  2004. if(pollactive[0] || pollactive2[0]){
  2005. var chatmessage = jsonargs[2].toUpperCase().trim().replace(")","");
  2006. var lettersindex = letters.indexOf(chatmessage);
  2007. if(ishost){
  2008. if(pollactive[3].length>0 && lettersindex!=-1 && lettersindex<pollactive[3].length){
  2009. playerids[jsonargs[1]].vote.poll = lettersindex;
  2010. }
  2011. }
  2012. else{
  2013. if(pollactive2[2].length>0 && lettersindex!=-1 && lettersindex<pollactive2[2].length){
  2014. playerids[jsonargs[1]].vote.poll = lettersindex;
  2015. }
  2016. }
  2017. }
  2018. }
  2019. if(args.data.startsWith('42[32')){
  2020. SEND('42[4,{"type":"inactive kick counter"}]');
  2021. }
  2022. if(args.data.startsWith('42[18')){
  2023. var jsonargs = JSON.parse(args.data.substring(2));
  2024. playerids[jsonargs[1]].team = jsonargs[2];
  2025. }
  2026. if(args.data.startsWith('42[40,')){
  2027. recordedTimeStamp = Date.now();
  2028. recordedId = JSON.parse(args.data.substring(2))[1];
  2029. }
  2030. if(args.data.startsWith('42[3,')){
  2031. playerids = {};
  2032. var jsonargs = JSON.parse(args.data.substring(2));
  2033. for(var i = 0; i<jsonargs[3].length;i++){
  2034. if(jsonargs[3][i]!=null){
  2035. playerids[i.toString()] = jsonargs[3][i];
  2036. playerids[i.toString()].ratelimit = {"pm":0,"mode":0,"team":0,"poll":0};
  2037. playerids[i.toString()].vote = {"poll":-1};
  2038. }
  2039. }
  2040. if(playerids[jsonargs[1]].userName.startsWith(Gdocument.getElementById("pretty_top_name").textContent)){
  2041. myid = jsonargs[1];
  2042. bonkwss = this;
  2043. }
  2044. else{
  2045. bonkwssextra.push(this);
  2046. }
  2047. hostid = jsonargs[2];
  2048. }
  2049. if(args.data.startsWith('42[15,')){
  2050. var jsonargs = JSON.parse(args.data.substring(2));
  2051. dontswitch = false;
  2052. mode = jsonargs[3]["mo"];
  2053. gameStartTimeStamp = Date.now();
  2054. killedids = [];
  2055. }
  2056. if(args.data.startsWith('42[33,')){
  2057. var jsonargs = JSON.parse(args.data.substring(2));
  2058. var decodedmap = decodeFromDatabase(jsonargs[1]);
  2059. if(decodedmap!=0){
  2060. requestedmaps.push([decodedmap,jsonargs[1]]);
  2061. }
  2062. }
  2063. if(args.data.startsWith('42[7,')){
  2064. var jsonargs2 = JSON.parse(args.data.substring(2));
  2065. var idofpacket = jsonargs2[1];
  2066. jsonargs = jsonargs2[2];
  2067. if(typeof(jsonargs["i"]) == "undefined"){
  2068. if(jsonargs["type"]=="private chat" && jsonargs["to"] == username){
  2069. from = jsonargs["from"];
  2070. if(Object.keys(playerids).includes(idofpacket.toString())){
  2071. from = playerids[idofpacket].userName;
  2072. }
  2073. if(!ignorepmlist.includes(from)){
  2074. if(typeof(jsonargs["message"])=="object" && typeof(jsonargs["password"]) == "object"){
  2075. if(public_key[0]==jsonargs["public key"][0] && public_key[1]==jsonargs["public key"][1]){
  2076. var now = Date.now();
  2077. if(jsonargs["password"].length<=25 && playerids[idofpacket].ratelimit.pm+250<now){
  2078. playerids[idofpacket].ratelimit.pm = now;
  2079. var password = CRYPT_MESSAGE(private_key,jsonargs["password"]);
  2080. var decodedtext = jsonargs["message"].slice(0,400);
  2081. var encodedtext = "";
  2082. for(var i=0;i<decodedtext.length;i++){
  2083. if(password[i%password.length]<1000){
  2084. encodedtext+=String.fromCharCode(password[i%password.length]^decodedtext[i]);
  2085. }
  2086. }
  2087. 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);';
  2088. displayInChat('> '+'<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+from+'</a>'+': ',"#DA0808","#1EBCC1",{sanitize:false},encodedtext);
  2089.  
  2090. Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true;
  2091. Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true;
  2092. Laster_message = lastmessage();
  2093. }
  2094. }
  2095. else{
  2096. SEND("42"+JSON.stringify([4,{"type":"public key correction","from":username,"to":private_chat_public_key[0],"public key":public_key}]));
  2097. }
  2098. }
  2099. }
  2100. }
  2101. if(jsonargs["type"]=="request public key" && jsonargs["to"] == username){
  2102. SEND("42"+JSON.stringify([4,{"type":"public key","from":username,"public key":public_key}]));
  2103. }
  2104. if(jsonargs["type"]=="private chat users" && pmuserstimestamp+1500>Date.now()){
  2105. if(typeof(jsonargs["from"])!='undefined'){
  2106. from = jsonargs["from"];
  2107. if(Object.keys(playerids).includes(idofpacket.toString())){
  2108. from = playerids[idofpacket].userName;
  2109. }
  2110. if(!pmusers.includes(from) && username == jsonargs["to"]){
  2111. pmusers.push(from);
  2112. }
  2113. }
  2114. }
  2115. if(jsonargs["type"]=="request private chat users"){
  2116. if(typeof(jsonargs["from"])!='undefined'){
  2117. from = jsonargs["from"];
  2118. if(Object.keys(playerids).includes(idofpacket.toString())){
  2119. from = playerids[idofpacket].userName;
  2120. }
  2121. SEND("42"+JSON.stringify([4,{"type":"private chat users","from":username,"to":from}]));
  2122. }
  2123. }
  2124. if(jsonargs["type"]=="public key" && request_public_key_time_stamp+1500>Date.now()){
  2125. from = jsonargs["from"];
  2126. if(Object.keys(playerids).includes(idofpacket.toString())){
  2127. from = playerids[idofpacket].userName;
  2128. }
  2129. if(from == private_chat){
  2130. private_chat_public_key = [private_chat,jsonargs["public key"]];
  2131. displayInChat("Private chatting with "+private_chat+".","#DA0808","#1EBCC1");
  2132. }
  2133. }
  2134. if(jsonargs["type"]=="vote poll"){
  2135. from = jsonargs["from"];
  2136. if(Object.keys(playerids).includes(idofpacket.toString())){
  2137. from = playerids[idofpacket].userName;
  2138. }
  2139. if(typeof(jsonargs["vote"]) == 'number' && idofpacket!=hostid){
  2140. var now = Date.now();
  2141. if(ishost && pollactive[3].length>1 && pollactive[0]){
  2142. if(jsonargs["vote"]>=0 && jsonargs["vote"]<pollactive[3].length){
  2143. playerids[idofpacket].vote.poll = jsonargs["vote"];
  2144. }
  2145. }
  2146. else if(pollactive2[0] && pollactive2[2].length>1){
  2147. if(jsonargs["vote"]>=0 && jsonargs["vote"]<pollactive2[2].length){
  2148. playerids[idofpacket].vote.poll = jsonargs["vote"];
  2149. }
  2150. }
  2151. }
  2152.  
  2153. }
  2154. if(jsonargs["type"]=="poll end"){
  2155. from = jsonargs["from"];
  2156. if(Object.keys(playerids).includes(idofpacket.toString())){
  2157. from = playerids[idofpacket].userName;
  2158. }
  2159. var now = Date.now();
  2160. if(hostid == idofpacket && playerids[idofpacket].ratelimit.poll+5000<now){
  2161. playerids[idofpacket].ratelimit.poll = now;
  2162. var count = [0,0,0,0];
  2163. var keys = Object.keys(playerids);
  2164. for(var i = 0;i<keys.length;i++){
  2165. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive2[2].length-1){
  2166. count[playerids[keys[i]].vote.poll]++;
  2167. }
  2168. playerids[keys[i]].vote.poll = -1;
  2169. }
  2170. displayInChat("The poll ended.","#DA0808","#1EBCC1");
  2171. for(var i = 0;i<count.length;i++){
  2172. if(count[i]>1){
  2173. displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  2174. }
  2175. if(count[i]==1){
  2176. displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  2177. }
  2178. }
  2179. pollactive2 = [false,0,[]];
  2180. }
  2181.  
  2182. }
  2183. if(jsonargs["type"]=="poll" && idofpacket == hostid){
  2184. from = jsonargs["from"];
  2185. if(Object.keys(playerids).includes(idofpacket.toString())){
  2186. from = playerids[idofpacket].userName;
  2187. }
  2188. if(Array.isArray(jsonargs["poll"])){
  2189. var propperpoll = true;
  2190. var pollifproper = [];
  2191. if(jsonargs["poll"].length>5){
  2192. propperpoll = false;
  2193. }
  2194. else{
  2195. for(var i = 0;i<jsonargs["poll"].length;i++){
  2196. if(typeof(jsonargs["poll"][i]) == 'string'){
  2197. if(jsonargs["poll"][i].length>50){
  2198. propperpoll = false;
  2199. break;
  2200. }
  2201. else{
  2202. pollifproper.push(jsonargs["poll"][i]);
  2203. }
  2204. }
  2205. else{
  2206. propperpoll = false;
  2207. break;
  2208. }
  2209. }
  2210. }
  2211. if(propperpoll){
  2212. var now = Date.now();
  2213. var keys = Object.keys(playerids);
  2214. for(var i = 0;i<keys.length;i++){
  2215. playerids[keys[i]].vote.poll = -1;
  2216. }
  2217. pollactive2 = [true,now,pollifproper];
  2218. playerids[idofpacket].ratelimit.poll = now;
  2219. displayInChat(from+" started a poll:","#DA0808","#1EBCC1");
  2220. for(var i = 0;i<pollifproper.length;i++){
  2221. 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();';
  2222. displayInChat('<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+letters[i]+')</a>',"#DA0808","#1EBCC1",{sanitize:false}," "+pollifproper[i]);
  2223. }
  2224. }
  2225. }
  2226.  
  2227. }
  2228. if(jsonargs["type"]=="request mode" && playerids[idofpacket].ratelimit.mode+1000<Date.now()){
  2229. playerids[idofpacket].ratelimit.mode = Date.now();
  2230. from = jsonargs["from"];
  2231. if(Object.keys(playerids).includes(idofpacket.toString())){
  2232. from = playerids[idofpacket].userName;
  2233. }
  2234. var req_mode = jsonargs["mode"];
  2235. var req_mode2 = "";
  2236. if(req_mode){
  2237. if(req_mode == "b"){
  2238. req_mode2 = "Classic";
  2239. }
  2240. else if(req_mode == "sp"){
  2241. req_mode2 = "Grapple";
  2242. }
  2243. else if(req_mode == "ar"){
  2244. req_mode2 = "Arrows";
  2245. }
  2246. else if(req_mode == "ard"){
  2247. req_mode2 = "Death Arrows";
  2248. }
  2249. }
  2250. if(req_mode2){
  2251. 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+'")}';
  2252. displayInChat('> '+playerids[idofpacket].userName+' requests [<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+req_mode2+'</a>]',"#DA0808","#1EBCC1",{sanitize:false}," mode.");
  2253. }
  2254.  
  2255. }
  2256. if(jsonargs["type"]=="public key correction" && private_chat_public_key[0] == private_chat){
  2257. from = jsonargs["from"];
  2258. if(Object.keys(playerids).includes(idofpacket.toString())){
  2259. from = playerids[idofpacket].userName;
  2260. }
  2261. if(from == private_chat){
  2262. private_chat_public_key = [private_chat,jsonargs["public key"]];
  2263. var text = pmlastmessage;
  2264. var password = [];
  2265. for(var i = 0;i<10;i++){
  2266. password.push(Math.floor(Math.random()*100+50));
  2267. }
  2268. var text2 = [];
  2269. for(var i = 0;i<text.length ;i++){
  2270. text2.push(password[i%password.length]^text.slice(0,400).charCodeAt(i));
  2271. }
  2272. 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)}]));
  2273. }
  2274. }
  2275.  
  2276. }
  2277. else{
  2278. var now = Date.now();
  2279. if(playerids[idofpacket.toString()]){
  2280. playerids[idofpacket.toString()].lastmove = now;
  2281. }
  2282. if(Math.abs(gameStartTimeStamp - (now-1000*jsonargs["f"]/30))>250){
  2283. gameStartTimeStamp = now-1000*jsonargs["f"]/30;
  2284. }
  2285. if(ishost){
  2286. for(var i = 0;i<disabledkeys.length;i++){
  2287. var get_keys_var = GET_KEYS(jsonargs["i"]);
  2288. if(get_keys_var[disabledkeys[i]]){
  2289. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden" && !killedids.includes(idofpacket)){
  2290. killedids.push(idofpacket);
  2291. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  2292. SEND('42[25,{"a":{"playersLeft":['+idofpacket.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  2293. RECIEVE('42[31,{"a":{"playersLeft":['+idofpacket.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  2294. break;
  2295. }
  2296. }
  2297. }
  2298. }
  2299. }
  2300. }
  2301.  
  2302. if(args.data.startsWith('42[4,')){
  2303. var jsonargs = JSON.parse(args.data.substring(2));
  2304. 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}};
  2305. if(ishost){
  2306. if(jointext!=""){
  2307. chat(flag_manage(jointext.replaceAll("username",jsonargs[3])));
  2308. }
  2309. if(freejoin){
  2310. var count = 0;
  2311. var keys = Object.keys(playerids);
  2312. for(var i = 0; i<keys.length;i++){
  2313. if(playerids[keys[i]].team!=0){
  2314. count++;
  2315. }
  2316. }
  2317. if(count <= 2 && jsonargs[6]!=0){
  2318. setTimeout(function(){
  2319. Gdocument.getElementById("newbonklobby_editorbutton").click();
  2320. Gdocument.getElementById("mapeditor_close").click();
  2321. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  2322. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  2323. if(transitioning == true){
  2324. canceled = true;
  2325. }
  2326. },150);
  2327. }
  2328. }
  2329. }
  2330.  
  2331. }
  2332. if(args.data.startsWith('42[5,')){
  2333. var jsonargs = JSON.parse(args.data.substring(2));
  2334. if(typeof(playerids[jsonargs[1]])!='undefined'){
  2335. delplayerids[jsonargs[1]] = playerids[jsonargs[1]];
  2336. delete playerids[jsonargs[1]];
  2337. }
  2338. }
  2339. }}
  2340. return originalRecieve.call(this,args);
  2341. };
  2342.  
  2343. var originalClose = this.onclose;
  2344. this.onclose = function () {
  2345. if(bonkwssextra.includes(this)){
  2346. bonkwssextra.splice(bonkwssextra.indexOf(this),1)
  2347. }
  2348. else{
  2349. window.bonkwss = 0;
  2350. }
  2351. return originalClose.call(this);
  2352. }
  2353.  
  2354. }
  2355. return originalSend.call(this,args);
  2356. };
  2357.  
  2358. scope.SEND = function(args){
  2359. if(bonkwss!=0){
  2360. bonkwss.send(args);
  2361. }
  2362. };
  2363. scope.RECIEVE = function(args){
  2364. if(bonkwss!=0){
  2365. bonkwss.onmessage({data:args});
  2366. }
  2367. };
  2368.  
  2369.  
  2370.  
  2371. scope.dontswitch = false;
  2372. scope.username = 0;
  2373. scope.timedelay = 1400;
  2374. scope.ishost = false;
  2375. scope.checkboxhidden = true;
  2376. scope.quicki=0;
  2377. scope.defaultmode = "d";
  2378. scope.recmodebool = false;
  2379. scope.shuffle = false;
  2380. scope.startedinqp = false;
  2381. scope.instaqp = false;
  2382. scope.freejoin = false;
  2383. scope.recordedTimeStamp = 0;
  2384. scope.recordedId = 0;
  2385. scope.smartteams = false;
  2386. scope.beenKickedTimeStamp = 0;
  2387. scope.stopquickplay = 1;
  2388. scope.currentFrame = 0;
  2389. scope.text2speech = false;
  2390. scope.gameStartTimeStamp = 0;
  2391. scope.canceled = false;
  2392. scope.wintext = "";
  2393. scope.banned = [];
  2394. scope.transitioning = false;
  2395. scope.echo_list = [];
  2396. scope.echoAppend = "";
  2397. scope.message = "";
  2398. scope.private_chat = "";
  2399. scope.private_chat_public_key = ["",[0,0]];
  2400. scope.disabledkeys = [];
  2401. scope.actuallyhost = false;
  2402. scope.pmusers = [];
  2403. scope.pmlastmessage = "";
  2404. scope.pmuserstimestamp = 0;
  2405. scope.ignorepmlist = [];
  2406. scope.scroll = false;
  2407. scope.elem = Gdocument.getElementById("maploadwindowmapscontainer");
  2408. scope.npermissions = 1;
  2409. scope.space_flag = false;
  2410. scope.rcaps_flag = false;
  2411. scope.number_flag = false;
  2412. scope.reverse_flag = false;
  2413. scope.request_public_key_time_stamp = 0;
  2414. scope.sandboxcopyme = false;
  2415. scope.recteams = false;
  2416. scope.chatheight = 128;
  2417. scope.onlykicked = false;
  2418. scope.killedids = [];
  2419. scope.jointext = "";
  2420. scope.afkkill = -1;
  2421. scope.tournament_mode = "";
  2422. scope.tournament_scores = [];
  2423. scope.tournament_in_and_out = {"in":[],"out":[]};
  2424. scope.echotext = "message";
  2425. scope.nextafter = 0;
  2426. scope.nextafterbuffer = -1;
  2427. scope.roundsperqp = 1;
  2428. scope.roundsperqp2 = 0;
  2429. scope.autorecord = false;
  2430. scope.poll = [];
  2431. scope.letters = ["A","B","C","D","E"];
  2432. scope.qppaused = false;
  2433. scope.FollowCam = false;
  2434. scope.gravity = 7.8;
  2435. scope.multiplier = 2.1;
  2436. scope.aimbot = false;
  2437. scope.heavybot = false;
  2438. scope.zoom = 1;
  2439.  
  2440. scope.prediction = 125;
  2441. scope.started = 0;
  2442. scope.holdheavy = 0;
  2443. scope.grappleheld = false;
  2444. scope.grappleheld2 = false;
  2445. scope.heavyheld = false;
  2446. scope.heavyheld2 = false;
  2447. 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};
  2448. scope.leftRight = [37,39];
  2449. scope.heavy = 88;
  2450. scope.special = 90;
  2451. scope.positive = function(angle){
  2452. if(angle<0){
  2453. angle += 2*Math.PI;
  2454. }
  2455. return angle%(Math.PI*2);
  2456. };
  2457. scope.angle_between = function(angle,angle2){
  2458. return Math.min(Math.abs(positive(angle)-positive(angle2)),Math.PI*2-Math.abs(positive(angle)-positive(angle2)));
  2459. };
  2460. scope.angle_between2 = function(angle,angle2){
  2461. if(angle_between(angle,angle2+Math.PI/2)<Math.PI/2){
  2462. return 1;
  2463. }
  2464. return -1;
  2465. };
  2466.  
  2467. 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]","/delplayer [number]","/copyme","Debugging commands are:","/eval [code]","/debugger","Hotkeys are:","Alt L","Alt B","Alt C","Alt I","Alt <","Alt >","Alt N","Alt G","Alt H","Alt J","Host hotkeys are:","Alt S","Alt T","Alt E","Alt K","Alt M","Alt Q","Alt A","Alt D","Alt F","Alt R"];
  2468.  
  2469. scope.adv_help = {"help":"Shows all command names.",
  2470. "?":"Shows all command names.",
  2471. "advhelp":"Shows a command in detail.",
  2472. "space":"Toggles space. When space is on, whatever you type will be spaced apart.",
  2473. "rcaps":"Toggles rcaps. When rcaps is on, each letter will randomly get capitalized.",
  2474. "number":"Toggles number. When number is on, 'a' becomes 4, 'e' becomes 3, 's' becomes 5, 'o' becomes 0, 'l' and 'i' become 1.",
  2475. "speech":"Turns on text to speech for the chat.",
  2476. "echo":"Echoes a username. It copies the username's chat messages.",
  2477. "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.",
  2478. "remove":"Removes username from echo list. You will not echo that username anymore.",
  2479. "clearecho":"Clears echo list. You will not echo anyone anymore.",
  2480. "chatw":"It private chats with username. Type /msg to message that username.",
  2481. "msg":"Messages with what username you are chatting with. Type /chatw to chat with a username.",
  2482. "ignorepm":"Ignores the username's private chat messages. To unignore, type '/ignorepm [username]'.",
  2483. "pmusers":"Dispays who you can private chat with.",
  2484. "pollstat":"Displays the current poll and its votes.",
  2485. "eval":"Evaluates code. Only use this if you are experienced in javascript.",
  2486. "debugger":"Opens debugger.",
  2487. "lobby":"Makes lobby visible when you are ingame. Type '/lobby' again to close lobby.",
  2488. "score":"Displays the current score while ingame. Type '/score' again to hide the score.",
  2489. "team":"Joins a specific team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  2490. "scroll":"Toggles a scrollbar in ingame chat.",
  2491. "followcam":"Enables follow camera. Your character will be centered on the screen.",
  2492. "zoom":"Zooms in, out, or resets zoom.",
  2493. "xray":"Removes all shapes that don't have a shadow. This means all non-physics shapes will be hidden.",
  2494. "aimbot":"Toggles aimbot. Aimbot will aim for you in arrows or death arrows mode.",
  2495. "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.",
  2496. "hidechat":"Hides ingame chat. Type '/showchat' to show it again.",
  2497. "showchat":"Shows ingame chat. '/hidechat' hides the chat.",
  2498. "notify":"You will be notified if a person types @username",
  2499. "stopnotify":"You will not be notified if a person types @username",
  2500. "support":"Displays many ways to support LEGENDBOSS123.",
  2501. "startqp":"Starts cycling maps in your map menu.",
  2502. "stopqp":"Stops cycling maps in your map menu.",
  2503. "pauseqp":"Only pauses or unpauses the quickplay cycle due to round end. '/next', '/previous' still work. Type 'pauseqp' to unpause quickplay.",
  2504. "next":"Skips the map. Usable only with '/startqp'.",
  2505. "nextafter":"Skips the map if no one is able to win/draw within a certain amount of time.",
  2506. "previous":"Goes to previous map. Usable only with '/startqp'.",
  2507. "shuffle":"Makes quickplay play random maps instead of in order.",
  2508. "freejoin":"Toggles freejoin. If freejoin is on, starts the game instantly if there are 1 or less players currently playing.",
  2509. "recmode":"In quickplay, it switches mode to recommended mode, according to editor.",
  2510. "recteam":"In quickplay, it sorts people into teams when teams are necessary.",
  2511. "defaultmode":"Switches mode to defaultmode if there is no recmode.",
  2512. "start":"Starts game instantly.",
  2513. "instaqp":"Rounds will instantly start without a countdown.",
  2514. "balanceA":"Balances everyone with balance number.",
  2515. "moveA":"Sets everyones team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  2516. "rounds":"Sets rounds to win.",
  2517. "roundsperqp":"After that many rounds, the map will change. Normally, the map will change after 1 round.",
  2518. "autorecord":"After a round ends, automatically records the last 15 seconds.",
  2519. "mode":"If host, switches mode. Otherwise, it requests the host to switch mode, as long as the host has this mod.",
  2520. "disablekeys":"If anyone presses a disabled key, they get killed. Key options: left right up down heavy special.",
  2521. "jointext":"Chats the jointext whenever someone joins. \"username\" will get replaced by the joining person's username.",
  2522. "wintext":"Chats the wintext whenever someone wins. \"username\" will get replaced by the winning person's username.",
  2523. "afkkill":"If a person stays afk for that many seconds, they get automatically killed.",
  2524. "ban":"Bans username from lobby. If they rejoin, it automatically bans.",
  2525. "kill":"Kills the person ingame.",
  2526. "resetpoll":"Clears the poll.",
  2527. "addoption":"Adds the option to the poll. You can only have 4 maximum options. Type '/deloption [letter]' to remove an option.",
  2528. "deloption":"Removes the option with that letter.",
  2529. "startpoll":"Starts a poll that lasts for at least 10 seconds. Type '/endpoll' to end it early.",
  2530. "endpoll":"Ends the poll early if the poll lasted for at least 10 seconds.",
  2531. "addplayer":"In sandbox, it adds players.",
  2532. "delplayer":"In sandbox, it deletes players.",
  2533. "copyme":"In sandbox, it makes each player copy your movements.",
  2534. "Alt L":"Makes lobby visible when you are ingame. Press Alt L again to close lobby.",
  2535. "Alt C":"Hides ingame chat. Press Alt C again to show ingame chat.",
  2536. "Alt S":"Starts game instantly.",
  2537. "Alt T":"Toggles teams.",
  2538. "Alt N":"Enables follow camera. Your character will be centered on the screen.",
  2539. "Alt G":"Zooms in.",
  2540. "Alt H":"Resets zoom.",
  2541. "Alt J":"Zooms out.",
  2542. "Alt Y":"Enables xray. Removes all shapes that don't have a shadow. This means all non-physics shapes will be hidden.",
  2543. "Alt E":"Toggles editor.",
  2544. "Alt K":"Exits ingame and returns to lobby.",
  2545. "Alt M":"Switches modes.",
  2546. "Alt Q":"Toggles quickplay.",
  2547. "Alt B":"Displays the current score while ingame. Press Alt B again to hide the score.",
  2548. "Alt A":"Skips the map if quickplay is on.",
  2549. "Alt D":"Goes to previous map if quickplay is on.",
  2550. "Alt F":"Toggles freejoin. If freejoin is on, starts the game instantly if there are 1 or less players currently playing.",
  2551. "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.",
  2552. "Alt P":"Only pauses or unpauses the quickplay cycle due to round end. '/next', '/previous' still work. Type 'pauseqp' to unpause quickplay.",
  2553. "Alt R":"In quickplay, it switches mode to recommended mode, according to editor.",
  2554. "Alt I":"Opens debugger.",
  2555. "Alt <":"Lowers ingame chat height.",
  2556. "Alt >":"Highers ingame chat height."
  2557. };
  2558. scope.displayadvhelp = function(command){
  2559. displayInChat(adv_help[command],"#009398","#DA0808",{sanitize:true},"",true);
  2560. };
  2561. scope.changemode = function(mode){
  2562. SEND('42[20,{"ga":"b","mo":"'+mode+'"}]');
  2563. RECIEVE('42[26,"b","'+mode+'"]');
  2564. };
  2565. Gdocument.getElementById("ingamechatcontent").style["pointer-events"]="all";
  2566. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  2567. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  2568. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  2569.  
  2570. document.getElementById('adboxverticalCurse').style["display"] = "none";
  2571. document.getElementById('adboxverticalleftCurse').style["display"] = "none";
  2572. elem.onclick=function(e){
  2573. if(stopquickplay==0 && ishost == true && e.isTrusted == true){
  2574. quicki = (Array.from(e.target.parentElement.parentNode.children).indexOf(e.target.parentNode)-1)%(Gdocument.getElementById("maploadwindowmapscontainer").children.length);
  2575. }
  2576. };
  2577. scope.urlify = function(text) {
  2578. if(!Gdocument.getElementById('bl_Menu')){
  2579. return text.replace(/(?:https?:\/\/)?(?:[A-Za-z0-9-ßàÁâãóôþüúðæåïçèõöÿýòäœêëìíøùîûñé]+)(?:\.[A-Za-z0-9-ßàÁâãóôþüúðæåïçèõöÿýòäœêëìíøùîûñé]+)+(?:\/(?:[A-Za-z0-9-._~:/?#\[\]@!$&'()*+,;=]|%[0-9a-fA-F]{2})*)?(?:\?(?:[^=]+=[^&](?:&[^=]+=[^&])*)?)?/g, function(url) {
  2580. if(url.startsWith('https://') || url.startsWith('http://')){return '<a href="' + url + '" target="_blank" style = "color:orange">' + url + '</a>';}
  2581. else{return '<a href="https://' + url + '" target="_blank" style = "color:orange">' + url + '</a>';}
  2582. })}return text;
  2583. };
  2584.  
  2585. scope.fire = function(type,options,d = Gdocument){
  2586. var event= document.createEvent("HTMLEvents");
  2587. event.initEvent(type,true,false);
  2588. for(var p in options){
  2589. event[p]=options[p];
  2590. }
  2591. d.dispatchEvent(event);
  2592. };
  2593.  
  2594. scope.chat = function(message){
  2595. SEND('42[10,{"message":'+JSON.stringify(message)+'}]');
  2596. };
  2597. scope.chat2 = function(message,enteragain=false){
  2598. mess = Gdocument.getElementById("newbonklobby_chat_input").value;
  2599. mess2 = Gdocument.getElementById("ingamechatinputtext").value;
  2600. Gdocument.getElementById("newbonklobby_chat_input").value = message;
  2601. Gdocument.getElementById("ingamechatinputtext").value = message;
  2602. fire("keydown",{keyCode:13});
  2603. if(!enteragain){
  2604. fire("keydown",{keyCode:13});
  2605. }
  2606. Gdocument.getElementById("newbonklobby_chat_input").value = mess;
  2607. Gdocument.getElementById("ingamechatinputtext").value = mess2;
  2608. };
  2609. scope.displayInChat = function(message, LobbyColor, InGameColor, options, message2, BringDown) {
  2610. options = options ?? {};
  2611. BringDown = BringDown ?? false;
  2612. message2 = message2 ?? "";
  2613. LobbyColor = LobbyColor ?? "#8800FF";
  2614. InGameColor = InGameColor ?? "#AA88FF";
  2615. let A = Gdocument.createElement("div");
  2616. let B = Gdocument.createElement("span");
  2617. B.className = "newbonklobby_chat_status";
  2618. B.style.color = LobbyColor;
  2619. A.appendChild(B);
  2620. B.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  2621. B.innerHTML+=urlify(message2.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;'));
  2622. let C = Gdocument.createElement("div");
  2623. let D = Gdocument.createElement("span");
  2624. D.style.color = InGameColor;
  2625. C.appendChild(D);
  2626. D.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  2627. D.innerHTML+=urlify(message2.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;'));
  2628. let a = BringDown;
  2629. if(Gdocument.getElementById("newbonklobby_chat_content").clientHeight + Gdocument.getElementById("newbonklobby_chat_content").scrollTop >= Gdocument.getElementById("newbonklobby_chat_content").scrollHeight-1) {
  2630. a = true;
  2631. }
  2632. A.style["parsed"] = true;
  2633. C.style["parsed"] = true;
  2634. Gdocument.getElementById("newbonklobby_chat_content").appendChild(A);
  2635. Gdocument.getElementById("ingamechatcontent").appendChild(C);
  2636. if (a) { Gdocument.getElementById("newbonklobby_chat_content").scrollTop = Number.MAX_SAFE_INTEGER;};
  2637. Gdocument.getElementById("ingamechatcontent").scrollTop = Number.MAX_SAFE_INTEGER;
  2638. chat2("");
  2639. };
  2640.  
  2641. scope.lobby = function(){
  2642. if (Gdocument.getElementById("newbonklobby").style["display"]=="none"){
  2643.  
  2644. Gdocument.getElementById("newbonklobby_editorbutton").click();
  2645. Gdocument.getElementById("mapeditor_close").click();
  2646. if(Gdocument.getElementById("newbonklobby_playerbox_elementcontainer").children.length+Gdocument.getElementById("newbonklobby_specbox_elementcontainer").children.length-3>0){
  2647. Gdocument.getElementById("newbonklobby").style["z-index"]=1;
  2648. Gdocument.getElementById("maploadwindowcontainer").style["z-index"]=1;
  2649. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=1;
  2650. Gdocument.getElementById("pretty_top").style["z-index"]=3;
  2651. Gdocument.getElementById("settingsContainer").style["z-index"]=3;
  2652. Gdocument.getElementById("leaveconfirmwindow").style["z-index"]=3;
  2653. Gdocument.getElementById("hostleaveconfirmwindow").style["z-index"]=3;
  2654. debuggermenu.style["z-index"] = 2;
  2655. }
  2656. else{
  2657. Gdocument.getElementById("newbonklobby").style["opacity"]=0;
  2658. Gdocument.getElementById("newbonklobby").style["display"]="none";
  2659. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
  2660.  
  2661. }
  2662.  
  2663. }
  2664. else if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  2665. Gdocument.getElementById("newbonklobby").style["opacity"]=0;
  2666. Gdocument.getElementById("newbonklobby").style["display"]="none";
  2667. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
  2668.  
  2669. }
  2670. };
  2671.  
  2672. scope.lastmessage = function(){
  2673. if(Gdocument.getElementById("newbonklobby_chat_content").children.length!=0){
  2674. var lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  2675. var lm2 = "";
  2676. for(var i = 0; i<lm.length;i++){
  2677. lm2+=" "+lm[i].textContent.trim();
  2678. }
  2679. lm2 = lm2.trim();
  2680. if(lm2.startsWith("*")){
  2681. return lm2;
  2682. }
  2683. }
  2684. if(Gdocument.getElementById("ingamechatcontent").children.length!=0){
  2685. var lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  2686. var lm2 = "";
  2687. for(var i = 0; i<lm.length;i++){
  2688. lm2+=" "+lm[i].textContent.trim();
  2689. }
  2690. return lm2.trim();
  2691. }
  2692. return "";
  2693.  
  2694. };
  2695. scope.map = function(e,t=timedelay){
  2696. if(e<0){
  2697. displayInChat("There is no previous map.","#DA0808","#1EBCC1");
  2698. quicki = 0;
  2699. return;
  2700. }
  2701. if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
  2702. displayInChat("Click the maps button.","#DA0808","#1EBCC1");
  2703. return;
  2704. }
  2705.  
  2706. setTimeout(function(){if(!canceled){
  2707. startedinqp = true;
  2708. if(roundsperqp2>=roundsperqp){
  2709. roundsperqp2 = 0;
  2710. }
  2711. gameStartTimeStamp = Date.now();
  2712. Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
  2713. Gdocument.getElementById("newbonklobby_editorbutton").click();
  2714. if(recmodebool && ishost){
  2715. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  2716. if(mode == "" && defaultmode!="d"){
  2717. mode = defaultmode;
  2718. }
  2719. if(mode != ""){
  2720. RECIEVE('42[26,"b","'+mode+'"]');
  2721. }
  2722. }
  2723. var displayblock = Gdocument.getElementById("newbonklobby").style["display"] == "block";
  2724. Gdocument.getElementById("mapeditorcontainer").style["display"] = "none";
  2725. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  2726. if(displayblock){
  2727. Gdocument.getElementById("newbonklobby").style["display"] = "block";
  2728. }
  2729. Gdocument.getElementById("mapeditor_midbox_testbutton").click();}
  2730. canceled = false;
  2731. transitioning = false;
  2732. },t);
  2733.  
  2734. };
  2735.  
  2736. scope.gotonextmap = function(e){
  2737. if(e<0){
  2738. displayInChat("There is no previous map.","#DA0808","#1EBCC1");
  2739. quicki = 0;
  2740. return;
  2741. }
  2742. if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
  2743. displayInChat("Click the maps button.","#DA0808","#1EBCC1");
  2744. return;
  2745. }
  2746. Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
  2747. Gdocument.getElementById("newbonklobby_editorbutton").click();
  2748. if(recmodebool && ishost){
  2749. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  2750. if(mode == "" && defaultmode!="d"){
  2751. mode = defaultmode;
  2752. }
  2753. if(mode != ""){
  2754. RECIEVE('42[26,"b","'+mode+'"]');
  2755. }
  2756. }
  2757. startedinqp = true;
  2758. if(roundsperqp2>=roundsperqp){
  2759. roundsperqp2 = 0;
  2760. }
  2761. gameStartTimeStamp = Date.now();
  2762. var displayblock = Gdocument.getElementById("newbonklobby").style["display"] == "block";
  2763. Gdocument.getElementById("mapeditorcontainer").style["display"] = "none";
  2764. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  2765. if(displayblock){
  2766. Gdocument.getElementById("newbonklobby").style["display"] = "block";
  2767. }
  2768. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  2769. Gdocument.getElementById("newbonklobby").style["visibility"] = "visible";
  2770. };
  2771. scope.commandhandle = function(chat_val){
  2772. if (chat_val.substring(1,6)=="echo " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  2773. if (chat_val.substring(6).replace(/^\s+|\s+$/g, '')==username){
  2774. displayInChat("You cannot echo yourself.","#DA0808","#1EBCC1");
  2775. return "";
  2776. }
  2777. else if (echo_list.indexOf(chat_val.substring(6).replace(/^\s+|\s+$/g, ''))===-1) {
  2778.  
  2779. echo_list.push(chat_val.substring(6).replace(/^\s+|\s+$/g, ''));
  2780. displayInChat(chat_val.substring(6).replace(/^\s+|\s+$/g, '') + " is being echoed.","#DA0808","#1EBCC1");
  2781. return "";
  2782. }
  2783. else{
  2784. displayInChat(chat_val.substring(6).replace(/^\s+|\s+$/g, '') + " is already being echoed.","#DA0808","#1EBCC1");
  2785. return "";
  2786. }
  2787. }
  2788. else if (chat_val.substring(1,8)=="remove " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  2789. if (echo_list.indexOf(chat_val.substring(7).replace(/^\s+|\s+$/g, ''))!==-1){
  2790. echo_list.splice(echo_list.indexOf(chat_val.substring(7).replace(/^\s+|\s+$/g, '')),1);
  2791. displayInChat(chat_val.substring(7).replace(/^\s+|\s+$/g, '')+" is not being echoed.","#DA0808","#1EBCC1");
  2792. return "";
  2793. }
  2794. else{
  2795. displayInChat("You cannot remove someone that you didn't echo.","#DA0808","#1EBCC1");
  2796. return "";
  2797. }
  2798.  
  2799. }
  2800. else if (chat_val.substring(1,10)=="echotext " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  2801. echotext = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  2802. displayInChat("Set echotext as: "+echotext,"#DA0808","#1EBCC1");
  2803. displayInChat("Type '/echotext' to reset echotext.","#DA0808","#1EBCC1");
  2804. return "";
  2805.  
  2806. }
  2807. else if (chat_val.substring(1,9)=="echotext"){
  2808. echotext = "message";
  2809. displayInChat("Reset echotext.","#DA0808","#1EBCC1");
  2810. return "";
  2811.  
  2812. }
  2813. else if (chat_val.substring(1,10)=="clearecho"){
  2814. echo_list = [];
  2815. displayInChat("Cleared the echo list.","#DA0808","#1EBCC1");
  2816. return "";
  2817. }
  2818. else if (chat_val.substring(1,6)=="space"){
  2819. if(space_flag == true){
  2820. displayInChat("Space is now off.","#DA0808","#1EBCC1");
  2821. space_flag = false;
  2822. }
  2823. else{
  2824. displayInChat("Space is now on.","#DA0808","#1EBCC1");
  2825. space_flag = true;
  2826. }
  2827. return "";
  2828. }
  2829. else if (chat_val.substring(1,6)=="rcaps"){
  2830. if(rcaps_flag == true){
  2831. displayInChat("Rcaps is now off.","#DA0808","#1EBCC1");
  2832. rcaps_flag = false;
  2833. }
  2834. else{
  2835. displayInChat("Rcaps is now on.","#DA0808","#1EBCC1");
  2836. rcaps_flag = true;
  2837. }
  2838.  
  2839. return "";
  2840. }
  2841. else if (chat_val.substring(1,7)=="number"){
  2842. if(number_flag == true){
  2843. displayInChat("Number is now off.","#DA0808","#1EBCC1");
  2844. number_flag = false;
  2845. }
  2846. else{
  2847. displayInChat("Number is now on.","#DA0808","#1EBCC1");
  2848. number_flag = true;
  2849. }
  2850.  
  2851. return "";
  2852. }
  2853. else if (chat_val.substring(1,8)=="reverse"){
  2854. if(reverse_flag == true){
  2855. displayInChat("Reverse is now off.","#DA0808","#1EBCC1");
  2856. reverse_flag = false;
  2857. }
  2858. else{
  2859. displayInChat("Reverse is now on.","#DA0808","#1EBCC1");
  2860. reverse_flag = true;
  2861. }
  2862.  
  2863. return "";
  2864. }
  2865. else if (chat_val.substring(1,7)=="speech"){
  2866. if(text2speech == true){
  2867. displayInChat("Text to speech is now off.","#DA0808","#1EBCC1");
  2868. text2speech = false;
  2869. }
  2870. else{
  2871. displayInChat("Text to speech is now on.","#DA0808","#1EBCC1");
  2872. text2speech = true;
  2873. }
  2874.  
  2875. return "";
  2876. }
  2877. else if (chat_val.substring(1,6)=="eval " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  2878. var ev = "";
  2879. try{
  2880. ev = eval(chat_val.substring(6).replace(/^\s+|\s+$/g, ''));
  2881. }
  2882. catch(e){
  2883. displayInChat(e.message,"#DA0808","#1EBCC1");
  2884. }
  2885. try{
  2886. displayInChat(ev.toString(),"#DA0808","#1EBCC1");
  2887. }
  2888. catch{
  2889. }
  2890.  
  2891. return "";
  2892.  
  2893. }
  2894. else if (chat_val.substring(1,10)=="followcam"){
  2895. if(FollowCam == true){
  2896. displayInChat("Follow Camera is now off.","#DA0808","#1EBCC1");
  2897. FollowCam = false;
  2898. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  2899. var addto = {"children":[]};
  2900. for(var i = 0;i<parentDraw.children.length;i++){
  2901. if(parentDraw.children[i].constructor.name == "e"){
  2902. addto = parentDraw.children[i];
  2903. break;
  2904. }
  2905. }
  2906. var canv = 0;
  2907. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  2908. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  2909. canv = Gdocument.getElementById("gamerenderer").children[i];
  2910. break;
  2911. }
  2912. }
  2913. var width = parseInt(canv.style["width"]);
  2914. var height = parseInt(canv.style["height"]);
  2915. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  2916. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  2917. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  2918. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  2919. if(addto.scale.x>=0.95 && addto.scale.y>=0.95){
  2920. pixiCircle.visible = false;
  2921. }
  2922. else{
  2923. pixiCircle.visible = true;
  2924. }
  2925. }
  2926. }
  2927. else{
  2928. displayInChat("Follow Camera is now on.","#DA0808","#1EBCC1");
  2929. FollowCam = true;
  2930. }
  2931.  
  2932. return "";
  2933. }
  2934. else if (chat_val.substring(1,7)=="aimbot"){
  2935. if(aimbot == true){
  2936. displayInChat("Aimbot is now off.","#DA0808","#1EBCC1");
  2937. aimbot = false;
  2938. }
  2939. else{
  2940. displayInChat("Aimbot is now on.","#DA0808","#1EBCC1");
  2941. aimbot = true;
  2942. var keykeys = Object.keys(keyCodes);
  2943. var keyslist = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[1].children).slice(1);
  2944. var keyslist2 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[2].children).slice(1);
  2945. for(var i = 0;i<keyslist.length;i++){
  2946. if(keykeys.includes(keyslist[i].textContent)){
  2947. leftRight[0] = keyCodes[keyslist[i].textContent];
  2948. break;
  2949. }
  2950. else{
  2951. leftRight[0] = keyslist[i].textContent.charCodeAt(0);
  2952. break
  2953. }
  2954. }
  2955. for(var i = 0;i<keyslist2.length;i++){
  2956. if(keykeys.includes(keyslist2[i].textContent)){
  2957. leftRight[1] = keyCodes[keyslist2[i].textContent];
  2958. break;
  2959. }
  2960. else{
  2961. leftRight[1] = keyslist2[i].textContent.charCodeAt(0);
  2962. }
  2963. }
  2964. }
  2965.  
  2966. return "";
  2967. }
  2968. else if (chat_val.substring(1,9)=="heavybot"){
  2969. if(heavybot == true){
  2970. displayInChat("Heavy bot is now off.","#DA0808","#1EBCC1");
  2971. heavybot = false;
  2972. }
  2973. else{
  2974. displayInChat("Heavy bot is now on.","#DA0808","#1EBCC1");
  2975. heavybot = true;
  2976. var keykeys = Object.keys(keyCodes);
  2977. var keyslist = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[5].children).slice(1);
  2978. for(var i = 0;i<keyslist.length;i++){
  2979. if(keykeys.includes(keyslist[i].textContent)){
  2980. heavy = keyCodes[keyslist[i].textContent];
  2981. break;
  2982. }
  2983. else{
  2984. heavy = keyslist[i].textContent.charCodeAt(0);
  2985. break
  2986. }
  2987. }
  2988. var keyslist2 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[6].children).slice(1);
  2989. for(var i = 0;i<keyslist2.length;i++){
  2990. if(keykeys.includes(keyslist2[i].textContent)){
  2991. special = keyCodes[keyslist2[i].textContent];
  2992. break;
  2993. }
  2994. else{
  2995. special = keyslist2[i].textContent.charCodeAt(0);
  2996. break
  2997. }
  2998. }
  2999. }
  3000.  
  3001. return "";
  3002. }
  3003. else if (chat_val.substring(1,5)=="xray"){
  3004. Gdocument.getElementById("pretty_top_settings").click();
  3005. Gdocument.getElementById("settings_close").click();
  3006. if(Gdocument.getElementById("settings_graphicsquality").value==1){
  3007. displayInChat("You must have medium or high quality enabled to use this feature.","#DA0808","#1EBCC1");
  3008. return "";
  3009. }
  3010.  
  3011.  
  3012. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  3013. var addto = {"children":[]};
  3014. for(var i = 0;i<parentDraw.children.length;i++){
  3015. if(parentDraw.children[i].constructor.name == "e"){
  3016. addto = parentDraw.children[i];
  3017. break;
  3018. }
  3019. }
  3020. var addto2 = {"children":[]};
  3021. for(var i = 0;i<addto.children.length;i++){
  3022. if(addto.children[i].constructor.name == "e"){
  3023. addto2 = addto.children[i];
  3024. break;
  3025. }
  3026. }
  3027. var checkxray = addto2.children[0];
  3028. var addto3 = addto2.children[0].children;
  3029. if(addto3.length==1){
  3030. checkxray = checkxray.children[0];
  3031. addto3 = addto3[0].children;
  3032. }
  3033. var xrayon = false;
  3034. if(checkxray.xrayon){
  3035. checkxray.xrayon = false;
  3036. xrayon = false;
  3037. }
  3038. else{
  3039. checkxray.xrayon = true;
  3040. xrayon = true;
  3041. }
  3042. if(xrayon){
  3043. displayInChat("Xray is now on.","#DA0808","#1EBCC1");
  3044. for(var i = 0;i<addto3.length;i++){
  3045. if(addto3[i].children.length>0){
  3046. for(var i3 = 0;i3<addto3[i].children.length;i3++){
  3047. addto3[i].children[i3].visible = false;
  3048. if(addto3[i].children[i3].children.length>0){
  3049. addto3[i].children[i3].visible = true;
  3050. }
  3051. }
  3052. }
  3053. }
  3054.  
  3055. }
  3056. else{
  3057. displayInChat("Xray is now off.","#DA0808","#1EBCC1");
  3058. for(var i = 0;i<addto3.length;i++){
  3059. for(var i2 = 0;i2<addto3[i].children.length;i2++){
  3060. addto3[i].children[i2].visible = true;
  3061. }
  3062. }
  3063. }
  3064. }
  3065.  
  3066. return "";
  3067. }
  3068. else if (chat_val.substring(1,6)=="zoom "){
  3069. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  3070. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  3071. var addto = 0;
  3072. for(var i = 0;i<parentDraw.children.length;i++){
  3073. if(parentDraw.children[i].constructor.name == "e"){
  3074. addto = parentDraw.children[i];
  3075. break;
  3076. }
  3077. }
  3078. var canv = 0;
  3079. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  3080. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  3081. canv = Gdocument.getElementById("gamerenderer").children[i];
  3082. break;
  3083. }
  3084. }
  3085. var width = parseInt(canv.style["width"]);
  3086. var height = parseInt(canv.style["height"]);
  3087. if(addto){
  3088. if(text == "in"){
  3089. zoom *= 1.1;
  3090. zoom *= 1.1;
  3091. }
  3092. else if(text == "out"){
  3093. zoom /= 1.1;
  3094. zoom /= 1.1;
  3095. }
  3096. else if(text == "reset"){
  3097. zoom = 1;
  3098. zoom = 1;
  3099. }
  3100. else{
  3101. displayInChat("Options for zooming:","#DA0808","#1EBCC1");
  3102. displayInChat("in","#DA0808","#1EBCC1");
  3103. displayInChat("out","#DA0808","#1EBCC1");
  3104. displayInChat("reset","#DA0808","#1EBCC1");
  3105. return "";
  3106. }
  3107. addto.scale.x=zoom;
  3108. addto.scale.y=zoom;
  3109. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  3110. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  3111. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  3112. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  3113. if(addto.scale.x>=0.95 && addto.scale.y>=0.95 && !FollowCam){
  3114. pixiCircle.visible = false;
  3115. }
  3116. else{
  3117. pixiCircle.visible = true;
  3118. }
  3119. }
  3120. }
  3121. return "";
  3122. }
  3123. else if (chat_val.substring(1,9)=="hidechat"){
  3124. Gdocument.getElementById("ingamechatcontent").style["max-height"]="0px";
  3125. return "";
  3126. }
  3127. else if (chat_val.substring(1,9)=="showchat"){
  3128. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  3129. return "";
  3130. }
  3131. else if (chat_val.substring(1,6)=="score"){
  3132. var element = Gdocument.getElementById("ingamewinner_scores");
  3133. element.style["visibility"] = "visible";
  3134. if(element.style["opacity"]<1){
  3135. element.style["opacity"] = 1;
  3136. }
  3137. else{
  3138. element.style["opacity"] = 0;
  3139. }
  3140. return "";
  3141. }
  3142.  
  3143. else if (chat_val.substring(1,7)=="scroll"){
  3144. if(scroll==false){
  3145. scroll = true;
  3146. Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="scroll";
  3147. Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
  3148. }
  3149. else if(scroll==true){
  3150. scroll = false;
  3151. Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="hidden";
  3152. Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
  3153. }
  3154.  
  3155. return "";
  3156. }
  3157.  
  3158. else if (chat_val.substring(1,7)=="chatw "){
  3159. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '');
  3160.  
  3161. if(username == text){
  3162. displayInChat("You cannot private chat with yourself.","#DA0808","#1EBCC1");
  3163. return "";
  3164. }
  3165. private_chat = text;
  3166.  
  3167. SEND("42"+JSON.stringify([4,{"type":"request public key","from":username,"to":private_chat}]));
  3168. request_public_key_time_stamp = Date.now();
  3169. 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);
  3170. return "";
  3171. }
  3172.  
  3173. else if (chat_val.substring(1,5)=="msg " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  3174. if(private_chat_public_key[1][0] != 0 && private_chat_public_key[1][1] != 0 && private_chat_public_key[0] == private_chat){
  3175. var text = chat_val.substring(5).replace(/^\s+|\s+$/g, '');
  3176. var password = [];
  3177. for(var i = 0;i<10;i++){
  3178. password.push(Math.floor(Math.random()*100+50));
  3179. }
  3180. var text2 = [];
  3181. for(var i = 0;i<text.slice(0,400).length ;i++){
  3182. text2.push(password[i%password.length]^text.slice(0,400).charCodeAt(i));
  3183. }
  3184. pmlastmessage = text.slice(0,400);
  3185. 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)}]));
  3186. displayInChat("> "+username+": ","#DA0808","#1EBCC1",{sanitize:false},text,false);
  3187. Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true;
  3188. Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true;
  3189. Laster_message = lastmessage();
  3190.  
  3191. }
  3192. return "";
  3193. }
  3194. else if (chat_val.substring(1,10)=="ignorepm " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  3195. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  3196. if(ignorepmlist.includes(text)){
  3197. var index = ignorepmlist.indexOf(text);
  3198. ignorepmlist.splice(index,1);
  3199. displayInChat("You are not ignoring private messages from "+text+".","#DA0808","#1EBCC1");
  3200.  
  3201. }
  3202. else{
  3203. ignorepmlist.push(text);
  3204. displayInChat("You are now ignoring private messages from "+text+".","#DA0808","#1EBCC1");
  3205. }
  3206. return "";
  3207. }
  3208. else if (chat_val.substring(1,8)=="pmusers"){
  3209. pmusers = [];
  3210. SEND("42"+JSON.stringify([4,{"type":"request private chat users","from":username}]));
  3211. pmuserstimestamp = Date.now();
  3212. setTimeout(function(){if(pmusers.length == 0){displayInChat("You cannot private chat with anyone.","#DA0808","#1EBCC1");
  3213. }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);
  3214. return "";
  3215. }
  3216. else if (chat_val.substring(1,6)=="lobby"){
  3217. lobby();
  3218. return "";
  3219. }
  3220. else if (chat_val.substring(1,9)=="debugger"){
  3221. if(Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"] == "none"){
  3222. debuggeropen = true;
  3223. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="block";
  3224. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="none";
  3225. Gdocument.getElementById("ingamechatinputtext").style["display"] = "none";
  3226. }
  3227. else{
  3228. debuggeropen = false;
  3229. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="none";
  3230. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  3231. Gdocument.getElementById("ingamechatinputtext").style["display"] = "";
  3232. }
  3233. return "";
  3234. }
  3235. else if (chat_val.substring(1,6)=="team " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  3236. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  3237. if(text == "r"){Gdocument.getElementById("newbonklobby_redbutton").click();}
  3238. else if(text == "g"){Gdocument.getElementById("newbonklobby_greenbutton").click();}
  3239. else if(text == "y"){Gdocument.getElementById("newbonklobby_yellowbutton").click();}
  3240. else if(text == "b"){Gdocument.getElementById("newbonklobby_bluebutton").click();}
  3241. else if(text == "s"){Gdocument.getElementById("newbonklobby_specbutton").click();}
  3242. else if(text == "f"){Gdocument.getElementById("newbonklobby_ffabutton").click();}
  3243. return "";
  3244. }
  3245. else if (chat_val.substring(1,7)=="notify"){
  3246.  
  3247. npermissions = 1;
  3248. return "";
  3249. }
  3250. else if (chat_val.substring(1,11)=="stopnotify"){
  3251.  
  3252. npermissions = 0;
  3253. return "";
  3254. }
  3255. else if (chat_val.substring(1,8)=="support"){
  3256. displayInChat("Thanks everyone for helping me make this mod - LEGENDBOSS123","#0000FF","#FFFFFF");
  3257. displayInChat("Join the giveaway here for a chance of winning an OP lvl 223 account:","#DA0808","#1EBCC1");
  3258. displayInChat("","#DA0808","#1EBCC1",{},"https://newskit.social/giveaways/BonkCommands-Giveaway-Account");
  3259. displayInChat("Get Bonk Commands Premium here:","#DA0808","#1EBCC1");
  3260. displayInChat("","#DA0808","#1EBCC1",{},"https://myshop.rocks/products/LEGENDBOSS123_BonkCommandsPremium");
  3261. npermissions = 0;
  3262. return "";
  3263. }
  3264. else if (chat_val.substring(1,9)=="pollstat"){
  3265. if(pollactive[0] || pollactive2[0]){
  3266. var count = [0,0,0,0];
  3267. var keys = Object.keys(playerids);
  3268. for(var i = 0;i<keys.length;i++){
  3269. if(ishost){
  3270. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive[3].length-1){
  3271. count[playerids[keys[i]].vote.poll]++;
  3272. }
  3273. }
  3274. else{
  3275. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive2[2].length-1){
  3276. count[playerids[keys[i]].vote.poll]++;
  3277. }
  3278. }
  3279. }
  3280. for(var i = 0;i<count.length;i++){
  3281. if(count[i]>1){
  3282. displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  3283. }
  3284. if(count[i]==1){
  3285. displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  3286. }
  3287. }
  3288. if(ishost){
  3289. displayInChat("The poll will end in: "+((pollactive[2]-Date.now())/1000).toString()+" seconds.","#DA0808","#1EBCC1");
  3290. }
  3291. displayInChat("The poll is:","#DA0808","#1EBCC1");
  3292. if(ishost){
  3293. for(var i = 0;i<pollactive[3].length;i++){
  3294. displayInChat(letters[i]+") "+pollactive[3][i],"#DA0808","#1EBCC1");
  3295. }
  3296. }
  3297. else{
  3298. for(var i = 0;i<pollactive2[2].length;i++){
  3299. displayInChat(letters[i]+") "+pollactive2[2][i],"#DA0808","#1EBCC1");
  3300. }
  3301. }
  3302. }
  3303. else{
  3304. displayInChat("No poll has been started.","#DA0808","#1EBCC1");
  3305. if(ishost){
  3306. displayInChat("Type '/startpoll [seconds]' to start a poll.","#DA0808","#1EBCC1");
  3307. if(poll.length>0){
  3308. displayInChat("The poll is:","#DA0808","#1EBCC1");
  3309. for(var i = 0;i<poll.length;i++){
  3310. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  3311. }
  3312. }
  3313. }
  3314. }
  3315. return "";
  3316. }
  3317. else if (chat_val.substring(1,5)=="help" || chat_val.substring(1,2)=="?"){
  3318. for(var i = 0;i<help.length;i++){
  3319. if(help[i].startsWith("/")){
  3320. var splitted = help[i].substring(1).split(" ");
  3321. var command = splitted[0];
  3322. var rest = "";
  3323. if(splitted.length>1){
  3324. rest = " "+splitted.slice(1).join(" ");
  3325. }
  3326. displayInChat("/"+'<a onclick = \'Gwindow.displayadvhelp("'+command+'");\' style = "color:green;" href = "javascript:void(0);">'+command+'</a>'+rest,"#DA0808","#1EBCC1",{sanitize:false},"",false);
  3327. }
  3328. else if(help[i].startsWith("Alt ")){
  3329. displayInChat('<a onclick = \'Gwindow.displayadvhelp("'+help[i]+'");\' style = "color:green;" href = "javascript:void(0);">'+help[i]+'</a>',"#DA0808","#1EBCC1",{sanitize:false},"",false);
  3330. }
  3331. else{
  3332. displayInChat(help[i],"#DA0808","#1EBCC1");
  3333. }
  3334.  
  3335. }
  3336. return "";
  3337. }
  3338. else if (chat_val.substring(1,9)=="advhelp " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  3339. var text = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  3340. if(typeof(adv_help[text])!='undefined'){
  3341. displayInChat(adv_help[text],"#DA0808","#1EBCC1");
  3342. }
  3343. return "";
  3344. }
  3345. else if (chat_val.substring(1,6)=="mode " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  3346. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  3347. var mode = "";
  3348. var text2 = text;
  3349. if(text == "arrows"){
  3350. text2 = "Arrows";
  3351. mode = "ar";
  3352. }
  3353. else if(text == "death arrows"){
  3354. mode = "ard";
  3355. text2 = "Death Arrows";
  3356. }
  3357. else if(text == "grapple"){
  3358. mode = "sp";
  3359. text2 = "Grapple";
  3360. }
  3361. else if(text == "classic"){
  3362. mode = "b";
  3363. text2 = "Classic";
  3364. }
  3365. else{
  3366. displayInChat("Mode options:","#DA0808","#1EBCC1");
  3367. displayInChat("classic","#DA0808","#1EBCC1");
  3368. displayInChat("arrows","#DA0808","#1EBCC1");
  3369. displayInChat("death arrows","#DA0808","#1EBCC1");
  3370. displayInChat("grapple","#DA0808","#1EBCC1");
  3371. }
  3372. if(mode != ""){
  3373. if(ishost){
  3374. SEND('42[20,{"ga":"b","mo":"'+mode+'"}]');
  3375. RECIEVE('42[26,"b","'+mode+'"]');
  3376. displayInChat("Changed mode to "+text+".","#DA0808","#1EBCC1");
  3377. }
  3378. else{
  3379. if(playerids[myid].ratelimit.mode+1000<Date.now()){
  3380. playerids[myid].ratelimit.mode=Date.now();
  3381. SEND("42"+JSON.stringify([4,{"type":"request mode","from":username,"mode":mode}]));
  3382. var code = 'if(!Gwindow.ishost){Gwindow.displayInChat("You must be host to change the mode.","#DA0808","#1EBCC1",{sanitize:false},"",true)}else{Gwindow.changemode("'+mode+'")}';
  3383. displayInChat('> '+username+' requests [<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+text2+'</a>]',"#DA0808","#1EBCC1",{sanitize:false}," mode.");
  3384.  
  3385. }
  3386. else{
  3387. displayInChat("You are requesting modes too quickly.","#DA0808","#1EBCC1");
  3388. }
  3389. }
  3390. }
  3391. return "";
  3392.  
  3393. }
  3394. else if(ishost){
  3395. if (chat_val.substring(1,11)=="nextafter " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  3396. var text = parseFloat(chat_val.substring(11).replace(/^\s+|\s+$/g, ''));
  3397. if(isNaN(text)){
  3398. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  3399. return "";
  3400. }
  3401. else if(text<=0){
  3402. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  3403. return "";
  3404. }
  3405. nextafter = text;
  3406. displayInChat("Set next after to: " + text.toString()+" seconds.","#DA0808","#1EBCC1");
  3407. displayInChat("Type '/nextafter' to reset next after.","#DA0808","#1EBCC1");
  3408. return "";
  3409.  
  3410. }
  3411. else if (chat_val.substring(1,10)=="nextafter"){
  3412. nextafter = 0;
  3413. displayInChat("Reset next after.","#DA0808","#1EBCC1");
  3414. return "";
  3415.  
  3416. }
  3417. else if (chat_val.substring(1,5)=="next" && stopquickplay == 0){
  3418. roundsperqp2 = 0;
  3419. if(shuffle){
  3420. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  3421. var available = [];
  3422. var availableindexes = [];
  3423. var notempty = false;
  3424. for(var i = 0; i<e.length;i++){
  3425. var a = false;
  3426. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  3427. available.push(a);
  3428. if(a){
  3429. availableindexes.push(i);
  3430. notempty = true;
  3431. }
  3432. }
  3433. if(notempty){
  3434.  
  3435. if(availableindexes.length!=1){
  3436. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  3437. }
  3438. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  3439. }
  3440. }
  3441. else{
  3442. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  3443. var available = [];
  3444. var availableindexes = [];
  3445. var notempty = false;
  3446. for(var i = 0; i<e.length;i++){
  3447. var a = false;
  3448. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  3449. available.push(a);
  3450. if(a){
  3451. availableindexes.push(i);
  3452. notempty = true;
  3453. }
  3454. }
  3455. if(notempty){
  3456. var above = [];
  3457. for(var i = 0;i<availableindexes.length;i++){
  3458. if(availableindexes[i]>quicki){
  3459. above.push(availableindexes[i]);
  3460. }
  3461. }
  3462. if(above.length>0){
  3463. quicki = above[0];
  3464. }
  3465. else{
  3466. quicki = availableindexes[0];
  3467. }
  3468. }
  3469. }
  3470. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  3471. displayInChat("Switched to next map.","#DA0808","#1EBCC1");
  3472. return "";
  3473.  
  3474. }
  3475. else if (chat_val.substring(1,9)=="freejoin"){
  3476. if(freejoin == false){
  3477. freejoin = true;
  3478. displayInChat("Freejoin is now on.","#DA0808","#1EBCC1");
  3479.  
  3480. }
  3481. else{
  3482. freejoin = false;
  3483. displayInChat("Freejoin is now off.","#DA0808","#1EBCC1");
  3484. }
  3485.  
  3486. return "";
  3487.  
  3488. }
  3489. else if (chat_val.substring(1,8)=="instaqp"){
  3490. if(instaqp == false){
  3491. instaqp = true;
  3492. displayInChat("Instaqp is now on.","#DA0808","#1EBCC1");
  3493.  
  3494. }
  3495. else{
  3496. instaqp = false;
  3497. displayInChat("Instaqp is now off.","#DA0808","#1EBCC1");
  3498. }
  3499.  
  3500. return "";
  3501.  
  3502. }
  3503.  
  3504. else if (chat_val.substring(1,9)=="previous" && stopquickplay == 0){
  3505. roundsperqp2 = 0;
  3506. if(shuffle){
  3507. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  3508. var available = [];
  3509. var availableindexes = [];
  3510. var notempty = false;
  3511. for(var i = 0; i<e.length;i++){
  3512. var a = false;
  3513. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  3514. available.push(a);
  3515. if(a){
  3516. availableindexes.push(i);
  3517. notempty = true;
  3518. }
  3519. }
  3520. if(notempty){
  3521.  
  3522. if(availableindexes.length!=1){
  3523. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  3524. }
  3525. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  3526. }
  3527. }
  3528. else{
  3529. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  3530. var available = [];
  3531. var availableindexes = [];
  3532. var notempty = false;
  3533. for(var i = 0; i<e.length;i++){
  3534. var a = false;
  3535. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  3536. available.push(a);
  3537. if(a){
  3538. availableindexes.push(i);
  3539. notempty = true;
  3540. }
  3541. }
  3542. if(notempty){
  3543. var above = [];
  3544. for(var i = 0;i<availableindexes.length;i++){
  3545. if(availableindexes[i]<quicki){
  3546. above.push(availableindexes[i]);
  3547. }
  3548. }
  3549. if(above.length>0){
  3550. quicki = above[above.length-1];
  3551. }
  3552. else{
  3553. quicki = availableindexes[availableindexes.length-1];
  3554. }
  3555. }
  3556. }
  3557. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  3558.  
  3559. displayInChat("Switched to previous map.","#DA0808","#1EBCC1");
  3560. return "";
  3561. }
  3562. else if (chat_val.substring(1,6)=="start" && chat_val.length == 6){
  3563. Gdocument.getElementById("newbonklobby_editorbutton").click();
  3564. if(recmodebool && ishost){
  3565. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  3566. if(mode == "" && defaultmode!="d"){
  3567. mode = defaultmode;
  3568. }
  3569. if(mode != ""){
  3570. RECIEVE('42[26,"b","'+mode+'"]');
  3571. }
  3572. }
  3573. Gdocument.getElementById("mapeditor_close").click();
  3574. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  3575. roundsperqp2 = 0;
  3576. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  3577.  
  3578. return "";
  3579. }
  3580.  
  3581. else if (chat_val.substring(1,8)=="startqp" && stopquickplay == 1){
  3582. stopquickplay = 0;
  3583. quicki = 0;
  3584. qppaused = false;
  3585. displayInChat("Enabled quickplay.","#DA0808","#1EBCC1");
  3586. return "";
  3587. }
  3588. else if (chat_val.substring(1,7)=="stopqp" && stopquickplay == 0){
  3589. stopquickplay = 1;
  3590. quicki = 0;
  3591. qppaused = false;
  3592. displayInChat("Disabled quickplay.","#DA0808","#1EBCC1");
  3593. return "";
  3594. }
  3595. else if (chat_val.substring(1,8)=="pauseqp" && stopquickplay == 0){
  3596. if(qppaused == false){
  3597. qppaused = true;
  3598. displayInChat("Paused quickplay.","#DA0808","#1EBCC1");
  3599. }
  3600. else{
  3601. qppaused = false;
  3602. displayInChat("Unpaused quickplay.","#DA0808","#1EBCC1");
  3603. }
  3604. return "";
  3605. }
  3606.  
  3607. else if (chat_val.substring(1,5)=="ban " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  3608. banned.push(chat_val.substring(5).replace(/^\s+|\s+$/g, ''));
  3609. displayInChat("Banned "+chat_val.substring(5).replace(/^\s+|\s+$/g, '')+".","#DA0808","#1EBCC1");
  3610. return "/kick '" + chat_val.substring(5).replace(/^\s+|\s+$/g, '') + "'";
  3611. }
  3612. else if (chat_val.substring(1,6)=="kill " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  3613. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  3614. var keys = Object.keys(playerids);
  3615. var killid = undefined;
  3616. for(var i = 0; i<keys.length; i++){
  3617. if(playerids[keys[i]].userName == text){
  3618. killid = keys[i];
  3619. }
  3620. }
  3621. if(typeof(killid)!="undefined" && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden" && !killedids.includes(killid)){
  3622. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  3623. killedids.push(killid);
  3624. SEND('42[25,{"a":{"playersLeft":['+killid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  3625. RECIEVE('42[31,{"a":{"playersLeft":['+killid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  3626. }
  3627. return "";
  3628. }
  3629. else if (chat_val.substring(1,10)=="balanceA " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  3630. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  3631. if(!isNaN(parseInt(text))){
  3632. if(parseInt(text)>=-100 && parseInt(text)<=100){
  3633. var keys = Object.keys(playerids);
  3634. for(var i = 0; i<keys.length;i++){
  3635. SEND('42[29,{"sid":'+keys[i]+',"bal":'+text+'}]');
  3636. RECIEVE('42[36,'+keys[i]+','+text+']');
  3637. }
  3638. }
  3639. }
  3640. return "";
  3641.  
  3642. }
  3643. else if (chat_val.substring(1,10)=="resetpoll"){
  3644. poll = [];
  3645. displayInChat("The poll has been reset.","#DA0808","#1EBCC1");
  3646. return "";
  3647. }
  3648. else if (chat_val.substring(1,11)=="addoption " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  3649. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  3650. if(text.length>50){
  3651. displayInChat("Your option is greater than 50 characters.","#DA0808","#1EBCC1");
  3652. return "";
  3653. }
  3654. if(poll.includes(text)){
  3655. displayInChat("This option already exists.","#DA0808","#1EBCC1");
  3656. }
  3657. else if(poll.length>=4){
  3658. displayInChat("Your poll already has the max 4 amounts of options.","#DA0808","#1EBCC1");
  3659. displayInChat("Type '/deloption [letter]' to remove a option.","#DA0808","#1EBCC1");
  3660. displayInChat("The poll is:","#DA0808","#1EBCC1");
  3661. for(var i = 0;i<poll.length;i++){
  3662. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  3663. }
  3664. }
  3665. else{
  3666. poll.push(text);
  3667. displayInChat("The poll is now:","#DA0808","#1EBCC1");
  3668. for(var i = 0;i<poll.length;i++){
  3669. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  3670. }
  3671. }
  3672. return "";
  3673. }
  3674. else if (chat_val.substring(1,11)=="deloption " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  3675. var text = letters.indexOf(chat_val.substring(11).replace(/^\s+|\s+$/g, ''));
  3676. if(text==-1 || text>=poll.length){
  3677. if(poll.length>0){
  3678. displayInChat("Available options are:","#DA0808","#1EBCC1");
  3679. for(var i = 0;i<poll.length;i++){
  3680. displayInChat(letters[i],"#DA0808","#1EBCC1");
  3681. }
  3682. }
  3683. else{
  3684. displayInChat("Your poll is empty.","#DA0808","#1EBCC1");
  3685. displayInChat("Type '/addoption [text]' to add an option.","#DA0808","#1EBCC1");
  3686. }
  3687. }
  3688. else{
  3689. poll.splice(text,1);
  3690. displayInChat("The poll is now:","#DA0808","#1EBCC1");
  3691. for(var i = 0;i<poll.length;i++){
  3692. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  3693. }
  3694. }
  3695. return "";
  3696. }
  3697. else if (chat_val.substring(1,11)=="startpoll " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  3698. var text = parseFloat(chat_val.substring(11).replace(/^\s+|\s+$/g, ''));
  3699. if(isNaN(text)){
  3700. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  3701. return "";
  3702. }
  3703. else if(text<=0){
  3704. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  3705. return "";
  3706. }
  3707. else if(text<10){
  3708. displayInChat("Your poll has to last for at least 10 seconds.","#DA0808","#1EBCC1");
  3709. return "";
  3710. }
  3711. if(pollactive[0]){
  3712. displayInChat("There is already an ongoing poll.","#DA0808","#1EBCC1");
  3713. displayInChat("Type '/endpoll' to end the poll.","#DA0808","#1EBCC1");
  3714. return "";
  3715. }
  3716. if(poll.length<2){
  3717. displayInChat("Your poll needs at least 2 options.","#DA0808","#1EBCC1");
  3718. displayInChat("Type '/addoption' to add to the poll.","#DA0808","#1EBCC1");
  3719. return "";
  3720. }
  3721. var now = Date.now();
  3722. pollactive = [true,now,now+text*1000,[...poll]];
  3723. playerids[myid].ratelimit.poll = now;
  3724. var chatpoll = [...poll];
  3725. chatpoll.push("Cancel vote.");
  3726. pollactive[3].push("Cancel vote.");
  3727. for(var i = 0;i<chatpoll.length;i++){
  3728. chatpoll[i] = letters[i]+") "+chatpoll[i];
  3729. }
  3730. chat(chatpoll.join("     "));
  3731. setTimeout(function(){
  3732. if(pollactive[0]){
  3733. SEND("42"+JSON.stringify([4,{"type":"poll","from":username,"poll":pollactive[3]}]));
  3734. var keys = Object.keys(playerids);
  3735. for(var i = 0;i<keys.length;i++){
  3736. playerids[keys[i]].vote.poll = -1;
  3737. }
  3738. displayInChat("The poll will end in: " + text.toString()+" seconds.","#DA0808","#1EBCC1");
  3739. displayInChat("Type '/endpoll' to end the poll early.","#DA0808","#1EBCC1");
  3740. }
  3741. },200);
  3742. return "";
  3743. }
  3744. else if (chat_val.substring(1,8)=="endpoll"){
  3745. if(pollactive[0]){
  3746. if(playerids[myid].ratelimit.poll+10000>Date.now()){
  3747. displayInChat("Your poll has to be at least 10 seconds.","#DA0808","#1EBCC1");
  3748. displayInChat("There are "+((playerids[myid].ratelimit.poll+10000-Date.now())/1000).toString()+" seconds left until you can end the poll early.","#DA0808","#1EBCC1");
  3749. return "";
  3750. }
  3751. playerids[myid].ratelimit.poll = Date.now();
  3752. SEND("42"+JSON.stringify([4,{"type":"poll end","from":username}]));
  3753. displayInChat("The poll ended.","#DA0808","#1EBCC1");
  3754. var count = [0,0,0,0];
  3755. var keys = Object.keys(playerids);
  3756. for(var i = 0;i<keys.length;i++){
  3757. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive[3].length-1){
  3758. count[playerids[keys[i]].vote.poll]++;
  3759. }
  3760. playerids[keys[i]].vote.poll = -1;
  3761. }
  3762. for(var i = 0;i<count.length;i++){
  3763. if(count[i]>1){
  3764. displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  3765. }
  3766. if(count[i]==1){
  3767. displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  3768. }
  3769. }
  3770. displayInChat("The poll was:","#DA0808","#1EBCC1");
  3771. for(var i = 0;i<pollactive[3].length;i++){
  3772. displayInChat(letters[i]+") "+pollactive[3][i],"#DA0808","#1EBCC1");
  3773. }
  3774. pollactive = [false,0,0,[]];
  3775. }
  3776. else{
  3777. displayInChat("No poll has been started","#DA0808","#1EBCC1");
  3778. displayInChat("Type '/startpoll [seconds]' to start a poll.","#DA0808","#1EBCC1");
  3779. }
  3780. return "";
  3781. }
  3782. else if (chat_val.substring(1,7)=="moveA " && chat_val.replace(/^\s+|\s+$/g, '').length>=8){
  3783. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '');
  3784. var keys = Object.keys(playerids);
  3785. if(text == "f"){
  3786. for(var i = 0; i<keys.length;i++){
  3787. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":1}]')
  3788. }
  3789. }
  3790. else if(text == "b"){
  3791. for(var i = 0; i<keys.length;i++){
  3792. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":3}]')
  3793. }
  3794. }
  3795. else if(text == "g"){
  3796. for(var i = 0; i<keys.length;i++){
  3797. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":4}]')
  3798. }
  3799. }
  3800. else if(text == "r"){
  3801. for(var i = 0; i<keys.length;i++){
  3802. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":2}]')
  3803. }
  3804. }
  3805. else if(text == "y"){
  3806. for(var i = 0; i<keys.length;i++){
  3807. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":5}]')
  3808. }
  3809. }
  3810. else if(text == "s"){
  3811. for(var i = 0; i<keys.length;i++){
  3812. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":0}]')
  3813. }
  3814. }
  3815. return "";
  3816. }
  3817. if (chat_val.substring(1,13)=="roundsperqp " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  3818. var text = parseInt(chat_val.substring(13).replace(/^\s+|\s+$/g, ''));
  3819. if(isNaN(text)){
  3820. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  3821. return "";
  3822. }
  3823. else if(text<=0){
  3824. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  3825. return "";
  3826. }
  3827. roundsperqp = text;
  3828. roundsperqp2 = 0;
  3829. displayInChat("Set rounds per quickplay to: " + text.toString(),"#DA0808","#1EBCC1");
  3830. displayInChat("Type '/roundsperqp' to reset rounds per quickplay.","#DA0808","#1EBCC1");
  3831. return "";
  3832.  
  3833. }
  3834. else if (chat_val.substring(1,12)=="roundsperqp"){
  3835. roundsperqp = 1;
  3836. roundsperqp2 = 0;
  3837. displayInChat("Reset rounds per quickplay.","#DA0808","#1EBCC1");
  3838. return "";
  3839.  
  3840. }
  3841. else if (chat_val.substring(1,8)=="rounds " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  3842. var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '');
  3843. if(!isNaN(parseInt(text))){
  3844. text = parseInt(text).toString();
  3845. SEND('42[21,{"w":'+text+'}]');
  3846. RECIEVE('42[27,'+text+']');
  3847. }
  3848. return "";
  3849.  
  3850. }
  3851. else if (chat_val.substring(1,13)=="disablekeys " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  3852. var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '');
  3853. var keys = text.split(" ");
  3854. var disabledkeys2 = [];
  3855. var possiblekeys = ["left","right","up","down","heavy","special"];
  3856. for(var i = 0; i<keys.length; i++){
  3857. if(keys[i]!="" && !disabledkeys2.includes(keys[i])){
  3858. if(possiblekeys.includes(keys[i])){
  3859. disabledkeys2.push(keys[i]);
  3860. }
  3861. else{
  3862. displayInChat("Key options: " + possiblekeys.join(" ") + ".","#DA0808","#1EBCC1");
  3863. return "";
  3864. }
  3865. }
  3866. }
  3867. disabledkeys = disabledkeys2;
  3868. displayInChat("Set disabled keys to: " + disabledkeys.join(" ") + ".","#DA0808","#1EBCC1");
  3869. displayInChat("Type '/disablekeys' to reset disabled keys.","#DA0808","#1EBCC1");
  3870. return "";
  3871.  
  3872. }
  3873. else if (chat_val.substring(1,12)=="disablekeys"){
  3874. displayInChat("Reset disabled keys.","#DA0808","#1EBCC1");
  3875. disabledkeys = [];
  3876. return "";
  3877.  
  3878. }
  3879. else if (chat_val.substring(1,10)=="jointext " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  3880. jointext = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  3881. displayInChat("Set jointext to: " + jointext,"#DA0808","#1EBCC1");
  3882. displayInChat("Type '/jointext' to reset jointext.","#DA0808","#1EBCC1");
  3883. return "";
  3884.  
  3885. }
  3886. else if (chat_val.substring(1,9)=="jointext"){
  3887. jointext = "";
  3888. displayInChat("Reset jointext.","#DA0808","#1EBCC1");
  3889. return "";
  3890.  
  3891. }
  3892. else if (chat_val.substring(1,9)=="wintext " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  3893. wintext = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  3894. displayInChat("Set wintext to: " + wintext,"#DA0808","#1EBCC1");
  3895. displayInChat("Type '/wintext' to reset wintext.","#DA0808","#1EBCC1");
  3896. return "";
  3897.  
  3898. }
  3899. else if (chat_val.substring(1,8)=="wintext"){
  3900. wintext = "";
  3901. displayInChat("Reset wintext.","#DA0808","#1EBCC1");
  3902. return "";
  3903.  
  3904. }
  3905. else if (chat_val.substring(1,11)=="autorecord"){
  3906. if(autorecord){
  3907. autorecord = false;
  3908. displayInChat("Autorecord is now off.","#DA0808","#1EBCC1");
  3909. }
  3910. else{
  3911. autorecord = true;
  3912. displayInChat("Autorecord is now on.","#DA0808","#1EBCC1");
  3913. }
  3914. return "";
  3915.  
  3916. }
  3917. else if (chat_val.substring(1,9)=="afkkill " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  3918. var text = parseFloat(chat_val.substring(9).replace(/^\s+|\s+$/g, ''));
  3919. if(!isNaN(text)){
  3920. if(text>0){
  3921. displayInChat("Set afk kill to: " + text.toString()+" seconds.","#DA0808","#1EBCC1");
  3922. displayInChat("Type '/afkkill' to reset afk kill.","#DA0808","#1EBCC1");
  3923. var keys = Object.keys(playerids);
  3924. var now = Date.now();
  3925. for(var i = 0;i<keys.length;i++){
  3926. playerids[keys[i]].lastmove = now;
  3927. }
  3928. afkkill = text;
  3929. }
  3930. else{
  3931. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  3932. }
  3933. }
  3934. else{
  3935. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  3936. }
  3937. return "";
  3938.  
  3939. }
  3940. else if (chat_val.substring(1,9)=="afkkill"){
  3941. afkkill = -1;
  3942. displayInChat("Reset afk kill.","#DA0808","#1EBCC1");
  3943. return "";
  3944.  
  3945. }
  3946. else if (chat_val.substring(1,13)=="defaultmode " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  3947. var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '');
  3948. if(text == "default"){
  3949. defaultmode = "";
  3950. displayInChat("Changed default mode to default.","#DA0808","#1EBCC1");
  3951. }
  3952. else if(text == "arrows"){
  3953. defaultmode = "ar";
  3954. displayInChat("Changed default mode to arrows.","#DA0808","#1EBCC1");
  3955. }
  3956. else if(text == "death arrows"){
  3957. defaultmode = "ard";
  3958. displayInChat("Changed default mode to death arrows.","#DA0808","#1EBCC1");
  3959. }
  3960. else if(text == "grapple"){
  3961. defaultmode = "sp";
  3962. displayInChat("Changed default mode to grapple.","#DA0808","#1EBCC1");
  3963. }
  3964. else if(text == "classic"){
  3965. defaultmode = "b";
  3966. displayInChat("Changed default mode to classic.","#DA0808","#1EBCC1");
  3967.  
  3968. }
  3969. else{
  3970. displayInChat("Default mode options:","#DA0808","#1EBCC1");
  3971. displayInChat("default","#DA0808","#1EBCC1");
  3972. displayInChat("classic","#DA0808","#1EBCC1");
  3973. displayInChat("arrows","#DA0808","#1EBCC1");
  3974. displayInChat("death arrows","#DA0808","#1EBCC1");
  3975. displayInChat("grapple","#DA0808","#1EBCC1");
  3976. }
  3977. return "";
  3978.  
  3979. }
  3980. else if (chat_val.substring(1,8)=="recmode"){
  3981. if(recmodebool == true){
  3982. recmodebool = false;
  3983. displayInChat("Recmode is now off.","#DA0808","#1EBCC1");
  3984.  
  3985. }
  3986. else{
  3987. recmodebool = true;
  3988. displayInChat("Recmode is now on.","#DA0808","#1EBCC1");
  3989.  
  3990. }
  3991.  
  3992. return "";
  3993.  
  3994. }
  3995. else if (chat_val.substring(1,8)=="recteam"){
  3996. if(recteams == true){
  3997. recteams = false;
  3998. displayInChat("Recteam is now off.","#DA0808","#1EBCC1");
  3999.  
  4000. }
  4001. else{
  4002. recteams = true;
  4003. displayInChat("Recteam is now on.","#DA0808","#1EBCC1");
  4004.  
  4005. }
  4006. return "";
  4007. }
  4008. else if (chat_val.substring(1,8)=="shuffle"){
  4009. if(shuffle == true){
  4010. shuffle = false;
  4011. displayInChat("Shuffle is now off.","#DA0808","#1EBCC1");
  4012.  
  4013. }
  4014. else{
  4015. shuffle = true;
  4016. displayInChat("Shuffle is now on.","#DA0808","#1EBCC1");
  4017.  
  4018. }
  4019.  
  4020. return "";
  4021.  
  4022. }
  4023. else if(sandboxon){
  4024. if (chat_val.substring(1,11)=="addplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  4025. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  4026. if(!isNaN(parseInt(text))){
  4027. var text2 = parseInt(text);
  4028. if(text2>0){
  4029. for(var i = 0;i<text2;i++){
  4030. RECIEVE('42[4,'+sandboxid+',"0123456789abcdef","'+sandboxid.toString()+'",true,0,1,{"layers":[],"bc":'+Math.floor(Math.random() * 16777215).toString()+'}]');
  4031. sandboxplayerids[sandboxid] = sandboxid.toString();
  4032. sandboxid+=1;
  4033. }
  4034.  
  4035. }
  4036. }
  4037. return "";
  4038.  
  4039. }
  4040. else if (chat_val.substring(1,11)=="delplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  4041. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  4042. if(!isNaN(parseInt(text))){
  4043. var text2 = parseInt(text);
  4044. if(text2>0){
  4045. if(Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden"){
  4046. var jsonkeys = Object.keys(sandboxplayerids).reverse();
  4047. for(var i = 0;i<text2 && i<jsonkeys.length;i++){
  4048. RECIEVE('42[5,'+jsonkeys[i]+',0]');
  4049. delete sandboxplayerids[jsonkeys[i]];
  4050. }
  4051. }
  4052. else{
  4053. displayInChat("Cannot delete players while ingame.","#DA0808","#1EBCC1");
  4054. }
  4055.  
  4056. }
  4057. }
  4058. return "";
  4059. }
  4060. else if (chat_val.substring(1,7)=="copyme"){
  4061. if(sandboxcopyme == true){
  4062. displayInChat("Copyme is now off.","#DA0808","#1EBCC1");
  4063. sandboxcopyme = false;
  4064. }
  4065. else{
  4066. displayInChat("Copyme is now on.","#DA0808","#1EBCC1");
  4067. sandboxcopyme = true;
  4068. }
  4069.  
  4070. return "";
  4071. }
  4072. }
  4073. }
  4074. return chat_val;
  4075. };
  4076.  
  4077. scope.flag_manage = function(t){
  4078. var text = t;
  4079. if(reverse_flag == true){
  4080. text = text.split("").reverse().join("")
  4081. }
  4082. if(rcaps_flag == true){
  4083. text = text.split('');
  4084. for(var i = 0; i<text.length;i++){
  4085. if(Math.floor(Math.random()*2)){
  4086. text[i] = text[i].toUpperCase();
  4087. }
  4088. else{
  4089. text[i] = text[i].toLowerCase();
  4090. }
  4091. }
  4092. text = text.join('');
  4093. }
  4094. if(space_flag == true){
  4095. text = text.split('').join(' ')
  4096. }
  4097. if(number_flag == true){
  4098. text = text.replace(/[t|T][Oo]+/g,"2");
  4099. text = text.replace(/[f|F][o|O][r|R]/g,"4");
  4100. text = text.replace(/[a|A][t|T][e|E]/g,"8");
  4101. text = text.replace(/[e|E]/g,"3");
  4102. text = text.replace(/[a|A]/g,"4");
  4103. text = text.replace(/[o|O]/g,"0");
  4104. text = text.replace(/[s|S]/g,"5");
  4105. text = text.replace(/[i|I|l|L]/g,"1");
  4106. }
  4107. return text;
  4108. };
  4109. Gdocument.getElementById("newbonklobby_chat_input").onkeydown = function(e){
  4110. if(e.keyCode==13){
  4111.  
  4112. var chat_val = Gdocument.getElementById("newbonklobby_chat_input").value;
  4113.  
  4114. if (chat_val!="" && chat_val[0]=="/"){
  4115.  
  4116. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  4117. chat2(commandhandle(chat_val));
  4118. }
  4119. else{
  4120. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  4121. chat2(flag_manage(chat_val));
  4122. }
  4123.  
  4124. }
  4125. };
  4126. Gdocument.getElementById("ingamechatinputtext").onkeydown = function(e){
  4127. if(e.keyCode==13){
  4128.  
  4129. var chat_val = Gdocument.getElementById("ingamechatinputtext").value;
  4130.  
  4131. if (chat_val!="" && chat_val[0]=="/"){
  4132.  
  4133. Gdocument.getElementById("ingamechatinputtext").value = "";
  4134. chat2(commandhandle(chat_val));
  4135. }
  4136. else{
  4137. Gdocument.getElementById("ingamechatinputtext").value = "";
  4138. chat2(flag_manage(chat_val));
  4139. }
  4140. }
  4141. };
  4142. scope.Last_message = "";
  4143. scope.Laster_message = "";
  4144. scope.new_message = false;
  4145. scope.changed_chat = false;
  4146. scope.injectedBonkCommandsScript = setInterval(timeout123,30);
  4147.  
  4148. scope.hotkeys = function(e){
  4149. var keycode = e.code;
  4150. if(e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  4151. if(keycode == "Period"){
  4152. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]!="0px"){
  4153. chatheight+=5;
  4154. if(chatheight>600){chatheight = 600;}
  4155. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  4156. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  4157. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  4158. }
  4159. e.preventDefault();
  4160. }
  4161. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  4162. if(keycode == "KeyG"){
  4163. var addto = 0;
  4164. for(var i = 0;i<parentDraw.children.length;i++){
  4165. if(parentDraw.children[i].constructor.name == "e"){
  4166. addto = parentDraw.children[i];
  4167. break;
  4168. }
  4169. }
  4170. var canv = 0;
  4171. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  4172. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  4173. canv = Gdocument.getElementById("gamerenderer").children[i];
  4174. break;
  4175. }
  4176. }
  4177. var width = parseInt(canv.style["width"]);
  4178. var height = parseInt(canv.style["height"]);
  4179. if(addto){
  4180. zoom *= 1.1;
  4181. zoom *= 1.1;
  4182. }
  4183. addto.scale.x = zoom;
  4184. addto.scale.y = zoom;
  4185. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  4186. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  4187. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  4188. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  4189. if(addto.scale.x>=0.95 && addto.scale.y>=0.95 && !FollowCam){
  4190. pixiCircle.visible = false;
  4191. }
  4192. else{
  4193. pixiCircle.visible = true;
  4194. }
  4195. e.preventDefault();
  4196. }
  4197. if(keycode == "KeyH"){
  4198. var addto = 0;
  4199. for(var i = 0;i<parentDraw.children.length;i++){
  4200. if(parentDraw.children[i].constructor.name == "e"){
  4201. addto = parentDraw.children[i];
  4202. break;
  4203. }
  4204. }
  4205. var canv = 0;
  4206. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  4207. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  4208. canv = Gdocument.getElementById("gamerenderer").children[i];
  4209. break;
  4210. }
  4211. }
  4212. var width = parseInt(canv.style["width"]);
  4213. var height = parseInt(canv.style["height"]);
  4214. if(addto){
  4215. zoom = 1;
  4216. zoom = 1;
  4217. }
  4218. addto.scale.x = zoom;
  4219. addto.scale.y = zoom;
  4220. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  4221. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  4222. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  4223. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  4224. if(addto.scale.x>=0.95 && addto.scale.y>=0.95 && !FollowCam){
  4225. pixiCircle.visible = false;
  4226. }
  4227. else{
  4228. pixiCircle.visible = true;
  4229. }
  4230. e.preventDefault();
  4231. }
  4232. if(keycode == "KeyJ"){
  4233. var addto = 0;
  4234. for(var i = 0;i<parentDraw.children.length;i++){
  4235. if(parentDraw.children[i].constructor.name == "e"){
  4236. addto = parentDraw.children[i];
  4237. break;
  4238. }
  4239. }
  4240. var canv = 0;
  4241. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  4242. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  4243. canv = Gdocument.getElementById("gamerenderer").children[i];
  4244. break;
  4245. }
  4246. }
  4247. var width = parseInt(canv.style["width"]);
  4248. var height = parseInt(canv.style["height"]);
  4249. if(addto){
  4250. zoom /= 1.1;
  4251. zoom /= 1.1;
  4252. }
  4253. addto.scale.x = zoom;
  4254. addto.scale.y = zoom;
  4255. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  4256. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  4257. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  4258. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  4259. if(addto.scale.x>=0.95 && addto.scale.y>=0.95 && !FollowCam){
  4260. pixiCircle.visible = false;
  4261. }
  4262. else{
  4263. pixiCircle.visible = true;
  4264. }
  4265. e.preventDefault();
  4266. }
  4267. }
  4268. if(keycode == "Comma"){
  4269. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]!="0px"){
  4270. chatheight-=5;
  4271. if(chatheight<100){chatheight = 100;}
  4272. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  4273. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  4274. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  4275. }
  4276. e.preventDefault();
  4277. }
  4278. }
  4279. if(e.repeat){return;}
  4280. if(e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  4281. if(ishost){
  4282. if(keycode == "KeyE"){
  4283. if(Gdocument.getElementById("newbonklobby").style["display"] == "block"){
  4284. Gdocument.getElementById("newbonklobby_editorbutton").click();
  4285. }
  4286. else if(Gdocument.getElementById("mapeditorcontainer").style["display"] == "block"){
  4287. Gdocument.getElementById("mapeditor_close").click();
  4288. }
  4289. e.preventDefault();
  4290.  
  4291. }
  4292. else if(keycode == "KeyT"){
  4293. Gdocument.getElementById("newbonklobby_teamsbutton").click();
  4294. e.preventDefault();
  4295. }
  4296. else if(keycode == "KeyM"){
  4297. Gdocument.getElementById("newbonklobby_modebutton").click();
  4298. e.preventDefault();
  4299. }
  4300. else if(keycode == "KeyK"){
  4301. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  4302. Gdocument.getElementById("pretty_top_exit").click();
  4303. }
  4304. e.preventDefault();
  4305. }
  4306. else if(keycode == "KeyS"){
  4307. Gdocument.getElementById("newbonklobby_editorbutton").click();
  4308. if(recmodebool && ishost){
  4309. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  4310. if(mode == "" && defaultmode!="d"){
  4311. mode = defaultmode;
  4312. }
  4313. if(mode != ""){
  4314. RECIEVE('42[26,"b","'+mode+'"]');
  4315. }
  4316. }
  4317. Gdocument.getElementById("mapeditor_close").click();
  4318. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  4319. roundsperqp2 = 0;
  4320. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  4321. e.preventDefault();
  4322. }
  4323. else if(keycode == "KeyD"){
  4324. roundsperqp2 = 0;
  4325. if(stopquickplay == 0){
  4326. if(shuffle){
  4327. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4328. var available = [];
  4329. var availableindexes = [];
  4330. var notempty = false;
  4331. for(var i = 0; i<e2.length;i++){
  4332. var a = false;
  4333. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4334. available.push(a);
  4335. if(a){
  4336. availableindexes.push(i);
  4337. notempty = true;
  4338. }
  4339. }
  4340. if(notempty){
  4341.  
  4342. if(availableindexes.length!=1){
  4343. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  4344. }
  4345. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  4346. }
  4347. }
  4348. else{
  4349. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4350. var available = [];
  4351. var availableindexes = [];
  4352. var notempty = false;
  4353. for(var i = 0; i<e2.length;i++){
  4354. var a = false;
  4355. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4356. available.push(a);
  4357. if(a){
  4358. availableindexes.push(i);
  4359. notempty = true;
  4360. }
  4361. }
  4362. if(notempty){
  4363. var above = [];
  4364. for(var i = 0;i<availableindexes.length;i++){
  4365. if(availableindexes[i]>quicki){
  4366. above.push(availableindexes[i]);
  4367. }
  4368. }
  4369. if(above.length>0){
  4370. quicki = above[0];
  4371. }
  4372. else{
  4373. quicki = availableindexes[0];
  4374. }
  4375. }
  4376. }
  4377. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  4378. }
  4379. e.preventDefault();
  4380. }
  4381. else if(keycode == "KeyA"){
  4382. if(stopquickplay == 0){
  4383. roundsperqp2 = 0;
  4384. if(shuffle){
  4385. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4386. var available = [];
  4387. var availableindexes = [];
  4388. var notempty = false;
  4389. for(var i = 0; i<e2.length;i++){
  4390. var a = false;
  4391. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4392. available.push(a);
  4393. if(a){
  4394. availableindexes.push(i);
  4395. notempty = true;
  4396. }
  4397. }
  4398. if(notempty){
  4399.  
  4400. if(availableindexes.length!=1){
  4401. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  4402. }
  4403. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  4404. }
  4405. }
  4406. else{
  4407. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4408. var available = [];
  4409. var availableindexes = [];
  4410. var notempty = false;
  4411. for(var i = 0; i<e2.length;i++){
  4412. var a = false;
  4413. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4414. available.push(a);
  4415. if(a){
  4416. availableindexes.push(i);
  4417. notempty = true;
  4418. }
  4419. }
  4420. if(notempty){
  4421. var above = [];
  4422. for(var i = 0;i<availableindexes.length;i++){
  4423. if(availableindexes[i]<quicki){
  4424. above.push(availableindexes[i]);
  4425. }
  4426. }
  4427. if(above.length>0){
  4428. quicki = above[above.length-1];
  4429. }
  4430. else{
  4431. quicki = availableindexes[availableindexes.length-1];
  4432. }
  4433. }
  4434. }
  4435. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  4436. }
  4437. e.preventDefault();
  4438. }
  4439. else if(keycode == "KeyQ"){
  4440. if(stopquickplay == 1){
  4441. stopquickplay = 0;
  4442. quicki = 0;
  4443. qppaused = false;
  4444. displayInChat("Enabled quickplay.","#DA0808","#1EBCC1");
  4445. }
  4446. else{
  4447. stopquickplay = 1;
  4448. quicki = 0;
  4449. qppaused = false;
  4450. displayInChat("Disabled quickplay.","#DA0808","#1EBCC1");
  4451. }
  4452. e.preventDefault();
  4453. }
  4454. else if(keycode == "KeyP" && stopquickplay==0){
  4455. if(qppaused == true){
  4456. qppaused = false;
  4457. displayInChat("Unpaused quickplay.","#DA0808","#1EBCC1");
  4458. }
  4459. else{
  4460. qppaused = true;
  4461. displayInChat("Paused quickplay.","#DA0808","#1EBCC1");
  4462. }
  4463. e.preventDefault();
  4464. }
  4465. else if(keycode == "KeyR"){
  4466. if(recmodebool == true){
  4467. recmodebool = false;
  4468. displayInChat("Recmode is now off.","#DA0808","#1EBCC1");
  4469.  
  4470. }
  4471. else{
  4472. recmodebool = true;
  4473. displayInChat("Recmode is now on.","#DA0808","#1EBCC1");
  4474.  
  4475. }
  4476. }
  4477. else if(keycode == "KeyF"){
  4478. if(freejoin == false){
  4479. freejoin = true;
  4480. displayInChat("Freejoin is now on.","#DA0808","#1EBCC1");
  4481.  
  4482. }
  4483. else{
  4484. freejoin = false;
  4485. displayInChat("Freejoin is now off.","#DA0808","#1EBCC1");
  4486. }
  4487. e.preventDefault();
  4488. }
  4489. }
  4490. else{
  4491. if(keycode == "KeyE"){
  4492. e.preventDefault();
  4493. }
  4494. else if(keycode == "KeyT"){
  4495. e.preventDefault();
  4496. }
  4497. else if(keycode == "KeyM"){
  4498. e.preventDefault();
  4499. }
  4500. else if(keycode == "KeyK"){
  4501. e.preventDefault();
  4502. }
  4503. else if(keycode == "KeyS"){
  4504. e.preventDefault();
  4505. }
  4506. else if(keycode == "KeyD"){
  4507. e.preventDefault();
  4508. }
  4509. else if(keycode == "KeyA"){
  4510. e.preventDefault();
  4511. }
  4512. else if(keycode == "KeyQ"){
  4513. e.preventDefault();
  4514. }
  4515. else if(keycode == "KeyP"){
  4516. e.preventDefault();
  4517. }
  4518. else if(keycode == "KeyF"){
  4519. e.preventDefault();
  4520. }
  4521. else if(keycode == "KeyR"){
  4522. e.preventDefault();
  4523. }
  4524.  
  4525. }
  4526. if(keycode == "KeyL"){
  4527. lobby();
  4528. e.preventDefault();
  4529. }
  4530. if(keycode == "KeyC"){
  4531. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  4532. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]=="0px"){
  4533. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  4534. }
  4535. else{
  4536. Gdocument.getElementById("ingamechatcontent").style["max-height"]="0px";
  4537. }
  4538. }
  4539. e.preventDefault();
  4540. }
  4541. if(keycode == "KeyI"){
  4542. if(Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"] == "none"){
  4543. debuggeropen = true;
  4544. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="block";
  4545. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="none";
  4546. Gdocument.getElementById("ingamechatinputtext").style["display"] = "none";
  4547. }
  4548. else{
  4549. debuggeropen = false;
  4550. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="none";
  4551. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  4552. Gdocument.getElementById("ingamechatinputtext").style["display"] = "";
  4553. }
  4554. e.preventDefault();
  4555. }
  4556. if(keycode == "KeyB"){
  4557. var element = Gdocument.getElementById("ingamewinner_scores");
  4558. element.style["visibility"] = "visible";
  4559. if(element.style["opacity"]<1){
  4560. element.style["opacity"] = 1;
  4561. }
  4562. else{
  4563. element.style["opacity"] = 0;
  4564. }
  4565. e.preventDefault();
  4566. }
  4567. if(keycode == "KeyY"){
  4568. Gdocument.getElementById("pretty_top_settings").click();
  4569. Gdocument.getElementById("settings_close").click();
  4570. if(Gdocument.getElementById("settings_graphicsquality").value==1){
  4571. displayInChat("You must have medium or high quality enabled to use this feature.","#DA0808","#1EBCC1");
  4572. return "";
  4573. }
  4574.  
  4575.  
  4576. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  4577. var addto = {"children":[]};
  4578. for(var i = 0;i<parentDraw.children.length;i++){
  4579. if(parentDraw.children[i].constructor.name == "e"){
  4580. addto = parentDraw.children[i];
  4581. break;
  4582. }
  4583. }
  4584. var addto2 = {"children":[]};
  4585. for(var i = 0;i<addto.children.length;i++){
  4586. if(addto.children[i].constructor.name == "e"){
  4587. addto2 = addto.children[i];
  4588. break;
  4589. }
  4590. }
  4591. var checkxray = addto2.children[0];
  4592. var addto3 = addto2.children[0].children;
  4593. if(addto3.length==1){
  4594. checkxray = checkxray.children[0];
  4595. addto3 = addto3[0].children;
  4596. }
  4597. var xrayon = false;
  4598. if(checkxray.xrayon){
  4599. checkxray.xrayon = false;
  4600. xrayon = false;
  4601. }
  4602. else{
  4603. checkxray.xrayon = true;
  4604. xrayon = true;
  4605. }
  4606. if(xrayon){
  4607. displayInChat("Xray is now on.","#DA0808","#1EBCC1");
  4608. for(var i = 0;i<addto3.length;i++){
  4609. if(addto3[i].children.length>0){
  4610. for(var i3 = 0;i3<addto3[i].children.length;i3++){
  4611. addto3[i].children[i3].visible = false;
  4612. if(addto3[i].children[i3].children.length>0){
  4613. addto3[i].children[i3].visible = true;
  4614. }
  4615. }
  4616. }
  4617. }
  4618.  
  4619. }
  4620. else{
  4621. displayInChat("Xray is now off.","#DA0808","#1EBCC1");
  4622. for(var i = 0;i<addto3.length;i++){
  4623. for(var i2 = 0;i2<addto3[i].children.length;i2++){
  4624. addto3[i].children[i2].visible = true;
  4625. }
  4626. }
  4627. }
  4628. }
  4629. e.preventDefault();
  4630. }
  4631. if(keycode == "KeyN"){
  4632. if(FollowCam == true){
  4633. displayInChat("Follow Camera is now off.","#DA0808","#1EBCC1");
  4634. FollowCam = false;
  4635. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  4636. var addto = {"children":[]};
  4637. for(var i = 0;i<parentDraw.children.length;i++){
  4638. if(parentDraw.children[i].constructor.name == "e"){
  4639. addto = parentDraw.children[i];
  4640. break;
  4641. }
  4642. }
  4643. var canv = 0;
  4644. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  4645. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  4646. canv = Gdocument.getElementById("gamerenderer").children[i];
  4647. break;
  4648. }
  4649. }
  4650. var width = parseInt(canv.style["width"]);
  4651. var height = parseInt(canv.style["height"]);
  4652. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  4653. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  4654. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  4655. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  4656. if(addto.scale.x>=0.95 && addto.scale.y>=0.95){
  4657. pixiCircle.visible = false;
  4658. }
  4659. else{
  4660. pixiCircle.visible = true;
  4661. }
  4662. }
  4663. }
  4664. else{
  4665. displayInChat("Follow Camera is now on.","#DA0808","#1EBCC1");
  4666. FollowCam = true;
  4667. }
  4668. e.preventDefault();
  4669. }
  4670. if(keycode == "KeyO"){
  4671. if(heavybot == true){
  4672. displayInChat("Heavy bot is now off.","#DA0808","#1EBCC1");
  4673. heavybot = false;
  4674. }
  4675. else{
  4676. displayInChat("Heavy bot is now on.","#DA0808","#1EBCC1");
  4677. heavybot = true;
  4678. var keykeys = Object.keys(keyCodes);
  4679. var keyslist = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[5].children).slice(1);
  4680. for(var i = 0;i<keyslist.length;i++){
  4681. if(keykeys.includes(keyslist[i].textContent)){
  4682. heavy = keyCodes[keyslist[i].textContent];
  4683. break;
  4684. }
  4685. else{
  4686. heavy = keyslist[i].textContent.charCodeAt(0);
  4687. break
  4688. }
  4689. }
  4690. var keyslist2 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[6].children).slice(1);
  4691. for(var i = 0;i<keyslist2.length;i++){
  4692. if(keykeys.includes(keyslist2[i].textContent)){
  4693. special = keyCodes[keyslist2[i].textContent];
  4694. break;
  4695. }
  4696. else{
  4697. special = keyslist2[i].textContent.charCodeAt(0);
  4698. break
  4699. }
  4700. }
  4701. }
  4702. e.preventDefault();
  4703. }
  4704. if(keycode == "KeyU"){
  4705. if(aimbot == true){
  4706. displayInChat("Aimbot is now off.","#DA0808","#1EBCC1");
  4707. aimbot = false;
  4708. }
  4709. else{
  4710. displayInChat("Aimbot is now on.","#DA0808","#1EBCC1");
  4711. aimbot = true;
  4712. var keykeys = Object.keys(keyCodes);
  4713. var keyslist = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[1].children).slice(1);
  4714. var keyslist2 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[2].children).slice(1);
  4715. for(var i = 0;i<keyslist.length;i++){
  4716. if(keykeys.includes(keyslist[i].textContent)){
  4717. leftRight[0] = keyCodes[keyslist[i].textContent];
  4718. break;
  4719. }
  4720. else{
  4721. leftRight[0] = keyslist[i].textContent.charCodeAt(0);
  4722. break
  4723. }
  4724. }
  4725. for(var i = 0;i<keyslist2.length;i++){
  4726. if(keykeys.includes(keyslist2[i].textContent)){
  4727. leftRight[1] = keyCodes[keyslist2[i].textContent];
  4728. break;
  4729. }
  4730. else{
  4731. leftRight[1] = keyslist2[i].textContent.charCodeAt(0);
  4732. }
  4733. }
  4734. }
  4735. e.preventDefault();
  4736. }
  4737. }
  4738. if(!e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  4739. if(keycode == "Slash" && !(Gdocument.getElementById("gmeditor")?.style["transform"] == "scale(1)")){
  4740. 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"]==""){
  4741. Gdocument.getElementById("newbonklobby_chat_input").value = "/";
  4742. if(Gdocument.getElementById("newbonklobby_chat_input").style["pointer-events"] == "none"){
  4743. fire("keydown",{keyCode:13});
  4744. }
  4745. else{
  4746. Gdocument.getElementById("newbonklobby_chat_input").focus();
  4747. }
  4748. e.preventDefault();
  4749.  
  4750. }
  4751. else if(Gdocument.getElementById("ingamechatinputtext").style["visibility"]=="visible" && Gdocument.getElementById("ingamechatinputtext").style["display"]=="" && Gdocument.getElementById("mapeditorcontainer").style["display"]!="block" && Gdocument.getElementById("ingamechatinputtext").value == ""){
  4752. Gdocument.getElementById("ingamechatinputtext").value = "/";
  4753. if(!Gdocument.getElementById("ingamechatinputtext").classList.value.includes("ingamechatinputtextbg")){
  4754. fire("keydown",{keyCode:13});
  4755. }
  4756. else{
  4757. Gdocument.getElementById("ingamechatinputtext").focus();
  4758. }
  4759. e.preventDefault();
  4760.  
  4761. }
  4762. }
  4763. }
  4764. };
  4765.  
  4766. Gdocument.onkeydown = hotkeys;
  4767.  
  4768. Gwindow.addEventListener('resize',function(e){
  4769. debuggermenu.style["width"] = Gdocument.getElementById("bonkiocontainer").style["width"];
  4770. debuggermenu.style["height"] = Gdocument.getElementById("bonkiocontainer").style["height"];
  4771. scope.width = parseInt(Gdocument.getElementById("bonkiocontainer").style["width"])-20;
  4772. scope.height = parseInt(Gdocument.getElementById("bonkiocontainer").style["height"])-210;
  4773. logmenu.style["width"] = width.toString()+"px";
  4774. logmenu.style["height"] = height.toString()+"px";
  4775. logmenutopleft.style["width"] = (width/2).toString()+"px";
  4776. logmenutopright.style["width"] = (width/2).toString()+"px";
  4777. logmenutopright.style["left"] = (width/2).toString()+"px";
  4778. debuggerinput.style["width"] = width.toString()+"px";
  4779. debuggerinput.style["top"] = (height+90).toString()+"px";
  4780. debuggersendrecieve.style["top"] = (height+120).toString()+"px";
  4781. debuggerpausebutton.style["top"] = (height+150).toString()+"px";
  4782. debuggereval.style["width"] = (width-150).toString()+"px";
  4783. debuggereval.style["top"] = (height+120).toString()+"px";},true);
  4784.  
  4785.  
  4786. function timeout123() {
  4787. updateWssLog();
  4788. EVENTLOOPFUNCTION();
  4789. var now = Date.now();
  4790. var keys = Object.keys(playerids);
  4791. /*for(var i = 0;i<keys.length;i++){
  4792. if(playerids[keys[i]].playerData){
  4793. if(playerids[keys[i]].playerData2){
  4794. if(playerids[keys[i]].playerData.transform){
  4795. playerids[keys[i]].playerData2.alive = true;
  4796. if(playerids[keys[i]].playerData2.timeStamp == 0){
  4797. playerids[keys[i]].playerData2.px = playerids[keys[i]].playerData.transform.position.x;
  4798. playerids[keys[i]].playerData2.py = playerids[keys[i]].playerData.transform.position.y;
  4799. playerids[keys[i]].playerData2.timeStamp = now;
  4800. }
  4801. else{
  4802. playerids[keys[i]].playerData2.xvel = (playerids[keys[i]].playerData2.px - playerids[keys[i]].playerData.transform.position.x)/(playerids[keys[i]].playerData2.timeStamp-now);
  4803. playerids[keys[i]].playerData2.yvel = (playerids[keys[i]].playerData2.py - playerids[keys[i]].playerData.transform.position.y)/(playerids[keys[i]].playerData2.timeStamp-now);
  4804. playerids[keys[i]].playerData2.px = playerids[keys[i]].playerData.transform.position.x;
  4805. playerids[keys[i]].playerData2.py = playerids[keys[i]].playerData.transform.position.y;
  4806. playerids[keys[i]].playerData2.timeStamp = now;
  4807. }
  4808. if(playerids[keys[i]].playerData2.timeStamp2 == 0){
  4809. playerids[keys[i]].playerData2.pvx = playerids[keys[i]].playerData2.xvel;
  4810. playerids[keys[i]].playerData2.pvx = playerids[keys[i]].playerData2.yvel;
  4811. playerids[keys[i]].playerData2.timeStamp2 = now;
  4812. }
  4813. else{
  4814. playerids[keys[i]].playerData2.xacc = (playerids[keys[i]].playerData2.pvx - playerids[keys[i]].playerData2.xvel)/((playerids[keys[i]].playerData2.timeStamp2-now)**2);
  4815. playerids[keys[i]].playerData2.yacc = (playerids[keys[i]].playerData2.pvy - playerids[keys[i]].playerData2.yvel)/((playerids[keys[i]].playerData2.timeStamp2-now)**2);
  4816. playerids[keys[i]].playerData2.pvx = playerids[keys[i]].playerData2.xvel;
  4817. playerids[keys[i]].playerData2.pvx = playerids[keys[i]].playerData2.yvel;
  4818. playerids[keys[i]].playerData2.timeStamp2 = now;
  4819. }
  4820. }
  4821. else{
  4822. if(playerids[keys[i]].playerData2.alive){
  4823. }
  4824. playerids[keys[i]].playerData2.alive = false;
  4825. }
  4826. }
  4827. else{
  4828. 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};
  4829. }
  4830. }
  4831. }*/
  4832. if(Gdocument.getElementById("redefineControls_table").children[0].children.length<=1){
  4833. Gdocument.getElementById("pretty_top_settings").click();
  4834. Gdocument.getElementById("settings_close").click();
  4835. }
  4836. if(pollactive[0] && pollactive[2]<now && ishost){
  4837. playerids[myid].ratelimit.poll = Date.now();
  4838. SEND("42"+JSON.stringify([4,{"type":"poll end","from":username}]));
  4839. var count = [0,0,0,0];
  4840. var keys = Object.keys(playerids);
  4841. for(var i = 0;i<keys.length;i++){
  4842. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive[3].length-1){
  4843. count[playerids[keys[i]].vote.poll]++;
  4844. }
  4845. playerids[keys[i]].vote.poll = -1;
  4846. }
  4847. displayInChat("The poll ended due to time.","#DA0808","#1EBCC1");
  4848. for(var i = 0;i<count.length;i++){
  4849. if(count[i]>1){
  4850. displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  4851. }
  4852. if(count[i]==1){
  4853. displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  4854. }
  4855. }
  4856. displayInChat("The poll was:","#DA0808","#1EBCC1");
  4857. for(var i = 0;i<pollactive[3].length;i++){
  4858. displayInChat(letters[i]+") "+pollactive[3][i],"#DA0808","#1EBCC1");
  4859. }
  4860. pollactive = [false,0,0,[]];
  4861. }
  4862. if(afkkill>0 && ishost){
  4863. var keys = Object.keys(playerids);
  4864. currentFrame = Math.floor((now - gameStartTimeStamp)/1000*30);
  4865. for(var i = 0; i<keys.length;i++){
  4866. if(typeof(playerids[keys[i]].lastmove)=="undefined"){
  4867. playerids[keys[i]].lastmove = now;
  4868. }
  4869. else{
  4870. if(playerids[keys[i]].playerData2?.alive && now-playerids[keys[i]].lastmove>=afkkill*1000 && now-gameStartTimeStamp>=afkkill*1000 && !killedids.includes(keys[i])){
  4871. killedids.push(keys[i]);
  4872. SEND('42[25,{"a":{"playersLeft":['+keys[i]+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  4873. RECIEVE('42[31,{"a":{"playersLeft":['+keys[i]+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  4874. break;
  4875. }
  4876. }
  4877. }
  4878. }
  4879. if(ishost && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS"){
  4880. clearmaprequests.style["display"] = "block";
  4881. refreshmaprequests.style["display"] = "block";
  4882. }
  4883. else{
  4884. clearmaprequests.style["display"] = "none";
  4885. refreshmaprequests.style["display"] = "none";
  4886. }
  4887. if(Gdocument.getElementById("gamerenderer").style["visibility"]=="hidden"){
  4888. Gdocument.getElementById("ingamewinner_scores").style["visibility"] = "unset";;
  4889. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  4890. }
  4891. if(Gdocument.getElementById("maploadwindowmapscontainer").children.length>0 && maponclick == 0){
  4892. maponclick = Gdocument.getElementById("maploadwindowmapscontainer").children[0].onclick;
  4893. }
  4894. if(Gdocument.getElementById("sm_connectingContainer").style["visibility"] == "hidden"){
  4895. var chatbox = Gdocument.getElementById("newbonklobby_chat_content");
  4896. while (chatbox.firstChild) {
  4897. chatbox.removeChild(chatbox.firstChild);
  4898. }
  4899. rcaps_flag = false;
  4900. space_flag = false;
  4901. number_flag = false;
  4902. reverse_flag = false;
  4903. echo_list = [];
  4904. scroll = false;
  4905. FollowCam = false;
  4906. aimbot = false;
  4907. zoom = 1;
  4908. heavybot = false;
  4909. stopquickplay = 1;
  4910. roundsperqp = 1;
  4911. roundsperqp2 = 0;
  4912. checkboxhidden = false;
  4913. freejoin = false;
  4914. shuffle = false;
  4915. defaultmode = "";
  4916. recmodebool = false;
  4917. recteams = false;
  4918. autorecord = false;
  4919. pollactive = [false,0,0,[]];
  4920. pollactive2 = [false,0,[]];
  4921. afkkill = -1;
  4922. nextafter = 0;
  4923. jointext = "";
  4924. ishost = false;
  4925. parentDraw = 0;
  4926. sandboxplayerids = {};
  4927. sandboxcopyme = false;
  4928. wintext = "";
  4929. sandboxon = false;
  4930. sandboxid = 1;
  4931. disabledkeys = [];
  4932. myid = -1;
  4933. if(!bonkwss){
  4934. playerids = {};
  4935. }
  4936. qppaused = false;
  4937. nextafterbuffer = -1;
  4938. hostid = -1;
  4939. if(chatlog[chatlog.length-1]!="ROOM END"){
  4940. chatlog.push("ROOM END");
  4941. }
  4942. }
  4943. else{
  4944. if(chatlog[chatlog.length-1]=="ROOM END"){
  4945. chatlog.push("ROOM START");
  4946. }
  4947. }
  4948.  
  4949. if(Gdocument.getElementById("newbonklobby").style["display"]=="block"){
  4950. Gdocument.getElementById("ingamechatinputtext").style["visibility"]="hidden";
  4951. }
  4952. else{
  4953. Gdocument.getElementById("ingamechatinputtext").style["visibility"]="visible";
  4954.  
  4955. }
  4956. 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
  4957. >0){
  4958. ishost = true;
  4959. }
  4960. else{
  4961. ishost = actuallyhost;
  4962. }
  4963.  
  4964. if(Gdocument.getElementById("pretty_top_name")!=null){
  4965. username = Gdocument.getElementById("pretty_top_name").textContent;
  4966. if(myid!=-1){
  4967. username = playerids[myid].userName;
  4968. }
  4969. }
  4970. try{
  4971. Last_message = lastmessage()
  4972. } catch{
  4973. Last_message = "";
  4974. }
  4975. if (Laster_message != Last_message){
  4976. Laster_message = Last_message;
  4977. if(changed_chat==false){
  4978. new_message = true;
  4979. }
  4980. else{
  4981. changed_chat = false;
  4982. }
  4983. }
  4984. if(new_message){
  4985. chatlog.push(Last_message);
  4986. var lm = "";
  4987. try{
  4988. lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  4989. if(typeof(lm[0].parentElement.style["parsed"]) == 'undefined'){
  4990. if (lm[0].className == "newbonklobby_chat_msg_colorbox"){
  4991. lm[2].innerHTML = urlify(lm[2].innerHTML);
  4992. Laster_message = lastmessage();
  4993. lm[0].parentElement.style["parsed"] = true;
  4994. }
  4995. if (lm[0].className == "newbonklobby_chat_status"){
  4996. lm[0].innerHTML = urlify(lm[0].innerHTML);
  4997. Laster_message = lastmessage();
  4998. lm[0].parentElement.style["parsed"] = true;
  4999. }
  5000. }
  5001. }
  5002. catch{
  5003. lm = "";
  5004. }
  5005.  
  5006. if(Last_message.indexOf("@"+username)!=-1 && npermissions == 1){
  5007. if(Notification.requestPermission()){
  5008. var n = new Notification(Last_message);
  5009. }
  5010. }
  5011.  
  5012. try{
  5013. lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  5014. if(typeof(lm[0].parentElement.style["parsed"])=='undefined'){
  5015. if(lm[0].className == "ingamechatname"){
  5016. lm[1].innerHTML = urlify(lm[1].innerHTML);
  5017. Laster_message = lastmessage();
  5018. lm[0].parentElement.style["parsed"] = true;
  5019. }
  5020. if(lm[0].className == ""){
  5021. lm[0].innerHTML = urlify(lm[0].innerHTML);
  5022. Laster_message = lastmessage();
  5023. lm[0].parentElement.style["parsed"] = true;
  5024. }
  5025. }
  5026. }
  5027. catch{
  5028. lm = "";
  5029. }
  5030. if(text2speech){
  5031. if(!sayer.speaking){
  5032. if(Last_message.includes(": ")){
  5033. speech.text = Last_message.substring(0,Last_message.indexOf(":")).toLowerCase();
  5034. speech.rate = 2.25;
  5035. sayer.speak(speech);
  5036. speech.text = Last_message.substring(Last_message.indexOf(": ")+3).toLowerCase();
  5037. speech.rate = 1.25;
  5038. sayer.speak(speech);
  5039. }
  5040. else{
  5041. speech.text = Last_message.toLowerCase();
  5042. sayer.speak(speech);
  5043. }
  5044. }
  5045. }
  5046. }
  5047. if (ishost==true && new_message){
  5048. for(i=0;i<banned.length;i++){
  5049. if(Last_message.startsWith("* "+banned[i]+" has joined the game")){
  5050. chat2("/kick '"+banned[i]+"'");
  5051. }
  5052. }
  5053. }
  5054. if(Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden" && ishost){
  5055. roundsperqp2 = 0;
  5056. }
  5057. if(Gdocument.getElementById("ingamewinner").style["visibility"]=="inherit" && ishost){
  5058. if(Gdocument.getElementById("ingamewinner").style["parsed"] != true){
  5059. if(stopquickplay!=1){
  5060. roundsperqp2++;
  5061. }
  5062. if(autorecord){
  5063. Gdocument.getElementById("pretty_top_replay").click();
  5064. }
  5065. }
  5066. if(Gdocument.getElementById("ingamewinner").style["parsed"] != true && wintext!="" && Gdocument.getElementById("ingamewinner_bottom").textContent!="DRAW"){
  5067. chat(flag_manage(wintext.replaceAll("username",Gdocument.getElementById("ingamewinner_top").textContent)));
  5068. }
  5069. Gdocument.getElementById("ingamewinner").style["parsed"] = true;
  5070. }
  5071. else{
  5072. Gdocument.getElementById("ingamewinner").style["parsed"] = false;
  5073. }
  5074. if(ishost && stopquickplay == 0){
  5075. if(checkboxhidden){
  5076. checkboxhidden = false;
  5077. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  5078. for(var i = 0; i<classes.length;i++){
  5079. classes[i].style["display"] = "block";
  5080. classes[i].className = "quickplaycheckbox quickplaychecked";
  5081. }
  5082. Gdocument.getElementById('clearallcheckboxes').style["display"] = "block";
  5083.  
  5084. }
  5085. if(nextafter>0 && gameStartTimeStamp+nextafter*1000<=now && Gdocument.getElementById("gamerenderer").style["visibility"] != "hidden" && dontswitch == false && Gdocument.getElementById("ingamewinner").style["visibility"]!="inherit" && !qppaused){
  5086. roundsperqp2 = 0;
  5087. if(shuffle){
  5088. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  5089. var available = [];
  5090. var availableindexes = [];
  5091. var notempty = false;
  5092. for(var i = 0; i<e.length;i++){
  5093. var a = false;
  5094. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  5095. available.push(a);
  5096. if(a){
  5097. availableindexes.push(i);
  5098. notempty = true;
  5099. }
  5100. }
  5101. if(notempty){
  5102. if(availableindexes.length!=1){
  5103. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  5104. }
  5105. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  5106. }
  5107. }
  5108. else{
  5109. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  5110. var available = [];
  5111. var availableindexes = [];
  5112. var notempty = false;
  5113. for(var i = 0; i<e.length;i++){
  5114. var a = false;
  5115. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  5116. available.push(a);
  5117. if(a){
  5118. availableindexes.push(i);
  5119. notempty = true;
  5120. }
  5121. }
  5122. if(notempty){
  5123. var above = [];
  5124. for(var i = 0;i<availableindexes.length;i++){
  5125. if(availableindexes[i]>quicki){
  5126. above.push(availableindexes[i]);
  5127. }
  5128. }
  5129. if(above.length>0){
  5130. quicki = above[0];
  5131. }
  5132. else{
  5133. quicki = availableindexes[0];
  5134. }
  5135. }
  5136. }
  5137. startedinqp = true;
  5138. dontswitch = true;
  5139. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  5140. }
  5141. if(Gdocument.getElementById("ingamewinner").style["visibility"]=="inherit" && dontswitch == false && !document.hidden && !qppaused){
  5142. if(roundsperqp2>=roundsperqp){
  5143. if(shuffle){
  5144. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  5145. var available = [];
  5146. var availableindexes = [];
  5147. var notempty = false;
  5148. for(var i = 0; i<e.length;i++){
  5149. var a = false;
  5150. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  5151. available.push(a);
  5152. if(a){
  5153. availableindexes.push(i);
  5154. notempty = true;
  5155. }
  5156. }
  5157. if(notempty){
  5158.  
  5159. if(availableindexes.length!=1){
  5160. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  5161. }
  5162. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  5163. }
  5164. }
  5165. else{
  5166. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  5167. var available = [];
  5168. var availableindexes = [];
  5169. var notempty = false;
  5170. for(var i = 0; i<e.length;i++){
  5171. var a = false;
  5172. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  5173. available.push(a);
  5174. if(a){
  5175. availableindexes.push(i);
  5176. notempty = true;
  5177. }
  5178. }
  5179. if(notempty){
  5180. var above = [];
  5181. for(var i = 0;i<availableindexes.length;i++){
  5182. if(availableindexes[i]>quicki){
  5183. above.push(availableindexes[i]);
  5184. }
  5185. }
  5186. if(above.length>0){
  5187. quicki = above[0];
  5188. }
  5189. else{
  5190. quicki = availableindexes[0];
  5191. }
  5192. }
  5193. }
  5194. }
  5195. transitioning = true;
  5196. startedinqp = true;
  5197. map(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  5198. dontswitch = true;
  5199. setTimeout(function(){Gdocument.getElementById("ingamewinner").style["visibility"]="hidden"; dontswitch = false;},timedelay);
  5200. }
  5201. }
  5202. else{
  5203. if(!checkboxhidden){
  5204. checkboxhidden = true;
  5205. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  5206. for(var i = 0; i<classes.length;i++){
  5207. classes[i].style["display"] = "none";
  5208. classes[i].className = "quickplaycheckbox quickplayunchecked";
  5209. }
  5210. Gdocument.getElementById('clearallcheckboxes').style["display"] = "none";
  5211. }
  5212. }
  5213. new_message = false;
  5214. };
  5215. });

QingJ © 2025

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