Bonk Commands

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

当前为 2023-07-11 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Bonk Commands
  3. // @namespace https://greasyfork.org/en/scripts/451341-bonk-commands
  4. // @version 17.2
  5. // @description Adds lots of commands to bonk.io. Type /? or /help in bonk chat to get started.
  6. // @author LEGENDBOSS123 + left paren + mastery3
  7. // @match https://bonk.io/*
  8. // @run-at document-idle
  9. // @grant none
  10. // @unwrap
  11. // ==/UserScript==
  12. function BonkCommandsScriptInjector(f){
  13. if(window.location == window.parent.location){
  14. if(document.readyState == "complete"){f();}
  15. else{document.addEventListener('readystatechange',function(){setTimeout(f,1500);});}
  16. }
  17. }
  18.  
  19. BonkCommandsScriptInjector(function(){
  20. var scope = window;
  21. scope.scope = scope;
  22. scope.Gwindow = document.getElementById("maingameframe").contentWindow;
  23. scope.Gdocument = document.getElementById("maingameframe").contentDocument;
  24. Gwindow.Gwindow = window;
  25. Gwindow.Gdocument = document;
  26.  
  27. scope.link2pastebin = "https://pastebin.com/2b8XqqYu";
  28. scope.link2greasyfork = "https://greasyfork.org/en/scripts/451341-bonk-commands";
  29.  
  30. if(typeof(scope.injectedBonkCommandsScript)=='undefined'){
  31. scope.injectedBonkCommandsScript = true;
  32. }
  33. else{
  34. clearInterval(injectedBonkCommandsScript);
  35. }
  36. scope.GENERATE_COPRIME_NUMBER = function(mini = 0,maxi = 0,coprimewith = 0,choices = []){
  37. if(choices.length == 0){
  38. for(var i = mini;i<maxi+1;i++){
  39. choices.push(i);
  40. }
  41. }
  42. firstTry = choices[Math.floor(Math.random()*choices.length)];
  43. for(var i = 2; i<firstTry+1;i++){
  44. if(firstTry%i == 0 && coprimewith%i == 0){
  45. choices.splice(choices.indexOf(firstTry),1);
  46. if(choices.length == 0){
  47. return 0;
  48. }
  49. return GENERATE_COPRIME_NUMBER(mini,maxi,coprimewith,choices);
  50. }
  51. }
  52. return firstTry;
  53. };
  54. scope.GENERATE_PRIME_NUMBER = function(mini = 0,maxi = 0,choices = []){
  55. if(choices.length == 0){
  56. for(var i = mini;i<maxi+1;i++){
  57. choices.push(i);
  58. }
  59. }
  60. firstTry = choices[Math.floor(Math.random()*choices.length)];
  61. for(var i = 2; i<Math.floor(Math.sqrt(firstTry)+1);i++){
  62. if(i!=firstTry){
  63. if(firstTry%i == 0){
  64. choices.splice(choices.indexOf(firstTry),1);
  65. if(choices.length == 0){
  66. return 0;
  67. }
  68. return GENERATE_PRIME_NUMBER(mini,maxi,choices);
  69. }
  70. }
  71. }
  72. return firstTry;
  73. };
  74. scope.SHUFFLE_LIST = function(x){
  75. var nl = x.slice();
  76. for(var i = nl.length - 1;i>0;i--){
  77. var r = Math.floor(Math.random()*(i+1));
  78. var t = nl[i];
  79. nl[i] = nl[r];
  80. nl[r] = t;
  81. }
  82. return nl;
  83. };
  84. scope.GENERATE_KEYS = function(){
  85. interval = [];
  86. for(var i = 100;i<301;i++){
  87. interval.push(i);
  88. }
  89. random_prime = [GENERATE_PRIME_NUMBER(0,0,choices = interval),0];
  90. interval.splice(interval.indexOf(random_prime[0]),1);
  91. random_prime[1] = GENERATE_PRIME_NUMBER(0,0,choices = interval);
  92.  
  93. n = random_prime[0]*random_prime[1];
  94. n2 = (random_prime[0]-1)*(random_prime[1]-1);
  95.  
  96. e = GENERATE_COPRIME_NUMBER(2,n2-1,n2);
  97. d = 0;
  98. redo = true;
  99. for(var i = 0;i<1000000;i++){
  100. if((e*i-1)%n2 == 0 && i!=e){
  101. d = i;
  102. redo = false;
  103. break;
  104. }
  105. }
  106. if(redo){
  107. return GENERATE_KEYS();
  108. }
  109. else{
  110. return [[n,e],[n,d]];
  111. }
  112.  
  113. };
  114. scope.CRYPT_NUMBER = function(key, data){
  115.  
  116. result = 1;
  117.  
  118. for(var i = 0;i<key[1];i++){
  119. result*=data;
  120. result = result%key[0];
  121. }
  122. return result%key[0];
  123.  
  124. };
  125.  
  126. scope.CRYPT_MESSAGE = function(key,data){
  127. var resulttext = [];
  128. for(var i = 0;i<data.length;i++){
  129. resulttext.push(CRYPT_NUMBER(key,data[i]));
  130. }
  131. return resulttext;
  132.  
  133. };
  134. if(typeof(scope.textdecoder)=='undefined'){scope.textdecoder = new Gwindow.TextDecoder;}
  135. if(typeof(scope.textencoder)=='undefined'){scope.textencoder = new Gwindow.TextEncoder;}
  136.  
  137. class bytebuffer2 {
  138. constructor() {
  139. var g1d = [arguments];
  140. this.index = 0;
  141. this.buffer = new ArrayBuffer(100*1024);
  142. this.view = new DataView(this.buffer);
  143. this.implicitClassAliasArray = [];
  144. this.implicitStringArray = [];
  145. this.bodgeCaptureZoneDataIdentifierArray = [];
  146. }
  147. readByte() {
  148. var N0H = [arguments];
  149. N0H[4] = this.view.getUint8(this.index);
  150. this.index += 1;
  151. return N0H[4];
  152. }
  153. writeByte(z0w) {
  154. var v8$ = [arguments];
  155. this.view.setUint8(this.index, v8$[0][0]);
  156. this.index += 1;
  157. }
  158. readInt() {
  159. var A71 = [arguments];
  160. A71[6] = this.view.getInt32(this.index);
  161. this.index += 4;
  162. return A71[6];
  163. }
  164. writeInt(W6i) {
  165. var p5u = [arguments];
  166. this.view.setInt32(this.index, p5u[0][0]);
  167. this.index += 4;
  168. }
  169. readShort() {
  170. var R1R = [arguments];
  171. R1R[9] = this.view.getInt16(this.index);
  172. this.index += 2;
  173. return R1R[9];
  174. }
  175. writeShort(H8B) {
  176. var d_3 = [arguments];
  177. this.view.setInt16(this.index, d_3[0][0]);
  178. this.index += 2;
  179. }
  180. readUint() {
  181. var W2$ = [arguments];
  182. W2$[8] = this.view.getUint32(this.index);
  183. this.index += 4;
  184. return W2$[8];
  185. }
  186. writeUint(B2X) {
  187. var f8B = [arguments];
  188. this.view.setUint32(this.index, f8B[0][0]);
  189. this.index += 4;
  190. }
  191. readBoolean() {
  192. var h6P = [arguments];
  193. h6P[6] = this.readByte();
  194. return h6P[6] == 1;
  195. }
  196. writeBoolean(Y3I) {
  197. var l79 = [arguments];
  198. if (l79[0][0]) {
  199. this.writeByte(1);
  200. } else {
  201. this.writeByte(0);
  202. }
  203. }
  204. readDouble() {
  205. var V60 = [arguments];
  206. V60[4] = this.view.getFloat64(this.index);
  207. this.index += 8;
  208. return V60[4];
  209. }
  210. writeDouble(z4Z) {
  211. var O41 = [arguments];
  212. this.view.setFloat64(this.index, O41[0][0]);
  213. this.index += 8;
  214. }
  215. readFloat() {
  216. var I0l = [arguments];
  217. I0l[5] = this.view.getFloat32(this.index);
  218. this.index += 4;
  219. return I0l[5];
  220. }
  221. writeFloat(y4B) {
  222. var B0v = [arguments];
  223. this.view.setFloat32(this.index, B0v[0][0]);
  224. this.index += 4;
  225. }
  226. readUTF() {
  227. var d6I = [arguments];
  228. d6I[8] = this.readByte();
  229. d6I[7] = this.readByte();
  230. d6I[9] = d6I[8] * 256 + d6I[7];
  231. d6I[1] = new Uint8Array(d6I[9]);
  232. for (d6I[6] = 0; d6I[6] < d6I[9]; d6I[6]++) {
  233. d6I[1][d6I[6]] = this.readByte();
  234. }
  235. return textdecoder.decode(d6I[1]);
  236. }
  237. writeUTF(L3Z) {
  238. var Z75 = [arguments];
  239. Z75[4] = textencoder.encode(Z75[0][0]);
  240. Z75[3] = Z75[4].length;
  241. Z75[5] = Math.floor(Z75[3]/256);
  242. Z75[8] = Z75[3] % 256;
  243. this.writeByte(Z75[5]);
  244. this.writeByte(Z75[8]);
  245. Z75[7] = this;
  246. Z75[4].forEach(I_O);
  247. function I_O(s0Q, H4K, j$o) {
  248. var N0o = [arguments];
  249. Z75[7].writeByte(N0o[0][0]);
  250. }
  251. }
  252. toBase64() {
  253. var P4$ = [arguments];
  254. P4$[4] = "";
  255. P4$[9] = new Uint8Array(this.buffer);
  256. P4$[8] = this.index;
  257. for (P4$[7] = 0; P4$[7] < P4$[8]; P4$[7]++) {
  258. P4$[4] += String.fromCharCode(P4$[9][P4$[7]]);
  259. }
  260. return Gwindow.btoa(P4$[4]);
  261. }
  262. fromBase64(W69, A8Q) {
  263. var o0n = [arguments];
  264. o0n[8] = Gwindow.pako;
  265. o0n[6] = Gwindow.atob(o0n[0][0]);
  266. o0n[9] = o0n[6].length;
  267. o0n[4] = new Uint8Array(o0n[9]);
  268. for (o0n[1] = 0; o0n[1] < o0n[9]; o0n[1]++) {
  269. o0n[4][o0n[1]] = o0n[6].charCodeAt(o0n[1]);
  270. }
  271. if (o0n[0][1] === true) {
  272. o0n[5] = o0n[8].inflate(o0n[4]);
  273. o0n[4] = o0n[5];
  274. }
  275. this.buffer = o0n[4].buffer.slice(
  276. o0n[4].byteOffset,
  277. o0n[4].byteLength + o0n[4].byteOffset
  278. );
  279. this.view = new DataView(this.buffer);
  280. this.index = 0;
  281. }
  282. };
  283.  
  284. if(typeof(scope.originalSend)=='undefined'){scope.originalSend = Gwindow.WebSocket.prototype.send;}
  285. if(typeof(scope.originalDatenow)=='undefined'){scope.originalDatenow = Gwindow.Date.now;}
  286.  
  287. if(typeof(scope.originalXMLOpen)=='undefined'){scope.originalXMLOpen = Gwindow.XMLHttpRequest.prototype.open;}
  288. if(typeof(scope.originalXMLSend)=='undefined'){scope.originalXMLSend = Gwindow.XMLHttpRequest.prototype.send;}
  289. if(typeof(scope.searchrequested)=='undefined'){scope.searchrequested = 0;}
  290. if(typeof(scope.originalDrawCircle)=='undefined'){scope.originalDrawCircle = Gwindow.PIXI.Graphics.prototype.drawCircle;}
  291. if(typeof(scope.parentDraw)=='undefined'){scope.parentDraw = 0;}
  292. if(typeof(scope.pixiCircle)=='undefined'){scope.pixiCircle = new Gwindow.PIXI.Graphics();}
  293. if(typeof(scope.container)=='undefined'){scope.container = new Gwindow.PIXI.Container();container.addChild(pixiCircle);}
  294. if(typeof(scope.canvasWidth)=='undefined'){scope.canvasWidth = -1;}
  295. if(typeof(scope.savedrooms)=='undefined'){scope.savedrooms = [];}
  296. if(typeof(scope.inroom)=='undefined'){scope.inroom = false;}
  297. if(typeof(scope.currentroomaddress)=='undefined'){scope.currentroomaddress = -1;}
  298. if(typeof(scope.savedroomsdata)=='undefined'){scope.savedroomsdata = {};}
  299. if(typeof(scope.jukeboxplayerURL)=='undefined'){scope.jukeboxplayerURL = "";}
  300. if(typeof(scope.jukeboxplayervolume)=='undefined'){scope.jukeboxplayervolume = 20;}
  301. if(typeof(scope.gameStartTimeStamp)=='undefined'){scope.gameStartTimeStamp = 0;}
  302. scope.checkInstance = async function(index){
  303. var doesitwork = false;
  304. await fetch(pipedurllist[index]+"dQw4w9WgXcQ").then(
  305. function(r){
  306. return r.json();
  307. }
  308. ).then(async function(r){
  309. if (r.audioStreams && !r.error){
  310. for(var i2 = 0;i2<r.audioStreams.length;i2++){
  311. if(r.audioStreams[i2].url){
  312. try{
  313. var f = await fetch(r.audioStreams[i2].url);
  314. if(f.ok){
  315. doesitwork = true;
  316. return;
  317. }
  318.  
  319. }
  320. catch(e){}
  321. }
  322. }
  323. }
  324. }).catch(function(e){});
  325. if(!doesitwork){
  326. return -1;
  327. }
  328. return index;
  329. };
  330. scope.checkJukeboxStream = async function(index,id){
  331. var doesitwork = false;
  332. var urlreturn = [];
  333. await fetch(pipedurllist[index]+id).then(
  334. function(r){
  335. return r.json();
  336. }
  337. ).then(async function(r){
  338. if (r.audioStreams && !r.error){
  339. for(var i2 = 0;i2<r.audioStreams.length;i2++){
  340. if(r.audioStreams[i2].url){
  341. try{
  342. var f = await fetch(r.audioStreams[i2].url);
  343. if(f.ok){
  344. doesitwork = true;
  345. urlreturn = [r.audioStreams[i2].url,r.title,r.uploader];
  346. return;
  347. }
  348.  
  349. }
  350. catch(e){}
  351. }
  352. }
  353. }
  354. }).catch(function(e){});
  355. if(!doesitwork){
  356. return -1;
  357. }
  358. return urlreturn;
  359. };
  360.  
  361. scope.checkInstances = async function (){
  362. pipedindexes = [];
  363. for (var index = 0;index<pipedurllist.length;index++){
  364. checkInstance(index).then(function(value){
  365. if(value!=-1){
  366. pipedindexes.push(value);
  367. }
  368. });
  369. }
  370. };
  371. if(typeof(scope.pipedurllist)=='undefined'){
  372. scope.pipedurllist = [
  373. "https://pipedapi.kavin.rocks/streams/",
  374. "https://pipedapi.pixelmelt.dev/streams/",
  375. "https://pipedapi.syncpundit.io/streams/",
  376. "https://api-piped.mha.fi/streams/",
  377. "https://piped-api.garudalinux.org/streams/",
  378. "https://pipedapi.rivo.lol/streams/",
  379. "https://pipedapi.leptons.xyz/streams/",
  380. "https://piped-api.lunar.icu/streams/",
  381. "https://ytapi.dc09.ru/streams/",
  382. "https://piped.tokhmi.xyz/streams/",
  383. "https://pipedapi.aeong.one/streams/"];
  384. scope.pipedindexes = [];
  385. checkInstances();
  386. }
  387.  
  388.  
  389.  
  390. if(typeof(scope.requestAnimationFrameOriginal)=='undefined'){scope.requestAnimationFrameOriginal = Gwindow.requestAnimationFrame;}
  391.  
  392.  
  393. if(typeof(scope.bonkwss)=='undefined'){scope.bonkwss = 0;}
  394. if(typeof(scope.bonkwssextra)=='undefined'){scope.bonkwssextra = [];}
  395. if(typeof(scope.chatlog)=='undefined'){scope.chatlog = ["ROOM START"];}
  396. if(typeof(scope.wsssendrecievelog)=='undefined'){scope.wsssendrecievelog = [];}
  397. if(typeof(scope.wsssendlog)=='undefined'){scope.wsssendlog = [];}
  398. if(typeof(scope.wssrecievelog)=='undefined'){scope.wssrecievelog = [];}
  399. if(typeof(scope.wsslogpaused)=='undefined'){scope.wsslogpaused = false;}
  400. if(typeof(scope.debuggeropen)=='undefined'){scope.debuggeropen = false;}
  401. if(typeof(scope.debuggercount)=='undefined'){scope.debuggercount = true;}
  402. if(typeof(scope.packetcount)=='undefined'){scope.packetcount = 0;}
  403. if(typeof(scope.requestedmaps)=='undefined'){scope.requestedmaps = [];}
  404. if(typeof(scope.maponclick)=='undefined'){scope.maponclick = 0;}
  405. if(typeof(scope.LZString)=='undefined'){scope.LZString = Gwindow.LZString;}
  406. if(typeof(scope.PSON)=='undefined'){scope.PSON = Gwindow.dcodeIO.PSON;}
  407. if(typeof(scope.bytebuffer)=='undefined'){scope.bytebuffer = Gwindow.dcodeIO.ByteBuffer;}
  408. if(typeof(scope.speech)=='undefined'){scope.speech = new SpeechSynthesisUtterance();speech.pitch = 0.75;}
  409. if(typeof(scope.sayer)=='undefined'){scope.sayer = speechSynthesis;sayer.volume = 0.5;sayer.rate = 1.25;}
  410. if(typeof(scope.pollactive)=='undefined'){scope.pollactive = [false,0,0,[]];}
  411. if(typeof(scope.pollactive2)=='undefined'){scope.pollactive2 = [false,0,[]];}
  412. if(typeof(scope.mode)=='undefined'){scope.mode = '';}
  413. if(typeof(scope.FFA)=='undefined'){scope.FFA = true;}
  414. if(typeof(scope.recording)=='undefined'){scope.recording = false;}
  415. if(typeof(scope.recordingdata)=='undefined'){scope.recordingdata = [];}
  416. if(typeof(scope.recorddata)=='undefined'){scope.recorddata = {};}
  417. if(typeof(scope.recordingid)=='undefined'){scope.recordingid = -1;}
  418. if(typeof(scope.wordlist)=='undefined'){
  419. scope.wordlist = [];
  420. fetch("https://api.github.com/repos/first20hours/google-10000-english/contents/20k.txt").then(function(data){
  421. return data.json();
  422. }).then(function(data){
  423. fetch("https://api.github.com/repos/first20hours/google-10000-english/git/blobs/"+data.sha).then(function(data){
  424. return data.json();
  425. }).then(function(data){
  426. scope.wordlist = atob(data.content).split("\n");
  427. });
  428. });
  429. }
  430.  
  431. if(typeof(scope.allstyles)=='undefined'){scope.allstyles = {};}
  432. if(typeof(scope.mystyle)=='undefined'){scope.mystyle = [0,0,0];}
  433. 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]);}
  434. if(typeof(scope.sandboxon)=='undefined'){scope.sandboxon = false;}
  435. if(typeof(scope.sandboxid)=='undefined'){scope.sandboxid = 200;}
  436. if(typeof(scope.playerids)=='undefined'){scope.playerids = {};}
  437. if(typeof(scope.delplayerids)=='undefined'){scope.delplayerids = {};}
  438. if(typeof(scope.myid)=='undefined'){scope.myid = -1;}
  439. if(typeof(scope.hostid)=='undefined'){scope.hostid = -1;}
  440. if(typeof(scope.sandboxplayerids)=='undefined'){scope.sandboxplayerids = {};}
  441. if(typeof(scope.originalMapLoad)=='undefined'){scope.originalMapLoad = Gdocument.getElementById("maploadwindowmapscontainer").appendChild;}
  442. if(typeof(scope.originalLobbyChat)=='undefined'){scope.originalLobbyChat = Gdocument.getElementById("newbonklobby_chat_content").appendChild;}
  443. if(typeof(scope.originalIngameChat)=='undefined'){scope.originalIngameChat = Gdocument.getElementById("ingamechatcontent").appendChild;}
  444. 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];}
  445.  
  446. if(typeof(scope.jukeboxplayer)=='undefined'){
  447. scope.jukeboxplayer = Gdocument.createElement("audio");
  448. jukeboxplayer.controls = true;
  449. jukeboxplayer.loop = true;
  450. }
  451.  
  452. if(Gdocument.getElementById("savedroombutton") == null){
  453. scope.savedroombutton = Gdocument.createElement("div");
  454. savedroombutton.id = "savedroombutton";
  455. savedroombutton.className = "brownButton brownButton_classic buttonShadow brownButtonDisabled";
  456. savedroombutton.textContent = "Save Room";
  457. savedroombutton.style["left"] = "120px";
  458. savedroombutton.style["position"] = "absolute";
  459. savedroombutton.style["width"] = "90px";
  460. savedroombutton.style["height"] = "30px";
  461. savedroombutton.style["color"] = "#ffffff";
  462. savedroombutton.style["text-align"] = "center";
  463. savedroombutton.style["vertical-align"] = "middle";
  464. savedroombutton.style["line-height"] = "30px";
  465. savedroombutton.style["right"] = "0";
  466. savedroombutton.style["cursor"] = "pointer";
  467. savedroombutton.style["bottom"] = "10px";
  468. savedroombutton.style["margin"] = "auto";
  469. savedroombutton.style["bottom"] = "10px";
  470. savedroombutton.onclick = function(){
  471. if(!savedrooms.includes(currentroomaddress) && currentroomaddress!=-1){
  472. savedrooms.push(currentroomaddress);
  473. savedroomsdata[currentroomaddress] = {"exists":true};
  474. }
  475. Gdocument.getElementById("sm_connectingWindowCancelButton").click();
  476. };
  477. Gdocument.getElementById("sm_connectingWindowCancelButton").style["left"] = "-120px";
  478. Gdocument.getElementById("sm_connectingWindow").appendChild(savedroombutton)
  479. }
  480. if(Gdocument.getElementById("maploadtypedropdowntitlerequested") == null){
  481. scope.clearmaprequests = Gdocument.createElement("div");
  482. clearmaprequests.id = "clearmaprequests";
  483. clearmaprequests.classList.value = "brownButton brownButton_classic buttonShadow";
  484. clearmaprequests.textContent = "Clear";
  485. clearmaprequests.style["position"] = "absolute";
  486. clearmaprequests.style["display"] = "none";
  487. if(typeof(ishost)!='undefined'){
  488. if(ishost && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS"){
  489. clearmaprequests.style["display"] = "block";
  490. }
  491. }
  492. clearmaprequests.style["right"] = "306px";
  493. clearmaprequests.style["top"] = "57px";
  494. clearmaprequests.style["height"] = "23px";
  495. clearmaprequests.style["width"] = "47px";
  496. clearmaprequests.style["line-height"] = "23px";
  497. clearmaprequests.style["font-size"] = "14px";
  498. clearmaprequests.addEventListener("click",function(){
  499. requestedmaps = [];
  500. Gdocument.getElementById("maploadwindowstatustext").style["visibility"] = "inherit";
  501. Gdocument.getElementById("maploadwindowstatustext").textContent = "No Maps";
  502. while(Gdocument.getElementById("maploadwindowmapscontainer").children.length>0){
  503. Gdocument.getElementById("maploadwindowmapscontainer").removeChild(Gdocument.getElementById("maploadwindowmapscontainer").firstChild);
  504. }
  505. });
  506. Gdocument.getElementById("maploadwindow").insertBefore(clearmaprequests,Gdocument.getElementById("maploadwindowsearchinput"));
  507. scope.refreshmaprequests = Gdocument.createElement("div");
  508. refreshmaprequests.id = "refreshmaprequests";
  509. refreshmaprequests.classList.value = "brownButton brownButton_classic buttonShadow";
  510. refreshmaprequests.textContent = "Refresh";
  511. refreshmaprequests.style["position"] = "absolute";
  512. refreshmaprequests.style["display"] = "none";
  513. if(typeof(ishost)!='undefined'){
  514. if(ishost && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS"){
  515. refreshmaprequests.style["display"] = "block";
  516. }
  517. }
  518. refreshmaprequests.style["right"] = "357px";
  519. refreshmaprequests.style["top"] = "57px";
  520. refreshmaprequests.style["height"] = "23px";
  521. refreshmaprequests.style["width"] = "47px";
  522. refreshmaprequests.style["line-height"] = "23px";
  523. refreshmaprequests.style["font-size"] = "14px";
  524. refreshmaprequests.addEventListener("click",function(){
  525. searchrequested = 1;
  526. Gdocument.getElementById("maploadtypedropdowntitle").click();
  527. Gdocument.getElementById("maploadtypedropdowntitle").textContent = dropdownrequested.textContent;
  528. dropdownrequested.style["display"] = "none";
  529. clearmaprequests.style["display"] = "block";
  530. refreshmaprequests.style["display"] = "block";
  531. Gdocument.getElementById("maploadwindowhotnessslider").style["visibility"] = "hidden";
  532. Gdocument.getElementById("maploadwindowsearchoptions").style["visibility"] = "hidden";
  533. Gdocument.getElementById("maploadtypedropdownoption10").click();
  534. });
  535. Gdocument.getElementById("maploadwindow").insertBefore(refreshmaprequests,Gdocument.getElementById("maploadwindowsearchinput"));
  536.  
  537. scope.dropdownrequested = Gdocument.createElement("div");
  538. dropdownrequested.classList = "dropdown-option dropdown_classic";
  539. dropdownrequested.style["display"] = "none";
  540. dropdownrequested.id = "maploadtypedropdowntitlerequested";
  541.  
  542. if(Gdocument.getElementById("maploadtypedropdownoption10").style["display"] == "block"){
  543. dropdownrequested.style["display"] = "block";
  544. }
  545. dropdownrequested.textContent = "MAP REQUESTS";
  546. dropdownrequested.onclick = function(){
  547. searchrequested = 1;
  548. Gdocument.getElementById("maploadtypedropdowntitle").click();
  549. Gdocument.getElementById("maploadtypedropdowntitle").textContent = dropdownrequested.textContent;
  550. dropdownrequested.style["display"] = "none";
  551. clearmaprequests.style["display"] = "block";
  552. refreshmaprequests.style["display"] = "block";
  553. Gdocument.getElementById("maploadwindowhotnessslider").style["visibility"] = "hidden";
  554. Gdocument.getElementById("maploadwindowsearchoptions").style["visibility"] = "hidden";
  555. Gdocument.getElementById("maploadtypedropdownoption10").click();
  556. };
  557. (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});
  558. Gdocument.getElementById("maploadtypedropdown").insertBefore(dropdownrequested,Gdocument.getElementById("maploadtypedropdownoption1"));
  559. Gdocument.getElementById("maploadwindowmapscontainer").__defineGetter__("clientHeight",function(){if(Gdocument.getElementById("maploadtypedropdowntitle").textContent != "MAP REQUESTS"){return Gdocument.getElementById("maploadwindowmapscontainer").getClientRects()[0].height;}else{return 0;}});
  560.  
  561. };
  562. scope.sandboxonclick = function(){
  563. Gdocument.getElementById("roomlistrefreshbutton").click();
  564. Gdocument.getElementById("roomlistcreatebutton").click();
  565. sandboxon = true;
  566. };
  567. scope.checkboxclearbuttononclick = function(){
  568. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  569. var e = true;
  570. for(var i = 0; i<classes.length;i++){
  571. if(classes[i].checked == true){
  572. e = false
  573. }
  574. classes[i].checked = false;
  575. }
  576. if(e){
  577. for(var i = 0; i<classes.length;i++){
  578. classes[i].checked = true;
  579. }
  580. }
  581. };
  582. Gdocument.getElementById("ingamechatcontent").__defineGetter__("childElementCount",function(){return this.children.length/50;});
  583. if(Gdocument.getElementById("classic_mid_sandbox")==null){
  584. Gdocument.getElementById("roomlistrefreshbutton").click();
  585. scope.sandboxbutton = Gdocument.createElement("div");
  586. sandboxbutton.id = "classic_mid_sandbox";
  587. sandboxbutton.classList.value = "brownButton brownButton_classic classic_mid_buttons";
  588. sandboxbutton.textContent = "Sandbox";
  589. sandboxbutton.addEventListener("click",sandboxonclick);
  590. Gdocument.getElementById("classic_mid").insertBefore(sandboxbutton,Gdocument.getElementById("classic_mid_news"));
  591.  
  592. }
  593. if(Gdocument.getElementById("clearallcheckboxes")==null){
  594. scope.checkboxclearbutton = Gdocument.createElement("div");
  595. checkboxclearbutton.id = "clearallcheckboxes";
  596. checkboxclearbutton.classList.value = "brownButton brownButton_classic buttonShadow";
  597. checkboxclearbutton.textContent = "On/Off";
  598. checkboxclearbutton.style["position"] = "absolute";
  599. checkboxclearbutton.style["display"] = "none";
  600. if(typeof(ishost)!='undefined'){
  601. if(ishost && stopquickplay == 0){
  602. checkboxclearbutton.style["display"] = "block";
  603. }
  604. }
  605. checkboxclearbutton.style["right"] = "255px";
  606. checkboxclearbutton.style["top"] = "57px";
  607. checkboxclearbutton.style["height"] = "23px";
  608. checkboxclearbutton.style["width"] = "47px";
  609. checkboxclearbutton.style["line-height"] = "23px";
  610. checkboxclearbutton.style["font-size"] = "13px";
  611. checkboxclearbutton.addEventListener("click",checkboxclearbuttononclick);
  612. Gdocument.getElementById("maploadwindow").insertBefore(checkboxclearbutton,Gdocument.getElementById("maploadwindowsearchinput"));
  613.  
  614. }
  615. scope.holdloadbuttonTimeout = [];
  616. scope.holdloadbutton = function(){
  617. var scrollcount = 0;
  618. var mapwindow = Gdocument.getElementById("maploadwindowmapscontainer");
  619. mapwindow.scroll(0,mapwindow.scrollHeight);
  620. };
  621.  
  622. if(Gdocument.getElementById("mapwindowloadall")==null){
  623. scope.loadall = Gdocument.createElement("div");
  624. loadall.id = "mapwindowloadall";
  625. loadall.classList.value = "brownButton brownButton_classic buttonShadow";
  626. loadall.textContent = "Load";
  627. loadall.style["position"] = "absolute";
  628. loadall.style["display"] = "block";
  629. loadall.style["left"] = "204px";
  630. loadall.style["top"] = "57px";
  631. loadall.style["height"] = "23px";
  632. loadall.style["width"] = "34px";
  633. loadall.style["line-height"] = "23px";
  634. loadall.style["font-size"] = "12px";
  635. var repeat = function(){holdloadbutton();holdloadbuttonTimeout.push(setTimeout(repeat,25));};
  636. loadall.onmousedown = function(){repeat();};
  637. loadall.onmouseup = function(){for(var i = 0; i<holdloadbuttonTimeout.length; i++){clearTimeout(holdloadbuttonTimeout[i]);}};
  638. loadall.onmouseout = function(){for(var i = 0; i<holdloadbuttonTimeout.length; i++){clearTimeout(holdloadbuttonTimeout[i]);}};
  639.  
  640. Gdocument.getElementById("maploadwindow").insertBefore(loadall,Gdocument.getElementById("maploadwindowsearchinput"));
  641.  
  642. }
  643. if(Gdocument.getElementById("BonkCommandsDebuggerContainer")==null){
  644. Gdocument.getElementById("leaveconfirmwindow").style["z-index"]=3;
  645. scope.debuggermenu = Gdocument.createElement("div");
  646. debuggermenu.id = "BonkCommandsDebuggerContainer";
  647. debuggermenu.style["position"] = "absolute";
  648. debuggermenu.style["display"] = "none";
  649. if(typeof(debuggeropen)!='undefined'){
  650. if(debuggeropen){
  651. debuggermenu.style["display"] = "block";
  652. }
  653. }
  654. debuggermenu.style["width"] = Gdocument.getElementById("bonkiocontainer").style["width"];
  655. debuggermenu.style["height"] = Gdocument.getElementById("bonkiocontainer").style["height"];
  656.  
  657. debuggermenu.style["background"] = "rgb(26, 39, 51)";
  658.  
  659. scope.width = parseInt(Gdocument.getElementById("bonkiocontainer").style["width"])-20;
  660. scope.height = parseInt(Gdocument.getElementById("bonkiocontainer").style["height"])-210;
  661.  
  662. scope.logmenu = Gdocument.createElement("div");
  663. logmenu.id = "BonkCommandsWebSocketLog";
  664. logmenu.style["position"] = "absolute";
  665. logmenu.style["width"] = width.toString()+"px";
  666. logmenu.style["height"] = height.toString()+"px";
  667. logmenu.style["top"] = "80px";
  668. logmenu.style["left"] = "10px";
  669. logmenu.style["background"] = "rgb(207, 216, 220)";
  670. scope.logmenutopleft = Gdocument.createElement("div");
  671. logmenutopleft.id = "BonkCommandsWebSocketLog";
  672. logmenutopleft.style["position"] = "absolute";
  673. logmenutopleft.textContent = "Sending";
  674. logmenutopleft.classList = "newbonklobby_boxtop newbonklobby_boxtop_classic";
  675. logmenutopleft.style["width"] = (width/2).toString()+"px";
  676. logmenutopleft.style["height"] = "30px";
  677. logmenutopleft.style["top"] = "-30px";
  678. logmenutopleft.style["background"] = "rgb(0, 150, 136)";
  679. logmenu.appendChild(logmenutopleft);
  680. scope.logmenutopright = Gdocument.createElement("div");
  681. logmenutopright.id = "BonkCommandsWebSocketLog";
  682. logmenutopright.style["position"] = "absolute";
  683. logmenutopright.textContent = "Recieving";
  684. logmenutopright.classList = "newbonklobby_boxtop newbonklobby_boxtop_classic";
  685. logmenutopright.style["width"] = (width/2).toString()+"px";
  686. logmenutopright.style["height"] = "30px";
  687. logmenutopright.style["left"] = (width/2).toString()+"px";
  688. logmenutopright.style["top"] = "-30px";
  689. logmenutopright.style["background"] = "rgb(0, 150, 136)";
  690. logmenu.appendChild(logmenutopright);
  691. scope.logmenutable = Gdocument.createElement("table");
  692. logmenutable.id = "BonkCommandsWebSocketTable";
  693. logmenutable.style["position"] = "absolute";
  694. logmenutable.style["border-spacing"] = "0px";
  695. logmenutable.style["font-size"] = "12px";
  696. logmenutable.style["display"] = "table-cell";
  697. logmenutable.style["width"] = "50%";
  698. logmenutable.style["height"] = "100%";
  699. logmenutable.style["table-layout"] = "fixed";
  700. logmenutable.style["overflow-y"] = "scroll";
  701.  
  702. scope.logmenutable2 = Gdocument.createElement("table");
  703. logmenutable2.id = "BonkCommandsWebSocketTable2";
  704. logmenutable2.style["position"] = "absolute";
  705. logmenutable2.style["width"] = "50%";
  706. logmenutable2.style["left"] = "50%";
  707. logmenutable2.style["font-size"] = "12px";
  708. logmenutable2.style["display"] = "table-cell";
  709. logmenutable2.style["height"] = "100%";
  710. logmenutable2.style["table-layout"] = "fixed";
  711. logmenutable2.style["overflow-y"] = "scroll";
  712. logmenutable2.style["border-spacing"] = "0px";
  713. scope.leftsync = false;
  714. scope.rightsync = false;
  715. logmenutable2.onscroll = function(){
  716. if(!leftsync){
  717. rightsync = true;
  718. logmenutable.scrollTop = this.scrollTop;
  719. }
  720. else{
  721. leftsync = false;
  722. }
  723. };
  724. logmenutable.onscroll = function(){
  725. if(!rightsync){
  726. leftsync = true;
  727. logmenutable2.scrollTop = this.scrollTop;
  728. }
  729. else{
  730. rightsync = false
  731. }
  732. };
  733. logmenu.appendChild(logmenutable);
  734. logmenu.appendChild(logmenutable2);
  735. debuggermenu.appendChild(logmenu);
  736. scope.debuggermenuclose = Gdocument.createElement("div");
  737. debuggermenuclose.id = "debuggerclose";
  738. debuggermenuclose.classList = "windowCloseButton brownButton brownButton_classic buttonShadow";
  739. debuggermenuclose.style["position"] = "absolute";
  740. debuggermenuclose.style["top"] = "40px";
  741. debuggermenuclose.style["right"] = "5px";
  742. debuggermenuclose.onclick = function(){debuggeropen = false;debuggermenu.style["display"] = "none";Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  743. Gdocument.getElementById("ingamechatinputtext").style["display"] = "";};
  744. debuggermenu.appendChild(debuggermenuclose);
  745. scope.debuggerform = Gdocument.createElement("form");
  746. debuggerform.autocomplete = "off";
  747. scope.debuggerinput = Gdocument.createElement("input");
  748. debuggerinput.style["position"] = "absolute";
  749. debuggerinput.style["width"] = width.toString()+"px";
  750. debuggerinput.style["left"] = "10px";
  751. debuggerinput.style["top"] = (height+90).toString()+"px";
  752. debuggerinput.style["font-size"] = "12px";
  753. debuggerinput.style["height"] = "20px";
  754. debuggerform.appendChild(debuggerinput);
  755. scope.debuggersendrecieve = Gdocument.createElement("div");
  756. debuggersendrecieve.style["position"] = "absolute";
  757. debuggersendrecieve.style["width"] = "140px";
  758. debuggersendrecieve.style["left"] = "10px";
  759. debuggersendrecieve.style["top"] = (height+120).toString()+"px";
  760. debuggersendrecieve.style["font-size"] = "15px";
  761. debuggersendrecieve.style["height"] = "20px";
  762. debuggersendrecieve.classList = "brownButton brownButton_classic buttonShadow";
  763. debuggersendrecieve.textContent = "Send";
  764. debuggersendrecieve.value = 0;
  765. debuggersendrecieve.onclick = function(){if(this.value == 0){this.textContent = "Recieve";this.value = 1;}else{this.textContent = "Send";this.value = 0;}};
  766.  
  767. debuggermenu.appendChild(debuggersendrecieve);
  768. scope.debuggerpausebutton = Gdocument.createElement("div");
  769. debuggerpausebutton.style["position"] = "absolute";
  770. debuggerpausebutton.style["width"] = "140px";
  771. debuggerpausebutton.style["left"] = "10px";
  772. debuggerpausebutton.style["top"] = (height+150).toString()+"px";
  773. debuggerpausebutton.style["font-size"] = "15px";
  774. debuggerpausebutton.style["height"] = "20px";
  775. debuggerpausebutton.classList = "brownButton brownButton_classic buttonShadow";
  776. debuggerpausebutton.textContent = "Pause";
  777. debuggerpausebutton.value = 0;
  778. debuggerpausebutton.onclick = function(){if(this.value == 0){this.textContent = "Play";this.value = 1;wsslogpaused = true}else{this.textContent = "Pause";this.value = 0;wsslogpaused = false;}};
  779.  
  780. debuggermenu.appendChild(debuggerpausebutton);
  781. scope.debuggereval = Gdocument.createElement("input");
  782. debuggereval.style["position"] = "absolute";
  783. debuggereval.style["width"] = (width-150).toString()+"px";
  784. debuggereval.style["right"] = "10px";
  785. debuggereval.style["top"] = (height+120).toString()+"px";
  786. debuggereval.style["font-size"] = "12px";
  787. debuggereval.style["height"] = "20px";
  788. 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);}}});
  789. debuggerform.appendChild(debuggereval);
  790. debuggermenu.appendChild(debuggerform);
  791. Gdocument.getElementById("newbonkgamecontainer").appendChild(debuggermenu);
  792.  
  793. }
  794. scope.ISdecode = function(rawdata) {
  795. rawdata_caseflipped = "";
  796. for (i = 0; i < rawdata.length; i++) {
  797. if (i <= 100 && rawdata.charAt(i) === rawdata.charAt(i).toLowerCase()) {
  798. rawdata_caseflipped += rawdata.charAt(i).toUpperCase();
  799. } else if (i <= 100 && rawdata.charAt(i) === rawdata.charAt(i).toUpperCase()) {
  800. rawdata_caseflipped += rawdata.charAt(i).toLowerCase();
  801. } else {
  802. rawdata_caseflipped += rawdata.charAt(i);
  803. }
  804. }
  805.  
  806. data_deLZd = LZString.decompressFromEncodedURIComponent(rawdata_caseflipped);
  807. databuffer = bytebuffer.fromBase64(data_deLZd);
  808. data = ISpsonpair.decode(databuffer.buffer);
  809. return data;
  810. };
  811. scope.ISencode = function(obj) {
  812. data = ISpsonpair.encode(obj);
  813. b64 = data.toBase64();
  814. lzd = LZString.compressToEncodedURIComponent(b64);
  815.  
  816. caseflipped = "";
  817. for (i = 0; i < lzd.length; i++) {
  818. if (i <= 100 && lzd.charAt(i) === lzd.charAt(i).toLowerCase()) {
  819. caseflipped += lzd.charAt(i).toUpperCase();
  820. } else if (i <= 100 && lzd.charAt(i) === lzd.charAt(i).toUpperCase()) {
  821. caseflipped += lzd.charAt(i).toLowerCase();
  822. } else {
  823. caseflipped += lzd.charAt(i);
  824. }
  825. }
  826.  
  827.  
  828. return caseflipped;
  829. };
  830. scope.decodeIS = function(x){
  831. return ISdecode(x);
  832. };
  833. scope.encodeIS = function(x){
  834. return ISencode(x);
  835. };
  836. scope.encodeToDatabase = function (W2A) {
  837. var M3n = [arguments];
  838. M3n[1] = new bytebuffer2;
  839. M3n[9] = M3n[0][0].physics;
  840. M3n[0][0].v = 14;
  841. M3n[1].writeShort(M3n[0][0].v);
  842. M3n[1].writeBoolean(M3n[0][0].s.re);
  843. M3n[1].writeBoolean(M3n[0][0].s.nc);
  844. M3n[1].writeShort(M3n[0][0].s.pq);
  845. M3n[1].writeFloat(M3n[0][0].s.gd);
  846. M3n[1].writeBoolean(M3n[0][0].s.fl);
  847. M3n[1].writeUTF(M3n[0][0].m.rxn);
  848. M3n[1].writeUTF(M3n[0][0].m.rxa);
  849. M3n[1].writeUint(M3n[0][0].m.rxid);
  850. M3n[1].writeShort(M3n[0][0].m.rxdb);
  851. M3n[1].writeUTF(M3n[0][0].m.n);
  852. M3n[1].writeUTF(M3n[0][0].m.a);
  853. M3n[1].writeUint(M3n[0][0].m.vu);
  854. M3n[1].writeUint(M3n[0][0].m.vd);
  855. M3n[1].writeShort(M3n[0][0].m.cr.length);
  856. for (
  857. M3n[84] = 0;
  858. M3n[84] < M3n[0][0].m.cr.length;
  859. M3n[84]++
  860. ) {
  861. M3n[1].writeUTF(M3n[0][0].m.cr[M3n[84]]);
  862. }
  863. M3n[1].writeUTF(M3n[0][0].m.mo);
  864. M3n[1].writeInt(M3n[0][0].m.dbid);
  865. M3n[1].writeBoolean(M3n[0][0].m.pub);
  866. M3n[1].writeInt(M3n[0][0].m.dbv);
  867. M3n[1].writeShort(M3n[9].ppm);
  868. M3n[1].writeShort(M3n[9].bro.length);
  869. for (M3n[17] = 0; M3n[17] < M3n[9].bro.length; M3n[17]++) {
  870. M3n[1].writeShort(M3n[9].bro[M3n[17]]);
  871. }
  872. M3n[1].writeShort(M3n[9].shapes.length);
  873. for (M3n[80] = 0; M3n[80] < M3n[9].shapes.length; M3n[80]++) {
  874. M3n[2] = M3n[9].shapes[M3n[80]];
  875. if (M3n[2].type == "bx") {
  876. M3n[1].writeShort(1);
  877. M3n[1].writeDouble(M3n[2].w);
  878. M3n[1].writeDouble(M3n[2].h);
  879. M3n[1].writeDouble(M3n[2].c[0]);
  880. M3n[1].writeDouble(M3n[2].c[1]);
  881. M3n[1].writeDouble(M3n[2].a);
  882. M3n[1].writeBoolean(M3n[2].sk);
  883. }
  884. if (M3n[2].type == "ci") {
  885. M3n[1].writeShort(2);
  886. M3n[1].writeDouble(M3n[2].r);
  887. M3n[1].writeDouble(M3n[2].c[0]);
  888. M3n[1].writeDouble(M3n[2].c[1]);
  889. M3n[1].writeBoolean(M3n[2].sk);
  890. }
  891. if (M3n[2].type == "po") {
  892. M3n[1].writeShort(3);
  893. M3n[1].writeDouble(M3n[2].s);
  894. M3n[1].writeDouble(M3n[2].a);
  895. M3n[1].writeDouble(M3n[2].c[0]);
  896. M3n[1].writeDouble(M3n[2].c[1]);
  897. M3n[1].writeShort(M3n[2].v.length);
  898. for (M3n[61] = 0; M3n[61] < M3n[2].v.length; M3n[61]++) {
  899. M3n[1].writeDouble(M3n[2].v[M3n[61]][0]);
  900. M3n[1].writeDouble(M3n[2].v[M3n[61]][1]);
  901. }
  902. }
  903. }
  904. M3n[1].writeShort(M3n[9].fixtures.length);
  905. for (M3n[20] = 0; M3n[20] < M3n[9].fixtures.length; M3n[20]++) {
  906. M3n[7] = M3n[9].fixtures[M3n[20]];
  907. M3n[1].writeShort(M3n[7].sh);
  908. M3n[1].writeUTF(M3n[7].n);
  909. if (M3n[7].fr === null) {
  910. M3n[1].writeDouble(Number.MAX_VALUE);
  911. } else {
  912. M3n[1].writeDouble(M3n[7].fr);
  913. }
  914. if (M3n[7].fp === null) {
  915. M3n[1].writeShort(0);
  916. }
  917. if (M3n[7].fp === false) {
  918. M3n[1].writeShort(1);
  919. }
  920. if (M3n[7].fp === true) {
  921. M3n[1].writeShort(2);
  922. }
  923. if (M3n[7].re === null) {
  924. M3n[1].writeDouble(Number.MAX_VALUE);
  925. } else {
  926. M3n[1].writeDouble(M3n[7].re);
  927. }
  928. if (M3n[7].de === null) {
  929. M3n[1].writeDouble(Number.MAX_VALUE);
  930. } else {
  931. M3n[1].writeDouble(M3n[7].de);
  932. }
  933. M3n[1].writeUint(M3n[7].f);
  934. M3n[1].writeBoolean(M3n[7].d);
  935. M3n[1].writeBoolean(M3n[7].np);
  936. M3n[1].writeBoolean(M3n[7].ng);
  937. M3n[1].writeBoolean(M3n[7].ig);
  938. }
  939. M3n[1].writeShort(M3n[9].bodies.length);
  940. for (M3n[37] = 0; M3n[37] < M3n[9].bodies.length; M3n[37]++) {
  941. M3n[4] = M3n[9].bodies[M3n[37]];
  942. M3n[1].writeUTF(M3n[4].type);
  943. M3n[1].writeUTF(M3n[4].n);
  944. M3n[1].writeDouble(M3n[4].p[0]);
  945. M3n[1].writeDouble(M3n[4].p[1]);
  946. M3n[1].writeDouble(M3n[4].a);
  947. M3n[1].writeDouble(M3n[4].fric);
  948. M3n[1].writeBoolean(M3n[4].fricp);
  949. M3n[1].writeDouble(M3n[4].re);
  950. M3n[1].writeDouble(M3n[4].de);
  951. M3n[1].writeDouble(M3n[4].lv[0]);
  952. M3n[1].writeDouble(M3n[4].lv[1]);
  953. M3n[1].writeDouble(M3n[4].av);
  954. M3n[1].writeDouble(M3n[4].ld);
  955. M3n[1].writeDouble(M3n[4].ad);
  956. M3n[1].writeBoolean(M3n[4].fr);
  957. M3n[1].writeBoolean(M3n[4].bu);
  958. M3n[1].writeDouble(M3n[4].cf.x);
  959. M3n[1].writeDouble(M3n[4].cf.y);
  960. M3n[1].writeDouble(M3n[4].cf.ct);
  961. M3n[1].writeBoolean(M3n[4].cf.w);
  962. M3n[1].writeShort(M3n[4].f_c);
  963. M3n[1].writeBoolean(M3n[4].f_1);
  964. M3n[1].writeBoolean(M3n[4].f_2);
  965. M3n[1].writeBoolean(M3n[4].f_3);
  966. M3n[1].writeBoolean(M3n[4].f_4);
  967. M3n[1].writeBoolean(M3n[4].f_p);
  968. M3n[1].writeBoolean(M3n[4].fz.on);
  969. if (M3n[4].fz.on) {
  970. M3n[1].writeDouble(M3n[4].fz.x);
  971. M3n[1].writeDouble(M3n[4].fz.y);
  972. M3n[1].writeBoolean(M3n[4].fz.d);
  973. M3n[1].writeBoolean(M3n[4].fz.p);
  974. M3n[1].writeBoolean(M3n[4].fz.a);
  975. }
  976. M3n[1].writeShort(M3n[4].fx.length);
  977. for (M3n[28] = 0; M3n[28] < M3n[4].fx.length; M3n[28]++) {
  978. M3n[1].writeShort(M3n[4].fx[M3n[28]]);
  979. }
  980. }
  981. M3n[1].writeShort(M3n[0][0].spawns.length);
  982. for (
  983. M3n[30] = 0;
  984. M3n[30] < M3n[0][0].spawns.length;
  985. M3n[30]++
  986. ) {
  987. M3n[6] = M3n[0][0].spawns[M3n[30]];
  988. M3n[1].writeDouble(M3n[6].x);
  989. M3n[1].writeDouble(M3n[6].y);
  990. M3n[1].writeDouble(M3n[6].xv);
  991. M3n[1].writeDouble(M3n[6].yv);
  992. M3n[1].writeShort(M3n[6].priority);
  993. M3n[1].writeBoolean(M3n[6].r);
  994. M3n[1].writeBoolean(M3n[6].f);
  995. M3n[1].writeBoolean(M3n[6].b);
  996. M3n[1].writeBoolean(M3n[6].gr);
  997. M3n[1].writeBoolean(M3n[6].ye);
  998. M3n[1].writeUTF(M3n[6].n);
  999. }
  1000. M3n[1].writeShort(M3n[0][0].capZones.length);
  1001. for (
  1002. M3n[74] = 0;
  1003. M3n[74] < M3n[0][0].capZones.length;
  1004. M3n[74]++
  1005. ) {
  1006. M3n[3] = M3n[0][0].capZones[M3n[74]];
  1007. M3n[1].writeUTF(M3n[3].n);
  1008. M3n[1].writeDouble(M3n[3].l);
  1009. M3n[1].writeShort(M3n[3].i);
  1010. M3n[1].writeShort(M3n[3].ty);
  1011. }
  1012. M3n[1].writeShort(M3n[9].joints.length);
  1013. for (M3n[89] = 0; M3n[89] < M3n[9].joints.length; M3n[89]++) {
  1014. M3n[5] = M3n[9].joints[M3n[89]];
  1015. if (M3n[5].type == "rv") {
  1016. M3n[1].writeShort(1);
  1017. M3n[1].writeDouble(M3n[5].d.la);
  1018. M3n[1].writeDouble(M3n[5].d.ua);
  1019. M3n[1].writeDouble(M3n[5].d.mmt);
  1020. M3n[1].writeDouble(M3n[5].d.ms);
  1021. M3n[1].writeBoolean(M3n[5].d.el);
  1022. M3n[1].writeBoolean(M3n[5].d.em);
  1023. M3n[1].writeDouble(M3n[5].aa[0]);
  1024. M3n[1].writeDouble(M3n[5].aa[1]);
  1025. }
  1026. if (M3n[5].type == "d") {
  1027. M3n[1].writeShort(2);
  1028. M3n[1].writeDouble(M3n[5].d.fh);
  1029. M3n[1].writeDouble(M3n[5].d.dr);
  1030. M3n[1].writeDouble(M3n[5].aa[0]);
  1031. M3n[1].writeDouble(M3n[5].aa[1]);
  1032. M3n[1].writeDouble(M3n[5].ab[0]);
  1033. M3n[1].writeDouble(M3n[5].ab[1]);
  1034. }
  1035. if (M3n[5].type == "lpj") {
  1036. M3n[1].writeShort(3);
  1037. M3n[1].writeDouble(M3n[5].pax);
  1038. M3n[1].writeDouble(M3n[5].pay);
  1039. M3n[1].writeDouble(M3n[5].pa);
  1040. M3n[1].writeDouble(M3n[5].pf);
  1041. M3n[1].writeDouble(M3n[5].pl);
  1042. M3n[1].writeDouble(M3n[5].pu);
  1043. M3n[1].writeDouble(M3n[5].plen);
  1044. M3n[1].writeDouble(M3n[5].pms);
  1045. }
  1046. if (M3n[5].type == "lsj") {
  1047. M3n[1].writeShort(4);
  1048. M3n[1].writeDouble(M3n[5].sax);
  1049. M3n[1].writeDouble(M3n[5].say);
  1050. M3n[1].writeDouble(M3n[5].sf);
  1051. M3n[1].writeDouble(M3n[5].slen);
  1052. }
  1053. M3n[1].writeShort(M3n[5].ba);
  1054. M3n[1].writeShort(M3n[5].bb);
  1055. M3n[1].writeBoolean(M3n[5].d.cc);
  1056. M3n[1].writeDouble(M3n[5].d.bf);
  1057. M3n[1].writeBoolean(M3n[5].d.dl);
  1058. }
  1059. M3n[32] = M3n[1].toBase64();
  1060. M3n[77] = LZString.compressToEncodedURIComponent(M3n[32]);
  1061. return M3n[77];
  1062. };
  1063. scope.decodeFromDatabase = function (map) {
  1064. var F5W = [arguments];
  1065. var b64mapdata = LZString.decompressFromEncodedURIComponent(map);
  1066. var binaryReader = new bytebuffer2;
  1067. binaryReader.fromBase64(b64mapdata, false);
  1068. 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: "", }};
  1069. map.physics = map.physics;
  1070. map.v = binaryReader.readShort();
  1071. if (map.v > 14) {
  1072. throw new Error("Future map version, please refresh page");
  1073. }
  1074. map.s.re = binaryReader.readBoolean();
  1075. map.s.nc = binaryReader.readBoolean();
  1076. if (map.v >= 3) {
  1077. map.s.pq = binaryReader.readShort();
  1078. }
  1079. if (map.v >= 4 && map.v <= 12) {
  1080. map.s.gd = binaryReader.readShort();
  1081. } else if (map.v >= 13) {
  1082. map.s.gd = binaryReader.readFloat();
  1083. }
  1084. if (map.v >= 9) {
  1085. map.s.fl = binaryReader.readBoolean();
  1086. }
  1087. map.m.rxn = binaryReader.readUTF();
  1088. map.m.rxa = binaryReader.readUTF();
  1089. map.m.rxid = binaryReader.readUint();
  1090. map.m.rxdb = binaryReader.readShort();
  1091. map.m.n = binaryReader.readUTF();
  1092. map.m.a = binaryReader.readUTF();
  1093. if (map.v >= 10) {
  1094. map.m.vu = binaryReader.readUint();
  1095. map.m.vd = binaryReader.readUint();
  1096. }
  1097. if (map.v >= 4) {
  1098. F5W[7] = binaryReader.readShort();
  1099. for (F5W[83] = 0; F5W[83] < F5W[7]; F5W[83]++) {
  1100. map.m.cr.push(binaryReader.readUTF());
  1101. }
  1102. }
  1103. if (map.v >= 5) {
  1104. map.m.mo = binaryReader.readUTF();
  1105. map.m.dbid = binaryReader.readInt();
  1106. }
  1107. if (map.v >= 7) {
  1108. map.m.pub = binaryReader.readBoolean();
  1109. }
  1110. if (map.v >= 8) {
  1111. map.m.dbv = binaryReader.readInt();
  1112. }
  1113. map.physics.ppm = binaryReader.readShort();
  1114. F5W[4] = binaryReader.readShort();
  1115. for (F5W[15] = 0; F5W[15] < F5W[4]; F5W[15]++) {
  1116. map.physics.bro[F5W[15]] = binaryReader.readShort();
  1117. }
  1118. F5W[6] = binaryReader.readShort();
  1119. for (F5W[28] = 0; F5W[28] < F5W[6]; F5W[28]++) {
  1120. F5W[5] = binaryReader.readShort();
  1121. if (F5W[5] == 1) {
  1122. map.physics.shapes[F5W[28]] = { type: "bx", w: 10, h: 40, c: [0, 0], a: 0.0, sk: false };
  1123. map.physics.shapes[F5W[28]].w = binaryReader.readDouble();
  1124. map.physics.shapes[F5W[28]].h = binaryReader.readDouble();
  1125. map.physics.shapes[F5W[28]].c = [
  1126. binaryReader.readDouble(),
  1127. binaryReader.readDouble(),
  1128. ];
  1129. map.physics.shapes[F5W[28]].a = binaryReader.readDouble();
  1130. map.physics.shapes[F5W[28]].sk = binaryReader.readBoolean();
  1131. }
  1132. if (F5W[5] == 2) {
  1133. map.physics.shapes[F5W[28]] = { type: "ci", r: 25, c: [0, 0], sk: false };
  1134. map.physics.shapes[F5W[28]].r = binaryReader.readDouble();
  1135. map.physics.shapes[F5W[28]].c = [
  1136. binaryReader.readDouble(),
  1137. binaryReader.readDouble(),
  1138. ];
  1139. map.physics.shapes[F5W[28]].sk = binaryReader.readBoolean();
  1140. }
  1141. if (F5W[5] == 3) {
  1142. map.physics.shapes[F5W[28]] = { type: "po", v: [], s: 1, a: 0, c: [0, 0] };
  1143. map.physics.shapes[F5W[28]].s = binaryReader.readDouble();
  1144. map.physics.shapes[F5W[28]].a = binaryReader.readDouble();
  1145. map.physics.shapes[F5W[28]].c = [
  1146. binaryReader.readDouble(),
  1147. binaryReader.readDouble(),
  1148. ];
  1149. F5W[74] = binaryReader.readShort();
  1150. map.physics.shapes[F5W[28]].v = [];
  1151. for (F5W[27] = 0; F5W[27] < F5W[74]; F5W[27]++) {
  1152. map.physics.shapes[F5W[28]].v.push([
  1153. binaryReader.readDouble(),
  1154. binaryReader.readDouble(),
  1155. ]);
  1156. }
  1157. }
  1158. }
  1159. F5W[71] = binaryReader.readShort();
  1160. for (F5W[17] = 0; F5W[17] < F5W[71]; F5W[17]++) {
  1161. map.physics.fixtures[F5W[17]] = { sh: 0, n: "Def Fix", fr: 0.3, fp: null, re: 0.8, de: 0.3, f: 0x4f7cac, d: false, np: false, ng: false };
  1162. map.physics.fixtures[F5W[17]].sh = binaryReader.readShort();
  1163. map.physics.fixtures[F5W[17]].n = binaryReader.readUTF();
  1164. map.physics.fixtures[F5W[17]].fr = binaryReader.readDouble();
  1165. if (map.physics.fixtures[F5W[17]].fr == Number.MAX_VALUE) {
  1166. map.physics.fixtures[F5W[17]].fr = null;
  1167. }
  1168. F5W[12] = binaryReader.readShort();
  1169. if (F5W[12] == 0) {
  1170. map.physics.fixtures[F5W[17]].fp = null;
  1171. }
  1172. if (F5W[12] == 1) {
  1173. map.physics.fixtures[F5W[17]].fp = false;
  1174. }
  1175. if (F5W[12] == 2) {
  1176. map.physics.fixtures[F5W[17]].fp = true;
  1177. }
  1178. map.physics.fixtures[F5W[17]].re = binaryReader.readDouble();
  1179. if (map.physics.fixtures[F5W[17]].re == Number.MAX_VALUE) {
  1180. map.physics.fixtures[F5W[17]].re = null;
  1181. }
  1182. map.physics.fixtures[F5W[17]].de = binaryReader.readDouble();
  1183. if (map.physics.fixtures[F5W[17]].de == Number.MAX_VALUE) {
  1184. map.physics.fixtures[F5W[17]].de = null;
  1185. }
  1186. map.physics.fixtures[F5W[17]].f = binaryReader.readUint();
  1187. map.physics.fixtures[F5W[17]].d = binaryReader.readBoolean();
  1188. map.physics.fixtures[F5W[17]].np = binaryReader.readBoolean();
  1189. if (map.v >= 11) {
  1190. map.physics.fixtures[F5W[17]].ng = binaryReader.readBoolean();
  1191. }
  1192. if (map.v >= 12) {
  1193. map.physics.fixtures[F5W[17]].ig = binaryReader.readBoolean();
  1194. }
  1195. }
  1196. F5W[63] = binaryReader.readShort();
  1197. for (F5W[52] = 0; F5W[52] < F5W[63]; F5W[52]++) {
  1198. map.physics.bodies[F5W[52]] ={ type: "s", n: "Unnamed", p: [0, 0], a: 0, fric: 0.3, fricp: false, re: 0.8, de: 0.3, lv: [0, 0], av: 0, ld: 0, ad: 0, fr: false, bu: false, cf: { x: 0, y: 0, w: true, ct: 0 }, fx: [], f_c: 1, f_p: true, f_1: true, f_2: true, f_3: true, f_4: true, fz: { on: false, x: 0, y: 0, d: true, p: true, a: true }};
  1199. map.physics.bodies[F5W[52]].type = binaryReader.readUTF();
  1200. map.physics.bodies[F5W[52]].n = binaryReader.readUTF();
  1201. map.physics.bodies[F5W[52]].p = [binaryReader.readDouble(), binaryReader.readDouble()];
  1202. map.physics.bodies[F5W[52]].a = binaryReader.readDouble();
  1203. map.physics.bodies[F5W[52]].fric = binaryReader.readDouble();
  1204. map.physics.bodies[F5W[52]].fricp = binaryReader.readBoolean();
  1205. map.physics.bodies[F5W[52]].re = binaryReader.readDouble();
  1206. map.physics.bodies[F5W[52]].de = binaryReader.readDouble();
  1207. map.physics.bodies[F5W[52]].lv = [
  1208. binaryReader.readDouble(),
  1209. binaryReader.readDouble(),
  1210. ];
  1211. map.physics.bodies[F5W[52]].av = binaryReader.readDouble();
  1212. map.physics.bodies[F5W[52]].ld = binaryReader.readDouble();
  1213. map.physics.bodies[F5W[52]].ad = binaryReader.readDouble();
  1214. map.physics.bodies[F5W[52]].fr = binaryReader.readBoolean();
  1215. map.physics.bodies[F5W[52]].bu = binaryReader.readBoolean();
  1216. map.physics.bodies[F5W[52]].cf.x = binaryReader.readDouble();
  1217. map.physics.bodies[F5W[52]].cf.y = binaryReader.readDouble();
  1218. map.physics.bodies[F5W[52]].cf.ct = binaryReader.readDouble();
  1219. map.physics.bodies[F5W[52]].cf.w = binaryReader.readBoolean();
  1220. map.physics.bodies[F5W[52]].f_c = binaryReader.readShort();
  1221. map.physics.bodies[F5W[52]].f_1 = binaryReader.readBoolean();
  1222. map.physics.bodies[F5W[52]].f_2 = binaryReader.readBoolean();
  1223. map.physics.bodies[F5W[52]].f_3 = binaryReader.readBoolean();
  1224. map.physics.bodies[F5W[52]].f_4 = binaryReader.readBoolean();
  1225. if (map.v >= 2) {
  1226. map.physics.bodies[F5W[52]].f_p = binaryReader.readBoolean();
  1227. }
  1228. if (map.v >= 14) {
  1229. map.physics.bodies[F5W[52]].fz.on = binaryReader.readBoolean();
  1230. if (map.physics.bodies[F5W[52]].fz.on) {
  1231. map.physics.bodies[F5W[52]].fz.x = binaryReader.readDouble();
  1232. map.physics.bodies[F5W[52]].fz.y = binaryReader.readDouble();
  1233. map.physics.bodies[F5W[52]].fz.d = binaryReader.readBoolean();
  1234. map.physics.bodies[F5W[52]].fz.p = binaryReader.readBoolean();
  1235. map.physics.bodies[F5W[52]].fz.a = binaryReader.readBoolean();
  1236. }
  1237. }
  1238. F5W[88] = binaryReader.readShort();
  1239. for (F5W[65] = 0; F5W[65] < F5W[88]; F5W[65]++) {
  1240. map.physics.bodies[F5W[52]].fx.push(binaryReader.readShort());
  1241. }
  1242. }
  1243. F5W[97] = binaryReader.readShort();
  1244. for (F5W[41] = 0; F5W[41] < F5W[97]; F5W[41]++) {
  1245. map.spawns[F5W[41]] = {"x":400,"y":300,"xv":0,"yv":0,"priority":5,"r":true,"f":true,"b":true,"gr":false,"ye":false,"n":"Spawn"};
  1246. F5W[35] = map.spawns[F5W[41]];
  1247. F5W[35].x = binaryReader.readDouble();
  1248. F5W[35].y = binaryReader.readDouble();
  1249. F5W[35].xv = binaryReader.readDouble();
  1250. F5W[35].yv = binaryReader.readDouble();
  1251. F5W[35].priority = binaryReader.readShort();
  1252. F5W[35].r = binaryReader.readBoolean();
  1253. F5W[35].f = binaryReader.readBoolean();
  1254. F5W[35].b = binaryReader.readBoolean();
  1255. F5W[35].gr = binaryReader.readBoolean();
  1256. F5W[35].ye = binaryReader.readBoolean();
  1257. F5W[35].n = binaryReader.readUTF();
  1258. }
  1259. F5W[16] = binaryReader.readShort();
  1260. for (F5W[25] = 0; F5W[25] < F5W[16]; F5W[25]++) {
  1261. map.capZones[F5W[25]] = {"n":"Cap Zone","ty":1,"l":10,"i":-1};
  1262. map.capZones[F5W[25]].n = binaryReader.readUTF();
  1263. map.capZones[F5W[25]].l = binaryReader.readDouble();
  1264. map.capZones[F5W[25]].i = binaryReader.readShort();
  1265. if (map.v >= 6) {
  1266. map.capZones[F5W[25]].ty = binaryReader.readShort();
  1267. }
  1268. }
  1269. F5W[98] = binaryReader.readShort();
  1270. for (F5W[19] = 0; F5W[19] < F5W[98]; F5W[19]++) {
  1271. F5W[31] = binaryReader.readShort();
  1272. if (F5W[31] == 1) {
  1273. map.physics.joints[F5W[19]] = {"type":"rv","d":{"la":0,"ua":0,"mmt":0,"ms":0,"el":false,"em":false,"cc":false,"bf":0,"dl":true},"aa":[0,0]};
  1274. F5W[20] = map.physics.joints[F5W[19]];
  1275. F5W[20].d.la = binaryReader.readDouble();
  1276. F5W[20].d.ua = binaryReader.readDouble();
  1277. F5W[20].d.mmt = binaryReader.readDouble();
  1278. F5W[20].d.ms = binaryReader.readDouble();
  1279. F5W[20].d.el = binaryReader.readBoolean();
  1280. F5W[20].d.em = binaryReader.readBoolean();
  1281. F5W[20].aa = [binaryReader.readDouble(), binaryReader.readDouble()];
  1282. }
  1283. if (F5W[31] == 2) {
  1284. map.physics.joints[F5W[19]] = {"type":"d","d":{"fh":0,"dr":0,"cc":false,"bf":0,"dl":true},"aa":[0,0],"ab":[0,0]};
  1285. F5W[87] = map.physics.joints[F5W[19]];
  1286. F5W[87].d.fh = binaryReader.readDouble();
  1287. F5W[87].d.dr = binaryReader.readDouble();
  1288. F5W[87].aa = [binaryReader.readDouble(), binaryReader.readDouble()];
  1289. F5W[87].ab = [binaryReader.readDouble(), binaryReader.readDouble()];
  1290. }
  1291. if (F5W[31] == 3) {
  1292. map.physics.joints[F5W[19]] = {"type":"lpj","d":{"cc":false,"bf":0,"dl":true},"pax":0,"pay":0,"pa":0,"pf":0,"pl":0,"pu":0,"plen":0,"pms":0};
  1293. F5W[90] = map.physics.joints[F5W[19]];
  1294. F5W[90].pax = binaryReader.readDouble();
  1295. F5W[90].pay = binaryReader.readDouble();
  1296. F5W[90].pa = binaryReader.readDouble();
  1297. F5W[90].pf = binaryReader.readDouble();
  1298. F5W[90].pl = binaryReader.readDouble();
  1299. F5W[90].pu = binaryReader.readDouble();
  1300. F5W[90].plen = binaryReader.readDouble();
  1301. F5W[90].pms = binaryReader.readDouble();
  1302. }
  1303. if (F5W[31] == 4) {
  1304. map.physics.joints[F5W[19]] = {"type":"lsj","d":{"cc":false,"bf":0,"dl":true},"sax":0,"say":0,"sf":0,"slen":0};
  1305. F5W[44] = map.physics.joints[F5W[19]];
  1306. F5W[44].sax = binaryReader.readDouble();
  1307. F5W[44].say = binaryReader.readDouble();
  1308. F5W[44].sf = binaryReader.readDouble();
  1309. F5W[44].slen = binaryReader.readDouble();
  1310. }
  1311. map.physics.joints[F5W[19]].ba = binaryReader.readShort();
  1312. map.physics.joints[F5W[19]].bb = binaryReader.readShort();
  1313. map.physics.joints[F5W[19]].d.cc = binaryReader.readBoolean();
  1314. map.physics.joints[F5W[19]].d.bf = binaryReader.readDouble();
  1315. map.physics.joints[F5W[19]].d.dl = binaryReader.readBoolean();
  1316. }
  1317. return map;
  1318. };
  1319. scope.updateWssLog = function(){
  1320. if(!wsslogpaused){
  1321. if(logmenutable.children.length < wsssendrecievelog.length){
  1322. var bottomscroll = logmenutable.clientHeight + logmenutable.scrollTop >= logmenutable.scrollHeight-1;
  1323. while (logmenutable.children.length>1000) {
  1324. logmenutable.removeChild(logmenutable.firstChild);
  1325. logmenutable2.removeChild(logmenutable2.firstChild);
  1326. }
  1327. var loopthro = wsssendrecievelog.slice(packetcount);
  1328. for(var i = 0; i < loopthro.length;i++){
  1329. packetcount++;
  1330. var row = document.createElement("tr");
  1331. var row2 = document.createElement("tr");
  1332.  
  1333. var cell1 = document.createElement("td");
  1334. cell1.style["overflow-x"] = "scroll";
  1335. cell1.style["padding"] = "0px";
  1336. cell1.style["width"] = "100000px";
  1337.  
  1338. var cell2 = document.createElement("td");
  1339. cell2.style["overflow-x"] = "scroll";
  1340. cell2.style["padding"] = "0px";
  1341. cell2.style["width"] = "100000px";
  1342. if(debuggercount){
  1343. cell1.style["background"] = "rgb(178, 185, 189)";
  1344. debuggercount = false;
  1345. }
  1346. else{
  1347. cell2.style["background"] = "rgb(178, 185, 189)";
  1348. debuggercount = true;
  1349. }
  1350. cell1.textContent = loopthro[i][1];
  1351. cell2.textContent = loopthro[i][1];
  1352. if(loopthro[i][0] == 0){
  1353. cell2.style["color"] = "transparent";
  1354. cell1.onclick = function(){debuggerinput.value = this.textContent};
  1355. }
  1356. else{
  1357. cell1.style["color"] = "transparent";
  1358. cell2.onclick = function(){debuggerinput.value = this.textContent};
  1359. }
  1360. row.appendChild(cell1);
  1361. row2.appendChild(cell2);
  1362. logmenutable.appendChild(row);
  1363. logmenutable2.appendChild(row2);
  1364. }
  1365. while (logmenutable.children.length>1000) {
  1366. logmenutable.removeChild(logmenutable.firstChild);
  1367. logmenutable2.removeChild(logmenutable2.firstChild);
  1368. }
  1369. if(bottomscroll){
  1370. logmenutable.scrollTop = logmenutable.scrollHeight;
  1371. logmenutable2.scrollTop = logmenutable.scrollHeight;
  1372. }
  1373. }
  1374. }
  1375. };
  1376. Gdocument.getElementById("maploadwindowmapscontainer").appendChild = function(args){
  1377.  
  1378. var checkbox = Gdocument.createElement("input");
  1379. checkbox.type = "checkbox";
  1380. checkbox.style["position"]="absolute";
  1381. checkbox.style["margin-top"] = "135px";
  1382. checkbox.style["margin-left"] = "140px";
  1383. checkbox.style["scale"] = "2";
  1384. checkbox.style["display"] = "none";
  1385. checkbox.className = "quickplaycheckbox quickplayunchecked";
  1386. if(ishost && stopquickplay==0){
  1387. checkbox.style["display"] = "block";
  1388. checkbox.className = "quickplaycheckbox quickplaychecked";
  1389. }
  1390. checkbox.checked = true;
  1391. checkbox.onclick = function(e){e.stopPropagation();};
  1392. args.appendChild(checkbox);
  1393. originalMapLoad.call(this,args);
  1394. };
  1395. Gdocument.getElementById("newbonklobby_chat_content").appendChild = function(args){
  1396. if(beenKickedTimeStamp+100>Date.now() && args.children.length>0){
  1397. if(args.children[0].textContent.endsWith(" has left the game ") && args.children[0].textContent.startsWith("* ")){
  1398. var kickedorbanned = "banned";
  1399. if(onlykicked){
  1400. kickedorbanned = "kicked";
  1401. }
  1402. args.children[0].textContent = args.children[0].textContent.substring(0,args.children[0].textContent.length-19)+" has been "+kickedorbanned+" from the game ";
  1403. }
  1404. }
  1405. setTimeout(function(){
  1406. if(args.textContent.startsWith("* ") && args.children.length>=5){
  1407. var newarg = args.cloneNode();
  1408. for(var i = 0;i<args.children.length;i++){
  1409. var newarg2 = args.children[i].cloneNode();
  1410. newarg2.textContent = args.children[i].textContent;
  1411. newarg2.style.color = '#ffffffd6';
  1412. newarg2.onclick = args.children[i].onclick;
  1413. newarg2.suggestID = args.children[i].suggestID;
  1414. newarg.appendChild(newarg2);
  1415. }
  1416. Gdocument.getElementById("ingamechatcontent").appendChild(newarg);
  1417. Gdocument.getElementById("ingamechatcontent").scrollTop = Number.MAX_SAFE_INTEGER;
  1418. }},0);
  1419. originalLobbyChat.call(this,args);
  1420. };
  1421. Gdocument.getElementById("ingamechatcontent").appendChild = function(args){
  1422. if(beenKickedTimeStamp+100>Date.now() && args.children.length>0){
  1423. if(args.children[0].textContent.endsWith(" has left the game.") && args.children[0].textContent.startsWith("* ")){
  1424. var kickedorbanned = "banned";
  1425. if(onlykicked){
  1426. kickedorbanned = "kicked";
  1427. }
  1428. args.children[0].textContent = args.children[0].textContent.substring(0,args.children[0].textContent.length-19)+" has been "+kickedorbanned+" from the game.";
  1429. }
  1430. }
  1431. if(recordedTimeStamp+100>Date.now() && args.children.length>0){
  1432. if(args.children[0].textContent.includes("seconds") && args.children[0].textContent.startsWith("* ")){
  1433. args.children[0].textContent = args.children[0].textContent + " - " + playerids[recordedId].userName;
  1434. }
  1435. }
  1436. originalIngameChat.call(this,args);
  1437. };
  1438. Gwindow.Date.now = function(){
  1439. if(overideDate[0]){
  1440. return overideDate[1];
  1441. }
  1442. else if(causelag){
  1443. return originalDatenow.call(this,...arguments)-causelag2;
  1444. }
  1445. return originalDatenow.call(this,...arguments);
  1446. };
  1447. Gwindow.XMLHttpRequest.prototype.open = function(_, url) {
  1448. if (url.includes("scripts/map_get") || url.includes("scripts/map_b1_get") || url.includes("scripts/hotmaps/")) {
  1449. if(searchrequested==1){
  1450. Gdocument.getElementById("maploadtypedropdowntitle").click();
  1451. Gdocument.getElementById("maploadtypedropdowntitle").textContent = dropdownrequested.textContent;
  1452. dropdownrequested.style["display"] = "none";
  1453. clearmaprequests.style["display"] = "block";
  1454. refreshmaprequests.style["display"] = "block";
  1455. Gdocument.getElementById("maploadwindowhotnessslider").style["visibility"] = "hidden";
  1456. Gdocument.getElementById("maploadwindowsearchoptions").style["visibility"] = "hidden";
  1457. searchrequested = 0;
  1458. this.isSearchMap = true;
  1459. }
  1460. }
  1461. else if(url.includes("getrooms.php")){
  1462. this.isGetRooms = true;
  1463. }
  1464. else if(url.includes("getroomaddress.php")){
  1465. this.isGetRoomAddress = true;
  1466. }
  1467. originalXMLOpen.call(this, ...arguments);
  1468. };
  1469. Gwindow.XMLHttpRequest.prototype.send = function(data) {
  1470. if(this.isGetRoomAddress){
  1471. currentroomaddress = parseInt(data.slice(3));
  1472. }
  1473. else if(this.isGetRooms && inroom){
  1474. this.onreadystatechange = function(){
  1475. if(this.readyState == 4){
  1476. lastrooms = JSON.parse(this.response)["rooms"];
  1477. if(lastrooms){
  1478. var keys = Object.keys(savedroomsdata);
  1479. for(var i = 0;i<lastrooms.length;i++){
  1480. if(savedrooms.includes(lastrooms[i].id)){
  1481. exists = true;
  1482. savedroomsdata[lastrooms[i].id] = lastrooms[i];
  1483. savedroomsdata[lastrooms[i].id].exists = true;
  1484. savedroomsdata[lastrooms[i].id].exists2 = true;
  1485. if(lastrooms[i].maxplayers>lastrooms[i].players){
  1486. if(inroom){
  1487. if(lastrooms[i].id!=currentroomaddress){
  1488. displayInChat('The room '+JSON.stringify(lastrooms[i].roomname)+' is now open with '+lastrooms[i].players+"/"+lastrooms[i].maxplayers+" players.","#DA0808","#1EBCC1");
  1489. savedrooms.splice(savedrooms.indexOf(lastrooms[i].id),1);
  1490. delete savedroomsdata[lastrooms[i].id];
  1491. keys.splice(keys.indexOf((lastrooms[i].id).toString()),1);
  1492. }
  1493. else{
  1494. savedrooms.splice(savedrooms.indexOf(lastrooms[i].id),1);
  1495. delete savedroomsdata[lastrooms[i].id];
  1496. keys.splice(keys.indexOf((lastrooms[i].id).toString()),1);
  1497. }
  1498. }
  1499. }
  1500. }
  1501. }
  1502. for(var i = 0;i<keys.length;i++){
  1503. if(!savedroomsdata[keys[i]].exists2){
  1504. savedroomsdata[keys[i]].exists = false;
  1505. }
  1506. savedroomsdata[keys[i]].exists2 = false;
  1507. }
  1508. for(var i = 0;i<keys.length;i++){
  1509. if(!savedroomsdata[keys[i]].exists){
  1510. savedrooms.splice(savedrooms.indexOf(parseInt(keys[i])),1);
  1511. displayInChat('The room '+JSON.stringify(savedroomsdata[keys[i]].roomname)+" does not exist anymore.","#DA0808","#1EBCC1");
  1512. delete savedroomsdata[keys[i]];
  1513. }
  1514. }
  1515. }
  1516. }
  1517. }
  1518. }
  1519. else if (this.isSearchMap) {
  1520. this.onreadystatechange = function () {
  1521. if (this.readyState == 4){
  1522. var jsonargs = {r:"success",maps:[],more:true};
  1523. for(var i = 0; i<requestedmaps.length; i++){
  1524. var dec = requestedmaps[i][0];
  1525. var undec = requestedmaps[i][1];
  1526. var map = {};
  1527. map.id = dec["m"]["dbid"];
  1528. map.name = dec["m"]["n"];
  1529. map.authorname = dec["m"]["a"];
  1530. map.leveldata = undec;
  1531. map.publisheddate = dec["m"]["date"];
  1532. map.remixauthor = dec["m"]["rxa"];
  1533. map.remixdb = dec["m"]["rxdb"];
  1534. map.remixid = dec["m"]["rxid"];
  1535. map.remixname = dec["m"]["rxn"];
  1536. map.vd = dec["m"]["vd"];
  1537. map.vu = dec["m"]["vu"];
  1538. jsonargs.maps.push(map);
  1539. }
  1540. jsonargs2 = JSON.stringify(jsonargs);
  1541. function stringifyjsonargs(){
  1542. return jsonargs2;
  1543. }
  1544. this.__defineGetter__("responseText", stringifyjsonargs);
  1545. this.__defineGetter__("response", stringifyjsonargs);
  1546. }
  1547. }
  1548. }
  1549. originalXMLSend.call(this, ...arguments);
  1550. };
  1551. scope.STB = function(x){
  1552. if(x == "0"){
  1553. return 0;
  1554. }
  1555. else{
  1556. return 1;
  1557. }
  1558. };
  1559. scope.BTS = function(x){
  1560. if(x == 0){
  1561. return "0";
  1562. }
  1563. else{
  1564. return "1";
  1565. }
  1566. };
  1567. scope.GET_KEYS = function(x){
  1568. var x2 = ((x+64)>>>0).toString(2).substring(1).split("");
  1569. 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])}
  1570. };
  1571. scope.MAKE_KEYS = function(x){
  1572. return x.special*32+x.heavy*16+x.down*8+x.up*4+x.right*2+x.left
  1573. };
  1574.  
  1575. Gwindow.PIXI.Graphics.prototype.drawCircle = function(...args){
  1576. var This = this;
  1577. var Args = [...args];
  1578. setTimeout(function(){
  1579. if(This.parent){
  1580. var childs = This.parent.children;
  1581. var user = 0;
  1582. for(var i = 0;i<childs.length;i++){
  1583. if(childs[i]._text){
  1584. user = childs[i]._text;
  1585. }
  1586. if(i==2 && childs[i]!=This){
  1587. return;
  1588. }
  1589. }
  1590. var keys = Object.keys(playerids);
  1591. for(var i = 0;i<keys.length;i++){
  1592. if(playerids[keys[i]].userName == user){
  1593. playerids[keys[i]].playerData = This.parent;
  1594. if(!playerids[keys[i]].playerData2){
  1595. 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};
  1596. }
  1597. playerids[keys[i]].playerData2.radius = Args[2];
  1598. parentDraw = This.parent;
  1599. while(parentDraw.parent){
  1600. parentDraw = parentDraw.parent;
  1601. }
  1602. }
  1603. }
  1604. }
  1605. },0);
  1606. return originalDrawCircle.call(this,...args);
  1607. };
  1608. Gwindow.requestAnimationFrame = function(...args){
  1609. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  1610. while(parentDraw.parent){
  1611. parentDraw = parentDraw.parent;
  1612. }
  1613. var canv = 0;
  1614. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  1615. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  1616. canv = Gdocument.getElementById("gamerenderer").children[i];
  1617. break;
  1618. }
  1619. }
  1620. var width = parseInt(canv.style["width"]);
  1621. var height = parseInt(canv.style["height"]);
  1622. scale = (parseInt(canv.style["width"])/730);
  1623. var now = Date.now();
  1624. var keys = Object.keys(playerids);
  1625. addto = {"children":[]};
  1626. for(var i = 0;i<parentDraw.children.length;i++){
  1627. if(parentDraw.children[i].constructor.name == "e"){
  1628. addto = parentDraw.children[i];
  1629. break;
  1630. }
  1631. }
  1632. if(autocam){
  1633. var autocamx = 365*scale;
  1634. var autocamy = 250*scale;
  1635. if(FollowCam && playerids[myid].playerData?.transform){
  1636. autocamx = playerids[myid].playerData.transform.position.x;
  1637. autocamy = playerids[myid].playerData.transform.position.y;
  1638. }
  1639. var distances = {};
  1640. for(var i = 0;i<keys.length;i++){
  1641. if(playerids[keys[i]].playerData && playerids[keys[i]].playerData2){
  1642. if(playerids[keys[i]].playerData.transform){
  1643. var ypos = playerids[keys[i]].playerData.transform.position.y;
  1644. if(ypos>460*scale && ypos< 500 * scale){
  1645. ypos = scale * 460;
  1646. }
  1647. distances[keys[i]] = [playerids[keys[i]].playerData.transform.position.x-autocamx,ypos-autocamy];
  1648. }
  1649. }
  1650. }
  1651. distances["topleft"] = [autocamx-40,autocamy-40];
  1652. distances["topright"] = [690*scale-autocamx,autocamy-40];
  1653. distances["bottomleft"] = [autocamx-40,460*scale-autocamy];
  1654. distances["bottomright"] = [690*scale-autocamx,460*scale-autocamy];
  1655. var lowestD = [-1,-1];
  1656. var keys2 = Object.keys(distances);
  1657. for(var i = 0;i<keys2.length;i++){
  1658. if(Math.abs(distances[keys2[i]][0]/scale)>lowestD[0]){
  1659. lowestD[0] = Math.abs(distances[keys2[i]][0]/scale);
  1660. }
  1661. if(Math.abs(distances[keys2[i]][1]/scale)>lowestD[1]){
  1662. lowestD[1] = Math.abs(distances[keys2[i]][1]/scale);
  1663. }
  1664. }
  1665. var horizontal = (lowestD[0])/345;
  1666. var vertical = (lowestD[1])/230;
  1667. newzoom = Math.min(Math.abs(1/Math.max(horizontal,vertical)),1);
  1668. }
  1669. else{
  1670. newzoom = 1;
  1671. }
  1672.  
  1673. newzoom2 = newzoom2 + 0.15*(newzoom-newzoom2);
  1674. zoom2 = zoom2 + 0.15*(zoom-zoom2);
  1675. addto.scale.x = newzoom2 * zoom2;
  1676. addto.scale.y = newzoom2 * zoom2;
  1677.  
  1678. if(holdheavy>0){
  1679. if(holdheavy==1){
  1680. holdheavy = -1;
  1681. }
  1682. else{
  1683. holdheavy-=1;
  1684. }
  1685. }
  1686. if(playerids[myid].playerData?.children){
  1687. for(var i = 0;i<playerids[myid].playerData.children.length;i++){
  1688. if(playerids[myid].playerData.children[i].alpha!=1){
  1689. heavyid = i;
  1690. }
  1691. if(playerids[myid].playerData.children[i].vertextData){
  1692. if(playerids[myid].playerData.children[i].vertextData.length == 0){
  1693. specialid = i;
  1694. }
  1695. }
  1696. }
  1697. }
  1698. for(var i = 0;i<keys.length;i++){
  1699. var isadmin = [false,0];
  1700. for(var i3 = 0;i3<admins.length;i3++){
  1701. if(admins[i3][0] == playerids[keys[i]].userName && !playerids[keys[i].guest]){
  1702. isadmin = [true,i3];
  1703. break;
  1704. }
  1705. }
  1706. if(isadmin[0]){
  1707. if(playerids[keys[i]].playerData?.children){
  1708. for(var i2 = 0;i2<playerids[keys[i]].playerData.children.length;i2++){
  1709. if(playerids[keys[i]].playerData.children[i2].text){
  1710. playerids[keys[i]].playerData.children[i2].tint = (75+Math.abs(180-admins[isadmin[1]][1][0]))*256**2 + (75+Math.abs(180-admins[isadmin[1]][1][1]))*256 + 75+Math.abs(180-admins[isadmin[1]][1][2]);
  1711. }
  1712. if(i2 == 1){
  1713. if(!Array.isArray(playerids[keys[i]].playerData.children[i2].filters)){
  1714. playerids[keys[i]].playerData.children[i2].filters = [new Gwindow.PIXI.filters.ColorMatrixFilter()];
  1715. }
  1716. var rotatevalue = 0;
  1717. if(admins[isadmin[1]][1][3]<90){
  1718. rotatevalue = admins[isadmin[1]][1][3]/2;
  1719. }
  1720. else if(admins[isadmin[1]][1][3]<270){
  1721. rotatevalue =(180-admins[isadmin[1]][1][3])/2;
  1722. }
  1723. else if(admins[isadmin[1]][1][3]<360){
  1724. rotatevalue = (-360+admins[isadmin[1]][1][3])/2;
  1725. }
  1726. playerids[keys[i]].playerData.children[i2].filters[0].hue(rotatevalue);
  1727. }
  1728. }
  1729. }
  1730. }
  1731. else{
  1732. if(playerids[keys[i]].playerData?.children){
  1733. for(var i2 = 0;i2<playerids[keys[i]].playerData.children.length;i2++){
  1734. if(playerids[keys[i]].playerData.children[i2].text){
  1735. playerids[keys[i]].playerData.children[i2].tint = (75+Math.abs(180-allstyles[playerids[keys[i]].userName][0]))*256**2 + (75+Math.abs(180-allstyles[playerids[keys[i]].userName][1]))*256 + 75+Math.abs(180-allstyles[playerids[keys[i]].userName][2]);
  1736. }
  1737. }
  1738. }
  1739. }
  1740. }
  1741. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  1742. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  1743. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  1744. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  1745. if(canvasWidth!=width){
  1746. canvasWidth = width;
  1747. pixiCircle.clear();
  1748. pixiCircle.x = parseInt(canv.style["width"])/2;
  1749. pixiCircle.y = parseInt(canv.style["height"])/2;
  1750. pixiCircle.lineStyle(3, 0x8B8000);
  1751. pixiCircle.drawRect(-parseInt(canv.style["width"])/2,-parseInt(canv.style["height"])/2,parseInt(canv.style["width"]),parseInt(canv.style["height"]));
  1752. pixiCircle.lineStyle(3, 0xFF0000);
  1753. pixiCircle.arc(0, 0, 850*scale,Math.atan2(250,-100*Math.sqrt(66)),Math.atan2(250,100*Math.sqrt(66)));
  1754. pixiCircle.lineTo(-100*Math.sqrt(66)*scale,250*scale);
  1755. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  1756. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  1757. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  1758. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  1759. }
  1760.  
  1761. if(!addto.children.includes(container)){
  1762. addto.addChild(container);
  1763. }
  1764. if(keys.length>0){
  1765. if(playerids[myid].playerData && playerids[myid].playerData2){
  1766. if(aimbot || heavybot || staystill){
  1767. var targetid = -1;
  1768. var distances = {};
  1769. if(Gdocument.getElementById("ingamecountdown").style["visibility"] == "hidden"){
  1770. if(playerids[myid].playerData.transform){
  1771. var teamok = true;
  1772. if(playerids[myid].team>1){
  1773. teamok = false;
  1774. }
  1775. for(var i = 0;i<keys.length;i++){
  1776. if(playerids[keys[i]].playerData && playerids[keys[i]].playerData2 && keys[i]!=myid){
  1777. if(playerids[keys[i]].playerData.transform && (playerids[keys[i]].team != playerids[myid].team || teamok || FFA)){
  1778. 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);
  1779. }
  1780. }
  1781. }
  1782. }
  1783. }
  1784. var lowestD = [-1,-1];
  1785. var keys2 = Object.keys(distances);
  1786. for(var i = 0;i<keys2.length;i++){
  1787. if(myid != keys2[i]){
  1788. if(lowestD[1] == -1){
  1789. lowestD[1] = distances[keys2[i]];
  1790. lowestD[0] = keys2[i];
  1791. }
  1792. else if(distances[keys2[i]]<lowestD[1]){
  1793. lowestD[1] = distances[keys2[i]];
  1794. lowestD[0] = keys2[i];
  1795. }
  1796. }
  1797. }
  1798. targetid = lowestD[0];
  1799. if(playerids[myid].playerData?.transform && playerids[myid].playerData2){
  1800. if(staystill & staystillpos[0]!=null){
  1801. var playerpos = playerids[myid].playerData.transform.position;
  1802. if(Math.abs(staystillpos[0]-playerpos.x/scale)<3){
  1803. if(playerids[myid].playerData2.xvel/scale>0){
  1804. fire("keydown",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1805. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1806. }
  1807. else if(playerids[myid].playerData2.xvel/scale<0){
  1808. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1809. fire("keydown",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1810. }
  1811. else{
  1812. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1813. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1814. }
  1815. }
  1816. else{
  1817. if(staystillpos[0]>playerpos.x/scale){
  1818. if(playerids[myid].playerData2.xvel/scale>10){
  1819. fire("keydown",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1820. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1821. }
  1822. else{
  1823. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1824. fire("keydown",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1825. }
  1826. }
  1827. else if(staystillpos[0]<playerpos.x/scale){
  1828. if(playerids[myid].playerData2.xvel/scale<-10){
  1829. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1830. fire("keydown",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1831. }
  1832. else{
  1833. fire("keydown",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1834. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1835. }
  1836. }
  1837. }
  1838. }
  1839. }
  1840. if(targetid != -1 && playerids[myid].playerData?.transform){
  1841. if(playerids[myid].playerData.children.length >= 7 && playerids[targetid].playerData && playerids[targetid].playerData.transform && playerids[targetid].playerData2 && aimbot){
  1842. var indexE = -1;
  1843. for(var i = 0;i<playerids[myid].playerData.children.length;i++){
  1844. if(playerids[myid].playerData.children[i].constructor.name == "e"){
  1845. indexE = i;
  1846. break;
  1847. }
  1848. }
  1849. if(indexE != -1 && playerids[myid].playerData.children[indexE].visible){
  1850. if(started == 0){
  1851. started = now;
  1852. }
  1853. var scale2=1/(parseInt(canv.style["width"])/730);
  1854. scale2 /= scale/(1 + playerids[myid].playerData2.balance*0.0088)*(playerids[myid].playerData2.radius/12);
  1855. var Dstarted = (Math.min((now-started)/1000,10/3)/(10/3));
  1856. var v = multiplier * (Dstarted*100+15)*scale2;
  1857. var g = gravity;
  1858. var mypos = playerids[myid].playerData.transform.position;
  1859. var targetpos = playerids[targetid].playerData.transform.position;
  1860. var deltapos = [(targetpos.x-mypos.x)*scale2,(targetpos.y-mypos.y)*scale2];
  1861. var dis = (Math.sqrt(deltapos[0]**2 + deltapos[1]**2))/v*prediction;
  1862. deltapos[0]+=(playerids[targetid].playerData2.xvel*scale2*dis+(playerids[targetid].playerData2.xacc*scale2*(dis))**2/2);
  1863. deltapos[1]+=(playerids[targetid].playerData2.yvel*scale2*dis+(playerids[targetid].playerData2.yacc*scale2*(dis))**2/2);
  1864. deltapos[1] = -deltapos[1];
  1865. var angle = positive(-Math.atan2(deltapos[1],deltapos[0]));
  1866. var rot = playerids[myid].playerData.children[indexE].transform.rotation;
  1867. rot = positive(rot);
  1868. angle = positive(angle);
  1869.  
  1870. var alpha = deltapos[0];
  1871. var beta = deltapos[1];
  1872. var v_squared = v**2;
  1873. var eff = 2*v_squared/g;
  1874. var rootterm = eff*(eff-2*beta)-2*alpha**2;
  1875. if(rootterm < 0) {
  1876. } else {
  1877. gamma_first = (eff + Math.sqrt(rootterm));
  1878. gamma_second = (eff - Math.sqrt(rootterm));
  1879. theta_first = positive(-Math.atan2(gamma_first, alpha));
  1880. theta_second = positive(-Math.atan2(gamma_second, alpha));
  1881. if(angle_between(angle,theta_first)<angle_between(angle,theta_second)){
  1882. angle = theta_first;
  1883. }
  1884. else{
  1885. angle = theta_second;
  1886. }
  1887. }
  1888. var min = angle_between(angle,rot);
  1889. if(angle_between2(angle,rot)<0){
  1890. fire("keydown",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1891. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1892. }
  1893. else{
  1894. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1895. fire("keydown",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1896. }
  1897. if(min<0.05){
  1898. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1899. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1900. }
  1901. }
  1902. else if(started>0){
  1903. started = 0;
  1904. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1905. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1906. }
  1907. }
  1908. }
  1909. if(playerids[myid].playerData?.transform && heavybot && mode!="f" && mode!="bs"){
  1910. var myradius = playerids[myid].playerData2.radius / scale;
  1911. var mypos = playerids[myid].playerData.transform.position;
  1912. var breakout = false;
  1913. for(var i = 0;i<keys2.length;i++){
  1914. var targetradius = playerids[keys2[i]].playerData2.radius / scale;
  1915. var targetpos = playerids[keys2[i]].playerData.transform.position;
  1916. var deltapos = [(targetpos.x-mypos.x)/scale,(targetpos.y-mypos.y)/scale];
  1917. for(var i2 = 0;i2<160;i2++){
  1918. deltapos2 = [...deltapos];
  1919. var i3 = i2*0.5;
  1920. deltapos2[0]+=((playerids[keys2[i]].playerData2.xvel-playerids[myid].playerData2.xvel)/scale*i3);
  1921. deltapos2[1]+=((playerids[keys2[i]].playerData2.yvel-playerids[myid].playerData2.yvel)/scale*i3);
  1922. var dis = Math.sqrt(deltapos2[0]**2+deltapos2[1]**2);
  1923. if(dis<myradius+targetradius){
  1924. breakout = true;
  1925. holdheavy = 20;
  1926. break;
  1927. }
  1928. }
  1929. if(breakout){
  1930. break;
  1931. }
  1932. }
  1933. if(holdheavy>0){
  1934. if(!heavyheld2){
  1935. heavyheld = playerids[myid].playerData.children[heavyid].alpha>0;
  1936. }
  1937. fire("keydown",{"keyCode":heavy},Gdocument.getElementById("gamerenderer"));
  1938. heavyheld2 = true;
  1939. if(mode == "sp"){
  1940. if(!grappleheld2){
  1941. grappleheld = playerids[myid].playerData.children[specialid].vertexData?.length>0;
  1942. }
  1943. if(grappleheld){
  1944. fire("keyup",{"keyCode":special},Gdocument.getElementById("gamerenderer"));
  1945. }
  1946. grappleheld2 = true;
  1947. }
  1948. }
  1949. else if(holdheavy<0){
  1950. holdheavy = 0;
  1951. heavyheld2 = false;
  1952. grappleheld2 = false;
  1953. if(!heavyheld){
  1954. heavyheld = false;
  1955. fire("keyup",{"keyCode":heavy},Gdocument.getElementById("gamerenderer"));
  1956. }
  1957. if(grappleheld && mode == "sp"){
  1958. grappleheld = false;
  1959. fire("keydown",{"keyCode":special},Gdocument.getElementById("gamerenderer"));
  1960. }
  1961. }
  1962. else{
  1963. heavyheld2 = false;
  1964. heavyheld = false;
  1965. grappleheld2 = false;
  1966. grappleheld = false;
  1967. }
  1968. }
  1969.  
  1970. }
  1971. if(FollowCam){
  1972. if(playerids[myid].playerData?.transform){
  1973.  
  1974. pixiCircle.visible = true;
  1975.  
  1976. parentDraw.x = -playerids[myid].playerData.x*addto.scale.x+parseInt(width)/2;
  1977. parentDraw.y = -playerids[myid].playerData.y*addto.scale.y+parseInt(height)/2;
  1978. parentDraw.children[0].x = playerids[myid].playerData.x*addto.scale.x-parseInt(width)/2;
  1979. parentDraw.children[0].y = playerids[myid].playerData.y*addto.scale.y-parseInt(height)/2;
  1980. }
  1981. else{
  1982. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  1983. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  1984. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  1985. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  1986. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999){
  1987. pixiCircle.visible = false;
  1988. }
  1989. else{
  1990. pixiCircle.visible = true;
  1991. }
  1992. }
  1993. }
  1994. }
  1995. }
  1996. if(!FollowCam){
  1997. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999){
  1998. pixiCircle.visible = false;
  1999. }
  2000. else{
  2001. pixiCircle.visible = true;
  2002. }
  2003. }
  2004. }
  2005. return requestAnimationFrameOriginal.call(this,...args);
  2006. };
  2007. scope.SENDFUNCTION = function(args){return args;};
  2008. scope.RECIEVEFUNCTION = function(args){return args;};
  2009. scope.EVENTLOOPFUNCTION = function(){};
  2010.  
  2011. Gwindow.WebSocket.prototype.send = function(args) {
  2012. if(this.url.includes(".bonk.io/socket.io/?EIO=3&transport=websocket&sid=")){
  2013. if(typeof(args) == "string" && !bonkwssextra.includes(this)){
  2014. args = SENDFUNCTION(args);
  2015. wsssendlog.push(args);
  2016. wsssendrecievelog.push([0,args]);
  2017. if(!bonkwss){
  2018. bonkwss = this;
  2019. }
  2020. if(args.startsWith('42[26,')){
  2021. var jsonargs = JSON.parse(args.substring(2));
  2022. if(sandboxon){
  2023. if(typeof(sandboxplayerids[jsonargs[1]["targetID"]])!='undefined'){
  2024. var packet = '42[18,'+jsonargs[1]["targetID"]+','+jsonargs[1]["targetTeam"]+']';
  2025. RECIEVE(packet);
  2026. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  2027. }
  2028. }
  2029. }
  2030. if(args.startsWith('42[9,')){
  2031. var jsonargs = JSON.parse(args.substring(2));
  2032. if(sandboxon){
  2033. if(typeof(sandboxplayerids[jsonargs[1]["banshortid"]])!='undefined'){
  2034. if(Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden"){
  2035. var packet = '42[24,'+jsonargs[1]["banshortid"].toString()+','+jsonargs[1]["kickonly"]+']';
  2036. var packet2 = '42[5,'+jsonargs[1]["banshortid"].toString()+',0]';
  2037. RECIEVE(packet);
  2038. RECIEVE(packet2);
  2039. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet,packet2],to:[-1]}]));
  2040. }
  2041. else{
  2042. displayInChat("Cannot delete players while ingame.","#DA0808","#1EBCC1");
  2043. }
  2044. }
  2045. }
  2046. }
  2047. if(args.startsWith('42[1,')){
  2048. return;
  2049. }
  2050.  
  2051. if(args.startsWith('42[4,')){
  2052. var jsonargs = JSON.parse(args.substring(2));
  2053. if(sandboxcopyme==myid && typeof(jsonargs[1]["i"])!="undefined"){
  2054. var jsonkeys = Object.keys(sandboxplayerids);
  2055. var jsonargs2 = jsonargs[1];
  2056. for(var i = 0; i<jsonkeys.length;i++){
  2057. jsonargs2["c"] = playerids[jsonkeys[i]].movecount;
  2058. var packet = '42[7,'+jsonkeys[i].toString()+','+JSON.stringify(jsonargs2)+']';
  2059. RECIEVE(packet);
  2060. }
  2061. jsonargs2["c"] = "CVALUE";
  2062. jsonargs2 = JSON.stringify(jsonargs2).replace('"CVALUE"',"CVALUE");
  2063. SEND("42"+JSON.stringify([4,{"type":"customfakerecieve","from":username,"packet":['42[7,ID,'+jsonargs2+']'],to:[-1]}]));
  2064. }
  2065. if(typeof(jsonargs[1]["i"]) != "undefined"){
  2066. if(playerids[myid].movecount>=jsonargs[1]["c"]){
  2067. jsonargs[1]["c"] = playerids[myid].movecount;
  2068. playerids[myid].movecount+=1;
  2069. }
  2070. else{
  2071. playerids[myid].movecount = jsonargs[1]["c"]+1;
  2072. }
  2073. }
  2074. if(recording && typeof(jsonargs[1]["i"])!="undefined"){
  2075. if(myid.toString() == recordingid){
  2076. if(recordingdata.length == 0){
  2077. recordingdata.push([jsonargs[1]["i"],jsonargs[1]["f"]]);
  2078. }
  2079. else{
  2080. recordingdata.push([jsonargs[1]["i"],jsonargs[1]["f"]-recordingdata[0][1]]);
  2081. }
  2082. }
  2083. }
  2084. playerids[myid].lastmove = Date.now();
  2085. if(ishost && typeof(jsonargs[1]["i"])!="undefined"){
  2086. for(var i = 0;i<disabledkeys.length;i++){
  2087. if(GET_KEYS(jsonargs[1]["i"])[disabledkeys[i]]){
  2088. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden" && !killedids.includes(myid)){
  2089. killedids.push(myid);
  2090. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  2091. SEND('42[25,{"a":{"playersLeft":['+myid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  2092. RECIEVE('42[31,{"a":{"playersLeft":['+myid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  2093. break;
  2094. }
  2095. }
  2096. }
  2097. }
  2098. args = "42"+JSON.stringify(jsonargs);
  2099. }
  2100. if(args.startsWith('42[29,')){
  2101. var jsonargs = JSON.parse(args.substring(2));
  2102. playerids[jsonargs[1]["sid"]].playerData2.balance = jsonargs[1]["bal"];
  2103. if(sandboxon){
  2104. if(typeof(sandboxplayerids[jsonargs[1]["sid"]])!='undefined'){
  2105. var packet = '42[36,'+jsonargs[1]["sid"]+','+jsonargs[1]["bal"]+']';
  2106. RECIEVE(packet);
  2107. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  2108. }
  2109. }
  2110. }
  2111. if(args.startsWith('42[12,')){
  2112. playerids = {};
  2113. var jsonargs2 = JSON.parse(args.substring(2));
  2114. var jsonargs = jsonargs2[1];
  2115. playerids["0"] = {"peerID":jsonargs["peerID"],"userName":username,"level":Gdocument.getElementById("pretty_top_level").textContent == "Guest" ? 0 : parseInt(Gdocument.getElementById("pretty_top_level").textContent.substring(3)),"guest":typeof(jsonargs.token)=="undefined","team":1,"avatar":jsonargs["avatar"],"movecount":0,"commands":true,"ratelimit":{"pm":0,"mode":0,"team":0,"poll":0,"join":Date.now(),"style":0},"vote":{"poll":-1}};
  2116. allstyles[username] = [0,0,0];
  2117. myid = 0;
  2118. bonkwss = this;
  2119. hostid = 0;
  2120. inroom = true;
  2121. if(savedrooms.length>0){
  2122. Gdocument.getElementById("roomlistrefreshbutton").click();
  2123. }
  2124. }
  2125. if(args.startsWith('42[10')){
  2126. var jsonargs = JSON.parse(args.substring(2));
  2127. if(jsonargs[2]){
  2128. args = "42"+JSON.stringify([10,jsonargs[1]]);
  2129. }
  2130. else if(translating2[0]){
  2131. text = translate(jsonargs[1]["message"],"auto",translating2[1]).then(function(r){SEND("42"+JSON.stringify([10,{"message":r},true]))});
  2132. return;
  2133. }
  2134. }
  2135. if(args.startsWith('42[23,') && recteams){
  2136. var jsonargs = JSON.parse(args.substring(2));
  2137. var map = decodeFromDatabase(jsonargs[1]["m"]);
  2138. var spawns = map["spawns"];
  2139. var teamsneeded = true;
  2140. var excludedindexes = [];
  2141. var ffaspawns = false;
  2142. var ffaforsure = false;
  2143. for(var i = 0; i<spawns.length;i++){
  2144. var currentSpawn = spawns[i];
  2145. if(Math.sqrt(currentSpawn.x**2 + currentSpawn.y**2)>=850 || currentSpawn.y>250){
  2146. excludedindexes.push(i);
  2147. }
  2148. else if(!(currentSpawn.f || currentSpawn.r || currentSpawn.b || currentSpawn.gr || currentSpawn.ye)){
  2149. excludedindexes.push(i);
  2150. }
  2151. else if(currentSpawn.f){
  2152. ffaspawns = true;
  2153. if(!(currentSpawn.r || currentSpawn.b || currentSpawn.gr || currentSpawn.ye)){
  2154. excludedindexes.push(i);
  2155. ffaforsure = true
  2156. }
  2157. }
  2158. }
  2159. if(!ffaspawns && !ffaforsure){
  2160. teamsneeded = true;
  2161. }
  2162. else{
  2163. teamsneeded = false;
  2164. }
  2165. if(teamsneeded){
  2166. var newspawns = [];
  2167. for(var i = 0; i<spawns.length;i++){
  2168. if(!excludedindexes.includes(i)){
  2169. 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"]});
  2170. }
  2171. }
  2172. if(newspawns.length>0){
  2173. var teamletters = ["r","g","b","y"];
  2174. var ratios = {"r":0,"g":0,"b":0,"y":0};
  2175. for(var i = 0; i < newspawns.length;i++){
  2176. for(var i2 = 0; i2<teamletters.length;i2++){
  2177. var ct = teamletters[i2];
  2178. if(newspawns[i]["priority"]!=0){
  2179. ratios[ct]+=(newspawns[i][ct])/newspawns[i]["total"]*newspawns[i]["priority"];
  2180. }
  2181. }
  2182. }
  2183. var highest = ["",0];
  2184. for(var i = 0; i<teamletters.length;i++){
  2185. var ct = teamletters[i];
  2186. if(ratios[ct]>0 && highest[1]<ratios[ct]){
  2187. highest = [ct,ratios[ct]];
  2188. }
  2189. }
  2190. if(highest[0]!=""){
  2191. for(var i = 0; i<teamletters.length;i++){
  2192. var ct = teamletters[i];
  2193. ratios[ct] = ratios[ct]/highest[1];
  2194. }
  2195. }
  2196. var playerids3 = Object.keys(playerids);
  2197. var playerids2 = [];
  2198. for(var i = 0; i<playerids3.length;i++){
  2199. if(playerids[playerids3[i]].team>0){
  2200. playerids2.push(playerids3[i]);
  2201. }
  2202. }
  2203. var pi2l = playerids2.length;
  2204. var ratios2 = {"r":0,"r1":0,"g":0,"g1":0,"b":0,"b1":0,"y":0,"y1":0};
  2205. var items = Object.entries(ratios);
  2206. items.sort(function(a,b){return a[1]-b[1];});
  2207. var items = items.map(function(e){return e[0];});
  2208. var highest2 = ["",0];
  2209. while(pi2l>0){
  2210. var done = false;
  2211. for(var i2 = 0; i2<items.length;i2++){
  2212. var ci = items[i2];
  2213. var ci2 = items[i2]+"1";
  2214. for(var i = 0; i<teamletters.length;i++){
  2215. var ct = teamletters[i];
  2216. if(ratios2[ct]>0 && highest2[1]<ratios2[ct]){
  2217. highest2 = [ct,ratios2[ct]];
  2218. }
  2219. }
  2220. if(highest2[0]!=""){
  2221. for(var i = 0; i<teamletters.length;i++){
  2222. var ct = teamletters[i];
  2223. ratios2[ct+"1"] = ratios2[ct]/highest2[1];
  2224. }
  2225. }
  2226. if(ratios[ci]>0 && ratios[ci]>=ratios2[ci2] && pi2l>0){
  2227. ratios2[ci]+=1;
  2228. pi2l--;
  2229. done = true;
  2230. }
  2231. }
  2232. if(pi2l>0 && !done){
  2233. ratios2[highest2[0]]+=1;
  2234. pi2l--;
  2235. }
  2236. }
  2237. SEND('42[32,{"t":true}]');
  2238. RECIEVE('42[39,true]');
  2239. for(var i = 0; i<ratios2["r"];i++){
  2240. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  2241. SEND('42[26,{"targetID":'+pid+',"targetTeam":2}]');
  2242. if(playerids[pid].peerID!="sandbox"){
  2243. RECIEVE('42[18,'+pid+',2]');
  2244. }
  2245. }
  2246. for(var i = 0; i<ratios2["g"];i++){
  2247. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  2248. SEND('42[26,{"targetID":'+pid+',"targetTeam":4}]');
  2249. if(playerids[pid].peerID!="sandbox"){
  2250. RECIEVE('42[18,'+pid+',4]');
  2251. }
  2252. }
  2253. for(var i = 0; i<ratios2["b"];i++){
  2254. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  2255. SEND('42[26,{"targetID":'+pid+',"targetTeam":3}]');
  2256. if(playerids[pid].peerID!="sandbox"){
  2257. RECIEVE('42[18,'+pid+',3]');
  2258. }
  2259. }
  2260. for(var i = 0; i<ratios2["y"];i++){
  2261. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  2262. SEND('42[26,{"targetID":'+pid+',"targetTeam":5}]');
  2263. if(playerids[pid].peerID!="sandbox"){
  2264. RECIEVE('42[18,'+pid+',5]');
  2265. }
  2266. }
  2267. }
  2268. }
  2269. else{
  2270. SEND('42[32,{"t":false}]');
  2271. RECIEVE('42[39,false]');
  2272. }
  2273. }
  2274.  
  2275. if(args.startsWith('42[47,') && stopquickplay == 0 && ishost && document.hidden && !qppaused){
  2276. roundsperqp2++;
  2277. if(roundsperqp2>=roundsperqp){
  2278. if(shuffle){
  2279. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  2280. var available = [];
  2281. var availableindexes = [];
  2282. var notempty = false;
  2283. for(var i = 0; i<e2.length;i++){
  2284. var a = false;
  2285. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  2286. available.push(a);
  2287. if(a){
  2288. availableindexes.push(i);
  2289. notempty = true;
  2290. }
  2291. }
  2292. if(notempty){
  2293.  
  2294. if(availableindexes.length!=1){
  2295. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  2296. }
  2297. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  2298. }
  2299. }
  2300. else{
  2301. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  2302. var available = [];
  2303. var availableindexes = [];
  2304. var notempty = false;
  2305. for(var i = 0; i<e2.length;i++){
  2306. var a = false;
  2307. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  2308. available.push(a);
  2309. if(a){
  2310. availableindexes.push(i);
  2311. notempty = true;
  2312. }
  2313. }
  2314. if(notempty){
  2315. var above = [];
  2316. for(var i = 0;i<availableindexes.length;i++){
  2317. if(availableindexes[i]>quicki && !reverseqp){
  2318. above.push(availableindexes[i]);
  2319. }
  2320. else if(availableindexes[i]<quicki && reverseqp){
  2321. above.push(availableindexes[i])
  2322. }
  2323. }
  2324. if(above.length>0){
  2325. quicki = above[0];
  2326. if(reverseqp){
  2327. quicki = above[above.length-1];
  2328. }
  2329. }
  2330. else{
  2331. quicki = availableindexes[0];
  2332. if(reverseqp){
  2333. quicki = availableindexes[availableindexes.length-1];
  2334. }
  2335. }
  2336. }
  2337. }
  2338. }
  2339. canceled = false;
  2340. startedinqp = true;
  2341. window.map(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length),0);
  2342. }
  2343. if(args.startsWith('42[32,')){
  2344. var jsonargs = JSON.parse(args.substring(2));
  2345. var keys = Object.keys(playerids);
  2346. if(!jsonargs[1]["t"]){
  2347. FFA = true;
  2348. for(var i = 0;i<keys.length;i++){
  2349. if(playerids[keys[i]].team!=0){
  2350. playerids[keys[i]].team = 1;
  2351. }
  2352. }
  2353. }
  2354. else{
  2355. FFA = false;
  2356. }
  2357. }
  2358. if(args.startsWith('42[5,')){
  2359. var jsonargs = JSON.parse(args.substring(2));
  2360. if(stopquickplay!=1 && startedinqp){
  2361. startedinqp = false;
  2362. jsonargs[1]["gs"]["wl"] = 999;
  2363. if(!instaqp){
  2364. var jsonargs2 = decodeIS(jsonargs[1]["is"]);
  2365. jsonargs2["ftu"] = 60;
  2366. if(jsonargs2["mm"]["rxa"] != ""){
  2367. jsonargs2["mm"]["a"] = jsonargs2["mm"]["rxa"];
  2368. jsonargs2["mm"]["n"] = jsonargs2["mm"]["rxn"];
  2369. }
  2370. jsonargs2 = encodeIS(jsonargs2);
  2371. jsonargs[1]["is"] = jsonargs2;
  2372. var jsonargs3 = decodeFromDatabase(jsonargs[1]["gs"]["map"]);
  2373. if(jsonargs3["m"]["rxa"] != ""){
  2374. jsonargs3["m"]["a"] = jsonargs3["m"]["rxa"];
  2375. jsonargs3["m"]["n"] = jsonargs3["m"]["rxn"];
  2376. }
  2377.  
  2378. jsonargs3 = encodeToDatabase(jsonargs3);
  2379. jsonargs[1]["gs"]["map"] = jsonargs3;
  2380. }
  2381. }
  2382.  
  2383. args = "42"+JSON.stringify(jsonargs);
  2384. }
  2385. }
  2386.  
  2387. }
  2388. else{
  2389. if(args.includes("rport")){
  2390. return;
  2391. }
  2392. }
  2393. if(this.url.includes(".bonk.io/socket.io/?EIO=3&transport=websocket&sid=") && !this.injected){
  2394. this.injected = true;
  2395.  
  2396. var originalRecieve = this.onmessage;
  2397. this.onmessage = function(args){
  2398. if(!bonkwssextra.includes(this)){
  2399. wssrecievelog.push(args.data);
  2400. wsssendrecievelog.push([1,args.data]);
  2401. if(typeof(args.data)=="string"){
  2402. args = {"data":RECIEVEFUNCTION(args.data)};
  2403. if(args.data.startsWith('42[1,')){
  2404. var jsonargs = JSON.parse(args.data.substring(2));
  2405. originalSend.call(this,'42[1,{"id":'+jsonargs[2]+'}]');
  2406. }
  2407. if(args.data.startsWith('42[36,')){
  2408. var jsonargs = JSON.parse(args.data.substring(2));
  2409. playerids[jsonargs[1]].playerData2.balance = jsonargs[2];
  2410. }
  2411. if(args.data.startsWith('42[24,')){
  2412. beenKickedTimeStamp = Date.now();
  2413. onlykicked = JSON.parse(args.data.substring(2))[2];
  2414. }
  2415. if(args.data.startsWith('42[21,')){
  2416. recievedinitdata = true;
  2417. }
  2418. if(args.data.startsWith('42[48,')){
  2419. recievedinitdata = true;
  2420. }
  2421. if(args.data.startsWith('42[23,')){
  2422. var jsonargs = JSON.parse(args.data.substring(2));
  2423. if(causelag){
  2424. jsonargs[1]["result"]-=causelag2;
  2425. }
  2426. args.data = '42'+JSON.stringify(jsonargs);
  2427. }
  2428. if(args.data.startsWith('42[16,')){
  2429. var jsonargs = JSON.parse(args.data.substring(2));
  2430. var now = Date.now();
  2431. if(jsonargs[1]=="chat_rate_limit"){
  2432. if(pollactive[1]+100>now){
  2433. pollactive = [false,0,0,[]];
  2434. displayInChat("Your poll failed due to chat rate limit.","#DA0808","#1EBCC1");
  2435. displayInChat("Please try again.","#DA0808","#1EBCC1");
  2436. }
  2437. }
  2438. else if(jsonargs[1]=="room_full"){
  2439. if(!savedrooms.includes(currentroomaddress)){
  2440. savedroombutton.className = "brownButton brownButton_classic buttonShadow";
  2441. }
  2442. }
  2443. }
  2444. if(args.data.startsWith('42[6,')){
  2445. var jsonargs = JSON.parse(args.data.substring(2));
  2446. if(typeof(playerids[jsonargs[1]])!='undefined'){
  2447. delplayerids[jsonargs[1]] = playerids[jsonargs[1]];
  2448. delete playerids[jsonargs[1]];
  2449. }
  2450. hostid = jsonargs[2];
  2451. }
  2452. if(args.data.startsWith('42[39,')){
  2453. var jsonargs = JSON.parse(args.data.substring(2));
  2454. var keys = Object.keys(playerids);
  2455. if(!jsonargs[1]){
  2456. FFA = true;
  2457. for(var i = 0;i<keys.length;i++){
  2458. if(playerids[keys[i]].team!=0){
  2459. playerids[keys[i]].team = 1;
  2460. }
  2461. }
  2462. }
  2463. else{
  2464. FFA = false;
  2465. }
  2466. }
  2467. if(args.data.startsWith('42[41,')){
  2468. var jsonargs = JSON.parse(args.data.substring(2));
  2469. hostid = jsonargs[1]["newHost"];
  2470. }
  2471. if(args.data.startsWith('42[20,')){
  2472. var jsonargs = JSON.parse(args.data.substring(2));
  2473. if(translating[0]){
  2474. translate(jsonargs[2],"auto",translating[1]).then(function(r){displayInChat(playerids[jsonargs[1]].userName+": "+r,"#DA0808","#1EBCC1")});
  2475. }
  2476. if(echo_list.includes(playerids[jsonargs[1]].userName)){
  2477. chat(flag_manage(echotext.replaceAll("username",playerids[jsonargs[1]].userName).replaceAll("message",jsonargs[2])));
  2478. }
  2479. if(randomchat){
  2480. var isin = false;
  2481. for(var i = 0;i<randomchatpriority[1].length;i++){
  2482. if(randomchatpriority[1][i][0] == jsonargs[2]){
  2483. isin = true;
  2484. if(myid!=jsonargs[1]){
  2485. randomchatpriority[1][i][1]+=2;
  2486. randomchatpriority[0]+=2;
  2487. }
  2488. break;
  2489. }
  2490. }
  2491. if(!isin){
  2492. randomchatpriority[1].push([jsonargs[2],Math.min(35-Math.abs(35-jsonargs[2].length),1)]);
  2493. randomchatpriority[0]+=Math.min(35-Math.abs(35-jsonargs[2].length),1);
  2494. }
  2495. }
  2496. if(pollactive[0] || pollactive2[0]){
  2497. var chatmessage = jsonargs[2].toUpperCase().trim().replace(")","");
  2498. var lettersindex = letters.indexOf(chatmessage);
  2499. if(ishost){
  2500. if(pollactive[3].length>0 && lettersindex!=-1 && lettersindex<pollactive[3].length){
  2501. playerids[jsonargs[1]].vote.poll = lettersindex;
  2502. }
  2503. }
  2504. else{
  2505. if(pollactive2[2].length>0 && lettersindex!=-1 && lettersindex<pollactive2[2].length){
  2506. playerids[jsonargs[1]].vote.poll = lettersindex;
  2507. }
  2508. }
  2509. }
  2510. }
  2511. if(args.data.startsWith('42[32')){
  2512. SEND('42[4,{"type":"inactive kick counter"}]');
  2513. }
  2514. if(args.data.startsWith('42[18')){
  2515. var jsonargs = JSON.parse(args.data.substring(2));
  2516. playerids[jsonargs[1]].team = jsonargs[2];
  2517. }
  2518. if(args.data.startsWith('42[40,')){
  2519. recordedTimeStamp = Date.now();
  2520. recordedId = JSON.parse(args.data.substring(2))[1];
  2521. }
  2522. if(args.data.startsWith('42[3,')){
  2523. playerids = {};
  2524. var jsonargs = JSON.parse(args.data.substring(2));
  2525. for(var i = 0; i<jsonargs[3].length;i++){
  2526. if(jsonargs[3][i]!=null){
  2527. playerids[i.toString()] = jsonargs[3][i];
  2528. playerids[i.toString()].commands = false;
  2529. playerids[i.toString()].ratelimit = {"pm":0,"mode":0,"team":0,"poll":0,"join":Date.now(),"style":0};
  2530. playerids[i.toString()].vote = {"poll":-1};
  2531. allstyles[playerids[i.toString()].userName] = [0,0,0];
  2532. }
  2533. }
  2534. if(playerids[jsonargs[1]].userName.startsWith(Gdocument.getElementById("pretty_top_name").textContent)){
  2535. myid = jsonargs[1];
  2536. bonkwss = this;
  2537. playerids[myid].commands = true;
  2538. /*setTimeout(function(){var me = playerids[myid];RECIEVE('42'+JSON.stringify([4,myid,me.peerID,me.userName,me.guest,me.level,me.team,me.avatar]));});*/
  2539. }
  2540. else{
  2541. bonkwssextra.push(this);
  2542. }
  2543. inroom = true;
  2544. hostid = jsonargs[2];
  2545. SEND('42[4,{"type":"commands"}]');
  2546. SEND("42"+JSON.stringify([4,{"type":"style","from":username,"style":mystyle}]));
  2547. allstyles[playerids[myid].userName] = [...mystyle];
  2548. ghostroomwss = bonkwss;
  2549. Gdocument.getElementById("roomlistrefreshbutton").click();
  2550. setTimeout(function(){if(bonkwss == ghostroomwss && !sandboxon && !recievedinitdata && myid!=0){RECIEVE('42[21,{"map":{"v":13,"s":{"re":false,"nc":false,"pq":1,"gd":25,"fl":false},"physics":{"shapes":[],"fixtures":[],"bodies":[],"bro":[],"joints":[],"ppm":12},"spawns":[],"capZones":[],"m":{"a":"","n":"","dbv":0,"dbid":0,"authid":-1,"date":"","rxid":0,"rxn":"","rxa":"","rxdb":0,"cr":[],"pub":false,"mo":"","vu":0,"vd":0}},"gt":2,"wl":3,"q":false,"tl":false,"tea":false,"ga":"b","mo":"b","bal":[]}]');displayInChat("You have joined a ghost room.","#DA0808","#1EBCC1");}},6000);
  2551.  
  2552. }
  2553. if(args.data.startsWith('42[21,')){
  2554. var jsonargs = JSON.parse(args.data.substring(2));
  2555. mode = jsonargs[1]["mo"];
  2556. FFA = !jsonargs[1]["tea"];
  2557. }
  2558. if(args.data.startsWith('42[48,')){
  2559. var jsonargs = JSON.parse(args.data.substring(2));
  2560. mode = jsonargs[1]["gs"]["mo"];
  2561. FFA = !jsonargs[1]["gs"]["tea"];
  2562. }
  2563. if(args.data.startsWith('42[49,')){
  2564. /*
  2565. var me = playerids[myid];
  2566. RECIEVE('42'+JSON.stringify([4,myid,me.peerID,me.userName,me.guest,me.level,me.team,me.avatar]));
  2567. */
  2568. }
  2569. if(args.data.startsWith('42[15,')){
  2570. var jsonargs = JSON.parse(args.data.substring(2));
  2571. dontswitch = false;
  2572. mode = jsonargs[3]["mo"];
  2573. gameStartTimeStamp = jsonargs[1];
  2574. killedids = [];
  2575. Gdocument.getElementById("newbonklobby").style["z-index"] = "unset";
  2576. Gdocument.getElementById("mapeditorcontainer").style["z-index"] = "unset";
  2577. }
  2578. if(args.data.startsWith('42[33,')){
  2579. var jsonargs = JSON.parse(args.data.substring(2));
  2580. var decodedmap = decodeFromDatabase(jsonargs[1]);
  2581. if(decodedmap!=0){
  2582. requestedmaps = [[decodedmap,jsonargs[1]]].concat(requestedmaps);
  2583. }
  2584. }
  2585. if(args.data.startsWith('42[7,')){
  2586. var jsonargs2 = JSON.parse(args.data.substring(2));
  2587. var idofpacket = jsonargs2[1];
  2588. jsonargs = jsonargs2[2];
  2589. if(typeof(jsonargs["i"]) == "undefined"){
  2590. if(jsonargs["type"]=="private chat" && jsonargs["to"] == username){
  2591. from = jsonargs["from"];
  2592. if(Object.keys(playerids).includes(idofpacket.toString())){
  2593. from = playerids[idofpacket].userName;
  2594. }
  2595. if(!ignorepmlist.includes(from)){
  2596. if(typeof(jsonargs["message"])=="object" && typeof(jsonargs["password"]) == "object"){
  2597. if(public_key[0]==jsonargs["public key"][0] && public_key[1]==jsonargs["public key"][1]){
  2598. var now = Date.now();
  2599. if(jsonargs["password"].length<=25 && playerids[idofpacket].ratelimit.pm+250<now){
  2600. playerids[idofpacket].ratelimit.pm = now;
  2601. var password = CRYPT_MESSAGE(private_key,jsonargs["password"]);
  2602. var decodedtext = jsonargs["message"].slice(0,400);
  2603. var encodedtext = "";
  2604. for(var i=0;i<decodedtext.length;i++){
  2605. if(password[i%password.length]<1000){
  2606. encodedtext+=String.fromCharCode(password[i%password.length]^decodedtext[i]);
  2607. }
  2608. }
  2609. 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);';
  2610. displayInChat('> '+'<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+sanitize(from)+'</a>'+': ',"#DA0808","#1EBCC1",{sanitize:false},encodedtext);
  2611.  
  2612. Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true;
  2613. Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true;
  2614. Laster_message = lastmessage();
  2615. }
  2616. }
  2617. else{
  2618. SEND("42"+JSON.stringify([4,{"type":"public key correction","from":username,"to":private_chat_public_key[0],"public key":public_key}]));
  2619. }
  2620. }
  2621. }
  2622. }
  2623. if(jsonargs["type"]=="request public key" && jsonargs["to"] == username){
  2624. SEND("42"+JSON.stringify([4,{"type":"public key","from":username,"public key":public_key}]));
  2625. }
  2626. if(jsonargs["type"]=="private chat users" && pmuserstimestamp+1500>Date.now()){
  2627. if(typeof(jsonargs["from"])!='undefined'){
  2628. from = jsonargs["from"];
  2629. if(Object.keys(playerids).includes(idofpacket.toString())){
  2630. from = playerids[idofpacket].userName;
  2631. }
  2632. if(!pmusers.includes(from) && username == jsonargs["to"]){
  2633. pmusers.push(from);
  2634. }
  2635. }
  2636. }
  2637. if(jsonargs["type"]=="style" && playerids[idofpacket].ratelimit["style"]+250<Date.now()){
  2638. playerids[idofpacket].ratelimit["style"] = Date.now();
  2639. if(Array.isArray(jsonargs["style"])){
  2640. if(jsonargs["style"].length == 3){
  2641. var valid = true;
  2642. for(var i = 0;i<jsonargs["style"].length;i++){
  2643. if(Number.isInteger(jsonargs["style"][i])){
  2644. if(jsonargs["style"][i]>255 || jsonargs["style"][i]<0){
  2645. valid = false;
  2646. break;
  2647. }
  2648. }
  2649. else{
  2650. valid = false;
  2651. break;
  2652. }
  2653. }
  2654. if(valid){
  2655. allstyles[playerids[idofpacket].userName] = jsonargs["style"];
  2656. }
  2657. }
  2658. }
  2659. }
  2660. if(jsonargs["type"]=="request private chat users"){
  2661. if(typeof(jsonargs["from"])!='undefined'){
  2662. from = jsonargs["from"];
  2663. if(Object.keys(playerids).includes(idofpacket.toString())){
  2664. from = playerids[idofpacket].userName;
  2665. }
  2666. SEND("42"+JSON.stringify([4,{"type":"private chat users","from":username,"to":from}]));
  2667. }
  2668. }
  2669. if(jsonargs["type"]=="public key" && request_public_key_time_stamp+1500>Date.now()){
  2670. from = jsonargs["from"];
  2671. if(Object.keys(playerids).includes(idofpacket.toString())){
  2672. from = playerids[idofpacket].userName;
  2673. }
  2674. if(from == private_chat){
  2675. private_chat_public_key = [private_chat,jsonargs["public key"]];
  2676. displayInChat("Private chatting with "+private_chat+".","#DA0808","#1EBCC1");
  2677. }
  2678. }
  2679. if(jsonargs["type"]=="fakerecieve" && hostid == idofpacket && sandboxon && ((jsonargs["to"].includes(myid) && jsonargs["to"][0]!=-1) || (!jsonargs["to"].includes(myid) && jsonargs["to"][0]==-1))){
  2680. for(var i = 0;i<jsonargs["packet"].length;i++){
  2681. if(!jsonargs["packet"][i].startsWith("42[20,")){
  2682. RECIEVE(jsonargs["packet"][i]);
  2683. }
  2684. }
  2685. }
  2686. if(jsonargs["type"]=="customfakerecieve" && hostid == idofpacket && sandboxon && ((jsonargs["to"].includes(myid) && jsonargs["to"][0]!=-1) || (!jsonargs["to"].includes(myid) && jsonargs["to"][0]==-1))){
  2687. for(var i2 = 0;i2<jsonargs["packet"].length;i2++){
  2688. var keys = Object.keys(sandboxplayerids);
  2689. for(var i = 0;i<keys.length;i++){
  2690. if(jsonargs["packet"][i2].startsWith("42[7,")){
  2691. originalRecieve.call(this,{data:jsonargs["packet"][i2].replace("ID",keys[i].toString()).replace("CVALUE",playerids[keys[i]].movecount.toString())});
  2692. playerids[keys[i]].movecount+=1;
  2693. }
  2694. }
  2695. }
  2696. }
  2697. if(jsonargs["type"]=="commands"){
  2698. playerids[idofpacket].commands = true;
  2699. }
  2700. if(jsonargs["type"]=="sandboxid" && hostid == idofpacket && sandboxon && ((jsonargs["to"].includes(myid) && jsonargs["to"][0]!=-1) || (!jsonargs["to"].includes(myid) && jsonargs["to"][0]==-1))){
  2701. sandboxid = jsonargs["lastid"];
  2702. }
  2703. if(jsonargs["type"]=="sandboxon" && idofpacket == hostid){
  2704. if(!sandboxon){
  2705. displayInChat("This is a sandbox lobby.","#DA0808","#1EBCC1");
  2706. sandboxon = true;
  2707. }
  2708. }
  2709. if(jsonargs["type"]=="vote poll"){
  2710. from = jsonargs["from"];
  2711. if(Object.keys(playerids).includes(idofpacket.toString())){
  2712. from = playerids[idofpacket].userName;
  2713. }
  2714. if(typeof(jsonargs["vote"]) == 'number' && idofpacket!=hostid){
  2715. var now = Date.now();
  2716. if(ishost && pollactive[3].length>1 && pollactive[0]){
  2717. if(jsonargs["vote"]>=0 && jsonargs["vote"]<pollactive[3].length){
  2718. playerids[idofpacket].vote.poll = jsonargs["vote"];
  2719. }
  2720. }
  2721. else if(pollactive2[0] && pollactive2[2].length>1){
  2722. if(jsonargs["vote"]>=0 && jsonargs["vote"]<pollactive2[2].length){
  2723. playerids[idofpacket].vote.poll = jsonargs["vote"];
  2724. }
  2725. }
  2726. }
  2727.  
  2728. }
  2729. if(jsonargs["type"]=="poll end"){
  2730. from = jsonargs["from"];
  2731. if(Object.keys(playerids).includes(idofpacket.toString())){
  2732. from = playerids[idofpacket].userName;
  2733. }
  2734. var now = Date.now();
  2735. if(hostid == idofpacket && playerids[idofpacket].ratelimit.poll+5000<now){
  2736. playerids[idofpacket].ratelimit.poll = now;
  2737. var count = [0,0,0,0];
  2738. var keys = Object.keys(playerids);
  2739. for(var i = 0;i<keys.length;i++){
  2740. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive2[2].length-1){
  2741. count[playerids[keys[i]].vote.poll]++;
  2742. }
  2743. playerids[keys[i]].vote.poll = -1;
  2744. }
  2745. displayInChat("The poll ended.","#DA0808","#1EBCC1");
  2746. for(var i = 0;i<count.length;i++){
  2747. if(count[i]>1){
  2748. displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  2749. }
  2750. if(count[i]==1){
  2751. displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  2752. }
  2753. }
  2754. pollactive2 = [false,0,[]];
  2755. }
  2756.  
  2757. }
  2758. if(jsonargs["type"] == "video player" && idofpacket == hostid && ((jsonargs["to"].includes(myid) && jsonargs["to"][0]!=-1) || (!jsonargs["to"].includes(myid) && jsonargs["to"][0]==-1))){
  2759. changeJukeboxURL(jsonargs["url"],jsonargs["timestamp"]);
  2760. }
  2761. if(jsonargs["type"]=="poll" && idofpacket == hostid){
  2762. from = jsonargs["from"];
  2763. if(Object.keys(playerids).includes(idofpacket.toString())){
  2764. from = playerids[idofpacket].userName;
  2765. }
  2766. if(Array.isArray(jsonargs["poll"])){
  2767. var propperpoll = true;
  2768. var pollifproper = [];
  2769. if(jsonargs["poll"].length>5){
  2770. propperpoll = false;
  2771. }
  2772. else{
  2773. for(var i = 0;i<jsonargs["poll"].length;i++){
  2774. if(typeof(jsonargs["poll"][i]) == 'string'){
  2775. if(jsonargs["poll"][i].length>50){
  2776. propperpoll = false;
  2777. break;
  2778. }
  2779. else{
  2780. pollifproper.push(jsonargs["poll"][i]);
  2781. }
  2782. }
  2783. else{
  2784. propperpoll = false;
  2785. break;
  2786. }
  2787. }
  2788. }
  2789. if(propperpoll){
  2790. var now = Date.now();
  2791. var keys = Object.keys(playerids);
  2792. for(var i = 0;i<keys.length;i++){
  2793. playerids[keys[i]].vote.poll = -1;
  2794. }
  2795. pollactive2 = [true,now,pollifproper];
  2796. playerids[idofpacket].ratelimit.poll = now;
  2797. displayInChat(from+" started a poll:","#DA0808","#1EBCC1");
  2798. for(var i = 0;i<pollifproper.length;i++){
  2799. 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();';
  2800. displayInChat('<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+letters[i]+')</a>',"#DA0808","#1EBCC1",{sanitize:false}," "+pollifproper[i]);
  2801. }
  2802. }
  2803. }
  2804. }
  2805. if(jsonargs["type"]=="request mode" && playerids[idofpacket].ratelimit.mode+1000<Date.now()){
  2806. playerids[idofpacket].ratelimit.mode = Date.now();
  2807. from = jsonargs["from"];
  2808. if(Object.keys(playerids).includes(idofpacket.toString())){
  2809. from = playerids[idofpacket].userName;
  2810. }
  2811. var req_mode = jsonargs["mode"];
  2812. var req_mode2 = "";
  2813. if(req_mode){
  2814. if(req_mode == "b"){
  2815. req_mode2 = "Classic";
  2816. }
  2817. else if(req_mode == "sp"){
  2818. req_mode2 = "Grapple";
  2819. }
  2820. else if(req_mode == "ar"){
  2821. req_mode2 = "Arrows";
  2822. }
  2823. else if(req_mode == "ard"){
  2824. req_mode2 = "Death Arrows";
  2825. }
  2826. }
  2827. if(req_mode2){
  2828. 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+'")}';
  2829. displayInChat('> '+playerids[idofpacket].userName+' requests [<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+req_mode2+'</a>]',"#DA0808","#1EBCC1",{sanitize:false}," mode.");
  2830. }
  2831.  
  2832. }
  2833. if(jsonargs["type"]=="public key correction" && private_chat_public_key[0] == private_chat){
  2834. from = jsonargs["from"];
  2835. if(Object.keys(playerids).includes(idofpacket.toString())){
  2836. from = playerids[idofpacket].userName;
  2837. }
  2838. if(from == private_chat){
  2839. private_chat_public_key = [private_chat,jsonargs["public key"]];
  2840. var text = pmlastmessage;
  2841. var password = [];
  2842. for(var i = 0;i<10;i++){
  2843. password.push(Math.floor(Math.random()*100+50));
  2844. }
  2845. var text2 = [];
  2846. for(var i = 0;i<text.length ;i++){
  2847. text2.push(password[i%password.length]^text.slice(0,400).charCodeAt(i));
  2848. }
  2849. cc
  2850. }
  2851. }
  2852.  
  2853. }
  2854. else{
  2855. var now = Date.now();
  2856. if(playerids[idofpacket.toString()]){
  2857. playerids[idofpacket.toString()].lastmove = now;
  2858. }
  2859. if(idofpacket!=myid){
  2860. playerids[idofpacket.toString()].movecount+=1;
  2861. }
  2862. if(Math.abs(gameStartTimeStamp - (now-1000*jsonargs["f"]/30))>1000 && idofpacket!=myid){
  2863. gameStartTimeStamp = now-1000*jsonargs["f"]/30;
  2864. }
  2865. if(recording){
  2866. if(idofpacket.toString() == recordingid){
  2867. if(recordingdata.length == 0){
  2868. recordingdata.push([jsonargs["i"],jsonargs["f"]]);
  2869. }
  2870. recordingdata.push([jsonargs["i"],jsonargs["f"]-recordingdata[0][1]]);
  2871. }
  2872. }
  2873. if(ishost){
  2874. if(sandboxon && idofpacket == sandboxcopyme){
  2875. var jsonkeys = Object.keys(sandboxplayerids);
  2876. if(!jsonkeys.includes(sandboxcopyme.toString())){
  2877. var jsonargs2 = jsonargs;
  2878. for(var i = 0; i<jsonkeys.length;i++){
  2879. jsonargs2["c"] = playerids[jsonkeys[i]].movecount;
  2880. var packet = '42[7,'+jsonkeys[i].toString()+','+JSON.stringify(jsonargs2)+']';
  2881. RECIEVE(packet);
  2882. }
  2883. jsonargs2["c"] = "CVALUE";
  2884. jsonargs2 = JSON.stringify(jsonargs2).replace('"CVALUE"',"CVALUE");
  2885. SEND("42"+JSON.stringify([4,{"type":"customfakerecieve","from":username,"packet":['42[7,ID,'+jsonargs2+']'],to:[-1]}]));
  2886. }
  2887. }
  2888. for(var i = 0;i<disabledkeys.length;i++){
  2889. var get_keys_var = GET_KEYS(jsonargs["i"]);
  2890. if(get_keys_var[disabledkeys[i]]){
  2891. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden" && !killedids.includes(idofpacket)){
  2892. killedids.push(idofpacket);
  2893. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  2894. SEND('42[25,{"a":{"playersLeft":['+idofpacket.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  2895. RECIEVE('42[31,{"a":{"playersLeft":['+idofpacket.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  2896. break;
  2897. }
  2898. }
  2899. }
  2900. }
  2901. }
  2902. }
  2903.  
  2904. if(args.data.startsWith('42[4,')){
  2905. var jsonargs = JSON.parse(args.data.substring(2));
  2906. playerids[jsonargs[1]] = {"peerID":jsonargs[2],"userName":jsonargs[3],"guest":jsonargs[4],"level":jsonargs[5],"team":jsonargs[6],"avatar":jsonargs[7],"movecount":0,"ratelimit":{"pm":0,"mode":0,"team":0,"poll":0,"join":Date.now(),"style":0},"vote":{"poll":-1}};
  2907. if(jsonargs[2]!="sandbox"){
  2908. SEND('42[4,{"type":"commands"}]');
  2909. if(!Object.keys(allstyles).includes(jsonargs[3])){
  2910. allstyles[jsonargs[3]] = [0,0,0];
  2911. SEND("42"+JSON.stringify([4,{"type":"style","from":username,"style":allstyles[playerids[myid].userName]}]));
  2912. }
  2913. }
  2914. if(sandboxon){
  2915. var sandboxkeys = Object.keys(sandboxplayerids);
  2916. if(sandboxkeys.includes(jsonargs[1].toString())){
  2917. delete sandboxplayerids[jsonargs[1]];
  2918. }
  2919. if(jsonargs[2]=="sandbox"){
  2920. sandboxplayerids[jsonargs[1]] = jsonargs[3];
  2921. if(jsonargs[1]>sandboxid){
  2922. sandboxid = parseInt(jsonargs[1])+1;
  2923. }
  2924. }
  2925. else{
  2926. if(ishost){
  2927. SEND('42[4,{"type":"sandboxon"}]');
  2928. var sandboxkeys = Object.keys(sandboxplayerids);
  2929. var packets = [];
  2930. for(var i = 0;i<sandboxkeys.length;i++){
  2931. var p = playerids[sandboxkeys[i]];
  2932. var packet = '42'+JSON.stringify([4,sandboxkeys[i],p.peerID,p.userName,p.guest,p.level,p.team,p.avatar]);
  2933. packets.push(packet);
  2934. }
  2935. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":packets,to:[jsonargs[1]]}]));
  2936. SEND("42"+JSON.stringify([4,{"type":"sandboxid","from":username,"lastid":sandboxid,to:[jsonargs[1]]}]));
  2937. }
  2938. }
  2939. }
  2940. if(ishost){
  2941. if(jointext!="" && jsonargs[2]!="sandbox"){
  2942. chat(flag_manage(jointext.replaceAll("username",jsonargs[3])));
  2943. }
  2944. if(jointeam!=-1 && jsonargs[2]!="sandbox"){
  2945. SEND('42[26,{"targetID":'+jsonargs[1].toString()+',"targetTeam":'+jointeam.toString()+'}]');
  2946. setTimeout(function(){RECIEVE('42[18,'+jsonargs[1].toString()+','+jointeam.toString()+']');});
  2947. }
  2948. if(jukeboxplayer.src!="" && !jukeboxplayer.paused){
  2949. SEND("42"+JSON.stringify([4,{"type":"video player","from":username,"url":jukeboxplayerURL,"timestamp":Date.now()-jukeboxplayer.currentTime*1000,"to":[jsonargs[1]]}]));
  2950. }
  2951. if(freejoin){
  2952. var count = 0;
  2953. var keys = Object.keys(playerids);
  2954. for(var i = 0; i<keys.length;i++){
  2955. if(playerids[keys[i]].team!=0){
  2956. count++;
  2957. }
  2958. }
  2959. if(count <= 2 && jsonargs[6]!=0){
  2960. setTimeout(function(){
  2961. Gdocument.getElementById("newbonklobby_editorbutton").click();
  2962. Gdocument.getElementById("mapeditor_close").click();
  2963. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  2964. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  2965. if(transitioning == true){
  2966. canceled = true;
  2967. }
  2968. },150);
  2969. }
  2970. }
  2971. }
  2972.  
  2973. }
  2974. if(args.data.startsWith('42[5,')){
  2975. var jsonargs = JSON.parse(args.data.substring(2));
  2976. if(typeof(playerids[jsonargs[1]])!='undefined'){
  2977. delplayerids[jsonargs[1]] = playerids[jsonargs[1]];
  2978. delete allstyles[playerids[jsonargs[1]].userName];
  2979. delete playerids[jsonargs[1]];
  2980. }
  2981. if(sandboxon && typeof(sandboxplayerids[jsonargs[1]])!='undefined'){
  2982. delete sandboxplayerids[jsonargs[1]];
  2983. }
  2984. }
  2985. }}
  2986. return originalRecieve.call(this,args);
  2987. };
  2988.  
  2989. var originalClose = this.onclose;
  2990. this.onclose = function () {
  2991. if(bonkwssextra.includes(this)){
  2992. bonkwssextra.splice(bonkwssextra.indexOf(this),1)
  2993. }
  2994. else{
  2995. window.bonkwss = 0;
  2996. }
  2997. return originalClose.call(this);
  2998. }
  2999.  
  3000. }
  3001. return originalSend.call(this,args);
  3002. };
  3003.  
  3004. scope.SEND = function(args){
  3005. if(bonkwss!=0){
  3006. bonkwss.send(args);
  3007. }
  3008. };
  3009. scope.RECIEVE = function(args){
  3010. if(bonkwss!=0){
  3011. bonkwss.onmessage({data:args});
  3012. }
  3013. };
  3014.  
  3015.  
  3016.  
  3017. scope.dontswitch = false;
  3018. scope.username = 0;
  3019. scope.timedelay = 1400;
  3020. scope.ishost = false;
  3021. scope.checkboxhidden = true;
  3022. scope.quicki=0;
  3023. scope.defaultmode = "d";
  3024. scope.recmodebool = false;
  3025. scope.shuffle = false;
  3026. scope.startedinqp = false;
  3027. scope.instaqp = false;
  3028. scope.freejoin = false;
  3029. scope.recordedTimeStamp = 0;
  3030. scope.recordedId = 0;
  3031. scope.smartteams = false;
  3032. scope.beenKickedTimeStamp = 0;
  3033. scope.stopquickplay = 1;
  3034. scope.currentFrame = 0;
  3035. scope.text2speech = false;
  3036. scope.canceled = false;
  3037. scope.wintext = "";
  3038. scope.banned = [];
  3039. scope.transitioning = false;
  3040. scope.echo_list = [];
  3041. scope.echoAppend = "";
  3042. scope.message = "";
  3043. scope.private_chat = "";
  3044. scope.private_chat_public_key = ["",[0,0]];
  3045. scope.disabledkeys = [];
  3046. scope.actuallyhost = false;
  3047. scope.pmusers = [];
  3048. scope.pmlastmessage = "";
  3049. scope.pmuserstimestamp = 0;
  3050. scope.ignorepmlist = [];
  3051. scope.scroll = false;
  3052. scope.elem = Gdocument.getElementById("maploadwindowmapscontainer");
  3053. scope.npermissions = 1;
  3054. scope.space_flag = false;
  3055. scope.rcaps_flag = false;
  3056. scope.number_flag = false;
  3057. scope.reverse_flag = false;
  3058. scope.autocorrect = false;
  3059. scope.request_public_key_time_stamp = 0;
  3060. scope.sandboxcopyme = -1;
  3061. scope.recteams = false;
  3062. scope.chatheight = 128;
  3063. scope.onlykicked = false;
  3064. scope.killedids = [];
  3065. scope.jointext = "";
  3066. scope.randomchat = false;
  3067. scope.randomchatpriority = [0,[]];
  3068. scope.randomchatlastmessage = ["",0];
  3069. scope.afkkill = -1;
  3070. scope.tournament_mode = "";
  3071. scope.tournament_scores = [];
  3072. scope.tournament_in_and_out = {"in":[],"out":[]};
  3073. scope.echotext = "message";
  3074. scope.nextafter = 0;
  3075. scope.nextafterbuffer = -1;
  3076. scope.roundsperqp = 1;
  3077. scope.roundsperqp2 = 0;
  3078. scope.autorecord = false;
  3079. scope.poll = [];
  3080. scope.letters = ["A","B","C","D","E"];
  3081. scope.qppaused = false;
  3082. scope.FollowCam = false;
  3083. scope.autocam = false;
  3084. scope.gravity = 20;
  3085. scope.randomchat = false;
  3086. scope.randomchat_randomtimestamp = 0;
  3087. scope.randomchat_timestamp = 0;
  3088. scope.multiplier = 3.65;
  3089. scope.aimbot = false;
  3090. scope.recievedinitdata = false;
  3091. scope.heavybot = false;
  3092. scope.zoom = 1;
  3093. scope.prediction = 350;
  3094. scope.started = 0;
  3095. scope.holdheavy = 0;
  3096. scope.grappleheld = false;
  3097. scope.grappleheld2 = false;
  3098. scope.heavyheld = false;
  3099. scope.reverseqp = false;
  3100. scope.jointeam = -1;
  3101. scope.heavyheld2 = false;
  3102. scope.heavyid = 3;
  3103. scope.specialid = 0;
  3104. 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};
  3105. scope.leftRight = [37,39];
  3106. scope.upDown = [38,40];
  3107. scope.heavy = 88;
  3108. scope.special = 90;
  3109. scope.newzoom2 = 1;
  3110. scope.staystill = false;
  3111. scope.staystillpos = [0,0];
  3112. scope.zoom2 = 1;
  3113. scope.admins = [["LEGENDBOSS123",[0,0,0,0]],["iNeonz",[0,0,0,0]],["left paren",[0,0,0,0]]];
  3114.  
  3115. scope.autokickban = 0;
  3116. scope.ghostroomwss = -1;
  3117. scope.autokickbantimestamp = 0;
  3118. scope.getroomslastcheck = 0;
  3119. scope.causelag = false;
  3120. scope.causelag2 = 0;
  3121. scope.overideDate = [false,0];
  3122. scope.scale = 1;
  3123. scope.translating = [false,""];
  3124. scope.translating2 = [false,""];
  3125. scope.translatingkeys = {"english":"en","chinese":"zh","hindi":"hi","spanish":"es","portugese":"pt","french":"fr","arabic":"ar","russian":"ru","korean":"ko"};
  3126. scope.translate = function(text,fromL,toL) {
  3127. var fL = fromL || 'en';
  3128. var tL = toL || 'de';
  3129. var url = 'https://translate.googleapis.com/translate_a/single?client=gtx&sl='+ fL + "&tl=" + tL + "&dt=t&q=" + encodeURI(text);
  3130. var parseJSON = txt => JSON.parse(txt.split(',').map( x => x || 'null').join(',')) ;
  3131. var joinSnippets = json => json[0].map( x => x[0] ).join('');
  3132. return fetch(url).then(function(res){
  3133. return res.text();
  3134. }).then(function(text){
  3135. return joinSnippets(parseJSON(text));
  3136. });
  3137. };
  3138. scope.positive = function(angle){
  3139. if(angle<0){
  3140. angle += 2*Math.PI;
  3141. }
  3142. return angle%(Math.PI*2);
  3143. };
  3144. scope.angle_between = function(angle,angle2){
  3145. return Math.min(Math.abs(positive(angle)-positive(angle2)),Math.PI*2-Math.abs(positive(angle)-positive(angle2)));
  3146. };
  3147. scope.angle_between2 = function(angle,angle2){
  3148. if(angle_between(angle,angle2+Math.PI/2)<Math.PI/2){
  3149. return 1;
  3150. }
  3151. return -1;
  3152. };
  3153.  
  3154. scope.stringdistance = function(s1,s2){
  3155. s1 = s1.toLowerCase();
  3156. s2 = s2.toLowerCase();
  3157. var matrix = Array(s1.length+1);
  3158. for(var i = 0;i<matrix.length;i++){
  3159. matrix[i] = Array(s2.length+1);
  3160. matrix[i][0] = i;
  3161. }
  3162. for(var i = 0;i<matrix[0].length;i++){
  3163. matrix[0][i] = i;
  3164. }
  3165. for(var i = 1;i<s1.length+1;i++){
  3166. for(var i2 = 1;i2<s2.length+1;i2++){
  3167. if(s1[i-1]==s2[i2-1]){
  3168. matrix[i][i2] = matrix[i-1][i2-1];
  3169. }
  3170. else{
  3171. matrix[i][i2] = Math.min(matrix[i][i2-1],matrix[i-1][i2],matrix[i-1][i2-1])+1;
  3172. }
  3173. }
  3174. }
  3175. return matrix[s1.length][s2.length];
  3176. };
  3177. scope.closestWord = function(word){
  3178. if(word.length>20 || word.length<2){
  3179. return word;
  3180. }
  3181. var distances = [word.length,""];
  3182. var playernamelist = [];
  3183. var keys = Object.keys(playerids);
  3184. for(var i = 0;i<keys.length;i++){
  3185. playernamelist.push(playerids[keys[i]].userName);
  3186. }
  3187. var wordlist2 = playernamelist.concat(wordlist);
  3188. for(var i = 0;i<wordlist2.length;i++){
  3189. var distance = stringdistance(word,wordlist2[i]);
  3190. if(distance<=distances[0]){
  3191. distances[0] = distance;
  3192. distances[1] = wordlist2[i];
  3193. if(distance == 0){
  3194. return wordlist2[i];
  3195. }
  3196. }
  3197. };
  3198. if(distances[1] == ""){
  3199. return word;
  3200. }
  3201. return distances[1];
  3202. };
  3203.  
  3204.  
  3205.  
  3206. scope.replay = function(){
  3207. var frame = getCurrentFrame();
  3208. /*var replaycounter = 0;
  3209. while(1){
  3210. if(replaycounter != recordingdata.length-1){
  3211. for(var i = 0;i<recordingdata[replaycounter+1][1]-recordingdata[replaycounter][1];i++){
  3212. RECIEVE('42[7,'+myid+',{"i":'+recordingdata[replaycounter][0]+',"f":'+(frame+i+recordingdata[replaycounter][1]).toString()+',"c":'+playerids[myid].movecount+'}]');
  3213. playerids[myid].movecount+=1;
  3214. }
  3215. replaycounter+=1;
  3216. }
  3217. else{
  3218. break;
  3219. }
  3220. }*/
  3221. for(var i = 0;i<recordingdata.length;i++){
  3222. SEND('42[4,{"i":'+recordingdata[i][0]+',"f":'+(frame+recordingdata[i][1]).toString()+',"c":'+playerids[myid].movecount+'}]');
  3223. }
  3224. };
  3225. scope.presskeys = function(x,y){
  3226. if(!x.left && y.left){
  3227. fire("keydown",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  3228. }
  3229. else if(x.left && !y.left){
  3230. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  3231. }
  3232. if(!x.right && y.right){
  3233. fire("keydown",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  3234. }
  3235. else if(x.right && !y.right){
  3236. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  3237. }
  3238. if(!x.up && y.up){
  3239. fire("keydown",{"keyCode":upDown[0]},Gdocument.getElementById("gamerenderer"));
  3240. }
  3241. else if(x.up && !y.up){
  3242. fire("keyup",{"keyCode":upDown[0]},Gdocument.getElementById("gamerenderer"));
  3243. }
  3244. if(!x.down && y.down){
  3245. fire("keydown",{"keyCode":upDown[1]},Gdocument.getElementById("gamerenderer"));
  3246. }
  3247. else if(x.down && !y.down){
  3248. fire("keyup",{"keyCode":upDown[1]},Gdocument.getElementById("gamerenderer"));
  3249. }
  3250. if(!x.heavy && y.heavy){
  3251. fire("keydown",{"keyCode":heavy},Gdocument.getElementById("gamerenderer"));
  3252. }
  3253. else if(x.heavy && !y.heavy){
  3254. fire("keyup",{"keyCode":heavy},Gdocument.getElementById("gamerenderer"));
  3255. }
  3256. if(!x.special && y.special){
  3257. fire("keydown",{"keyCode":special},Gdocument.getElementById("gamerenderer"));
  3258. }
  3259. else if(x.special && !y.special){
  3260. fire("keyup",{"keyCode":special},Gdocument.getElementById("gamerenderer"));
  3261. }
  3262. };
  3263. scope.getplayerkeys = function(){
  3264. var keykeys = Object.keys(keyCodes);
  3265. var keyslist = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[1].children).slice(1);
  3266. var keyslist2 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[2].children).slice(1);
  3267. var keyslist3 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[3].children).slice(1);
  3268. var keyslist4 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[4].children).slice(1);
  3269. var keyslist5 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[5].children).slice(1);
  3270. var keyslist6 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[6].children).slice(1);
  3271. for(var i = 0;i<keyslist.length;i++){
  3272. if(keykeys.includes(keyslist[i].textContent)){
  3273. leftRight[0] = keyCodes[keyslist[i].textContent];
  3274. break;
  3275. }
  3276. else{
  3277. leftRight[0] = keyslist[i].textContent.charCodeAt(0);
  3278. break
  3279. }
  3280. }
  3281. for(var i = 0;i<keyslist2.length;i++){
  3282. if(keykeys.includes(keyslist2[i].textContent)){
  3283. leftRight[1] = keyCodes[keyslist2[i].textContent];
  3284. break;
  3285. }
  3286. else{
  3287. leftRight[1] = keyslist2[i].textContent.charCodeAt(0);
  3288. break
  3289. }
  3290. }
  3291. for(var i = 0;i<keyslist3.length;i++){
  3292. if(keykeys.includes(keyslist3[i].textContent)){
  3293. upDown[0] = keyCodes[keyslist3[i].textContent];
  3294. break;
  3295. }
  3296. else{
  3297. upDown[0] = keyslist3[i].textContent.charCodeAt(0);
  3298. break
  3299. }
  3300. }
  3301. for(var i = 0;i<keyslist4.length;i++){
  3302. if(keykeys.includes(keyslist4[i].textContent)){
  3303. upDown[1] = keyCodes[keyslist4[i].textContent];
  3304. break;
  3305. }
  3306. else{
  3307. upDown[1] = keyslist4[i].textContent.charCodeAt(0);
  3308. break
  3309. }
  3310. }
  3311. for(var i = 0;i<keyslist5.length;i++){
  3312. if(keykeys.includes(keyslist5[i].textContent)){
  3313. heavy = keyCodes[keyslist5[i].textContent];
  3314. break;
  3315. }
  3316. else{
  3317. heavy = keyslist5[i].textContent.charCodeAt(0);
  3318. break
  3319. }
  3320. }
  3321. for(var i = 0;i<keyslist6.length;i++){
  3322. if(keykeys.includes(keyslist6[i].textContent)){
  3323. special = keyCodes[keyslist6[i].textContent];
  3324. break;
  3325. }
  3326. else{
  3327. special = keyslist6[i].textContent.charCodeAt(0);
  3328. break
  3329. }
  3330. }
  3331. };
  3332. scope.changeJukeboxURL = function(url,timestamp = 0){
  3333. if(pipedurllist.length == 0){
  3334. displayInChat("The jukebox is still being set up.","#DA0808","#1EBCC1");
  3335. return;
  3336. }
  3337. if(url == ""){
  3338. jukeboxplayer.pause();
  3339. jukeboxplayer.src = '';
  3340. displayInChat("The jukebox has been paused.","#DA0808","#1EBCC1");
  3341. }
  3342. else if(url == jukeboxplayerURL && Date.now()-timestamp >= 2000){
  3343. jukeboxplayer.volume = jukeboxplayervolume/100;
  3344. displayInChat("The jukebox has been unpaused.","#DA0808","#1EBCC1",{sanitize:false});
  3345. jukeboxplayer.play();
  3346. jukeboxplayer.currentTime = (Date.now()-timestamp)/1000;
  3347. }
  3348. else{
  3349. var id = url.match(/youtu\.?be.com\/watch\?.*v=[a-z|A-Z|0-9|_|-]{11}/)[0].split("?v=");
  3350. id = id[id.length-1];
  3351. var loaded = false;
  3352. var loaded2 = 0;
  3353. for(var inst = 0;inst<pipedindexes.length;inst++){
  3354. checkJukeboxStream(pipedindexes[inst],id).then(function(value){
  3355. loaded2+=1;
  3356. if(value!=-1 && !loaded){
  3357. loaded = true;
  3358. jukeboxplayer.src = value[0];
  3359. jukeboxplayer.volume = jukeboxplayervolume/100;
  3360. jukeboxplayerURL = url;
  3361. jukeboxplayer.oncanplaythrough = function(){
  3362. displayInChat("The jukebox has been changed to: ","#DA0808","#1EBCC1",{sanitize:false},url);
  3363. displayInChat("Jukebox is now playing: "+value[1]+" by "+value[2]+".","#DA0808","#1EBCC1");
  3364. jukeboxplayer.play();
  3365. jukeboxplayer.currentTime = (Date.now()-timestamp)/1000;
  3366. jukeboxplayer.oncanplaythrough = null;
  3367. };
  3368. jukeboxplayer.onerror = function(){
  3369. displayInChat("The jukebox failed to load. Please try again.","#DA0808","#1EBCC1");
  3370. };
  3371. }
  3372. });
  3373. }
  3374. new Promise(function(r){
  3375. var interv = setInterval(function(){
  3376. if(loaded2>=pipedindexes.length){
  3377. if(!loaded){
  3378. displayInChat("The jukebox failed to load. Please try again.","#DA0808","#1EBCC1");
  3379. }
  3380. clearInterval(interv);
  3381. }
  3382. },60)
  3383. });
  3384. }
  3385. };
  3386. scope.help = ["All the commands are:","/help","/?","/advhelp [command]","/space","/rcaps","/number","/autocorrect","/translateto [language]","/translate [language]","/randomchat","/speech","/savedroom","/clearsavedroom","/style [R G B]","/followcam","/autocam","/zoom [in/out/reset]","/xray","/aimbot","/heavybot","/still","/echo [username]","/clearecho","/remove [username]","/echotext [text]","/chatw [username]","/msg [text]","/ignorepm [username]","/record [username]","/replay","/stoprecord","/loadrecording [text]","/saverecording [text]","/delrecording [text]","/volume [0-100]","/pmusers","/pollstat","/lobby","/score","/team [letter]","/mode [mode]","/scroll","/hidechat","/showchat","/notify","/stopnotify","/support","Host commands are:","/startqp","/stopqp","/pauseqp","/revqp","/next","/nextafter [seconds]","/previous","/shuffle","/instaqp","/jukebox [link]","/pausejukebox","/resetjukebox","/playjukebox","/freejoin","/recmode","/recteam","/defaultmode [mode]","/start","/balanceA [number]","/moveA [letter]","/moveT [letter] [letter]","/rounds [number]","/roundsperqp [number]","/disablekeys [keys]","/jointext [text]","/jointeam [letter]","/wintext [text]","/autorecord","/afkkill [number]","/ban [username]","/kill [username]","/resetpoll","/addoption [text]","/deloption [letter]","/startpoll [seconds]","/endpoll","/autokick","/autoban","/sandbox","Sandbox commands are:","/addplayer [number]","/addname [text]","/delplayer [number]","/copy [username]","Debugging commands are:","/eval [code]","/debugger","Hotkeys are:","Alt L","Alt B","Alt C","Alt I","Alt <","Alt >","Alt N","Alt V","Alt G","Alt H","Alt J","Alt W","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"];
  3387.  
  3388. scope.adv_help = {"help":"Shows all command names.",
  3389. "?":"Shows all command names.",
  3390. "advhelp":"Shows a command in detail.",
  3391. "space":"Toggles space. When space is on, whatever you type will be spaced apart.",
  3392. "rcaps":"Toggles rcaps. When rcaps is on, each letter will randomly get capitalized.",
  3393. "number":"Toggles number. When number is on, 'a' becomes 4, 'e' becomes 3, 's' becomes 5, 'o' becomes 0, 'l' and 'i' become 1.",
  3394. "speech":"Turns on text to speech for the chat.",
  3395. "savedroom":"Displays all the rooms you have saved, you can remove individual ones from the saved rooms by clicking \"Remove\".",
  3396. "clearsavedroom":"Clears all the saved rooms.",
  3397. "echo":"Echoes a username. It copies the username's chat messages.",
  3398. "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.",
  3399. "remove":"Removes username from echo list. You will not echo that username anymore.",
  3400. "clearecho":"Clears echo list. You will not echo anyone anymore.",
  3401. "chatw":"It private chats with username. Type /msg to message that username.",
  3402. "msg":"Messages with what username you are chatting with. Type /chatw to chat with a username.",
  3403. "ignorepm":"Ignores the username's private chat messages. To unignore, type '/ignorepm [username]'.",
  3404. "pmusers":"Dispays who you can private chat with.",
  3405. "pollstat":"Displays the current poll and its votes.",
  3406. "eval":"Evaluates code. Only use this if you are experienced in javascript.",
  3407. "debugger":"Opens debugger.",
  3408. "style":"Change the color of your username, level, and background. For example, '/style 255 0 0' will make your username red.",
  3409. "translate":"Translates peoples texts to the chosen language.",
  3410. "translateto":"You will now speak the chosen language.",
  3411. "autocorrect":"Fixes spelling mistakes.",
  3412. "randomchat":"Spams random chat messages from the past.",
  3413. "lobby":"Makes lobby visible when you are ingame. Type '/lobby' again to close lobby.",
  3414. "score":"Displays the current score while ingame. Type '/score' again to hide the score.",
  3415. "team":"Joins a specific team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  3416. "scroll":"Toggles a scrollbar in ingame chat.",
  3417. "followcam":"Enables follow camera. Your character will be centered on the screen.",
  3418. "autocam":"Zooms in/out enough for you to see everyone on the screen.",
  3419. "zoom":"Zooms in, out, or resets zoom.",
  3420. "xray":"Removes all shapes that don't have a shadow. This means all non-physics shapes will be hidden.",
  3421. "aimbot":"Toggles aimbot. Aimbot will aim for you in arrows or death arrows mode.",
  3422. "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.",
  3423. "still":"Saves your position, and tries to reach it constantly. This is useful in parkour if you want to go afk. Use Alt+W instead, because this feature will fail when you are in chat.",
  3424. "lagbot":"Makes your movements very laggy. Type '/lagbot 0' to turn it off.",
  3425. "hidechat":"Hides ingame chat. Type '/showchat' to show it again.",
  3426. "showchat":"Shows ingame chat. '/hidechat' hides the chat.",
  3427. "notify":"You will be notified if a person types @username",
  3428. "stopnotify":"You will not be notified if a person types @username",
  3429. "support":"Displays all the people who have supported this mod.",
  3430. "startqp":"Starts cycling maps in your map menu.",
  3431. "stopqp":"Stops cycling maps in your map menu.",
  3432. "revqp":"Reverses the order of quickplay. '/next', '/previous' will be inverted.",
  3433. "pauseqp":"Only pauses or unpauses the quickplay cycle due to round end. '/next', '/previous' still work. Type 'pauseqp' to unpause quickplay.",
  3434. "next":"Skips the map. Usable only with '/startqp'.",
  3435. "nextafter":"Skips the map if no one is able to win/draw within a certain amount of time.",
  3436. "previous":"Goes to previous map. Usable only with '/startqp'.",
  3437. "shuffle":"Makes quickplay play random maps instead of in order.",
  3438. "freejoin":"Toggles freejoin. If freejoin is on, starts the game instantly if there are 1 or less players currently playing.",
  3439. "recmode":"In quickplay, it switches mode to recommended mode, according to editor.",
  3440. "recteam":"In quickplay, it sorts people into teams when teams are necessary.",
  3441. "defaultmode":"Switches mode to defaultmode if there is no recmode.",
  3442. "start":"Starts game instantly.",
  3443. "instaqp":"Rounds will instantly start without a countdown.",
  3444. "balanceA":"Balances everyone with balance number.",
  3445. "moveA":"Sets everyones team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  3446. "jointeam":"Sets the team of anyone who joins. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  3447. "moveT":"Sets everyone in one team to another team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  3448. "rounds":"Sets rounds to win.",
  3449. "replay":"Replays the movements that were recorded",
  3450. "record":"Records movements of the username",
  3451. "delrecording":"Deletes the recording with the name.",
  3452. "saverecording":"Saves the recording with the name.",
  3453. "loadrecording":"Loads the recording with the name. Type '/replay' to replay it.",
  3454. "stoprecord":"Stops recording the player. Type '/saverecording [text]' to save it.",
  3455. "jukebox":"Sets the jukebox to a link. That link will play for everyone who has this mod.",
  3456. "volume":"Sets the volume of the jukebox.",
  3457. "pausejukebox":"If the jukebox is playing, it pauses it.",
  3458. "resetjukebox":"Resets the jukebox, so it starts from the very beginning.",
  3459. "playjukebox":"If the jukebox is paused, it plays it.",
  3460. "roundsperqp":"After that many rounds, the map will change. Normally, the map will change after 1 round.",
  3461. "autorecord":"After a round ends, automatically records the last 15 seconds.",
  3462. "mode":"If host, switches mode. Otherwise, it requests the host to switch mode, as long as the host has this mod.",
  3463. "disablekeys":"If anyone presses a disabled key, they get killed. Key options: left right up down heavy special.",
  3464. "jointext":"Chats the jointext whenever someone joins. \"username\" will get replaced by the joining person's username.",
  3465. "wintext":"Chats the wintext whenever someone wins. \"username\" will get replaced by the winning person's username.",
  3466. "afkkill":"If a person stays afk for that many seconds, they get automatically killed.",
  3467. "ban":"Bans username from lobby. If they rejoin, it automatically bans.",
  3468. "kill":"Kills the person ingame.",
  3469. "resetpoll":"Clears the poll.",
  3470. "addoption":"Adds the option to the poll. You can only have 4 maximum options. Type '/deloption [letter]' to remove an option.",
  3471. "deloption":"Removes the option with that letter.",
  3472. "startpoll":"Starts a poll that lasts for at least 10 seconds. Type '/endpoll' to end it early.",
  3473. "endpoll":"Ends the poll early if the poll lasted for at least 10 seconds.",
  3474. "addplayer":"In sandbox, it adds bots.",
  3475. "addname":"Adds a bot with a specific name. If that name already exists, it will copy the skin of that player to the bot.",
  3476. "delplayer":"In sandbox, it deletes bots.",
  3477. "copy":"In sandbox, it makes all bots copy the username's movements.",
  3478. "sandbox":"Turns a normal lobby into a sandbox lobby. You cannot turn a sandbox lobby back into a normal lobby.",
  3479. "autokick":"Automatically kicks everyone who is not using this mod.",
  3480. "autoban":"Automatically bans everyone who is not using this mod.",
  3481. "Alt L":"Makes lobby visible when you are ingame. Press Alt L again to close lobby.",
  3482. "Alt C":"Hides ingame chat. Press Alt C again to show ingame chat.",
  3483. "Alt S":"Starts game instantly.",
  3484. "Alt T":"Toggles teams.",
  3485. "Alt N":"Enables follow camera. Your character will be centered on the screen.",
  3486. "Alt G":"Zooms in.",
  3487. "Alt H":"Resets zoom.",
  3488. "Alt J":"Zooms out.",
  3489. "Alt Y":"Enables xray. Removes all shapes that don't have a shadow. This means all non-physics shapes will be hidden.",
  3490. "Alt E":"Toggles editor.",
  3491. "Alt K":"Exits ingame and returns to lobby.",
  3492. "Alt M":"Switches modes.",
  3493. "Alt V":"Toggles autocam. Autocam zooms in/out enough for you to see everyone on the screen.",
  3494. "Alt Q":"Toggles quickplay.",
  3495. "Alt B":"Displays the current score while ingame. Press Alt B again to hide the score.",
  3496. "Alt A":"Skips the map if quickplay is on.",
  3497. "Alt D":"Goes to previous map if quickplay is on.",
  3498. "Alt F":"Toggles freejoin. If freejoin is on, starts the game instantly if there are 1 or less players currently playing.",
  3499. "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.",
  3500. "Alt U":"Toggles aimbot. Aimbot will aim for you in arrows or death arrows mode.",
  3501. "Alt P":"Only pauses or unpauses the quickplay cycle due to round end. '/next', '/previous' still work. Type 'pauseqp' to unpause quickplay.",
  3502. "Alt R":"In quickplay, it switches mode to recommended mode, according to editor.",
  3503. "Alt I":"Opens debugger.",
  3504. "Alt W":"Saves your position, and tries to reach it constantly. This is useful in parkour if you want to go afk.",
  3505. "Alt <":"Lowers ingame chat height.",
  3506. "Alt >":"Highers ingame chat height."
  3507. };
  3508. scope.displayadvhelp = function(command){
  3509. displayInChat(adv_help[command],"#009398","#DA0808",{sanitize:true},"",true);
  3510. };
  3511. scope.changemode = function(mode){
  3512. SEND('42[20,{"ga":"b","mo":"'+mode+'"}]');
  3513. RECIEVE('42[26,"b","'+mode+'"]');
  3514. };
  3515. Gdocument.getElementById("ingamechatcontent").style["pointer-events"]="all";
  3516. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  3517. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  3518. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  3519.  
  3520. document.getElementById('adboxverticalCurse').style["display"] = "none";
  3521. document.getElementById('adboxverticalleftCurse').style["display"] = "none";
  3522. elem.onclick=function(e){
  3523. if(stopquickplay==0 && ishost == true && e.isTrusted == true){
  3524. quicki = (Array.from(e.target.parentElement.parentNode.children).indexOf(e.target.parentNode)-1)%(Gdocument.getElementById("maploadwindowmapscontainer").children.length);
  3525. if(reverseqp){
  3526. quicki+=2;
  3527. quicki = quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length);
  3528. }
  3529. }
  3530. };
  3531. scope.getCurrentFrame = function(){
  3532. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  3533. return currentFrame;
  3534. };
  3535. scope.urlify = function(text) {
  3536. if(!Gdocument.getElementById('bl_Menu')){
  3537. return text.replace(/[(http(s)?):\/\/(www\.)?a-zA-Z0-9@:;%.\-_\+~#=]{2,256}\.[\-a-z]{2,6}\b([\-a-zA-Z0-9@:;%_\+.~#?&//=]*)/ig, function(url) {
  3538. var extratext = "";
  3539. var matches = url.match(/youtu\.?be.com\/watch\?.*v=[a-z|A-Z|0-9|_|-]{11}/);
  3540. if(matches){
  3541. var button = Gdocument.createElement("a");
  3542. button.style["color"] = "green";
  3543. button.textContent = "Play";
  3544. button.href = "javascript:void(0)";
  3545. button.setAttribute("onclick",function(){
  3546. if(Gwindow.ishost){
  3547. Gwindow.SEND("42"+JSON.stringify([4,{"type":"video player","from":Gwindow.username,"url":"URL INSERT HERE","timestamp":Gwindow.Date.now()+2000,"to":[-1]}]));
  3548. Gwindow.displayInChat("Jukebox is loading... Please wait a few seconds.","#DA0808","#1EBCC1");
  3549. Gwindow.changeJukeboxURL("URL INSERT HERE",Gwindow.Date.now()+2000);
  3550. }
  3551. else{
  3552. Gwindow.displayInChat("You need to be host.","#DA0808","#1EBCC1");
  3553. }
  3554. });
  3555. button.attributes["onclick"].nodeValue = button.attributes["onclick"].nodeValue.slice(11,-1).replaceAll("URL INSERT HERE","https://www."+matches[0]);
  3556. var extratext = ' ['+button.outerHTML+']';
  3557. }
  3558. if(url.startsWith('https://') || url.startsWith('http://')){return '<a href="' + url + '" target="_blank" style = "color:orange">' + sanitize(url) + '</a>'+extratext;}
  3559. else{return '<a href="https://' + url + '" target="_blank" style = "color:orange">' + sanitize(url) + '</a>'+extratext;}
  3560. })}return text;
  3561. };
  3562. scope.fire = function(type,options,d = Gdocument){
  3563. var event= document.createEvent("HTMLEvents");
  3564. event.initEvent(type,true,false);
  3565. for(var p in options){
  3566. event[p]=options[p];
  3567. }
  3568. d.dispatchEvent(event);
  3569. };
  3570.  
  3571. scope.chat = function(message){
  3572. SEND('42[10,{"message":'+JSON.stringify(message)+'}]');
  3573. };
  3574. scope.chat2 = function(message,enteragain=false){
  3575. mess = Gdocument.getElementById("newbonklobby_chat_input").value;
  3576. mess2 = Gdocument.getElementById("ingamechatinputtext").value;
  3577. Gdocument.getElementById("newbonklobby_chat_input").value = message;
  3578. Gdocument.getElementById("ingamechatinputtext").value = message;
  3579. fire("keydown",{keyCode:13});
  3580. if(!enteragain){
  3581. fire("keydown",{keyCode:13});
  3582. }
  3583. Gdocument.getElementById("newbonklobby_chat_input").value = mess;
  3584. Gdocument.getElementById("ingamechatinputtext").value = mess2;
  3585. };
  3586. scope.sanitize = function(message){
  3587. return message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;');
  3588. };
  3589. scope.displayInChat = function(message, LobbyColor, InGameColor, options, message2, BringDown) {
  3590. options = options ?? {};
  3591. BringDown = BringDown ?? false;
  3592. message2 = message2 ?? "";
  3593. LobbyColor = LobbyColor ?? "#8800FF";
  3594. InGameColor = InGameColor ?? "#AA88FF";
  3595. var A = Gdocument.createElement("div");
  3596. var B = Gdocument.createElement("span");
  3597. B.className = "newbonklobby_chat_status";
  3598. B.style.color = LobbyColor;
  3599. A.appendChild(B);
  3600. B.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  3601. B.innerHTML+=urlify(message2.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;'));
  3602. var C = Gdocument.createElement("div");
  3603. var D = Gdocument.createElement("span");
  3604. D.style.color = InGameColor;
  3605. C.appendChild(D);
  3606. D.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  3607. D.innerHTML+=urlify(message2.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;'));
  3608. var a = BringDown;
  3609. if(Gdocument.getElementById("newbonklobby_chat_content").clientHeight + Gdocument.getElementById("newbonklobby_chat_content").scrollTop >= Gdocument.getElementById("newbonklobby_chat_content").scrollHeight-1) {
  3610. a = true;
  3611. }
  3612. var b = BringDown;
  3613. if(Gdocument.getElementById("ingamechatcontent").clientHeight + Gdocument.getElementById("ingamechatcontent").scrollTop >= Gdocument.getElementById("ingamechatcontent").scrollHeight-1) {
  3614. b = true;
  3615. }
  3616. A.style["parsed"] = true;
  3617. C.style["parsed"] = true;
  3618. Gdocument.getElementById("newbonklobby_chat_content").appendChild(A);
  3619. Gdocument.getElementById("ingamechatcontent").appendChild(C);
  3620. if (a) { Gdocument.getElementById("newbonklobby_chat_content").scrollTop = Gdocument.getElementById("newbonklobby_chat_content").scrollHeight;};
  3621. if (b) { Gdocument.getElementById("ingamechatcontent").scrollTop = Gdocument.getElementById("ingamechatcontent").scrollHeight;};
  3622. if(Gdocument.getElementById("newbonklobby_chat_input").style["pointer-events"]!="auto" && !Gdocument.getElementById("ingamechatinputtext").classList.value.includes("ingamechatinputtextbg")){
  3623. chat2("");
  3624. }
  3625. };
  3626.  
  3627. scope.lobby = function(){
  3628. if (Gdocument.getElementById("newbonklobby").style["display"]=="none"){
  3629.  
  3630. Gdocument.getElementById("newbonklobby_editorbutton").click();
  3631. Gdocument.getElementById("mapeditor_close").click();
  3632. if(Gdocument.getElementById("newbonklobby_playerbox_elementcontainer").children.length+Gdocument.getElementById("newbonklobby_specbox_elementcontainer").children.length-3>0){
  3633. Gdocument.getElementById("newbonklobby").style["z-index"]=1;
  3634. Gdocument.getElementById("maploadwindowcontainer").style["z-index"]=1;
  3635. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=1;
  3636. Gdocument.getElementById("pretty_top").style["z-index"]=3;
  3637. Gdocument.getElementById("settingsContainer").style["z-index"]=3;
  3638. Gdocument.getElementById("leaveconfirmwindow").style["z-index"]=3;
  3639. Gdocument.getElementById("hostleaveconfirmwindow").style["z-index"]=3;
  3640. debuggermenu.style["z-index"] = 2;
  3641. }
  3642. else{
  3643. Gdocument.getElementById("newbonklobby").style["opacity"]=0;
  3644. Gdocument.getElementById("newbonklobby").style["display"]="none";
  3645. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
  3646.  
  3647. }
  3648.  
  3649. }
  3650. else if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  3651. Gdocument.getElementById("newbonklobby").style["opacity"]=0;
  3652. Gdocument.getElementById("newbonklobby").style["display"]="none";
  3653. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
  3654.  
  3655. }
  3656. };
  3657.  
  3658. scope.lastmessage = function(){
  3659. if(Gdocument.getElementById("newbonklobby_chat_content").children.length!=0){
  3660. var lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  3661. var lm2 = "";
  3662. for(var i = 0; i<lm.length;i++){
  3663. lm2+=" "+lm[i].textContent.trim();
  3664. }
  3665. lm2 = lm2.trim();
  3666. if(lm2.startsWith("*")){
  3667. return lm2;
  3668. }
  3669. }
  3670. if(Gdocument.getElementById("ingamechatcontent").children.length!=0){
  3671. var lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  3672. var lm2 = "";
  3673. for(var i = 0; i<lm.length;i++){
  3674. lm2+=" "+lm[i].textContent.trim();
  3675. }
  3676. return lm2.trim();
  3677. }
  3678. return "";
  3679.  
  3680. };
  3681. scope.map = function(e,t=timedelay){
  3682. if(e<0){
  3683. displayInChat("There is no previous map.","#DA0808","#1EBCC1");
  3684. quicki = 0;
  3685. return;
  3686. }
  3687. if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
  3688. displayInChat("Click the maps button.","#DA0808","#1EBCC1");
  3689. return;
  3690. }
  3691.  
  3692. setTimeout(function(){if(!canceled){
  3693. startedinqp = true;
  3694. if(roundsperqp2>=roundsperqp){
  3695. roundsperqp2 = 0;
  3696. }
  3697. Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
  3698. Gdocument.getElementById("newbonklobby_editorbutton").click();
  3699. if(recmodebool && ishost){
  3700. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  3701. if(mode == "" && defaultmode!="d"){
  3702. mode = defaultmode;
  3703. }
  3704. if(mode != ""){
  3705. RECIEVE('42[26,"b","'+mode+'"]');
  3706. }
  3707. }
  3708. var displayblock = Gdocument.getElementById("newbonklobby").style["display"] == "block";
  3709. Gdocument.getElementById("mapeditorcontainer").style["display"] = "none";
  3710. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  3711. if(displayblock){
  3712. Gdocument.getElementById("newbonklobby").style["display"] = "block";
  3713. }
  3714. Gdocument.getElementById("mapeditor_midbox_testbutton").click();}
  3715. canceled = false;
  3716. transitioning = false;
  3717. },t);
  3718.  
  3719. };
  3720.  
  3721. scope.gotonextmap = function(e){
  3722. if(e<0){
  3723. displayInChat("There is no previous map.","#DA0808","#1EBCC1");
  3724. quicki = 0;
  3725. return;
  3726. }
  3727. if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
  3728. displayInChat("Click the maps button.","#DA0808","#1EBCC1");
  3729. return;
  3730. }
  3731. Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
  3732. Gdocument.getElementById("newbonklobby_editorbutton").click();
  3733. if(recmodebool && ishost){
  3734. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  3735. if(mode == "" && defaultmode!="d"){
  3736. mode = defaultmode;
  3737. }
  3738. if(mode != ""){
  3739. RECIEVE('42[26,"b","'+mode+'"]');
  3740. }
  3741. }
  3742. startedinqp = true;
  3743. if(roundsperqp2>=roundsperqp){
  3744. roundsperqp2 = 0;
  3745. }
  3746. var displayblock = Gdocument.getElementById("newbonklobby").style["display"] == "block";
  3747. Gdocument.getElementById("mapeditorcontainer").style["display"] = "none";
  3748. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  3749. if(displayblock){
  3750. Gdocument.getElementById("newbonklobby").style["display"] = "block";
  3751. }
  3752. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  3753. Gdocument.getElementById("newbonklobby").style["visibility"] = "visible";
  3754. };
  3755. scope.commandhandle = function(chat_val){
  3756. if (chat_val.substring(1,6)=="echo " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  3757. if (chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"")==username){
  3758. displayInChat("You cannot echo yourself.","#DA0808","#1EBCC1");
  3759. return "";
  3760. }
  3761. else if (echo_list.indexOf(chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',""))===-1) {
  3762.  
  3763. echo_list.push(chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',""));
  3764. displayInChat(chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"") + " is being echoed.","#DA0808","#1EBCC1");
  3765. return "";
  3766. }
  3767. else{
  3768. displayInChat(chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"") + " is already being echoed.","#DA0808","#1EBCC1");
  3769. return "";
  3770. }
  3771. }
  3772. else if (chat_val.substring(1,8)=="remove " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  3773. if (echo_list.indexOf(chat_val.substring(7).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',""))!==-1){
  3774. echo_list.splice(echo_list.indexOf(chat_val.substring(7).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"")),1);
  3775. displayInChat(chat_val.substring(7).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"")+" is not being echoed.","#DA0808","#1EBCC1");
  3776. return "";
  3777. }
  3778. else{
  3779. displayInChat("You cannot remove someone that you didn't echo.","#DA0808","#1EBCC1");
  3780. return "";
  3781. }
  3782.  
  3783. }
  3784. else if (chat_val.substring(1,10)=="echotext " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  3785. echotext = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  3786. displayInChat("Set echotext as: "+echotext,"#DA0808","#1EBCC1");
  3787. displayInChat("Type '/echotext' to reset echotext.","#DA0808","#1EBCC1");
  3788. return "";
  3789.  
  3790. }
  3791. else if (chat_val.substring(1,9)=="echotext"){
  3792. echotext = "message";
  3793. displayInChat("Reset echotext.","#DA0808","#1EBCC1");
  3794. return "";
  3795.  
  3796. }
  3797. else if (chat_val.substring(1,10)=="clearecho"){
  3798. echo_list = [];
  3799. displayInChat("Cleared the echo list.","#DA0808","#1EBCC1");
  3800. return "";
  3801. }
  3802. else if (chat_val.substring(1,11)=="randomchat"){
  3803. if(randomchat == true){
  3804. displayInChat("Random chat is now off.","#DA0808","#1EBCC1");
  3805. randomchat = false;
  3806. }
  3807. else{
  3808. displayInChat("Random chat is now on.","#DA0808","#1EBCC1");
  3809. randomchat = true;
  3810. }
  3811. return "";
  3812. }
  3813. else if (chat_val.substring(1,12)=="autocorrect"){
  3814. if(autocorrect == true){
  3815. displayInChat("Autocorrect is now off.","#DA0808","#1EBCC1");
  3816. autocorrect = false;
  3817. }
  3818. else{
  3819. displayInChat("Autocorrect is now on.","#DA0808","#1EBCC1");
  3820. autocorrect = true;
  3821. }
  3822. return "";
  3823. }
  3824. else if (chat_val.substring(1,13)=="translateto " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  3825. var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '').toLowerCase();
  3826. var keys = Object.keys(translatingkeys);
  3827. if(keys.includes(text)){
  3828. translating2 = [true,translatingkeys[text]];
  3829. displayInChat("You will now speak the "+text+" language.","#DA0808","#1EBCC1");
  3830. }
  3831. else{
  3832. displayInChat("Invalid language. Here are the current language options:","#DA0808","#1EBCC1");
  3833. for(var i = 0;i<keys.length;i++){
  3834. displayInChat(keys[i],"#DA0808","#1EBCC1");
  3835. }
  3836. }
  3837. return "";
  3838. }
  3839. else if (chat_val.substring(1,12)=="translateto"){
  3840. translating2 = [false,""];
  3841. displayInChat("You will not speak another language anymore.","#DA0808","#1EBCC1");
  3842. return "";
  3843. }
  3844. else if (chat_val.substring(1,11)=="translate " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  3845. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '').toLowerCase();
  3846. var keys = Object.keys(translatingkeys);
  3847. if(keys.includes(text)){
  3848. translating = [true,translatingkeys[text]];
  3849. displayInChat("Translator has been set to the "+text+" language.","#DA0808","#1EBCC1");
  3850. }
  3851. else{
  3852. displayInChat("Invalid language. Here are the current language options:","#DA0808","#1EBCC1");
  3853. for(var i = 0;i<keys.length;i++){
  3854. displayInChat(keys[i],"#DA0808","#1EBCC1");
  3855. }
  3856. }
  3857. return "";
  3858. }
  3859. else if (chat_val.substring(1,10)=="translate"){
  3860. translating = [false,""];
  3861. displayInChat("Translator has been turned off.","#DA0808","#1EBCC1");
  3862. return "";
  3863. }
  3864. else if (chat_val.substring(1,6)=="space"){
  3865. if(space_flag == true){
  3866. displayInChat("Space is now off.","#DA0808","#1EBCC1");
  3867. space_flag = false;
  3868. }
  3869. else{
  3870. displayInChat("Space is now on.","#DA0808","#1EBCC1");
  3871. space_flag = true;
  3872. }
  3873. return "";
  3874. }
  3875. else if (chat_val.substring(1,6)=="rcaps"){
  3876. if(rcaps_flag == true){
  3877. displayInChat("Rcaps is now off.","#DA0808","#1EBCC1");
  3878. rcaps_flag = false;
  3879. }
  3880. else{
  3881. displayInChat("Rcaps is now on.","#DA0808","#1EBCC1");
  3882. rcaps_flag = true;
  3883. }
  3884.  
  3885. return "";
  3886. }
  3887. else if (chat_val.substring(1,7)=="number"){
  3888. if(number_flag == true){
  3889. displayInChat("Number is now off.","#DA0808","#1EBCC1");
  3890. number_flag = false;
  3891. }
  3892. else{
  3893. displayInChat("Number is now on.","#DA0808","#1EBCC1");
  3894. number_flag = true;
  3895. }
  3896.  
  3897. return "";
  3898. }
  3899. else if (chat_val.substring(1,8)=="reverse"){
  3900. if(reverse_flag == true){
  3901. displayInChat("Reverse is now off.","#DA0808","#1EBCC1");
  3902. reverse_flag = false;
  3903. }
  3904. else{
  3905. displayInChat("Reverse is now on.","#DA0808","#1EBCC1");
  3906. reverse_flag = true;
  3907. }
  3908.  
  3909. return "";
  3910. }
  3911. else if (chat_val.substring(1,7)=="speech"){
  3912. if(text2speech == true){
  3913. displayInChat("Text to speech is now off.","#DA0808","#1EBCC1");
  3914. text2speech = false;
  3915. }
  3916. else{
  3917. displayInChat("Text to speech is now on.","#DA0808","#1EBCC1");
  3918. text2speech = true;
  3919. }
  3920.  
  3921. return "";
  3922. }
  3923. else if (chat_val.substring(1,6)=="eval " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  3924. var ev = "";
  3925. try{
  3926. ev = eval(chat_val.substring(6).replace(/^\s+|\s+$/g, ''));
  3927. }
  3928. catch(e){
  3929. displayInChat(e.message,"#DA0808","#1EBCC1");
  3930. }
  3931. try{
  3932. displayInChat(ev.toString(),"#DA0808","#1EBCC1");
  3933. }
  3934. catch{
  3935. }
  3936.  
  3937. return "";
  3938.  
  3939. }
  3940. else if (chat_val.substring(1,10)=="savedroom"){
  3941. if(savedrooms.length == 0){
  3942. displayInChat("You do not have any saved rooms.","#DA0808","#1EBCC1");
  3943. return "";
  3944. }
  3945. else{
  3946. var keys = Object.keys(savedroomsdata);
  3947. for(var i = 0;i<keys.length;i++){
  3948. var code = 'this.parentElement.remove();delete Gwindow.savedroomsdata["'+keys[i]+'"];Gwindow.savedrooms.splice(Gwindow.savedrooms.indexOf('+keys[i]+'),1);';
  3949. displayInChat('<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">Remove</a>'+' - ',"#DA0808","#1EBCC1",{sanitize:false},JSON.stringify(savedroomsdata[keys[i]].roomname)+" - "+savedroomsdata[keys[i]].players+"/"+savedroomsdata[keys[i]].maxplayers+" players.");
  3950.  
  3951. Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true;
  3952. Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true;
  3953. Laster_message = lastmessage();
  3954. }
  3955. }
  3956. return "";
  3957. }
  3958. else if (chat_val.substring(1,15)=="clearsavedroom"){
  3959. if(savedrooms.length == 0){
  3960. displayInChat("You do not have any saved rooms.","#DA0808","#1EBCC1");
  3961. return "";
  3962. }
  3963. else{
  3964. var keys = Object.keys(savedroomsdata);
  3965. for(var i = 0;i<keys.length;i++){
  3966. savedrooms.splice(savedrooms.indexOf(parseInt(keys[i])),1);
  3967. delete savedroomsdata[keys[i]];
  3968. }
  3969. }
  3970. return "";
  3971. }
  3972. else if (chat_val.substring(1,10)=="followcam"){
  3973. if(FollowCam == true){
  3974. displayInChat("Follow Camera is now off.","#DA0808","#1EBCC1");
  3975. FollowCam = false;
  3976. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  3977. var addto = {"children":[]};
  3978. for(var i = 0;i<parentDraw.children.length;i++){
  3979. if(parentDraw.children[i].constructor.name == "e"){
  3980. addto = parentDraw.children[i];
  3981. break;
  3982. }
  3983. }
  3984. var canv = 0;
  3985. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  3986. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  3987. canv = Gdocument.getElementById("gamerenderer").children[i];
  3988. break;
  3989. }
  3990. }
  3991. var width = parseInt(canv.style["width"]);
  3992. var height = parseInt(canv.style["height"]);
  3993. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  3994. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  3995. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  3996. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  3997. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999){
  3998. pixiCircle.visible = false;
  3999. }
  4000. else{
  4001. pixiCircle.visible = true;
  4002. }
  4003. }
  4004. }
  4005. else{
  4006. displayInChat("Follow Camera is now on.","#DA0808","#1EBCC1");
  4007. FollowCam = true;
  4008. }
  4009.  
  4010. return "";
  4011. }
  4012. else if (chat_val.substring(1,8)=="autocam"){
  4013. if(autocam == true){
  4014. displayInChat("Auto Cam is now off.","#DA0808","#1EBCC1");
  4015. autocam = false
  4016. }
  4017. else{
  4018. displayInChat("Auto Cam is now on.","#DA0808","#1EBCC1");
  4019. autocam = true;
  4020. }
  4021.  
  4022. return "";
  4023. }
  4024. else if (chat_val.substring(1,7)=="aimbot"){
  4025. if(aimbot == true){
  4026. displayInChat("Aimbot is now off.","#DA0808","#1EBCC1");
  4027. aimbot = false;
  4028. }
  4029. else{
  4030. displayInChat("Aimbot is now on.","#DA0808","#1EBCC1");
  4031. aimbot = true;
  4032. getplayerkeys();
  4033. }
  4034.  
  4035. return "";
  4036. }
  4037. else if (chat_val.substring(1,8)=="volume " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  4038. var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '');
  4039. if(!isNaN(parseInt(text))){
  4040. int_text = parseInt(text);
  4041. if(int_text>=0 && int_text<=100){
  4042. jukeboxplayer.volume = int_text/100;
  4043. jukeboxplayervolume = int_text;
  4044. displayInChat("Jukebox volume set to: "+int_text.toString()+" percent.","#DA0808","#1EBCC1");
  4045. }
  4046. else{
  4047. displayInChat("Volume must be between 0 and 100 percent.","#DA0808","#1EBCC1");
  4048. }
  4049. }
  4050. return "";
  4051. }
  4052. else if (chat_val.substring(1,6)=="still"){
  4053. if(staystill == true){
  4054. displayInChat("Still is now off.","#DA0808","#1EBCC1");
  4055. staystill = false;
  4056. staystillpos = [0,0];
  4057. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  4058. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  4059. }
  4060. else{
  4061. if(playerids[myid].playerData?.transform){
  4062. displayInChat("Still is now on.","#DA0808","#1EBCC1");
  4063. staystill = true;
  4064. staystillpos = [playerids[myid].playerData.transform.position.x/scale,playerids[myid].playerData.transform.position.y/scale];
  4065. getplayerkeys();
  4066. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  4067. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  4068. }
  4069. else{
  4070. displayInChat("You have to be alive to use this command.","#DA0808","#1EBCC1");
  4071. }
  4072. }
  4073.  
  4074. return "";
  4075. }
  4076. else if (chat_val.substring(1,9)=="heavybot"){
  4077. if(heavybot == true){
  4078. displayInChat("Heavy bot is now off.","#DA0808","#1EBCC1");
  4079. heavybot = false;
  4080. }
  4081. else{
  4082. displayInChat("Heavy bot is now on.","#DA0808","#1EBCC1");
  4083. heavybot = true;
  4084. getplayerkeys();
  4085. }
  4086.  
  4087. return "";
  4088. }
  4089. else if (chat_val.substring(1,5)=="xray"){
  4090. Gdocument.getElementById("pretty_top_settings").click();
  4091. Gdocument.getElementById("settings_close").click();
  4092. if(Gdocument.getElementById("settings_graphicsquality").value==1){
  4093. displayInChat("You must have medium or high quality enabled to use this feature.","#DA0808","#1EBCC1");
  4094. return "";
  4095. }
  4096.  
  4097.  
  4098. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  4099. var addto = {"children":[]};
  4100. for(var i = 0;i<parentDraw.children.length;i++){
  4101. if(parentDraw.children[i].constructor.name == "e"){
  4102. addto = parentDraw.children[i];
  4103. break;
  4104. }
  4105. }
  4106. var addto2 = {"children":[]};
  4107. for(var i = 0;i<addto.children.length;i++){
  4108. if(addto.children[i].constructor.name == "e"){
  4109. addto2 = addto.children[i];
  4110. break;
  4111. }
  4112. }
  4113. var checkxray = addto2.children[0];
  4114. var addto3 = addto2.children[0].children;
  4115. if(addto3.length==1){
  4116. checkxray = checkxray.children[0];
  4117. addto3 = addto3[0].children;
  4118. }
  4119. var xrayon = false;
  4120. if(checkxray.xrayon){
  4121. checkxray.xrayon = false;
  4122. xrayon = false;
  4123. }
  4124. else{
  4125. checkxray.xrayon = true;
  4126. xrayon = true;
  4127. }
  4128. if(xrayon){
  4129. displayInChat("Xray is now on.","#DA0808","#1EBCC1");
  4130. for(var i = 0;i<addto3.length;i++){
  4131. if(addto3[i].children.length>0){
  4132. var ids = [];
  4133. var ids2 = [];
  4134. for(var i3 = 0;i3<addto3[i].children.length;i3++){
  4135. addto3[i].children[i3].visible = false;
  4136. if(addto3[i].children[i3].children.length>0){
  4137. for(var i4 = 0;i4<addto3[i].children[i3].children.length;i4++){
  4138. if(addto3[i].children[i3].children[i4].geometry?.id){
  4139. ids.push(addto3[i].children[i3].children[i4].geometry.id);
  4140. }
  4141. else if(addto3[i].children[i3].children[i4].texture?.baseTexture?.uid){
  4142. ids2.push(addto3[i].children[i3].children[i4].texture.baseTexture.uid);
  4143. }
  4144. }
  4145. }
  4146. }
  4147. for(var i3 = 0;i3<addto3[i].children.length;i3++){
  4148. if(addto3[i].children[i3].children.length==0){
  4149. if(addto3[i].children[i3].geometry?.id){
  4150. if(ids.includes(addto3[i].children[i3].geometry.id+1)){
  4151. addto3[i].children[i3].visible = true;
  4152. addto3[i].children[i3].alpha = 0.5;
  4153. }
  4154. }
  4155. else if(addto3[i].children[i3].texture?.baseTexture?.uid){
  4156. if(ids2.includes(addto3[i].children[i3].texture.baseTexture.uid+1)){
  4157. addto3[i].children[i3].visible = true;
  4158. addto3[i].children[i3].alpha = 0.5;
  4159. }
  4160. }
  4161. }
  4162. }
  4163. }
  4164. }
  4165.  
  4166. }
  4167. else{
  4168. displayInChat("Xray is now off.","#DA0808","#1EBCC1");
  4169. for(var i = 0;i<addto3.length;i++){
  4170. for(var i2 = 0;i2<addto3[i].children.length;i2++){
  4171. addto3[i].children[i2].visible = true;
  4172. addto3[i].children[i2].alpha = 1;
  4173. }
  4174. }
  4175. }
  4176. }
  4177.  
  4178. return "";
  4179. }
  4180. else if (chat_val.substring(1,6)=="zoom "){
  4181. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  4182. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  4183. var addto = 0;
  4184. for(var i = 0;i<parentDraw.children.length;i++){
  4185. if(parentDraw.children[i].constructor.name == "e"){
  4186. addto = parentDraw.children[i];
  4187. break;
  4188. }
  4189. }
  4190. var canv = 0;
  4191. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  4192. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  4193. canv = Gdocument.getElementById("gamerenderer").children[i];
  4194. break;
  4195. }
  4196. }
  4197. var width = parseInt(canv.style["width"]);
  4198. var height = parseInt(canv.style["height"]);
  4199. if(addto){
  4200. if(text == "in"){
  4201. zoom *= 1.1;
  4202. }
  4203. else if(text == "out"){
  4204. zoom /= 1.1;
  4205. }
  4206. else if(text == "reset"){
  4207. zoom = 1;
  4208. }
  4209. else{
  4210. displayInChat("Options for zooming:","#DA0808","#1EBCC1");
  4211. displayInChat("in","#DA0808","#1EBCC1");
  4212. displayInChat("out","#DA0808","#1EBCC1");
  4213. displayInChat("reset","#DA0808","#1EBCC1");
  4214. return "";
  4215. }
  4216. addto.scale.x=zoom;
  4217. addto.scale.y=zoom;
  4218. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  4219. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  4220. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  4221. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  4222. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999 && !FollowCam){
  4223. pixiCircle.visible = false;
  4224. }
  4225. else{
  4226. pixiCircle.visible = true;
  4227. }
  4228. }
  4229. }
  4230. return "";
  4231. }
  4232. else if (chat_val.substring(1,9)=="hidechat"){
  4233. Gdocument.getElementById("ingamechatcontent").style["max-height"]="0px";
  4234. return "";
  4235. }
  4236. else if (chat_val.substring(1,9)=="showchat"){
  4237. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  4238. return "";
  4239. }
  4240. else if (chat_val.substring(1,6)=="score"){
  4241. var element = Gdocument.getElementById("ingamewinner_scores");
  4242. if(element.style["opacity"]<1){
  4243. element.style["opacity"] = 1;
  4244. element.style["visibility"] = "visible";
  4245. }
  4246. else{
  4247. element.style["opacity"] = 0;
  4248. element.style["visibility"] = "unset";
  4249. }
  4250. return "";
  4251. }
  4252.  
  4253. else if (chat_val.substring(1,7)=="scroll"){
  4254. if(scroll==false){
  4255. scroll = true;
  4256. Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="scroll";
  4257. Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
  4258. }
  4259. else if(scroll==true){
  4260. scroll = false;
  4261. Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="hidden";
  4262. Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
  4263. }
  4264.  
  4265. return "";
  4266. }
  4267.  
  4268. else if (chat_val.substring(1,7)=="chatw "){
  4269. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  4270.  
  4271. if(username == text){
  4272. displayInChat("You cannot private chat with yourself.","#DA0808","#1EBCC1");
  4273. return "";
  4274. }
  4275. private_chat = text;
  4276.  
  4277. SEND("42"+JSON.stringify([4,{"type":"request public key","from":username,"to":private_chat}]));
  4278. request_public_key_time_stamp = Date.now();
  4279. 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);
  4280. return "";
  4281. }
  4282. else if (chat_val.substring(1,8)=="lagbot " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  4283. var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '');
  4284. if(!isNaN(parseInt(text))){
  4285. int_text = parseInt(text);
  4286. if(int_text == 0){
  4287. causelag = false;
  4288. causelag2 = 0;
  4289. displayInChat("Lagbot is now off.","#DA0808","#1EBCC1");
  4290. displayInChat("To enable lagbot, type '/lagbot [number]' with a number between 1 and 10.","#DA0808","#1EBCC1");
  4291. }
  4292. else if(int_text>0 && int_text<=10){
  4293. causelag = true;
  4294. causelag2 = 45*int_text;
  4295. displayInChat("Lagbot is now on with a lag setting of "+int_text.toString()+" (~"+(45*int_text).toString()+"MS).","#DA0808","#1EBCC1");
  4296. displayInChat("Type '/lagbot 0' to turn off lagbot.","#DA0808","#1EBCC1");
  4297. }
  4298. else{
  4299. displayInChat("To enable lagbot, type '/lagbot [number]' with a number between 1 and 10.","#DA0808","#1EBCC1");
  4300. displayInChat("Type '/lagbot 0' to turn off lagbot.","#DA0808","#1EBCC1");
  4301. }
  4302. }
  4303. return "";
  4304. }
  4305. else if (chat_val.substring(1,8)=="record " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  4306. var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  4307. var keys = Object.keys(playerids);
  4308. var recordingid2 = -1;
  4309. for(var i = 0;i<keys.length;i++){
  4310. if(playerids[keys[i]].userName == text){
  4311. recordingid2 = keys[i];
  4312. }
  4313. }
  4314. if(recordingid2 == -1){
  4315. displayInChat("Player not found. Please type a valid username.","#DA0808","#1EBCC1");
  4316. return "";
  4317. }
  4318. else{
  4319. recording = true;
  4320. recordingid = recordingid2;
  4321. displayInChat(playerids[recordingid].userName+" is now being recorded.","#DA0808","#1EBCC1");
  4322. if(recordingdata.length>0){
  4323. displayInChat("Any unsaved recording data is now cleared.","#DA0808","#1EBCC1");
  4324. }
  4325. recordingdata = [];
  4326. }
  4327. return "";
  4328. }
  4329. else if (chat_val.substring(1,11)=="stoprecord"){
  4330. if(recording){
  4331. displayInChat(playerids[recordingid].userName+" is not being recorded anymore.","#DA0808","#1EBCC1");
  4332. displayInChat("Type '/saverecording [text]' to save this recording.","#DA0808","#1EBCC1");
  4333. recording = false;
  4334. recordingid = -1;
  4335. recordingdata[0][1] = 0;
  4336. }
  4337. else{
  4338. displayInChat("No one is being recorded.","#DA0808","#1EBCC1");
  4339. }
  4340. return "";
  4341. }
  4342. else if (chat_val.substring(1,15)=="saverecording " && chat_val.replace(/^\s+|\s+$/g, '').length>=16){
  4343. var text = chat_val.substring(15).replace(/^\s+|\s+$/g, '');
  4344. if(Object.keys(recorddata).includes(text)){
  4345. displayInChat("This recording already exists. Please use a different name or type '/delrecording "+text+"'.","#DA0808","#1EBCC1");
  4346. }
  4347. else if(recordingdata.length>0){
  4348. recorddata[text] = JSON.parse(JSON.stringify(recordingdata));
  4349. displayInChat("Recording saved as: "+text,"#DA0808","#1EBCC1");
  4350. }
  4351. else{
  4352. displayInChat("There is no recording data to save. Please record data using '/record [username]'","#DA0808","#1EBCC1");
  4353. }
  4354. return "";
  4355. }
  4356. else if (chat_val.substring(1,14)=="delrecording " && chat_val.replace(/^\s+|\s+$/g, '').length>=15){
  4357. var text = chat_val.substring(14).replace(/^\s+|\s+$/g, '');
  4358. if(Object.keys(recorddata).includes(text)){
  4359. displayInChat("Recording deleted.","#DA0808","#1EBCC1");
  4360. delete recorddata[text];
  4361. }
  4362. else{
  4363. displayInChat("This recording does not exist.","#DA0808","#1EBCC1");
  4364. }
  4365. return "";
  4366. }
  4367. else if (chat_val.substring(1,15)=="loadrecording " && chat_val.replace(/^\s+|\s+$/g, '').length>=16){
  4368. var text = chat_val.substring(15).replace(/^\s+|\s+$/g, '');
  4369. if(!Object.keys(recorddata).includes(text)){
  4370. displayInChat("This recording does not exist.","#DA0808","#1EBCC1");
  4371. }
  4372. else{
  4373. if(recordingdata.length>0){
  4374. displayInChat("Any unsaved recording data is now cleared.","#DA0808","#1EBCC1");
  4375. }
  4376. recordingdata = JSON.parse(JSON.stringify(recorddata[text]));
  4377. displayInChat("Recording data is now loaded.","#DA0808","#1EBCC1");
  4378. }
  4379. return "";
  4380. }
  4381. else if (chat_val.substring(1,7)=="replay"){
  4382. if(recording){
  4383. displayInChat(playerids[recordingid].userName+" is not being recorded anymore.","#DA0808","#1EBCC1");
  4384. displayInChat("Type '/saverecording [text]' to save this recording.","#DA0808","#1EBCC1");
  4385. recordingid = -1;
  4386. recording = false;
  4387. recordingdata[0][1] = 0;
  4388. }
  4389. replay();
  4390. return "";
  4391. }
  4392. else if (chat_val.substring(1,5)=="msg " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  4393. if(private_chat_public_key[1][0] != 0 && private_chat_public_key[1][1] != 0 && private_chat_public_key[0] == private_chat){
  4394. var text = chat_val.substring(5).replace(/^\s+|\s+$/g, '');
  4395. var password = [];
  4396. for(var i = 0;i<10;i++){
  4397. password.push(Math.floor(Math.random()*100+50));
  4398. }
  4399. var text2 = [];
  4400. for(var i = 0;i<text.slice(0,400).length ;i++){
  4401. text2.push(password[i%password.length]^text.slice(0,400).charCodeAt(i));
  4402. }
  4403. pmlastmessage = text.slice(0,400);
  4404. 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)}]));
  4405. displayInChat("> "+username+": ","#DA0808","#1EBCC1",{sanitize:false},text,false);
  4406. Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true;
  4407. Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true;
  4408. Laster_message = lastmessage();
  4409.  
  4410. }
  4411. return "";
  4412. }
  4413. else if (chat_val.substring(1,10)=="ignorepm " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  4414. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  4415. if(ignorepmlist.includes(text)){
  4416. var index = ignorepmlist.indexOf(text);
  4417. ignorepmlist.splice(index,1);
  4418. displayInChat("You are not ignoring private messages from "+text+".","#DA0808","#1EBCC1");
  4419.  
  4420. }
  4421. else{
  4422. ignorepmlist.push(text);
  4423. displayInChat("You are now ignoring private messages from "+text+".","#DA0808","#1EBCC1");
  4424. }
  4425. return "";
  4426. }
  4427. else if (chat_val.substring(1,8)=="pmusers"){
  4428. pmusers = [];
  4429. SEND("42"+JSON.stringify([4,{"type":"request private chat users","from":username}]));
  4430. pmuserstimestamp = Date.now();
  4431. setTimeout(function(){if(pmusers.length == 0){displayInChat("You cannot private chat with anyone.","#DA0808","#1EBCC1");
  4432. }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">'+sanitize(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);
  4433. return "";
  4434. }
  4435. else if (chat_val.substring(1,6)=="lobby"){
  4436. lobby();
  4437. return "";
  4438. }
  4439. else if (chat_val.substring(1,7)=="style " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  4440. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '');
  4441. var text2 = text.split(" ");
  4442. var array = [];
  4443. for(var i = 0;i<text2.length;i++){
  4444. var parsed = parseInt(text2[i]);
  4445. if(!isNaN(parsed)){
  4446. array.push(parsed);
  4447. }
  4448. }
  4449. if(array.length == 3){
  4450. SEND("42"+JSON.stringify([4,{"type":"style","from":username,"style":array}]));
  4451. allstyles[username] = array;
  4452. mystyle = [...array];
  4453. }
  4454. else{
  4455. displayInChat("Please enter a valid RGB color code seperated by space. For example, white = '/style 255 255 255'.","#DA0808","#1EBCC1");
  4456. }
  4457. return "";
  4458. }
  4459. else if (chat_val.substring(1,6)=="lobby"){
  4460. lobby();
  4461. return "";
  4462. }
  4463. else if (chat_val.substring(1,9)=="debugger"){
  4464. if(Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"] == "none"){
  4465. debuggeropen = true;
  4466. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="block";
  4467. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="none";
  4468. Gdocument.getElementById("ingamechatinputtext").style["display"] = "none";
  4469. }
  4470. else{
  4471. debuggeropen = false;
  4472. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="none";
  4473. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  4474. Gdocument.getElementById("ingamechatinputtext").style["display"] = "";
  4475. }
  4476. return "";
  4477. }
  4478. else if (chat_val.substring(1,6)=="team " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  4479. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  4480. if(text == "r"){Gdocument.getElementById("newbonklobby_redbutton").click();}
  4481. else if(text == "g"){Gdocument.getElementById("newbonklobby_greenbutton").click();}
  4482. else if(text == "y"){Gdocument.getElementById("newbonklobby_yellowbutton").click();}
  4483. else if(text == "b"){Gdocument.getElementById("newbonklobby_bluebutton").click();}
  4484. else if(text == "s"){Gdocument.getElementById("newbonklobby_specbutton").click();}
  4485. else if(text == "f"){Gdocument.getElementById("newbonklobby_ffabutton").click();}
  4486. return "";
  4487. }
  4488. else if (chat_val.substring(1,7)=="notify"){
  4489. npermissions = 1;
  4490. return "";
  4491. }
  4492. else if (chat_val.substring(1,11)=="stopnotify"){
  4493. npermissions = 0;
  4494. return "";
  4495. }
  4496. else if (chat_val.substring(1,8)=="support"){
  4497. displayInChat("Thanks everyone for helping me make this mod - LEGENDBOSS123","#0000FF","#FFFFFF");
  4498. displayInChat("mastery3","#0000FF","#FFFFFF");
  4499. displayInChat("UnmatchedBracket aka Left Paren","#0000FF","#FFFFFF");
  4500. displayInChat("iNeonz","#0000FF","#FFFFFF");
  4501. return "";
  4502. }
  4503. else if (chat_val.substring(1,9)=="pollstat"){
  4504. if(pollactive[0] || pollactive2[0]){
  4505. var count = [0,0,0,0];
  4506. var keys = Object.keys(playerids);
  4507. for(var i = 0;i<keys.length;i++){
  4508. if(ishost){
  4509. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive[3].length-1){
  4510. count[playerids[keys[i]].vote.poll]++;
  4511. }
  4512. }
  4513. else{
  4514. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive2[2].length-1){
  4515. count[playerids[keys[i]].vote.poll]++;
  4516. }
  4517. }
  4518. }
  4519. for(var i = 0;i<count.length;i++){
  4520. if(count[i]>1){
  4521. displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  4522. }
  4523. if(count[i]==1){
  4524. displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  4525. }
  4526. }
  4527. if(ishost){
  4528. displayInChat("The poll will end in: "+((pollactive[2]-Date.now())/1000).toString()+" seconds.","#DA0808","#1EBCC1");
  4529. }
  4530. displayInChat("The poll is:","#DA0808","#1EBCC1");
  4531. if(ishost){
  4532. for(var i = 0;i<pollactive[3].length;i++){
  4533. displayInChat(letters[i]+") "+pollactive[3][i],"#DA0808","#1EBCC1");
  4534. }
  4535. }
  4536. else{
  4537. for(var i = 0;i<pollactive2[2].length;i++){
  4538. displayInChat(letters[i]+") "+pollactive2[2][i],"#DA0808","#1EBCC1");
  4539. }
  4540. }
  4541. }
  4542. else{
  4543. displayInChat("No poll has been started.","#DA0808","#1EBCC1");
  4544. if(ishost){
  4545. displayInChat("Type '/startpoll [seconds]' to start a poll.","#DA0808","#1EBCC1");
  4546. if(poll.length>0){
  4547. displayInChat("The poll is:","#DA0808","#1EBCC1");
  4548. for(var i = 0;i<poll.length;i++){
  4549. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  4550. }
  4551. }
  4552. }
  4553. }
  4554. return "";
  4555. }
  4556. else if (chat_val.substring(1,5)=="help" || chat_val.substring(1,2)=="?"){
  4557. for(var i = 0;i<help.length;i++){
  4558. if(help[i].startsWith("/")){
  4559. var splitted = help[i].substring(1).split(" ");
  4560. var command = splitted[0];
  4561. var rest = "";
  4562. if(splitted.length>1){
  4563. rest = " "+splitted.slice(1).join(" ");
  4564. }
  4565. displayInChat("/"+'<a onclick = \'Gwindow.displayadvhelp("'+command+'");\' style = "color:green;" href = "javascript:void(0);">'+command+'</a>'+rest,"#DA0808","#1EBCC1",{sanitize:false},"",false);
  4566. }
  4567. else if(help[i].startsWith("Alt ")){
  4568. displayInChat('<a onclick = \'Gwindow.displayadvhelp("'+help[i]+'");\' style = "color:green;" href = "javascript:void(0);">'+help[i]+'</a>',"#DA0808","#1EBCC1",{sanitize:false},"",false);
  4569. }
  4570. else{
  4571. displayInChat(help[i],"#DA0808","#1EBCC1");
  4572. }
  4573.  
  4574. }
  4575. return "";
  4576. }
  4577. else if (chat_val.substring(1,9)=="advhelp " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  4578. var text = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  4579. if(typeof(adv_help[text])!='undefined'){
  4580. displayInChat(adv_help[text],"#DA0808","#1EBCC1");
  4581. }
  4582. return "";
  4583. }
  4584. else if (chat_val.substring(1,6)=="mode " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  4585. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  4586. var mode = "";
  4587. var text2 = text;
  4588. if(text == "arrows"){
  4589. text2 = "Arrows";
  4590. mode = "ar";
  4591. }
  4592. else if(text == "death arrows"){
  4593. mode = "ard";
  4594. text2 = "Death Arrows";
  4595. }
  4596. else if(text == "grapple"){
  4597. mode = "sp";
  4598. text2 = "Grapple";
  4599. }
  4600. else if(text == "classic"){
  4601. mode = "b";
  4602. text2 = "Classic";
  4603. }
  4604. else{
  4605. displayInChat("Mode options:","#DA0808","#1EBCC1");
  4606. displayInChat("classic","#DA0808","#1EBCC1");
  4607. displayInChat("arrows","#DA0808","#1EBCC1");
  4608. displayInChat("death arrows","#DA0808","#1EBCC1");
  4609. displayInChat("grapple","#DA0808","#1EBCC1");
  4610. }
  4611. if(mode != ""){
  4612. if(ishost){
  4613. SEND('42[20,{"ga":"b","mo":"'+mode+'"}]');
  4614. RECIEVE('42[26,"b","'+mode+'"]');
  4615. displayInChat("Changed mode to "+text+".","#DA0808","#1EBCC1");
  4616. }
  4617. else{
  4618. if(playerids[myid].ratelimit.mode+1000<Date.now()){
  4619. playerids[myid].ratelimit.mode=Date.now();
  4620. SEND("42"+JSON.stringify([4,{"type":"request mode","from":username,"mode":mode}]));
  4621. var code = 'if(!Gwindow.ishost){Gwindow.displayInChat("You must be host to change the mode.","#DA0808","#1EBCC1",{sanitize:false},"",true)}else{Gwindow.changemode("'+mode+'")}';
  4622. displayInChat('> '+username+' requests [<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+text2+'</a>]',"#DA0808","#1EBCC1",{sanitize:false}," mode.");
  4623.  
  4624. }
  4625. else{
  4626. displayInChat("You are requesting modes too quickly.","#DA0808","#1EBCC1");
  4627. }
  4628. }
  4629. }
  4630. return "";
  4631.  
  4632. }
  4633. else if(ishost){
  4634. if (chat_val.substring(1,11)=="nextafter " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  4635. var text = parseFloat(chat_val.substring(11).replace(/^\s+|\s+$/g, ''));
  4636. if(isNaN(text)){
  4637. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  4638. return "";
  4639. }
  4640. else if(text<=0){
  4641. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  4642. return "";
  4643. }
  4644. nextafter = text;
  4645. displayInChat("Set next after to: " + text.toString()+" seconds.","#DA0808","#1EBCC1");
  4646. displayInChat("Type '/nextafter' to reset next after.","#DA0808","#1EBCC1");
  4647. return "";
  4648.  
  4649. }
  4650. else if (chat_val.substring(1,10)=="nextafter"){
  4651. nextafter = 0;
  4652. displayInChat("Reset next after.","#DA0808","#1EBCC1");
  4653. return "";
  4654.  
  4655. }
  4656. else if (chat_val.substring(1,5)=="next" && stopquickplay == 0){
  4657. roundsperqp2 = 0;
  4658. if(shuffle){
  4659. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4660. var available = [];
  4661. var availableindexes = [];
  4662. var notempty = false;
  4663. for(var i = 0; i<e.length;i++){
  4664. var a = false;
  4665. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4666. available.push(a);
  4667. if(a){
  4668. availableindexes.push(i);
  4669. notempty = true;
  4670. }
  4671. }
  4672. if(notempty){
  4673.  
  4674. if(availableindexes.length!=1){
  4675. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  4676. }
  4677. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  4678. }
  4679. }
  4680. else{
  4681. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4682. var available = [];
  4683. var availableindexes = [];
  4684. var notempty = false;
  4685. for(var i = 0; i<e.length;i++){
  4686. var a = false;
  4687. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4688. available.push(a);
  4689. if(a){
  4690. availableindexes.push(i);
  4691. notempty = true;
  4692. }
  4693. }
  4694. if(notempty){
  4695. var above = [];
  4696. for(var i = 0;i<availableindexes.length;i++){
  4697. if(availableindexes[i]>quicki && !reverseqp){
  4698. above.push(availableindexes[i]);
  4699. }
  4700. else if(availableindexes[i]<quicki && reverseqp){
  4701. above.push(availableindexes[i])
  4702. }
  4703. }
  4704. if(above.length>0){
  4705. quicki = above[0];
  4706. if(reverseqp){
  4707. quicki = above[above.length-1];
  4708. }
  4709. }
  4710. else{
  4711. quicki = availableindexes[0];
  4712. if(reverseqp){
  4713. quicki = availableindexes[availableindexes.length-1];
  4714. }
  4715. }
  4716. }
  4717. }
  4718. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  4719. displayInChat("Switched to next map.","#DA0808","#1EBCC1");
  4720. return "";
  4721.  
  4722. }
  4723. else if (chat_val.substring(1,9)=="freejoin"){
  4724. if(freejoin == false){
  4725. freejoin = true;
  4726. displayInChat("Freejoin is now on.","#DA0808","#1EBCC1");
  4727.  
  4728. }
  4729. else{
  4730. freejoin = false;
  4731. displayInChat("Freejoin is now off.","#DA0808","#1EBCC1");
  4732. }
  4733.  
  4734. return "";
  4735.  
  4736. }
  4737. else if (chat_val.substring(1,8)=="instaqp"){
  4738. if(instaqp == false){
  4739. instaqp = true;
  4740. displayInChat("Instaqp is now on.","#DA0808","#1EBCC1");
  4741.  
  4742. }
  4743. else{
  4744. instaqp = false;
  4745. displayInChat("Instaqp is now off.","#DA0808","#1EBCC1");
  4746. }
  4747.  
  4748. return "";
  4749.  
  4750. }
  4751.  
  4752. else if (chat_val.substring(1,9)=="previous" && stopquickplay == 0){
  4753. roundsperqp2 = 0;
  4754. if(shuffle){
  4755. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4756. var available = [];
  4757. var availableindexes = [];
  4758. var notempty = false;
  4759. for(var i = 0; i<e.length;i++){
  4760. var a = false;
  4761. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4762. available.push(a);
  4763. if(a){
  4764. availableindexes.push(i);
  4765. notempty = true;
  4766. }
  4767. }
  4768. if(notempty){
  4769.  
  4770. if(availableindexes.length!=1){
  4771. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  4772. }
  4773. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  4774. }
  4775. }
  4776. else{
  4777. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4778. var available = [];
  4779. var availableindexes = [];
  4780. var notempty = false;
  4781. for(var i = 0; i<e.length;i++){
  4782. var a = false;
  4783. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4784. available.push(a);
  4785. if(a){
  4786. availableindexes.push(i);
  4787. notempty = true;
  4788. }
  4789. }
  4790. if(notempty){
  4791. var above = [];
  4792. for(var i = 0;i<availableindexes.length;i++){
  4793. if(availableindexes[i]<quicki && !reverseqp){
  4794. above.push(availableindexes[i]);
  4795. }
  4796. else if(availableindexes[i]>quicki && reverseqp){
  4797. above.push(availableindexes[i])
  4798. }
  4799. }
  4800. if(above.length>0){
  4801. quicki = above[above.length-1];
  4802. if(reverseqp){
  4803. quicki = above[0];
  4804. }
  4805. }
  4806. else{
  4807. quicki = availableindexes[availableindexes.length-1];
  4808. if(reverseqp){
  4809. quicki = availableindexes[0];
  4810. }
  4811. }
  4812. }
  4813. }
  4814. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  4815.  
  4816. displayInChat("Switched to previous map.","#DA0808","#1EBCC1");
  4817. return "";
  4818. }
  4819. else if (chat_val.substring(1,6)=="start" && chat_val.length == 6){
  4820. if(Gdocument.getElementById("mapeditorcontainer").style["display"]!="block"){
  4821. Gdocument.getElementById("newbonklobby_editorbutton").click();
  4822. }
  4823. if(recmodebool && ishost){
  4824. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  4825. if(mode == "" && defaultmode!="d"){
  4826. mode = defaultmode;
  4827. }
  4828. if(mode != ""){
  4829. RECIEVE('42[26,"b","'+mode+'"]');
  4830. }
  4831. }
  4832. Gdocument.getElementById("mapeditor_close").click();
  4833. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  4834. roundsperqp2 = 0;
  4835. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  4836.  
  4837. return "";
  4838. }
  4839.  
  4840. else if (chat_val.substring(1,8)=="startqp" && stopquickplay == 1){
  4841. stopquickplay = 0;
  4842. quicki = 0;
  4843. qppaused = false;
  4844. displayInChat("Enabled quickplay.","#DA0808","#1EBCC1");
  4845. return "";
  4846. }
  4847. else if (chat_val.substring(1,7)=="stopqp" && stopquickplay == 0){
  4848. stopquickplay = 1;
  4849. quicki = 0;
  4850. qppaused = false;
  4851. displayInChat("Disabled quickplay.","#DA0808","#1EBCC1");
  4852. return "";
  4853. }
  4854. else if (chat_val.substring(1,8)=="pauseqp" && stopquickplay == 0){
  4855. if(qppaused == false){
  4856. qppaused = true;
  4857. displayInChat("Paused quickplay.","#DA0808","#1EBCC1");
  4858. }
  4859. else{
  4860. qppaused = false;
  4861. displayInChat("Unpaused quickplay.","#DA0808","#1EBCC1");
  4862. }
  4863. return "";
  4864. }
  4865. else if (chat_val.substring(1,6)=="revqp" && stopquickplay == 0){
  4866. if(reverseqp == false){
  4867. reverseqp = true;
  4868. displayInChat("Reverseqp is now on..","#DA0808","#1EBCC1");
  4869. }
  4870. else{
  4871. reverseqp = false;
  4872. displayInChat("Reverseqp is now off.","#DA0808","#1EBCC1");
  4873. }
  4874. return "";
  4875. }
  4876. else if (chat_val.substring(1,9)=="jukebox " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  4877. var text = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  4878. SEND("42"+JSON.stringify([4,{"type":"video player","from":username,"url":text,"timestamp":Date.now()+2000,"to":[-1]}]));
  4879. displayInChat("Jukebox is loading... Please wait a few seconds.","#DA0808","#1EBCC1");
  4880. changeJukeboxURL(text,Date.now()+2000);
  4881. return "";
  4882. }
  4883. else if (chat_val.substring(1,13)=="pausejukebox"){
  4884. if(jukeboxplayer.src!="" && !jukeboxplayer.paused){
  4885. displayInChat("Jukebox is now paused.","#DA0808","#1EBCC1");
  4886. jukeboxplayer.pause();
  4887. SEND("42"+JSON.stringify([4,{"type":"video player","from":username,"url":"","timestamp":Date.now(),"to":[-1]}]));
  4888. }
  4889. return "";
  4890. }
  4891. else if (chat_val.substring(1,13)=="resetjukebox"){
  4892. if(jukeboxplayer.src!=""){
  4893. jukeboxplayer.currentTime = 0;
  4894. displayInChat("Jukebox has reset.","#DA0808","#1EBCC1");
  4895. changeJukeboxURL(jukeboxplayerURL,Date.now()+2000);
  4896. SEND("42"+JSON.stringify([4,{"type":"video player","from":username,"url":jukeboxplayerURL,"timestamp":Date.now()+2000,"to":[-1]}]));
  4897. }
  4898. return "";
  4899. }
  4900. else if (chat_val.substring(1,12)=="playjukebox"){
  4901. if(jukeboxplayer.src!="" && jukeboxplayer.paused){
  4902. changeJukeboxURL(jukeboxplayerURL,Date.now()-jukeboxplayer.currentTime*1000);
  4903. SEND("42"+JSON.stringify([4,{"type":"video player","from":username,"url":jukeboxplayerURL,"timestamp":Date.now()-jukeboxplayer.currentTime*1000,"to":[-1]}]));
  4904. }
  4905. return "";
  4906. }
  4907. else if (chat_val.substring(1,5)=="ban " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  4908. banned.push(chat_val.substring(5).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',""));
  4909. displayInChat("Banned "+chat_val.substring(5).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"")+".","#DA0808","#1EBCC1");
  4910. return "/kick '" + chat_val.substring(5).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"") + "'";
  4911. }
  4912. else if (chat_val.substring(1,6)=="kill " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  4913. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  4914. var keys = Object.keys(playerids);
  4915. var killid = undefined;
  4916. for(var i = 0; i<keys.length; i++){
  4917. if(playerids[keys[i]].userName == text){
  4918. killid = keys[i];
  4919. }
  4920. }
  4921. if(typeof(killid)!="undefined" && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden" && !killedids.includes(killid)){
  4922. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  4923. killedids.push(killid);
  4924. SEND('42[25,{"a":{"playersLeft":['+killid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  4925. RECIEVE('42[31,{"a":{"playersLeft":['+killid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  4926. }
  4927. return "";
  4928. }
  4929. else if (chat_val.substring(1,10)=="balanceA " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  4930. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  4931. if(!isNaN(parseInt(text))){
  4932. if(parseInt(text)>=-100 && parseInt(text)<=100){
  4933. var keys = Object.keys(playerids);
  4934. for(var i = 0; i<keys.length;i++){
  4935. SEND('42[29,{"sid":'+keys[i]+',"bal":'+text+'}]');
  4936. RECIEVE('42[36,'+keys[i]+','+text+']');
  4937. }
  4938. }
  4939. }
  4940. return "";
  4941.  
  4942. }
  4943. else if (chat_val.substring(1,10)=="resetpoll"){
  4944. poll = [];
  4945. displayInChat("The poll has been reset.","#DA0808","#1EBCC1");
  4946. return "";
  4947. }
  4948. else if (chat_val.substring(1,11)=="addoption " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  4949. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  4950. if(text.length>50){
  4951. displayInChat("Your option is greater than 50 characters.","#DA0808","#1EBCC1");
  4952. return "";
  4953. }
  4954. if(poll.includes(text)){
  4955. displayInChat("This option already exists.","#DA0808","#1EBCC1");
  4956. }
  4957. else if(poll.length>=4){
  4958. displayInChat("Your poll already has the max 4 amounts of options.","#DA0808","#1EBCC1");
  4959. displayInChat("Type '/deloption [letter]' to remove a option.","#DA0808","#1EBCC1");
  4960. displayInChat("The poll is:","#DA0808","#1EBCC1");
  4961. for(var i = 0;i<poll.length;i++){
  4962. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  4963. }
  4964. }
  4965. else{
  4966. poll.push(text);
  4967. displayInChat("The poll is now:","#DA0808","#1EBCC1");
  4968. for(var i = 0;i<poll.length;i++){
  4969. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  4970. }
  4971. }
  4972. return "";
  4973. }
  4974. else if (chat_val.substring(1,11)=="deloption " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  4975. var text = letters.indexOf(chat_val.substring(11).replace(/^\s+|\s+$/g, ''));
  4976. if(text==-1 || text>=poll.length){
  4977. if(poll.length>0){
  4978. displayInChat("Available options are:","#DA0808","#1EBCC1");
  4979. for(var i = 0;i<poll.length;i++){
  4980. displayInChat(letters[i],"#DA0808","#1EBCC1");
  4981. }
  4982. }
  4983. else{
  4984. displayInChat("Your poll is empty.","#DA0808","#1EBCC1");
  4985. displayInChat("Type '/addoption [text]' to add an option.","#DA0808","#1EBCC1");
  4986. }
  4987. }
  4988. else{
  4989. poll.splice(text,1);
  4990. displayInChat("The poll is now:","#DA0808","#1EBCC1");
  4991. for(var i = 0;i<poll.length;i++){
  4992. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  4993. }
  4994. }
  4995. return "";
  4996. }
  4997. else if (chat_val.substring(1,11)=="startpoll " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  4998. var text = parseFloat(chat_val.substring(11).replace(/^\s+|\s+$/g, ''));
  4999. if(isNaN(text)){
  5000. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  5001. return "";
  5002. }
  5003. else if(text<=0){
  5004. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  5005. return "";
  5006. }
  5007. else if(text<10){
  5008. displayInChat("Your poll has to last for at least 10 seconds.","#DA0808","#1EBCC1");
  5009. return "";
  5010. }
  5011. if(pollactive[0]){
  5012. displayInChat("There is already an ongoing poll.","#DA0808","#1EBCC1");
  5013. displayInChat("Type '/endpoll' to end the poll.","#DA0808","#1EBCC1");
  5014. return "";
  5015. }
  5016. if(poll.length<2){
  5017. displayInChat("Your poll needs at least 2 options.","#DA0808","#1EBCC1");
  5018. displayInChat("Type '/addoption' to add to the poll.","#DA0808","#1EBCC1");
  5019. return "";
  5020. }
  5021. var now = Date.now();
  5022. pollactive = [true,now,now+text*1000,[...poll]];
  5023. playerids[myid].ratelimit.poll = now;
  5024. var chatpoll = [...poll];
  5025. chatpoll.push("Cancel vote.");
  5026. pollactive[3].push("Cancel vote.");
  5027. for(var i = 0;i<chatpoll.length;i++){
  5028. chatpoll[i] = letters[i]+") "+chatpoll[i];
  5029. }
  5030. chat(chatpoll.join("     "));
  5031. setTimeout(function(){
  5032. if(pollactive[0]){
  5033. SEND("42"+JSON.stringify([4,{"type":"poll","from":username,"poll":pollactive[3]}]));
  5034. var keys = Object.keys(playerids);
  5035. for(var i = 0;i<keys.length;i++){
  5036. playerids[keys[i]].vote.poll = -1;
  5037. }
  5038. displayInChat("The poll will end in: " + text.toString()+" seconds.","#DA0808","#1EBCC1");
  5039. displayInChat("Type '/endpoll' to end the poll early.","#DA0808","#1EBCC1");
  5040. }
  5041. },200);
  5042. return "";
  5043. }
  5044. else if (chat_val.substring(1,8)=="endpoll"){
  5045. if(pollactive[0]){
  5046. if(playerids[myid].ratelimit.poll+10000>Date.now()){
  5047. displayInChat("Your poll has to be at least 10 seconds.","#DA0808","#1EBCC1");
  5048. displayInChat("There are "+((playerids[myid].ratelimit.poll+10000-Date.now())/1000).toString()+" seconds left until you can end the poll early.","#DA0808","#1EBCC1");
  5049. return "";
  5050. }
  5051. playerids[myid].ratelimit.poll = Date.now();
  5052. SEND("42"+JSON.stringify([4,{"type":"poll end","from":username}]));
  5053. displayInChat("The poll ended.","#DA0808","#1EBCC1");
  5054. var count = [0,0,0,0];
  5055. var keys = Object.keys(playerids);
  5056. for(var i = 0;i<keys.length;i++){
  5057. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive[3].length-1){
  5058. count[playerids[keys[i]].vote.poll]++;
  5059. }
  5060. playerids[keys[i]].vote.poll = -1;
  5061. }
  5062. for(var i = 0;i<count.length;i++){
  5063. if(count[i]>1){
  5064. displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  5065. }
  5066. if(count[i]==1){
  5067. displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  5068. }
  5069. }
  5070. displayInChat("The poll was:","#DA0808","#1EBCC1");
  5071. for(var i = 0;i<pollactive[3].length;i++){
  5072. displayInChat(letters[i]+") "+pollactive[3][i],"#DA0808","#1EBCC1");
  5073. }
  5074. pollactive = [false,0,0,[]];
  5075. }
  5076. else{
  5077. displayInChat("No poll has been started","#DA0808","#1EBCC1");
  5078. displayInChat("Type '/startpoll [seconds]' to start a poll.","#DA0808","#1EBCC1");
  5079. }
  5080. return "";
  5081. }
  5082. else if (chat_val.substring(1,7)=="moveA " && chat_val.replace(/^\s+|\s+$/g, '').length>=8){
  5083. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '');
  5084. var keys = Object.keys(playerids);
  5085. var t = -1;
  5086. if(text == "f"){
  5087. t = 1;
  5088. }
  5089. else if(text == "b"){
  5090. t = 3;
  5091. }
  5092. else if(text == "g"){
  5093. t = 4;
  5094. }
  5095. else if(text == "r"){
  5096. t = 2;
  5097. }
  5098. else if(text == "y"){
  5099. t = 5;
  5100. }
  5101. else if(text == "s"){
  5102. t = 0;
  5103. }
  5104. if(t == -1){
  5105. displayInChat("The format for this command is:","#DA0808","#1EBCC1");
  5106. displayInChat("/moveA [letter]","#DA0808","#1EBCC1");
  5107. displayInChat("For example: '/moveA r' would move everyone to red team.","#DA0808","#1EBCC1");
  5108. return "";
  5109. }
  5110. for(var i = 0;i<keys.length;i++){
  5111. SEND('42[26,{"targetID":'+keys[i].toString()+',"targetTeam":'+t.toString()+'}]');
  5112. if(playerids[keys[i]].peerID!="sandbox"){
  5113. RECIEVE('42[18,'+keys[i].toString()+','+t.toString()+']');
  5114. }
  5115. }
  5116. return "";
  5117. }
  5118. else if (chat_val.substring(1,7)=="moveT " && chat_val.replace(/^\s+|\s+$/g, '').length>=8){
  5119. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '').split(" ").filter(function(i){if(i==""){return false}else{return true}});
  5120. if(text.length == 2){
  5121. var firstteam = -1;
  5122. var secondteam = -1;
  5123. for(var i = 0;i<2;i++){
  5124. var t = -1;
  5125. if(text[i] == "f"){
  5126. t = 1;
  5127. }
  5128. else if(text[i] == "b"){
  5129. t = 3;
  5130. }
  5131. else if(text[i] == "g"){
  5132. t = 4;
  5133. }
  5134. else if(text[i] == "r"){
  5135. t = 2;
  5136. }
  5137. else if(text[i] == "y"){
  5138. t = 5;
  5139. }
  5140. else if(text[i] == "s"){
  5141. t = 0;
  5142. }
  5143. if(t==-1){
  5144. displayInChat("The format for this command is:","#DA0808","#1EBCC1");
  5145. displayInChat("/moveT [letter] [letter]","#DA0808","#1EBCC1");
  5146. displayInChat("For example: '/moveT s r' would move everyone in spectate to red team.","#DA0808","#1EBCC1");
  5147. return "";
  5148. }
  5149. else{
  5150. if(i == 0){
  5151. firstteam = t;
  5152. }
  5153. else{
  5154. secondteam = t;
  5155. }
  5156. }
  5157. }
  5158. var keys = Object.keys(playerids);
  5159. for(var i = 0;i<keys.length;i++){
  5160. if(playerids[keys[i]].team == firstteam){
  5161. SEND('42[26,{"targetID":'+keys[i].toString()+',"targetTeam":'+secondteam.toString()+'}]');
  5162. if(playerids[keys[i]].peerID!="sandbox"){
  5163. RECIEVE('42[18,'+keys[i].toString()+','+secondteam.toString()+']');
  5164. }
  5165. }
  5166. }
  5167. }
  5168. else{
  5169. displayInChat("The format for this command is:","#DA0808","#1EBCC1");
  5170. displayInChat("/moveT [team] [team]","#DA0808","#1EBCC1");
  5171. displayInChat("For example: '/moveT s r' would move everyone in spectate to red team.","#DA0808","#1EBCC1");
  5172. return "";
  5173. }
  5174. return "";
  5175. }
  5176. if (chat_val.substring(1,13)=="roundsperqp " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  5177. var text = parseInt(chat_val.substring(13).replace(/^\s+|\s+$/g, ''));
  5178. if(isNaN(text)){
  5179. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  5180. return "";
  5181. }
  5182. else if(text<=0){
  5183. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  5184. return "";
  5185. }
  5186. roundsperqp = text;
  5187. roundsperqp2 = 0;
  5188. displayInChat("Set rounds per quickplay to: " + text.toString(),"#DA0808","#1EBCC1");
  5189. displayInChat("Type '/roundsperqp' to reset rounds per quickplay.","#DA0808","#1EBCC1");
  5190. return "";
  5191.  
  5192. }
  5193. else if (chat_val.substring(1,12)=="roundsperqp"){
  5194. roundsperqp = 1;
  5195. roundsperqp2 = 0;
  5196. displayInChat("Reset rounds per quickplay.","#DA0808","#1EBCC1");
  5197. return "";
  5198.  
  5199. }
  5200. else if (chat_val.substring(1,8)=="rounds " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  5201. var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '');
  5202. if(!isNaN(parseInt(text))){
  5203. text = parseInt(text).toString();
  5204. SEND('42[21,{"w":'+text+'}]');
  5205. RECIEVE('42[27,'+text+']');
  5206. }
  5207. return "";
  5208.  
  5209. }
  5210. else if (chat_val.substring(1,13)=="disablekeys " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  5211. var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '');
  5212. var keys = text.split(" ");
  5213. var disabledkeys2 = [];
  5214. var possiblekeys = ["left","right","up","down","heavy","special"];
  5215. for(var i = 0; i<keys.length; i++){
  5216. if(keys[i]!="" && !disabledkeys2.includes(keys[i])){
  5217. if(possiblekeys.includes(keys[i])){
  5218. disabledkeys2.push(keys[i]);
  5219. }
  5220. else{
  5221. displayInChat("Key options: " + possiblekeys.join(" ") + ".","#DA0808","#1EBCC1");
  5222. return "";
  5223. }
  5224. }
  5225. }
  5226. disabledkeys = disabledkeys2;
  5227. displayInChat("Set disabled keys to: " + disabledkeys.join(" ") + ".","#DA0808","#1EBCC1");
  5228. displayInChat("Type '/disablekeys' to reset disabled keys.","#DA0808","#1EBCC1");
  5229. return "";
  5230.  
  5231. }
  5232. else if (chat_val.substring(1,12)=="disablekeys"){
  5233. displayInChat("Reset disabled keys.","#DA0808","#1EBCC1");
  5234. disabledkeys = [];
  5235. return "";
  5236.  
  5237. }
  5238. else if (chat_val.substring(1,10)=="jointext " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  5239. jointext = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  5240. displayInChat("Set jointext to: " + jointext,"#DA0808","#1EBCC1");
  5241. displayInChat("Type '/jointext' to reset jointext.","#DA0808","#1EBCC1");
  5242. return "";
  5243.  
  5244. }
  5245. else if (chat_val.substring(1,9)=="jointext"){
  5246. jointext = "";
  5247. displayInChat("Reset jointext.","#DA0808","#1EBCC1");
  5248. return "";
  5249.  
  5250. }
  5251. else if (chat_val.substring(1,10)=="jointeam " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  5252. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  5253. var keys = Object.keys(playerids);
  5254. var t = -1;
  5255. if(text == "f"){
  5256. t = 1;
  5257. displayInChat("Set jointeam to FFA.","#DA0808","#1EBCC1");
  5258. }
  5259. else if(text == "b"){
  5260. t = 3;
  5261. displayInChat("Set jointeam to blue team.","#DA0808","#1EBCC1");
  5262. }
  5263. else if(text == "g"){
  5264. t = 4;
  5265. displayInChat("Set jointeam to green team.","#DA0808","#1EBCC1");
  5266. }
  5267. else if(text == "r"){
  5268. t = 2;
  5269. displayInChat("Set jointeam to red team.","#DA0808","#1EBCC1");
  5270. }
  5271. else if(text == "y"){
  5272. t = 5;
  5273. displayInChat("Set jointeam to yellow team.","#DA0808","#1EBCC1");
  5274. }
  5275. else if(text == "s"){
  5276. t = 0;
  5277. displayInChat("Set jointeam to spectate.","#DA0808","#1EBCC1");
  5278. }
  5279. if(t == -1){
  5280. displayInChat("The format for this command is:","#DA0808","#1EBCC1");
  5281. displayInChat("/jointeam [letter]","#DA0808","#1EBCC1");
  5282. displayInChat("For example: '/jointeam r' would move every joined person to red team.","#DA0808","#1EBCC1");
  5283. return "";
  5284. }
  5285. displayInChat("Type '/jointeam' to reset jointeam.","#DA0808","#1EBCC1");
  5286. jointeam = t;
  5287. return "";
  5288. }
  5289. else if (chat_val.substring(1,9)=="jointeam"){
  5290. jointeam = -1;
  5291. displayInChat("Reset jointeam.","#DA0808","#1EBCC1");
  5292. return "";
  5293.  
  5294. }
  5295. else if (chat_val.substring(1,9)=="wintext " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  5296. wintext = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  5297. displayInChat("Set wintext to: " + wintext,"#DA0808","#1EBCC1");
  5298. displayInChat("Type '/wintext' to reset wintext.","#DA0808","#1EBCC1");
  5299. return "";
  5300.  
  5301. }
  5302. else if (chat_val.substring(1,8)=="wintext"){
  5303. wintext = "";
  5304. displayInChat("Reset wintext.","#DA0808","#1EBCC1");
  5305. return "";
  5306.  
  5307. }
  5308. else if (chat_val.substring(1,11)=="autorecord"){
  5309. if(autorecord){
  5310. autorecord = false;
  5311. displayInChat("Autorecord is now off.","#DA0808","#1EBCC1");
  5312. }
  5313. else{
  5314. autorecord = true;
  5315. displayInChat("Autorecord is now on.","#DA0808","#1EBCC1");
  5316. }
  5317. return "";
  5318.  
  5319. }
  5320. else if (chat_val.substring(1,9)=="afkkill " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  5321. var text = parseFloat(chat_val.substring(9).replace(/^\s+|\s+$/g, ''));
  5322. if(!isNaN(text)){
  5323. if(text>0){
  5324. displayInChat("Set afk kill to: " + text.toString()+" seconds.","#DA0808","#1EBCC1");
  5325. displayInChat("Type '/afkkill' to reset afk kill.","#DA0808","#1EBCC1");
  5326. var keys = Object.keys(playerids);
  5327. var now = Date.now();
  5328. for(var i = 0;i<keys.length;i++){
  5329. playerids[keys[i]].lastmove = now;
  5330. }
  5331. afkkill = text;
  5332. }
  5333. else{
  5334. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  5335. }
  5336. }
  5337. else{
  5338. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  5339. }
  5340. return "";
  5341.  
  5342. }
  5343. else if (chat_val.substring(1,9)=="afkkill"){
  5344. afkkill = -1;
  5345. displayInChat("Reset afk kill.","#DA0808","#1EBCC1");
  5346. return "";
  5347.  
  5348. }
  5349. else if (chat_val.substring(1,13)=="defaultmode " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  5350. var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '');
  5351. if(text == "default"){
  5352. defaultmode = "";
  5353. displayInChat("Changed default mode to default.","#DA0808","#1EBCC1");
  5354. }
  5355. else if(text == "arrows"){
  5356. defaultmode = "ar";
  5357. displayInChat("Changed default mode to arrows.","#DA0808","#1EBCC1");
  5358. }
  5359. else if(text == "death arrows"){
  5360. defaultmode = "ard";
  5361. displayInChat("Changed default mode to death arrows.","#DA0808","#1EBCC1");
  5362. }
  5363. else if(text == "grapple"){
  5364. defaultmode = "sp";
  5365. displayInChat("Changed default mode to grapple.","#DA0808","#1EBCC1");
  5366. }
  5367. else if(text == "classic"){
  5368. defaultmode = "b";
  5369. displayInChat("Changed default mode to classic.","#DA0808","#1EBCC1");
  5370.  
  5371. }
  5372. else{
  5373. displayInChat("Default mode options:","#DA0808","#1EBCC1");
  5374. displayInChat("default","#DA0808","#1EBCC1");
  5375. displayInChat("classic","#DA0808","#1EBCC1");
  5376. displayInChat("arrows","#DA0808","#1EBCC1");
  5377. displayInChat("death arrows","#DA0808","#1EBCC1");
  5378. displayInChat("grapple","#DA0808","#1EBCC1");
  5379. }
  5380. return "";
  5381.  
  5382. }
  5383. else if (chat_val.substring(1,8)=="recmode"){
  5384. if(recmodebool == true){
  5385. recmodebool = false;
  5386. displayInChat("Recmode is now off.","#DA0808","#1EBCC1");
  5387.  
  5388. }
  5389. else{
  5390. recmodebool = true;
  5391. displayInChat("Recmode is now on.","#DA0808","#1EBCC1");
  5392.  
  5393. }
  5394.  
  5395. return "";
  5396.  
  5397. }
  5398. else if (chat_val.substring(1,8)=="recteam"){
  5399. if(recteams == true){
  5400. recteams = false;
  5401. displayInChat("Recteam is now off.","#DA0808","#1EBCC1");
  5402.  
  5403. }
  5404. else{
  5405. recteams = true;
  5406. displayInChat("Recteam is now on.","#DA0808","#1EBCC1");
  5407.  
  5408. }
  5409. return "";
  5410. }
  5411. else if (chat_val.substring(1,8)=="shuffle"){
  5412. if(shuffle == true){
  5413. shuffle = false;
  5414. displayInChat("Shuffle is now off.","#DA0808","#1EBCC1");
  5415.  
  5416. }
  5417. else{
  5418. shuffle = true;
  5419. displayInChat("Shuffle is now on.","#DA0808","#1EBCC1");
  5420.  
  5421. }
  5422.  
  5423. return "";
  5424.  
  5425. }
  5426. else if (chat_val.substring(1,9)=="autokick"){
  5427. if(autokickban == 0){
  5428. displayInChat("Autokick is now on.","#DA0808","#1EBCC1");
  5429. autokickban = 1;
  5430. }
  5431. else if(autokickban == 1){
  5432. autokickban = 0;
  5433. displayInChat("Autokick is now off.","#DA0808","#1EBCC1");
  5434. }
  5435. else{
  5436. autokickban = 1;
  5437. displayInChat("Autokick is now on, and Autoban is now off.","#DA0808","#1EBCC1");
  5438. }
  5439.  
  5440. return "";
  5441. }
  5442. else if (chat_val.substring(1,8)=="autoban"){
  5443. if(autokickban == 0){
  5444. displayInChat("Autoban is now on.","#DA0808","#1EBCC1");
  5445. autokickban = 2;
  5446. }
  5447. else if(autokickban == 2){
  5448. autokickban = 0;
  5449. displayInChat("Autoban is now off.","#DA0808","#1EBCC1");
  5450. }
  5451. else{
  5452. autokickban = 2;
  5453. displayInChat("Autoban is now on, and Autokick is now off.","#DA0808","#1EBCC1");
  5454. }
  5455.  
  5456. return "";
  5457. }
  5458. else if (chat_val.substring(1,8)=="sandbox"){
  5459. if(sandboxon == false){
  5460. displayInChat("This room is now a sandbox room.","#DA0808","#1EBCC1");
  5461. sandboxon = true;
  5462. SEND('42[4,{"type":"sandboxon"}]');
  5463. var sandboxkeys = Object.keys(sandboxplayerids);
  5464. var packets = [];
  5465. for(var i = 0;i<sandboxkeys.length;i++){
  5466. var p = playerids[sandboxkeys[i]];
  5467. var packet = '42'+JSON.stringify([4,sandboxkeys[i],p.peerID,p.userName,p.guest,p.level,p.team,p.avatar]);
  5468. packets.push(packet);
  5469. }
  5470. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":packets,to:[-1]}]));
  5471. SEND("42"+JSON.stringify([4,{"type":"sandboxid","from":username,"lastid":sandboxid,to:[-1]}]));
  5472. }
  5473. else{
  5474. displayInChat("You cannot turn a sandbox room back into a normal room.","#DA0808","#1EBCC1");
  5475. }
  5476.  
  5477. return "";
  5478. }
  5479. else if(sandboxon){
  5480. if (chat_val.substring(1,11)=="addplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  5481. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  5482. if(!isNaN(parseInt(text))){
  5483. var text2 = parseInt(text);
  5484. if(text2>0){
  5485. for(var i = 0;i<text2;i++){
  5486. while(playerids[sandboxid]){
  5487. sandboxid+=1;
  5488. }
  5489. var color = Math.floor(Math.random() * 16777215).toString();
  5490. var packet = '42'+JSON.stringify([4,sandboxid,"sandbox",sandboxid.toString(),true,0,0,{"layers":[],"bc":color}]);
  5491. RECIEVE(packet);
  5492. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  5493. sandboxplayerids[sandboxid] = sandboxid.toString();
  5494. sandboxid+=1;
  5495. }
  5496.  
  5497. }
  5498. }
  5499. return "";
  5500.  
  5501. }
  5502. if (chat_val.substring(1,9)=="addname " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  5503. var text = chat_val.substring(9).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  5504. while(playerids[sandboxid]){
  5505. sandboxid+=1;
  5506. }
  5507. var keys = Object.keys(playerids);
  5508. var addon = "";
  5509. var escape = false;
  5510. var keysi = -1;
  5511. while(!escape){
  5512. escape = true;
  5513. for(var i = 0;i<keys.length;i++){
  5514. if(playerids[keys[i]].userName == text+addon){
  5515. addon+="‎";
  5516. var escape = false;
  5517. }
  5518. if(playerids[keys[i]].userName == text){
  5519. keysi = keys[i];
  5520. }
  5521. }
  5522. }
  5523. if(keysi!=-1){
  5524. var packet = '42'+JSON.stringify([4,sandboxid,"sandbox",text+addon,playerids[keysi].guest,playerids[keysi].level,0,playerids[keysi].avatar]);
  5525. RECIEVE(packet);
  5526. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  5527. }
  5528. else{
  5529. var color = Math.floor(Math.random() * 16777215).toString();
  5530. var packet = '42'+JSON.stringify([4,sandboxid,"sandbox",text+addon,true,0,0,{"layers":[],"bc":color}]);
  5531. RECIEVE(packet);
  5532. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  5533. }
  5534. sandboxplayerids[sandboxid] = sandboxid.toString();
  5535. sandboxid+=1;
  5536. return "";
  5537.  
  5538. }
  5539. else if (chat_val.substring(1,11)=="delplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  5540. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  5541. if(!isNaN(parseInt(text))){
  5542. var text2 = parseInt(text);
  5543. if(text2>0){
  5544. if(Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden"){
  5545. var jsonkeys = Object.keys(sandboxplayerids).reverse();
  5546. var packets = [];
  5547. for(var i = 0;i<text2 && i<jsonkeys.length;i++){
  5548. var packet = '42[5,'+jsonkeys[i]+',0]';
  5549. RECIEVE(packet);
  5550. packets.push(packet);
  5551. delete sandboxplayerids[jsonkeys[i]];
  5552. }
  5553. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":packets,to:[-1]}]));
  5554. }
  5555. else{
  5556. displayInChat("Cannot delete players while ingame.","#DA0808","#1EBCC1");
  5557. }
  5558.  
  5559. }
  5560. }
  5561. return "";
  5562. }
  5563. else if (chat_val.substring(1,6)=="copy " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  5564. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  5565. var keys = Object.keys(playerids);
  5566. var keys2 = Object.keys(sandboxplayerids);
  5567. var copiedperson = -1;
  5568. for(var i = 0;i<keys.length;i++){
  5569. if(playerids[keys[i]].userName==text){
  5570. copiedperson = keys[i];
  5571. }
  5572. }
  5573. if(copiedperson==-1){
  5574. displayInChat(playerids[copiedperson].userName + " was not found in this room.","#DA0808","#1EBCC1");
  5575. return "";
  5576. }
  5577. if(keys2.includes(copiedperson.toString())){
  5578. displayInChat("Bots cannot copy a bot.","#DA0808","#1EBCC1");
  5579. return "";
  5580. }
  5581. displayInChat("All bots will now copy "+playerids[copiedperson].userName+".","#DA0808","#1EBCC1");
  5582. displayInChat("To reset copy, type '/copy'.","#DA0808","#1EBCC1");
  5583. sandboxcopyme = copiedperson;
  5584.  
  5585. return "";
  5586. }
  5587. else if (chat_val.substring(1,5)=="copy"){
  5588. sandboxcopyme = -1;
  5589. displayInChat("Copy is now off.","#DA0808","#1EBCC1");
  5590. return "";
  5591. }
  5592. }
  5593. }
  5594. return chat_val;
  5595. };
  5596.  
  5597. scope.flag_manage = function(t){
  5598. var text = t;
  5599. if(autocorrect == true){
  5600. var text2 = text.split(" ");
  5601. for(var i = 0;i<text2.length;i++){
  5602. text2[i] = closestWord(text2[i]);
  5603. }
  5604. text = text2.join(" ");
  5605. }
  5606. if(reverse_flag == true){
  5607. text = text.split("").reverse().join("")
  5608. }
  5609. if(rcaps_flag == true){
  5610. text = text.split('');
  5611. for(var i = 0; i<text.length;i++){
  5612. if(Math.floor(Math.random()*2)){
  5613. text[i] = text[i].toUpperCase();
  5614. }
  5615. else{
  5616. text[i] = text[i].toLowerCase();
  5617. }
  5618. }
  5619. text = text.join('');
  5620. }
  5621. if(space_flag == true){
  5622. text = text.split('').join(' ')
  5623. }
  5624. if(number_flag == true){
  5625. text = text.replace(/[t|T][Oo]+/g,"2");
  5626. text = text.replace(/[f|F][o|O][r|R]/g,"4");
  5627. text = text.replace(/[a|A][t|T][e|E]/g,"8");
  5628. text = text.replace(/[e|E]/g,"3");
  5629. text = text.replace(/[a|A]/g,"4");
  5630. text = text.replace(/[o|O]/g,"0");
  5631. text = text.replace(/[s|S]/g,"5");
  5632. text = text.replace(/[i|I|l|L]/g,"1");
  5633. }
  5634. return text;
  5635. };
  5636. Gdocument.getElementById("newbonklobby_chat_input").onkeydown = function(e){
  5637. if(e.keyCode==13){
  5638.  
  5639. var chat_val = Gdocument.getElementById("newbonklobby_chat_input").value;
  5640.  
  5641. if (chat_val!="" && chat_val[0]=="/"){
  5642.  
  5643. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  5644. chat2(commandhandle(chat_val));
  5645. }
  5646. else{
  5647. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  5648. chat2(flag_manage(chat_val));
  5649. }
  5650.  
  5651. }
  5652. };
  5653. Gdocument.getElementById("ingamechatinputtext").onkeydown = function(e){
  5654. if(e.keyCode==13){
  5655.  
  5656. var chat_val = Gdocument.getElementById("ingamechatinputtext").value;
  5657.  
  5658. if (chat_val!="" && chat_val[0]=="/"){
  5659.  
  5660. Gdocument.getElementById("ingamechatinputtext").value = "";
  5661. chat2(commandhandle(chat_val));
  5662. }
  5663. else{
  5664. Gdocument.getElementById("ingamechatinputtext").value = "";
  5665. chat2(flag_manage(chat_val));
  5666. }
  5667. }
  5668. };
  5669. scope.Last_message = "";
  5670. scope.Laster_message = "";
  5671. scope.new_message = false;
  5672. scope.changed_chat = false;
  5673. scope.injectedBonkCommandsScript = setInterval(timeout123,60);
  5674.  
  5675. scope.hotkeys = function(e){
  5676. var keycode = e.code;
  5677. if(e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  5678. if(keycode == "Period"){
  5679. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]!="0px"){
  5680. chatheight+=5;
  5681. if(chatheight>600){chatheight = 600;}
  5682. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  5683. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  5684. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  5685. }
  5686. e.preventDefault();
  5687. }
  5688. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  5689. if(keycode == "KeyG"){
  5690. var addto = 0;
  5691. for(var i = 0;i<parentDraw.children.length;i++){
  5692. if(parentDraw.children[i].constructor.name == "e"){
  5693. addto = parentDraw.children[i];
  5694. break;
  5695. }
  5696. }
  5697. var canv = 0;
  5698. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  5699. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  5700. canv = Gdocument.getElementById("gamerenderer").children[i];
  5701. break;
  5702. }
  5703. }
  5704. var width = parseInt(canv.style["width"]);
  5705. var height = parseInt(canv.style["height"]);
  5706. if(addto){
  5707. zoom *= 1.1;
  5708. }
  5709. addto.scale.x = zoom;
  5710. addto.scale.y = zoom;
  5711. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  5712. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  5713. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  5714. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  5715. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999 && !FollowCam){
  5716. pixiCircle.visible = false;
  5717. }
  5718. else{
  5719. pixiCircle.visible = true;
  5720. }
  5721. e.preventDefault();
  5722. }
  5723. if(keycode == "KeyH"){
  5724. var addto = 0;
  5725. for(var i = 0;i<parentDraw.children.length;i++){
  5726. if(parentDraw.children[i].constructor.name == "e"){
  5727. addto = parentDraw.children[i];
  5728. break;
  5729. }
  5730. }
  5731. var canv = 0;
  5732. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  5733. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  5734. canv = Gdocument.getElementById("gamerenderer").children[i];
  5735. break;
  5736. }
  5737. }
  5738. var width = parseInt(canv.style["width"]);
  5739. var height = parseInt(canv.style["height"]);
  5740. if(addto){
  5741. zoom = 1;
  5742. }
  5743. addto.scale.x = zoom;
  5744. addto.scale.y = zoom;
  5745. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  5746. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  5747. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  5748. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  5749. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999 && !FollowCam){
  5750. pixiCircle.visible = false;
  5751. }
  5752. else{
  5753. pixiCircle.visible = true;
  5754. }
  5755. e.preventDefault();
  5756. }
  5757. if(keycode == "KeyJ"){
  5758. var addto = 0;
  5759. for(var i = 0;i<parentDraw.children.length;i++){
  5760. if(parentDraw.children[i].constructor.name == "e"){
  5761. addto = parentDraw.children[i];
  5762. break;
  5763. }
  5764. }
  5765. var canv = 0;
  5766. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  5767. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  5768. canv = Gdocument.getElementById("gamerenderer").children[i];
  5769. break;
  5770. }
  5771. }
  5772. var width = parseInt(canv.style["width"]);
  5773. var height = parseInt(canv.style["height"]);
  5774. if(addto){
  5775. zoom /= 1.1;
  5776. }
  5777. addto.scale.x = zoom;
  5778. addto.scale.y = zoom;
  5779. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  5780. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  5781. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  5782. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  5783. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999 && !FollowCam){
  5784. pixiCircle.visible = false;
  5785. }
  5786. else{
  5787. pixiCircle.visible = true;
  5788. }
  5789. e.preventDefault();
  5790. }
  5791. }
  5792. if(keycode == "Comma"){
  5793. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]!="0px"){
  5794. chatheight-=5;
  5795. if(chatheight<100){chatheight = 100;}
  5796. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  5797. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  5798. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  5799. }
  5800. e.preventDefault();
  5801. }
  5802. }
  5803. if(e.repeat){return;}
  5804. if(e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  5805. if(ishost){
  5806. if(keycode == "KeyE"){
  5807. if(Gdocument.getElementById("newbonklobby").style["display"] == "block"){
  5808. Gdocument.getElementById("newbonklobby_editorbutton").click();
  5809. }
  5810. else if(Gdocument.getElementById("mapeditorcontainer").style["display"] == "block"){
  5811. Gdocument.getElementById("mapeditor_close").click();
  5812. }
  5813. e.preventDefault();
  5814.  
  5815. }
  5816. else if(keycode == "KeyT"){
  5817. Gdocument.getElementById("newbonklobby_teamsbutton").click();
  5818. e.preventDefault();
  5819. }
  5820. else if(keycode == "KeyM"){
  5821. Gdocument.getElementById("newbonklobby_modebutton").click();
  5822. e.preventDefault();
  5823. }
  5824. else if(keycode == "KeyK"){
  5825. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  5826. Gdocument.getElementById("pretty_top_exit").click();
  5827. }
  5828. e.preventDefault();
  5829. }
  5830. else if(keycode == "KeyS"){
  5831. if(Gdocument.getElementById("mapeditorcontainer").style["display"]!="block"){
  5832. Gdocument.getElementById("newbonklobby_editorbutton").click();
  5833. }
  5834. if(recmodebool && ishost){
  5835. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  5836. if(mode == "" && defaultmode!="d"){
  5837. mode = defaultmode;
  5838. }
  5839. if(mode != ""){
  5840. RECIEVE('42[26,"b","'+mode+'"]');
  5841. }
  5842. }
  5843. Gdocument.getElementById("mapeditor_close").click();
  5844. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  5845. roundsperqp2 = 0;
  5846. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  5847. e.preventDefault();
  5848. }
  5849. else if(keycode == "KeyD"){
  5850. roundsperqp2 = 0;
  5851. if(stopquickplay == 0){
  5852. if(shuffle){
  5853. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  5854. var available = [];
  5855. var availableindexes = [];
  5856. var notempty = false;
  5857. for(var i = 0; i<e2.length;i++){
  5858. var a = false;
  5859. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  5860. available.push(a);
  5861. if(a){
  5862. availableindexes.push(i);
  5863. notempty = true;
  5864. }
  5865. }
  5866. if(notempty){
  5867.  
  5868. if(availableindexes.length!=1){
  5869. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  5870. }
  5871. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  5872. }
  5873. }
  5874. else{
  5875. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  5876. var available = [];
  5877. var availableindexes = [];
  5878. var notempty = false;
  5879. for(var i = 0; i<e2.length;i++){
  5880. var a = false;
  5881. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  5882. available.push(a);
  5883. if(a){
  5884. availableindexes.push(i);
  5885. notempty = true;
  5886. }
  5887. }
  5888. if(notempty){
  5889. var above = [];
  5890. for(var i = 0;i<availableindexes.length;i++){
  5891. if(availableindexes[i]>quicki && !reverseqp){
  5892. above.push(availableindexes[i]);
  5893. }
  5894. else if(availableindexes[i]<quicki && reverseqp){
  5895. above.push(availableindexes[i])
  5896. }
  5897. }
  5898. if(above.length>0){
  5899. quicki = above[0];
  5900. if(reverseqp){
  5901. quicki = above[above.length-1];
  5902. }
  5903. }
  5904. else{
  5905. quicki = availableindexes[0];
  5906. if(reverseqp){
  5907. quicki = availableindexes[availableindexes.length-1];
  5908. }
  5909. }
  5910. }
  5911. }
  5912. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  5913. }
  5914. e.preventDefault();
  5915. }
  5916. else if(keycode == "KeyA"){
  5917. if(stopquickplay == 0){
  5918. roundsperqp2 = 0;
  5919. if(shuffle){
  5920. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  5921. var available = [];
  5922. var availableindexes = [];
  5923. var notempty = false;
  5924. for(var i = 0; i<e2.length;i++){
  5925. var a = false;
  5926. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  5927. available.push(a);
  5928. if(a){
  5929. availableindexes.push(i);
  5930. notempty = true;
  5931. }
  5932. }
  5933. if(notempty){
  5934.  
  5935. if(availableindexes.length!=1){
  5936. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  5937. }
  5938. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  5939. }
  5940. }
  5941. else{
  5942. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  5943. var available = [];
  5944. var availableindexes = [];
  5945. var notempty = false;
  5946. for(var i = 0; i<e2.length;i++){
  5947. var a = false;
  5948. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  5949. available.push(a);
  5950. if(a){
  5951. availableindexes.push(i);
  5952. notempty = true;
  5953. }
  5954. }
  5955. if(notempty){
  5956. var above = [];
  5957. for(var i = 0;i<availableindexes.length;i++){
  5958. if(availableindexes[i]<quicki && !reverseqp){
  5959. above.push(availableindexes[i]);
  5960. }
  5961. else if(availableindexes[i]>quicki && reverseqp){
  5962. above.push(availableindexes[i])
  5963. }
  5964. }
  5965. if(above.length>0){
  5966. quicki = above[above.length-1];
  5967. if(reverseqp){
  5968. quicki = above[0];
  5969. }
  5970. }
  5971. else{
  5972. quicki = availableindexes[availableindexes.length-1];
  5973. if(reverseqp){
  5974. quicki = availableindexes[0];
  5975. }
  5976. }
  5977. }
  5978. }
  5979. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  5980. }
  5981. e.preventDefault();
  5982. }
  5983. else if(keycode == "KeyQ"){
  5984. if(stopquickplay == 1){
  5985. stopquickplay = 0;
  5986. quicki = 0;
  5987. qppaused = false;
  5988. displayInChat("Enabled quickplay.","#DA0808","#1EBCC1");
  5989. }
  5990. else{
  5991. stopquickplay = 1;
  5992. quicki = 0;
  5993. qppaused = false;
  5994. displayInChat("Disabled quickplay.","#DA0808","#1EBCC1");
  5995. }
  5996. e.preventDefault();
  5997. }
  5998. else if(keycode == "KeyP" && stopquickplay==0){
  5999. if(qppaused == true){
  6000. qppaused = false;
  6001. displayInChat("Unpaused quickplay.","#DA0808","#1EBCC1");
  6002. }
  6003. else{
  6004. qppaused = true;
  6005. displayInChat("Paused quickplay.","#DA0808","#1EBCC1");
  6006. }
  6007. e.preventDefault();
  6008. }
  6009. else if(keycode == "KeyR"){
  6010. if(recmodebool == true){
  6011. recmodebool = false;
  6012. displayInChat("Recmode is now off.","#DA0808","#1EBCC1");
  6013.  
  6014. }
  6015. else{
  6016. recmodebool = true;
  6017. displayInChat("Recmode is now on.","#DA0808","#1EBCC1");
  6018.  
  6019. }
  6020. }
  6021. else if(keycode == "KeyF"){
  6022. if(freejoin == false){
  6023. freejoin = true;
  6024. displayInChat("Freejoin is now on.","#DA0808","#1EBCC1");
  6025.  
  6026. }
  6027. else{
  6028. freejoin = false;
  6029. displayInChat("Freejoin is now off.","#DA0808","#1EBCC1");
  6030. }
  6031. e.preventDefault();
  6032. }
  6033. }
  6034. else{
  6035. if(keycode == "KeyE"){
  6036. e.preventDefault();
  6037. }
  6038. else if(keycode == "KeyT"){
  6039. e.preventDefault();
  6040. }
  6041. else if(keycode == "KeyM"){
  6042. e.preventDefault();
  6043. }
  6044. else if(keycode == "KeyK"){
  6045. e.preventDefault();
  6046. }
  6047. else if(keycode == "KeyS"){
  6048. e.preventDefault();
  6049. }
  6050. else if(keycode == "KeyD"){
  6051. e.preventDefault();
  6052. }
  6053. else if(keycode == "KeyA"){
  6054. e.preventDefault();
  6055. }
  6056. else if(keycode == "KeyQ"){
  6057. e.preventDefault();
  6058. }
  6059. else if(keycode == "KeyP"){
  6060. e.preventDefault();
  6061. }
  6062. else if(keycode == "KeyF"){
  6063. e.preventDefault();
  6064. }
  6065. else if(keycode == "KeyR"){
  6066. e.preventDefault();
  6067. }
  6068.  
  6069. }
  6070. if(keycode == "KeyL"){
  6071. lobby();
  6072. e.preventDefault();
  6073. }
  6074. if(keycode == "KeyC"){
  6075. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  6076. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]=="0px"){
  6077. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  6078. }
  6079. else{
  6080. Gdocument.getElementById("ingamechatcontent").style["max-height"]="0px";
  6081. }
  6082. }
  6083. e.preventDefault();
  6084. }
  6085. if(keycode == "KeyI"){
  6086. if(Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"] == "none"){
  6087. debuggeropen = true;
  6088. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="block";
  6089. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="none";
  6090. Gdocument.getElementById("ingamechatinputtext").style["display"] = "none";
  6091. }
  6092. else{
  6093. debuggeropen = false;
  6094. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="none";
  6095. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  6096. Gdocument.getElementById("ingamechatinputtext").style["display"] = "";
  6097. }
  6098. e.preventDefault();
  6099. }
  6100. if(keycode == "KeyB"){
  6101. var element = Gdocument.getElementById("ingamewinner_scores");
  6102. if(element.style["opacity"]<1){
  6103. element.style["opacity"] = 1;
  6104. element.style["visibility"] = "visible";
  6105. }
  6106. else{
  6107. element.style["opacity"] = 0;
  6108. element.style["visibility"] = "unset";
  6109. }
  6110. e.preventDefault();
  6111. }
  6112. if(keycode == "KeyY"){
  6113. Gdocument.getElementById("pretty_top_settings").click();
  6114. Gdocument.getElementById("settings_close").click();
  6115. if(Gdocument.getElementById("settings_graphicsquality").value==1){
  6116. displayInChat("You must have medium or high quality enabled to use this feature.","#DA0808","#1EBCC1");
  6117. return "";
  6118. }
  6119.  
  6120.  
  6121. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  6122. var addto = {"children":[]};
  6123. for(var i = 0;i<parentDraw.children.length;i++){
  6124. if(parentDraw.children[i].constructor.name == "e"){
  6125. addto = parentDraw.children[i];
  6126. break;
  6127. }
  6128. }
  6129. var addto2 = {"children":[]};
  6130. for(var i = 0;i<addto.children.length;i++){
  6131. if(addto.children[i].constructor.name == "e"){
  6132. addto2 = addto.children[i];
  6133. break;
  6134. }
  6135. }
  6136. var checkxray = addto2.children[0];
  6137. var addto3 = addto2.children[0].children;
  6138. if(addto3.length==1){
  6139. checkxray = checkxray.children[0];
  6140. addto3 = addto3[0].children;
  6141. }
  6142. var xrayon = false;
  6143. if(checkxray.xrayon){
  6144. checkxray.xrayon = false;
  6145. xrayon = false;
  6146. }
  6147. else{
  6148. checkxray.xrayon = true;
  6149. xrayon = true;
  6150. }
  6151. if(xrayon){
  6152. displayInChat("Xray is now on.","#DA0808","#1EBCC1");
  6153. for(var i = 0;i<addto3.length;i++){
  6154. if(addto3[i].children.length>0){
  6155. var ids = [];
  6156. var ids2 = [];
  6157. for(var i3 = 0;i3<addto3[i].children.length;i3++){
  6158. addto3[i].children[i3].visible = false;
  6159. if(addto3[i].children[i3].children.length>0){
  6160. for(var i4 = 0;i4<addto3[i].children[i3].children.length;i4++){
  6161. if(addto3[i].children[i3].children[i4].geometry?.id){
  6162. ids.push(addto3[i].children[i3].children[i4].geometry.id);
  6163. }
  6164. else if(addto3[i].children[i3].children[i4].texture?.baseTexture?.uid){
  6165. ids2.push(addto3[i].children[i3].children[i4].texture.baseTexture.uid);
  6166. }
  6167. }
  6168. }
  6169. }
  6170. for(var i3 = 0;i3<addto3[i].children.length;i3++){
  6171. if(addto3[i].children[i3].children.length==0){
  6172. if(addto3[i].children[i3].geometry?.id){
  6173. if(ids.includes(addto3[i].children[i3].geometry.id+1)){
  6174. addto3[i].children[i3].visible = true;
  6175. addto3[i].children[i3].alpha = 0.5;
  6176. }
  6177. }
  6178. else if(addto3[i].children[i3].texture?.baseTexture?.uid){
  6179. if(ids2.includes(addto3[i].children[i3].texture.baseTexture.uid+1)){
  6180. addto3[i].children[i3].visible = true;
  6181. addto3[i].children[i3].alpha = 0.5;
  6182. }
  6183. }
  6184. }
  6185. }
  6186. }
  6187. }
  6188.  
  6189. }
  6190. else{
  6191. displayInChat("Xray is now off.","#DA0808","#1EBCC1");
  6192. for(var i = 0;i<addto3.length;i++){
  6193. for(var i2 = 0;i2<addto3[i].children.length;i2++){
  6194. addto3[i].children[i2].visible = true;
  6195. addto3[i].children[i2].alpha = 1;
  6196. }
  6197. }
  6198. }
  6199. }
  6200. e.preventDefault();
  6201. }
  6202. if(keycode == "KeyN"){
  6203. if(FollowCam == true){
  6204. displayInChat("Follow Camera is now off.","#DA0808","#1EBCC1");
  6205. FollowCam = false;
  6206. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  6207. var addto = {"children":[]};
  6208. for(var i = 0;i<parentDraw.children.length;i++){
  6209. if(parentDraw.children[i].constructor.name == "e"){
  6210. addto = parentDraw.children[i];
  6211. break;
  6212. }
  6213. }
  6214. var canv = 0;
  6215. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  6216. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  6217. canv = Gdocument.getElementById("gamerenderer").children[i];
  6218. break;
  6219. }
  6220. }
  6221. var width = parseInt(canv.style["width"]);
  6222. var height = parseInt(canv.style["height"]);
  6223. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  6224. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  6225. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  6226. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  6227. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999){
  6228. pixiCircle.visible = false;
  6229. }
  6230. else{
  6231. pixiCircle.visible = true;
  6232. }
  6233. }
  6234. }
  6235. else{
  6236. displayInChat("Follow Camera is now on.","#DA0808","#1EBCC1");
  6237. FollowCam = true;
  6238. }
  6239. e.preventDefault();
  6240. }
  6241. if(keycode == "KeyV"){
  6242. if(autocam == true){
  6243. displayInChat("Auto Cam is now off.","#DA0808","#1EBCC1");
  6244. autocam = false
  6245. }
  6246. else{
  6247. displayInChat("Auto Cam is now on.","#DA0808","#1EBCC1");
  6248. autocam = true;
  6249. }
  6250. e.preventDefault();
  6251. }
  6252. if(keycode == "KeyO"){
  6253. if(heavybot == true){
  6254. displayInChat("Heavy bot is now off.","#DA0808","#1EBCC1");
  6255. heavybot = false;
  6256. }
  6257. else{
  6258. displayInChat("Heavy bot is now on.","#DA0808","#1EBCC1");
  6259. heavybot = true;
  6260. getplayerkeys();
  6261. }
  6262. e.preventDefault();
  6263. }
  6264. if(keycode == "KeyU"){
  6265. if(aimbot == true){
  6266. displayInChat("Aimbot is now off.","#DA0808","#1EBCC1");
  6267. aimbot = false;
  6268. }
  6269. else{
  6270. displayInChat("Aimbot is now on.","#DA0808","#1EBCC1");
  6271. aimbot = true;
  6272. getplayerkeys();
  6273. }
  6274. e.preventDefault();
  6275. }
  6276. if(keycode == "KeyW"){
  6277. if(staystill == true){
  6278. displayInChat("Still is now off.","#DA0808","#1EBCC1");
  6279. staystill = false;
  6280. staystillpos = [0,0];
  6281. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  6282. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  6283. }
  6284. else{
  6285. if(playerids[myid].playerData?.transform){
  6286. displayInChat("Still is now on.","#DA0808","#1EBCC1");
  6287. staystill = true;
  6288. staystillpos = [playerids[myid].playerData.transform.position.x/scale,playerids[myid].playerData.transform.position.y/scale];
  6289. getplayerkeys();
  6290. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  6291. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  6292. }
  6293. else{
  6294. displayInChat("You have to be alive to use this command.","#DA0808","#1EBCC1");
  6295. }
  6296. }
  6297. e.preventDefault();
  6298. }
  6299. }
  6300. if(!e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  6301. if(keycode == "Slash" && !(Gdocument.getElementById("gmeditor")?.style["transform"] == "scale(1)")){
  6302. 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"]==""){
  6303. Gdocument.getElementById("newbonklobby_chat_input").value = "/";
  6304. if(Gdocument.getElementById("newbonklobby_chat_input").style["pointer-events"] == "none"){
  6305. fire("keydown",{keyCode:13});
  6306. }
  6307. else{
  6308. Gdocument.getElementById("newbonklobby_chat_input").focus();
  6309. }
  6310. e.preventDefault();
  6311.  
  6312. }
  6313. else if(Gdocument.getElementById("ingamechatinputtext").style["visibility"]=="visible" && Gdocument.getElementById("ingamechatinputtext").style["display"]=="" && Gdocument.getElementById("mapeditorcontainer").style["display"]!="block" && Gdocument.getElementById("ingamechatinputtext").value == ""){
  6314. Gdocument.getElementById("ingamechatinputtext").value = "/";
  6315. if(!Gdocument.getElementById("ingamechatinputtext").classList.value.includes("ingamechatinputtextbg")){
  6316. fire("keydown",{keyCode:13});
  6317. }
  6318. else{
  6319. Gdocument.getElementById("ingamechatinputtext").focus();
  6320. }
  6321. e.preventDefault();
  6322.  
  6323. }
  6324. }
  6325. }
  6326. };
  6327.  
  6328. Gdocument.onkeydown = hotkeys;
  6329.  
  6330. Gwindow.addEventListener('resize',function(e){
  6331. debuggermenu.style["width"] = Gdocument.getElementById("bonkiocontainer").style["width"];
  6332. debuggermenu.style["height"] = Gdocument.getElementById("bonkiocontainer").style["height"];
  6333. scope.width = parseInt(Gdocument.getElementById("bonkiocontainer").style["width"])-20;
  6334. scope.height = parseInt(Gdocument.getElementById("bonkiocontainer").style["height"])-210;
  6335. logmenu.style["width"] = width.toString()+"px";
  6336. logmenu.style["height"] = height.toString()+"px";
  6337. logmenutopleft.style["width"] = (width/2).toString()+"px";
  6338. logmenutopright.style["width"] = (width/2).toString()+"px";
  6339. logmenutopright.style["left"] = (width/2).toString()+"px";
  6340. debuggerinput.style["width"] = width.toString()+"px";
  6341. debuggerinput.style["top"] = (height+90).toString()+"px";
  6342. debuggersendrecieve.style["top"] = (height+120).toString()+"px";
  6343. debuggerpausebutton.style["top"] = (height+150).toString()+"px";
  6344. debuggereval.style["width"] = (width-150).toString()+"px";
  6345. debuggereval.style["top"] = (height+120).toString()+"px";},true);
  6346.  
  6347.  
  6348. function timeout123() {
  6349. updateWssLog();
  6350. EVENTLOOPFUNCTION();
  6351. var now = Date.now();
  6352. var keys = Object.keys(playerids);
  6353. if(getroomslastcheck+3000<now){
  6354. getroomslastcheck = now;
  6355. if(inroom && savedrooms.length>0){
  6356. Gdocument.getElementById("roomlistrefreshbutton").click();
  6357. }
  6358. }
  6359. var namelist = Gdocument.getElementsByClassName("newbonklobby_playerentry_name");
  6360. for(var i = 0;i<namelist.length;i++){
  6361. var level = 0;
  6362. var levelelement = 0;
  6363. var pingelement = 0;
  6364. var avatarelement = 0;
  6365. var children = namelist[i].parentElement.children;
  6366. for(var i2 = 0;i2<children.length;i2++){
  6367. if(children[i2].className == "newbonklobby_playerentry_level"){
  6368. levelelement = children[i2];
  6369. level = parseInt(children[i2].textContent.slice(6));
  6370. }
  6371. else if(children[i2].className == "newbonklobby_playerentry_pingtext"){
  6372. pingelement = children[i2];
  6373. }
  6374. else if(children[i2].className == "newbonklobby_playerentry_avatar"){
  6375. avatarelement = children[i2];
  6376. }
  6377. }
  6378. var isadmin = [false,0];
  6379. for(var i3 = 0;i3<admins.length;i3++){
  6380. if(admins[i3][0] == namelist[i].textContent){
  6381. isadmin = [true,i3];
  6382. break;
  6383. }
  6384. }
  6385. if(level){
  6386. if(isadmin[0]){
  6387. namelist[i].style["color"] = "rgb("+admins[isadmin[1]][1].slice(0,-1).toString()+")";
  6388. var rotatevalue = 0;
  6389. if(admins[isadmin[1]][1][3]<90){
  6390. rotatevalue = admins[isadmin[1]][1][3]/2;
  6391. }
  6392. else if(admins[isadmin[1]][1][3]<270){
  6393. rotatevalue =(180-admins[isadmin[1]][1][3])/2;
  6394. }
  6395. else if(admins[isadmin[1]][1][3]<360){
  6396. rotatevalue = (-360+admins[isadmin[1]][1][3])/2;
  6397. }
  6398. namelist[i].parentElement.style["filter"] = "hue-rotate("+rotatevalue.toString()+"deg)";
  6399. namelist[i].parentElement.style["font-size"] = "17px";
  6400. namelist[i].parentElement.style["background"] = "rgb("+[255-admins[isadmin[1]][1][0],255-admins[isadmin[1]][1][1],255-admins[isadmin[1]][1][2]].toString()+")";
  6401. if(levelelement){
  6402. levelelement.style["color"] = "rgb("+admins[isadmin[1]][1].slice(0,-1).toString()+")";
  6403. }
  6404. if(pingelement){
  6405. pingelement.style["color"] = "rgb("+admins[isadmin[1]][1].slice(0,-1).toString()+")";
  6406. }
  6407. if(avatarelement){
  6408. avatarelement.style["filter"] = "hue-rotate("+rotatevalue.toString()+"deg)";
  6409. }
  6410. }
  6411. }
  6412. var stylekeys = Object.keys(allstyles);
  6413. for(var i3 = 0;i3<stylekeys.length;i3++){
  6414. if(stylekeys[i3] == namelist[i].textContent){
  6415. if(namelist[i].style["color"]!="rgb("+allstyles[stylekeys[i3]].toString()+")" && (allstyles[stylekeys[i3]][0]+allstyles[stylekeys[i3]][1]+allstyles[stylekeys[i3]][2]!=0 || !isadmin[0])){
  6416. var rgbvalue = [allstyles[stylekeys[i3]][0]*0.8,allstyles[stylekeys[i3]][1]*0.8,allstyles[stylekeys[i3]][2]*0.8];
  6417. namelist[i].style["color"] = "rgb("+rgbvalue.toString()+")";
  6418. if(!isadmin[0]){
  6419. var n = 255;
  6420. namelist[i].parentElement.style["background"] = "rgb("+[(203+rgbvalue[0])%n,(212+rgbvalue[1])%n,(215+rgbvalue[2])%n].toString()+")";
  6421. }
  6422. if(levelelement){
  6423. levelelement.style["color"] = "rgb("+rgbvalue.toString()+")";
  6424. }
  6425. if(pingelement){
  6426. pingelement.style["color"] = "rgb("+rgbvalue.toString()+")";
  6427. }
  6428. }
  6429. }
  6430. }
  6431. }
  6432. for(var i3 = 0;i3<admins.length;i3++){
  6433. if(admins[i3][1][0]==0 && admins[i3][1][1]==0 && admins[i3][1][2]==0){
  6434. admins[i3][1][2] = 180;
  6435. admins[i3][1][1] = 0;
  6436. admins[i3][1][0] = 0;
  6437. }
  6438. var rate = 5;
  6439. var lowest = 0;
  6440. var number = 360;
  6441. admins[i3][1][3] = (admins[i3][1][3]%number+4+number)%number;
  6442. if(admins[i3][1][0]>lowest && admins[i3][1][1] == lowest){
  6443. admins[i3][1][0]-=rate;
  6444. admins[i3][1][2]+=rate;
  6445. }
  6446. if(admins[i3][1][2]>lowest && admins[i3][1][0] == lowest){
  6447. admins[i3][1][2]-=rate;
  6448. admins[i3][1][1]+=rate;
  6449. }
  6450. if(admins[i3][1][1]>lowest && admins[i3][1][2] == lowest){
  6451. admins[i3][1][0]+=rate;
  6452. admins[i3][1][1]-=rate;
  6453. }
  6454. for(var i4 = 0;i4<3;i4++){
  6455. if(admins[i3][1][i4]<lowest){
  6456. admins[i3][1][i4]=lowest;
  6457. }
  6458. else if(admins[i3][1][i4]>255){
  6459. admins[i3][1][i4]=255;
  6460. }
  6461. }
  6462. }
  6463. if(randomchat){
  6464. if(randomchat_timestamp+randomchat_randomtimestamp<now){
  6465. randomchat_timestamp = now;
  6466. randomchat_randomtimestamp = 2000+Math.random()*2000;
  6467. var randnumber = Math.floor(Math.random()*randomchatpriority[0])-randomchatlastmessage[1];
  6468. for(var i = 0;i<randomchatpriority[1].length;i++){
  6469. if(randomchatpriority[1][i][0]!=randomchatlastmessage[0] && randomchatpriority[1][i][1]!=randomchatlastmessage[1]){
  6470. randnumber-=randomchatpriority[1][i][1];
  6471. if(randnumber<=0){
  6472. chat(flag_manage(randomchatpriority[1][i][0]));
  6473. randomchatpriority[1][i][1]+=2;
  6474. randomchatpriority[0]+=2;
  6475. randomchatlastmessage = randomchatpriority[1][i];
  6476. break;
  6477. }
  6478. }
  6479. }
  6480. }
  6481. }
  6482. for(var i = 0;i<keys.length;i++){
  6483. if(autokickbantimestamp+500<now && keys[i]!=myid && !playerids[keys[i]]?.commands && autokickban>0 && playerids[keys[i]].peerID!="sandbox" && ishost && playerids[keys[i]].ratelimit.join+750<now){
  6484. SEND('42[9,{"banshortid":'+keys[i].toString()+',"kickonly":'+(autokickban == 1).toString()+'}]');
  6485. autokickbantimestamp = now;
  6486. }
  6487. if(playerids[keys[i]].playerData){
  6488. if(playerids[keys[i]].playerData2){
  6489. if(playerids[keys[i]].playerData.transform){
  6490. playerids[keys[i]].playerData2.alive = true;
  6491. if(playerids[keys[i]].playerData2.timeStamp == 0){
  6492. playerids[keys[i]].playerData2.px = playerids[keys[i]].playerData.transform.position.x;
  6493. playerids[keys[i]].playerData2.py = playerids[keys[i]].playerData.transform.position.y;
  6494. playerids[keys[i]].playerData2.timeStamp = now;
  6495. }
  6496. else{
  6497. playerids[keys[i]].playerData2.xvel = (playerids[keys[i]].playerData2.px - playerids[keys[i]].playerData.transform.position.x)/(playerids[keys[i]].playerData2.timeStamp-now);
  6498. playerids[keys[i]].playerData2.yvel = (playerids[keys[i]].playerData2.py - playerids[keys[i]].playerData.transform.position.y)/(playerids[keys[i]].playerData2.timeStamp-now);
  6499. playerids[keys[i]].playerData2.px = playerids[keys[i]].playerData.transform.position.x;
  6500. playerids[keys[i]].playerData2.py = playerids[keys[i]].playerData.transform.position.y;
  6501. playerids[keys[i]].playerData2.timeStamp = now;
  6502. }
  6503. if(playerids[keys[i]].playerData2.timeStamp2 == 0){
  6504. playerids[keys[i]].playerData2.pvx = playerids[keys[i]].playerData2.xvel;
  6505. playerids[keys[i]].playerData2.pvy = playerids[keys[i]].playerData2.yvel;
  6506. playerids[keys[i]].playerData2.timeStamp2 = now;
  6507. }
  6508. else{
  6509. playerids[keys[i]].playerData2.xacc = (playerids[keys[i]].playerData2.pvx - playerids[keys[i]].playerData2.xvel)/((playerids[keys[i]].playerData2.timeStamp2-now));
  6510. playerids[keys[i]].playerData2.yacc = (playerids[keys[i]].playerData2.pvy - playerids[keys[i]].playerData2.yvel)/((playerids[keys[i]].playerData2.timeStamp2-now));
  6511. playerids[keys[i]].playerData2.pvx = playerids[keys[i]].playerData2.xvel;
  6512. playerids[keys[i]].playerData2.pvy = playerids[keys[i]].playerData2.yvel;
  6513. playerids[keys[i]].playerData2.timeStamp2 = now;
  6514. }
  6515. }
  6516. else{
  6517. if(playerids[keys[i]].playerData2.alive){
  6518.  
  6519. }
  6520. playerids[keys[i]].playerData2.alive = false;
  6521. }
  6522. }
  6523. else{
  6524. 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};
  6525. }
  6526. }
  6527. }
  6528. for(var i = 0;i<keys.length;i++){
  6529. if(!playerids[keys[i]].playerData2){
  6530. 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};
  6531. }
  6532. }
  6533. if(Gdocument.getElementById("redefineControls_table").children[0].children.length<=1 && keys.length>0){
  6534. Gdocument.getElementById("pretty_top_settings").click();
  6535. Gdocument.getElementById("settings_close").click();
  6536. }
  6537. if(pollactive[0] && pollactive[2]<now && ishost){
  6538. playerids[myid].ratelimit.poll = Date.now();
  6539. SEND("42"+JSON.stringify([4,{"type":"poll end","from":username}]));
  6540. var count = [0,0,0,0];
  6541. var keys = Object.keys(playerids);
  6542. for(var i = 0;i<keys.length;i++){
  6543. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive[3].length-1){
  6544. count[playerids[keys[i]].vote.poll]++;
  6545. }
  6546. playerids[keys[i]].vote.poll = -1;
  6547. }
  6548. displayInChat("The poll ended due to time.","#DA0808","#1EBCC1");
  6549. for(var i = 0;i<count.length;i++){
  6550. if(count[i]>1){
  6551. displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  6552. }
  6553. if(count[i]==1){
  6554. displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  6555. }
  6556. }
  6557. displayInChat("The poll was:","#DA0808","#1EBCC1");
  6558. for(var i = 0;i<pollactive[3].length;i++){
  6559. displayInChat(letters[i]+") "+pollactive[3][i],"#DA0808","#1EBCC1");
  6560. }
  6561. pollactive = [false,0,0,[]];
  6562. }
  6563. if(!ishost && sandboxcopyme!=-1){
  6564. sandboxcopyme = -1;
  6565. }
  6566. if(afkkill>0 && ishost){
  6567. var keys = Object.keys(playerids);
  6568. currentFrame = Math.floor((now - gameStartTimeStamp)/1000*30);
  6569. for(var i = 0; i<keys.length;i++){
  6570. if(typeof(playerids[keys[i]].lastmove)=="undefined"){
  6571. playerids[keys[i]].lastmove = now;
  6572. }
  6573. else{
  6574. if(playerids[keys[i]].playerData2?.alive && now-playerids[keys[i]].lastmove>=afkkill*1000 && now-gameStartTimeStamp>=afkkill*1000 && !killedids.includes(keys[i])){
  6575. killedids.push(keys[i]);
  6576. SEND('42[25,{"a":{"playersLeft":['+keys[i]+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  6577. RECIEVE('42[31,{"a":{"playersLeft":['+keys[i]+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  6578. break;
  6579. }
  6580. }
  6581. }
  6582. }
  6583. if(ishost && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS"){
  6584. clearmaprequests.style["display"] = "block";
  6585. refreshmaprequests.style["display"] = "block";
  6586. }
  6587. else{
  6588. clearmaprequests.style["display"] = "none";
  6589. refreshmaprequests.style["display"] = "none";
  6590. }
  6591. if(Gdocument.getElementById("gamerenderer").style["visibility"]=="hidden"){
  6592. Gdocument.getElementById("ingamewinner_scores").style["visibility"] = "unset";
  6593. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  6594. }
  6595. if(Gdocument.getElementById("maploadwindowmapscontainer").children.length>0 && maponclick == 0){
  6596. maponclick = Gdocument.getElementById("maploadwindowmapscontainer").children[0].onclick;
  6597. }
  6598. 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"] == "")){
  6599. var chatbox = Gdocument.getElementById("newbonklobby_chat_content");
  6600. while (chatbox.firstChild) {
  6601. chatbox.removeChild(chatbox.firstChild);
  6602. }
  6603. chatbox = Gdocument.getElementById("ingamechatcontent");
  6604. while (chatbox.firstChild) {
  6605. chatbox.removeChild(chatbox.firstChild);
  6606. }
  6607. rcaps_flag = false;
  6608. space_flag = false;
  6609. number_flag = false;
  6610. reverse_flag = false;
  6611. autocorrect = false;
  6612. translating2 = [false,""];
  6613. translating = [false,""];
  6614. echo_list = [];
  6615. scroll = false;
  6616. FollowCam = false;
  6617. autocam = false;
  6618. aimbot = false;
  6619. recievedinitdata = false;
  6620. zoom = 1;
  6621. zoom2 = 1;
  6622. newzoom = 1;
  6623. newzoom2 = 1;
  6624. FFA = true;
  6625. mode = "b";
  6626. ghostroomwss = -1;
  6627. heavybot = false;
  6628. stopquickplay = 1;
  6629. roundsperqp = 1;
  6630. roundsperqp2 = 0;
  6631. staystill = false;
  6632. staystillpos = [0,0];
  6633. recording = false;
  6634. recordingid = -1;
  6635. reverseqp = false;
  6636. jointeam = -1;
  6637. currentroomaddress = -1;
  6638. checkboxhidden = false;
  6639. freejoin = false;
  6640. shuffle = false;
  6641. defaultmode = "";
  6642. recmodebool = false;
  6643. recteams = false;
  6644. autorecord = false;
  6645. pollactive = [false,0,0,[]];
  6646. pollactive2 = [false,0,[]];
  6647. afkkill = -1;
  6648. nextafter = 0;
  6649. jointext = "";
  6650. ishost = false;
  6651. parentDraw = 0;
  6652. sandboxplayerids = {};
  6653. sandboxcopyme = -1;
  6654. wintext = "";
  6655. sandboxon = false;
  6656. sandboxid = 200;
  6657. disabledkeys = [];
  6658. myid = -1;
  6659. randomchat = false;
  6660. savedroombutton.className = "brownButton brownButton_classic buttonShadow brownButtonDisabled";
  6661. randomchatpriority = [0,[]];
  6662. randomchatlastmessage = ["",0];
  6663. autokickbantimestamp = 0;
  6664. autokickban = 0;
  6665. inroom = false;
  6666. causelag = false;
  6667. causelag2 = 0;
  6668. jukeboxplayerURL = "";
  6669. jukeboxplayer.src = "";
  6670. jukeboxplayervolume = 20;
  6671. allstyles = {};
  6672. if(!bonkwss){
  6673. playerids = {};
  6674. }
  6675.  
  6676. qppaused = false;
  6677. nextafterbuffer = -1;
  6678. hostid = -1;
  6679. if(chatlog[chatlog.length-1]!="ROOM END"){
  6680. chatlog.push("ROOM END");
  6681. }
  6682. }
  6683. else{
  6684. if(chatlog[chatlog.length-1]=="ROOM END"){
  6685. chatlog.push("ROOM START");
  6686. }
  6687. }
  6688.  
  6689. if(Gdocument.getElementById("newbonklobby").style["display"]=="block"){
  6690. Gdocument.getElementById("ingamechatinputtext").style["visibility"]="hidden";
  6691. }
  6692. else{
  6693. Gdocument.getElementById("ingamechatinputtext").style["visibility"]="visible";
  6694.  
  6695. }
  6696. if(Gdocument.getElementsByClassName('newbonklobby_settings_button brownButton brownButton_classic buttonShadow brownButtonDisabled').length == 0){
  6697. ishost = true;
  6698. }
  6699. else{
  6700. ishost = actuallyhost;
  6701. }
  6702.  
  6703. if(Gdocument.getElementById("pretty_top_name")!=null){
  6704. username = Gdocument.getElementById("pretty_top_name").textContent;
  6705. if(myid!=-1){
  6706. username = playerids[myid].userName;
  6707. }
  6708. }
  6709. try{
  6710. Last_message = lastmessage()
  6711. } catch{
  6712. Last_message = "";
  6713. }
  6714. if (Laster_message != Last_message){
  6715. Laster_message = Last_message;
  6716. if(changed_chat==false){
  6717. new_message = true;
  6718. }
  6719. else{
  6720. changed_chat = false;
  6721. }
  6722. }
  6723. if(new_message){
  6724. chatlog.push(Last_message);
  6725. var lm = "";
  6726. try{
  6727. lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  6728. if(typeof(lm[0].parentElement.style["parsed"]) == 'undefined'){
  6729. if (lm[0].className == "newbonklobby_chat_msg_colorbox"){
  6730. lm[2].innerHTML = urlify(lm[2].innerHTML);
  6731. Laster_message = lastmessage();
  6732. lm[0].parentElement.style["parsed"] = true;
  6733. }
  6734. if (lm[0].className == "newbonklobby_chat_status"){
  6735. lm[0].innerHTML = urlify(lm[0].innerHTML);
  6736. Laster_message = lastmessage();
  6737. lm[0].parentElement.style["parsed"] = true;
  6738. }
  6739. }
  6740. }
  6741. catch{
  6742. lm = "";
  6743. }
  6744.  
  6745. if(Last_message.indexOf("@"+username)!=-1 && npermissions == 1){
  6746. if(Notification.requestPermission()){
  6747. var n = new Notification(Last_message);
  6748. }
  6749. }
  6750.  
  6751. try{
  6752. lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  6753. if(typeof(lm[0].parentElement.style["parsed"])=='undefined'){
  6754. if(lm[0].className == "ingamechatname"){
  6755. lm[1].innerHTML = urlify(lm[1].innerHTML);
  6756. Laster_message = lastmessage();
  6757. lm[0].parentElement.style["parsed"] = true;
  6758. }
  6759. if(lm[0].className == ""){
  6760. lm[0].innerHTML = urlify(lm[0].innerHTML);
  6761. Laster_message = lastmessage();
  6762. lm[0].parentElement.style["parsed"] = true;
  6763. }
  6764. }
  6765. }
  6766. catch{
  6767. lm = "";
  6768. }
  6769. if(text2speech){
  6770. if(!sayer.speaking){
  6771. if(Last_message.includes(": ")){
  6772. speech.text = Last_message.substring(0,Last_message.indexOf(":")).toLowerCase();
  6773. speech.rate = 2.25;
  6774. sayer.speak(speech);
  6775. speech.text = Last_message.substring(Last_message.indexOf(": ")+3).toLowerCase();
  6776. speech.rate = 1.25;
  6777. sayer.speak(speech);
  6778. }
  6779. else{
  6780. speech.text = Last_message.toLowerCase();
  6781. sayer.speak(speech);
  6782. }
  6783. }
  6784. }
  6785. }
  6786. if (ishost==true && new_message){
  6787. for(i=0;i<banned.length;i++){
  6788. if(Last_message.startsWith("* "+banned[i]+" has joined the game")){
  6789. chat2("/kick '"+banned[i]+"'");
  6790. }
  6791. }
  6792. }
  6793. if(Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden" && ishost){
  6794. roundsperqp2 = 0;
  6795. }
  6796. if(Gdocument.getElementById("ingamewinner").style["visibility"]=="inherit" && ishost){
  6797. if(Gdocument.getElementById("ingamewinner").style["parsed"] != true){
  6798. if(stopquickplay!=1){
  6799. roundsperqp2++;
  6800. }
  6801. if(autorecord){
  6802. Gdocument.getElementById("pretty_top_replay").click();
  6803. }
  6804. }
  6805. if(Gdocument.getElementById("ingamewinner").style["parsed"] != true && wintext!="" && Gdocument.getElementById("ingamewinner_bottom").textContent!="DRAW"){
  6806. chat(flag_manage(wintext.replaceAll("username",Gdocument.getElementById("ingamewinner_top").textContent)));
  6807. }
  6808. Gdocument.getElementById("ingamewinner").style["parsed"] = true;
  6809. }
  6810. else{
  6811. Gdocument.getElementById("ingamewinner").style["parsed"] = false;
  6812. }
  6813. if(ishost && stopquickplay == 0){
  6814. if(checkboxhidden){
  6815. checkboxhidden = false;
  6816. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  6817. for(var i = 0; i<classes.length;i++){
  6818. classes[i].style["display"] = "block";
  6819. classes[i].className = "quickplaycheckbox quickplaychecked";
  6820. }
  6821. Gdocument.getElementById('clearallcheckboxes').style["display"] = "block";
  6822.  
  6823. }
  6824. if(nextafter>0 && gameStartTimeStamp+nextafter*1000<=now && Gdocument.getElementById("gamerenderer").style["visibility"] != "hidden" && dontswitch == false && Gdocument.getElementById("ingamewinner").style["visibility"]!="inherit" && !qppaused){
  6825. roundsperqp2 = 0;
  6826. if(shuffle){
  6827. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  6828. var available = [];
  6829. var availableindexes = [];
  6830. var notempty = false;
  6831. for(var i = 0; i<e.length;i++){
  6832. var a = false;
  6833. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  6834. available.push(a);
  6835. if(a){
  6836. availableindexes.push(i);
  6837. notempty = true;
  6838. }
  6839. }
  6840. if(notempty){
  6841. if(availableindexes.length!=1){
  6842. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  6843. }
  6844. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  6845. }
  6846. }
  6847. else{
  6848. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  6849. var available = [];
  6850. var availableindexes = [];
  6851. var notempty = false;
  6852. for(var i = 0; i<e.length;i++){
  6853. var a = false;
  6854. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  6855. available.push(a);
  6856. if(a){
  6857. availableindexes.push(i);
  6858. notempty = true;
  6859. }
  6860. }
  6861. if(notempty){
  6862. var above = [];
  6863. for(var i = 0;i<availableindexes.length;i++){
  6864. if(availableindexes[i]>quicki && !reverseqp){
  6865. above.push(availableindexes[i]);
  6866. }
  6867. else if(availableindexes[i]<quicki && reverseqp){
  6868. above.push(availableindexes[i]);
  6869. }
  6870. }
  6871. if(above.length>0){
  6872. quicki = above[0];
  6873. if(reverseqp){
  6874. above[above.length-1];
  6875. }
  6876. }
  6877. else{
  6878. quicki = availableindexes[0];
  6879. if(reverseqp){
  6880. quicki = availableindexes[availableindexes.length-1];
  6881. }
  6882. }
  6883. }
  6884. }
  6885. startedinqp = true;
  6886. dontswitch = true;
  6887. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  6888. }
  6889. if(Gdocument.getElementById("ingamewinner").style["visibility"]=="inherit" && dontswitch == false && !document.hidden && !qppaused){
  6890. if(roundsperqp2>=roundsperqp){
  6891. if(shuffle){
  6892. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  6893. var available = [];
  6894. var availableindexes = [];
  6895. var notempty = false;
  6896. for(var i = 0; i<e.length;i++){
  6897. var a = false;
  6898. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  6899. available.push(a);
  6900. if(a){
  6901. availableindexes.push(i);
  6902. notempty = true;
  6903. }
  6904. }
  6905. if(notempty){
  6906.  
  6907. if(availableindexes.length!=1){
  6908. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  6909. }
  6910. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  6911. }
  6912. }
  6913. else{
  6914. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  6915. var available = [];
  6916. var availableindexes = [];
  6917. var notempty = false;
  6918. for(var i = 0; i<e.length;i++){
  6919. var a = false;
  6920. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  6921. available.push(a);
  6922. if(a){
  6923. availableindexes.push(i);
  6924. notempty = true;
  6925. }
  6926. }
  6927. if(notempty){
  6928. var above = [];
  6929. for(var i = 0;i<availableindexes.length;i++){
  6930. if(availableindexes[i]>quicki && !reverseqp){
  6931. above.push(availableindexes[i]);
  6932. }
  6933. else if(availableindexes[i]<quicki && reverseqp){
  6934. above.push(availableindexes[i])
  6935. }
  6936. }
  6937. if(above.length>0){
  6938. quicki = above[0];
  6939. if(reverseqp){
  6940. quicki = above[above.length-1];
  6941. }
  6942. }
  6943. else{
  6944. quicki = availableindexes[0];
  6945. if(reverseqp){
  6946. quicki = availableindexes[availableindexes.length-1];
  6947. }
  6948.  
  6949. }
  6950. }
  6951. }
  6952. }
  6953. transitioning = true;
  6954. startedinqp = true;
  6955. map(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  6956. dontswitch = true;
  6957. setTimeout(function(){Gdocument.getElementById("ingamewinner").style["visibility"]="hidden"; dontswitch = false;},timedelay);
  6958. }
  6959. }
  6960. else{
  6961. if(!checkboxhidden){
  6962. checkboxhidden = true;
  6963. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  6964. for(var i = 0; i<classes.length;i++){
  6965. classes[i].style["display"] = "none";
  6966. classes[i].className = "quickplaycheckbox quickplayunchecked";
  6967. }
  6968. Gdocument.getElementById('clearallcheckboxes').style["display"] = "none";
  6969. }
  6970. }
  6971. new_message = false;
  6972. };
  6973. });