Bonk Commands

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

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

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

QingJ © 2025

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