Bonk Commands

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

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

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

QingJ © 2025

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