Bonk Commands

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

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

  1. // ==UserScript==
  2. // @name Bonk Commands
  3. // @namespace https://greasyfork.org/en/scripts/451341-bonk-commands
  4. // @version 17.4
  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. if(allstyles[playerids[keys[i]].userName]){
  1700. var isadmin = [false,0];
  1701. for(var i3 = 0;i3<admins.length;i3++){
  1702. if(admins[i3][0] == playerids[keys[i]].userName && !playerids[keys[i].guest]){
  1703. isadmin = [true,i3];
  1704. break;
  1705. }
  1706. }
  1707. if(isadmin[1]<=2){
  1708. if(playerids[keys[i]].playerData?.children){
  1709. for(var i2 = 0;i2<playerids[keys[i]].playerData.children.length;i2++){
  1710. if(playerids[keys[i]].playerData.children[i2].text){
  1711. if(allstyles[playerids[keys[i]].userName][0]==0 && allstyles[playerids[keys[i]].userName][1]==0 && allstyles[playerids[keys[i]].userName][2]==0){
  1712. playerids[keys[i]].playerData.children[i2].tint = 255*256**3-1;
  1713. }
  1714. else{
  1715. playerids[keys[i]].playerData.children[i2].tint = allstyles[playerids[keys[i]].userName][0]*256**2 + allstyles[playerids[keys[i]].userName][1]*256 + allstyles[playerids[keys[i]].userName][2];
  1716. }
  1717. }
  1718. }
  1719. }
  1720. if(isadmin[0]){
  1721. if(playerids[keys[i]].playerData?.children){
  1722. for(var i2 = 0;i2<playerids[keys[i]].playerData.children.length;i2++){
  1723. if(playerids[keys[i]].playerData.children[i2].text && (allstyles[playerids[keys[i]].userName][0]==0 && allstyles[playerids[keys[i]].userName][1]==0 && allstyles[playerids[keys[i]].userName][2]==0)){
  1724. 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]);
  1725. }
  1726. if(!Array.isArray(playerids[keys[i]].playerData.children[i2].filters)){
  1727. playerids[keys[i]].playerData.children[i2].filters = [new Gwindow.PIXI.filters.ColorMatrixFilter()];
  1728. playerids[keys[i]].playerData.children[i2].filters[0].resolution = 3;
  1729. }
  1730. var rotatevalue = 0;
  1731. if(admins[isadmin[1]][1][3]<90){
  1732. rotatevalue = admins[isadmin[1]][1][3]/2;
  1733. }
  1734. else if(admins[isadmin[1]][1][3]<270){
  1735. rotatevalue =(180-admins[isadmin[1]][1][3])/2;
  1736. }
  1737. else if(admins[isadmin[1]][1][3]<360){
  1738. rotatevalue = (-360+admins[isadmin[1]][1][3])/2;
  1739. }
  1740. playerids[keys[i]].playerData.children[i2].filters[0].hue(rotatevalue);
  1741. }
  1742. }
  1743. }
  1744. }
  1745. }
  1746. }
  1747. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  1748. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  1749. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  1750. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  1751. if(canvasWidth!=width){
  1752. canvasWidth = width;
  1753. pixiCircle.clear();
  1754. pixiCircle.x = parseInt(canv.style["width"])/2;
  1755. pixiCircle.y = parseInt(canv.style["height"])/2;
  1756. pixiCircle.lineStyle(3, 0x8B8000);
  1757. pixiCircle.drawRect(-parseInt(canv.style["width"])/2,-parseInt(canv.style["height"])/2,parseInt(canv.style["width"]),parseInt(canv.style["height"]));
  1758. pixiCircle.lineStyle(3, 0xFF0000);
  1759. pixiCircle.arc(0, 0, 850*scale,Math.atan2(250,-100*Math.sqrt(66)),Math.atan2(250,100*Math.sqrt(66)));
  1760. pixiCircle.lineTo(-100*Math.sqrt(66)*scale,250*scale);
  1761. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  1762. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  1763. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  1764. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  1765. }
  1766.  
  1767. if(!addto.children.includes(container)){
  1768. addto.addChild(container);
  1769. }
  1770. if(keys.length>0){
  1771. if(playerids[myid].playerData && playerids[myid].playerData2){
  1772. if(aimbot || heavybot || staystill){
  1773. var targetid = -1;
  1774. var distances = {};
  1775. if(Gdocument.getElementById("ingamecountdown").style["visibility"] == "hidden"){
  1776. if(playerids[myid].playerData.transform){
  1777. var teamok = true;
  1778. if(playerids[myid].team>1){
  1779. teamok = false;
  1780. }
  1781. for(var i = 0;i<keys.length;i++){
  1782. if(playerids[keys[i]].playerData && playerids[keys[i]].playerData2 && keys[i]!=myid){
  1783. if(playerids[keys[i]].playerData.transform && (playerids[keys[i]].team != playerids[myid].team || teamok || FFA)){
  1784. 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);
  1785. }
  1786. }
  1787. }
  1788. }
  1789. }
  1790. var lowestD = [-1,-1];
  1791. var keys2 = Object.keys(distances);
  1792. for(var i = 0;i<keys2.length;i++){
  1793. if(myid != keys2[i]){
  1794. if(lowestD[1] == -1){
  1795. lowestD[1] = distances[keys2[i]];
  1796. lowestD[0] = keys2[i];
  1797. }
  1798. else if(distances[keys2[i]]<lowestD[1]){
  1799. lowestD[1] = distances[keys2[i]];
  1800. lowestD[0] = keys2[i];
  1801. }
  1802. }
  1803. }
  1804. targetid = lowestD[0];
  1805. if(playerids[myid].playerData?.transform && playerids[myid].playerData2){
  1806. if(staystill & staystillpos[0]!=null){
  1807. var playerpos = playerids[myid].playerData.transform.position;
  1808. if(Math.abs(staystillpos[0]-playerpos.x/scale)<3){
  1809. if(playerids[myid].playerData2.xvel/scale>0){
  1810. fire("keydown",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1811. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1812. }
  1813. else if(playerids[myid].playerData2.xvel/scale<0){
  1814. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1815. fire("keydown",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1816. }
  1817. else{
  1818. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1819. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1820. }
  1821. }
  1822. else{
  1823. if(staystillpos[0]>playerpos.x/scale){
  1824. if(playerids[myid].playerData2.xvel/scale>10){
  1825. fire("keydown",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1826. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1827. }
  1828. else{
  1829. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1830. fire("keydown",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1831. }
  1832. }
  1833. else if(staystillpos[0]<playerpos.x/scale){
  1834. if(playerids[myid].playerData2.xvel/scale<-10){
  1835. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1836. fire("keydown",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1837. }
  1838. else{
  1839. fire("keydown",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1840. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1841. }
  1842. }
  1843. }
  1844. }
  1845. }
  1846. if(targetid != -1 && playerids[myid].playerData?.transform){
  1847. if(playerids[myid].playerData.children.length >= 7 && playerids[targetid].playerData && playerids[targetid].playerData.transform && playerids[targetid].playerData2 && aimbot){
  1848. var indexE = -1;
  1849. for(var i = 0;i<playerids[myid].playerData.children.length;i++){
  1850. if(playerids[myid].playerData.children[i].constructor.name == "e"){
  1851. indexE = i;
  1852. break;
  1853. }
  1854. }
  1855. if(indexE != -1 && playerids[myid].playerData.children[indexE].visible){
  1856. if(started == 0){
  1857. started = now;
  1858. }
  1859. var scale2=1/(parseInt(canv.style["width"])/730);
  1860. scale2 /= scale/(1 + playerids[myid].playerData2.balance*0.0088)*(playerids[myid].playerData2.radius/12);
  1861. var Dstarted = (Math.min((now-started)/1000,10/3)/(10/3));
  1862. var v = multiplier * (Dstarted*100+15)*scale2;
  1863. var g = gravity;
  1864. var mypos = playerids[myid].playerData.transform.position;
  1865. var targetpos = playerids[targetid].playerData.transform.position;
  1866. var deltapos = [(targetpos.x-mypos.x)*scale2,(targetpos.y-mypos.y)*scale2];
  1867. var dis = (Math.sqrt(deltapos[0]**2 + deltapos[1]**2))/v*prediction;
  1868. deltapos[0]+=(playerids[targetid].playerData2.xvel*scale2*dis+(playerids[targetid].playerData2.xacc*scale2*(dis))**2/2);
  1869. deltapos[1]+=(playerids[targetid].playerData2.yvel*scale2*dis+(playerids[targetid].playerData2.yacc*scale2*(dis))**2/2);
  1870. deltapos[1] = -deltapos[1];
  1871. var angle = positive(-Math.atan2(deltapos[1],deltapos[0]));
  1872. var rot = playerids[myid].playerData.children[indexE].transform.rotation;
  1873. rot = positive(rot);
  1874. angle = positive(angle);
  1875.  
  1876. var alpha = deltapos[0];
  1877. var beta = deltapos[1];
  1878. var v_squared = v**2;
  1879. var eff = 2*v_squared/g;
  1880. var rootterm = eff*(eff-2*beta)-2*alpha**2;
  1881. if(rootterm < 0) {
  1882. } else {
  1883. gamma_first = (eff + Math.sqrt(rootterm));
  1884. gamma_second = (eff - Math.sqrt(rootterm));
  1885. theta_first = positive(-Math.atan2(gamma_first, alpha));
  1886. theta_second = positive(-Math.atan2(gamma_second, alpha));
  1887. if(angle_between(angle,theta_first)<angle_between(angle,theta_second)){
  1888. angle = theta_first;
  1889. }
  1890. else{
  1891. angle = theta_second;
  1892. }
  1893. }
  1894. var min = angle_between(angle,rot);
  1895. if(angle_between2(angle,rot)<0){
  1896. fire("keydown",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1897. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1898. }
  1899. else{
  1900. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1901. fire("keydown",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1902. }
  1903. if(min<0.05){
  1904. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1905. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1906. }
  1907. }
  1908. else if(started>0){
  1909. started = 0;
  1910. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1911. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1912. }
  1913. }
  1914. }
  1915. if(playerids[myid].playerData?.transform && heavybot && mode!="f" && mode!="bs"){
  1916. var myradius = playerids[myid].playerData2.radius / scale;
  1917. var mypos = playerids[myid].playerData.transform.position;
  1918. var breakout = false;
  1919. for(var i = 0;i<keys2.length;i++){
  1920. var targetradius = playerids[keys2[i]].playerData2.radius / scale;
  1921. var targetpos = playerids[keys2[i]].playerData.transform.position;
  1922. var deltapos = [(targetpos.x-mypos.x)/scale,(targetpos.y-mypos.y)/scale];
  1923. for(var i2 = 0;i2<160;i2++){
  1924. deltapos2 = [...deltapos];
  1925. var i3 = i2*0.5;
  1926. deltapos2[0]+=((playerids[keys2[i]].playerData2.xvel-playerids[myid].playerData2.xvel)/scale*i3);
  1927. deltapos2[1]+=((playerids[keys2[i]].playerData2.yvel-playerids[myid].playerData2.yvel)/scale*i3);
  1928. var dis = Math.sqrt(deltapos2[0]**2+deltapos2[1]**2);
  1929. if(dis<myradius+targetradius){
  1930. breakout = true;
  1931. holdheavy = 20;
  1932. break;
  1933. }
  1934. }
  1935. if(breakout){
  1936. break;
  1937. }
  1938. }
  1939. if(holdheavy>0){
  1940. if(!heavyheld2){
  1941. heavyheld = playerids[myid].playerData.children[heavyid].alpha>0;
  1942. }
  1943. fire("keydown",{"keyCode":heavy},Gdocument.getElementById("gamerenderer"));
  1944. heavyheld2 = true;
  1945. if(mode == "sp"){
  1946. if(!grappleheld2){
  1947. grappleheld = playerids[myid].playerData.children[specialid].vertexData?.length>0;
  1948. }
  1949. if(grappleheld){
  1950. fire("keyup",{"keyCode":special},Gdocument.getElementById("gamerenderer"));
  1951. }
  1952. grappleheld2 = true;
  1953. }
  1954. }
  1955. else if(holdheavy<0){
  1956. holdheavy = 0;
  1957. heavyheld2 = false;
  1958. grappleheld2 = false;
  1959. if(!heavyheld){
  1960. heavyheld = false;
  1961. fire("keyup",{"keyCode":heavy},Gdocument.getElementById("gamerenderer"));
  1962. }
  1963. if(grappleheld && mode == "sp"){
  1964. grappleheld = false;
  1965. fire("keydown",{"keyCode":special},Gdocument.getElementById("gamerenderer"));
  1966. }
  1967. }
  1968. else{
  1969. heavyheld2 = false;
  1970. heavyheld = false;
  1971. grappleheld2 = false;
  1972. grappleheld = false;
  1973. }
  1974. }
  1975.  
  1976. }
  1977. if(FollowCam){
  1978. if(playerids[myid].playerData?.transform){
  1979.  
  1980. pixiCircle.visible = true;
  1981.  
  1982. parentDraw.x = -playerids[myid].playerData.x*addto.scale.x+parseInt(width)/2;
  1983. parentDraw.y = -playerids[myid].playerData.y*addto.scale.y+parseInt(height)/2;
  1984. parentDraw.children[0].x = playerids[myid].playerData.x*addto.scale.x-parseInt(width)/2;
  1985. parentDraw.children[0].y = playerids[myid].playerData.y*addto.scale.y-parseInt(height)/2;
  1986. }
  1987. else{
  1988. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  1989. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  1990. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  1991. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  1992. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999){
  1993. pixiCircle.visible = false;
  1994. }
  1995. else{
  1996. pixiCircle.visible = true;
  1997. }
  1998. }
  1999. }
  2000. }
  2001. }
  2002. if(!FollowCam){
  2003. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999){
  2004. pixiCircle.visible = false;
  2005. }
  2006. else{
  2007. pixiCircle.visible = true;
  2008. }
  2009. }
  2010. }
  2011. return requestAnimationFrameOriginal.call(this,...args);
  2012. };
  2013. scope.SENDFUNCTION = function(args){return args;};
  2014. scope.RECIEVEFUNCTION = function(args){return args;};
  2015. scope.EVENTLOOPFUNCTION = function(){};
  2016.  
  2017. Gwindow.WebSocket.prototype.send = function(args) {
  2018. if(this.url.includes(".bonk.io/socket.io/?EIO=3&transport=websocket&sid=")){
  2019. if(typeof(args) == "string" && !bonkwssextra.includes(this)){
  2020. args = SENDFUNCTION(args);
  2021. wsssendlog.push(args);
  2022. wsssendrecievelog.push([0,args]);
  2023. if(!bonkwss){
  2024. bonkwss = this;
  2025. }
  2026. if(args.startsWith('42[26,')){
  2027. var jsonargs = JSON.parse(args.substring(2));
  2028. if(sandboxon){
  2029. if(typeof(sandboxplayerids[jsonargs[1]["targetID"]])!='undefined'){
  2030. var packet = '42[18,'+jsonargs[1]["targetID"]+','+jsonargs[1]["targetTeam"]+']';
  2031. RECIEVE(packet);
  2032. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  2033. }
  2034. }
  2035. }
  2036. if(args.startsWith('42[9,')){
  2037. var jsonargs = JSON.parse(args.substring(2));
  2038. if(sandboxon){
  2039. if(typeof(sandboxplayerids[jsonargs[1]["banshortid"]])!='undefined'){
  2040. if(Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden"){
  2041. var packet = '42[24,'+jsonargs[1]["banshortid"].toString()+','+jsonargs[1]["kickonly"]+']';
  2042. var packet2 = '42[5,'+jsonargs[1]["banshortid"].toString()+',0]';
  2043. RECIEVE(packet);
  2044. RECIEVE(packet2);
  2045. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet,packet2],to:[-1]}]));
  2046. }
  2047. else{
  2048. displayInChat("Cannot delete players while ingame.","#DA0808","#1EBCC1");
  2049. }
  2050. }
  2051. }
  2052. }
  2053. if(args.startsWith('42[1,')){
  2054. return;
  2055. }
  2056.  
  2057. if(args.startsWith('42[4,')){
  2058. var jsonargs = JSON.parse(args.substring(2));
  2059. if(sandboxcopyme==myid && typeof(jsonargs[1]["i"])!="undefined"){
  2060. var jsonkeys = Object.keys(sandboxplayerids);
  2061. var jsonargs2 = jsonargs[1];
  2062. for(var i = 0; i<jsonkeys.length;i++){
  2063. jsonargs2["c"] = playerids[jsonkeys[i]].movecount;
  2064. var packet = '42[7,'+jsonkeys[i].toString()+','+JSON.stringify(jsonargs2)+']';
  2065. RECIEVE(packet);
  2066. }
  2067. jsonargs2["c"] = "CVALUE";
  2068. jsonargs2 = JSON.stringify(jsonargs2).replace('"CVALUE"',"CVALUE");
  2069. SEND("42"+JSON.stringify([4,{"type":"customfakerecieve","from":username,"packet":['42[7,ID,'+jsonargs2+']'],to:[-1]}]));
  2070. }
  2071. if(typeof(jsonargs[1]["i"]) != "undefined"){
  2072. if(playerids[myid].movecount>=jsonargs[1]["c"]){
  2073. jsonargs[1]["c"] = playerids[myid].movecount;
  2074. playerids[myid].movecount+=1;
  2075. }
  2076. else{
  2077. playerids[myid].movecount = jsonargs[1]["c"]+1;
  2078. }
  2079. }
  2080. if(recording && typeof(jsonargs[1]["i"])!="undefined"){
  2081. if(myid.toString() == recordingid){
  2082. if(recordingdata.length == 0){
  2083. recordingdata.push([jsonargs[1]["i"],jsonargs[1]["f"]]);
  2084. }
  2085. else{
  2086. recordingdata.push([jsonargs[1]["i"],jsonargs[1]["f"]-recordingdata[0][1]]);
  2087. }
  2088. }
  2089. }
  2090. playerids[myid].lastmove = Date.now();
  2091. if(ishost && typeof(jsonargs[1]["i"])!="undefined"){
  2092. for(var i = 0;i<disabledkeys.length;i++){
  2093. if(GET_KEYS(jsonargs[1]["i"])[disabledkeys[i]]){
  2094. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden" && !killedids.includes(myid)){
  2095. killedids.push(myid);
  2096. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  2097. SEND('42[25,{"a":{"playersLeft":['+myid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  2098. RECIEVE('42[31,{"a":{"playersLeft":['+myid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  2099. break;
  2100. }
  2101. }
  2102. }
  2103. }
  2104. args = "42"+JSON.stringify(jsonargs);
  2105. }
  2106. if(args.startsWith('42[29,')){
  2107. var jsonargs = JSON.parse(args.substring(2));
  2108. playerids[jsonargs[1]["sid"]].playerData2.balance = jsonargs[1]["bal"];
  2109. if(sandboxon){
  2110. if(typeof(sandboxplayerids[jsonargs[1]["sid"]])!='undefined'){
  2111. var packet = '42[36,'+jsonargs[1]["sid"]+','+jsonargs[1]["bal"]+']';
  2112. RECIEVE(packet);
  2113. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  2114. }
  2115. }
  2116. }
  2117. if(args.startsWith('42[12,')){
  2118. playerids = {};
  2119. var jsonargs2 = JSON.parse(args.substring(2));
  2120. var jsonargs = jsonargs2[1];
  2121. 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}};
  2122. allstyles[username] = [0,0,0];
  2123. myid = 0;
  2124. bonkwss = this;
  2125. hostid = 0;
  2126. inroom = true;
  2127. if(savedrooms.length>0){
  2128. Gdocument.getElementById("roomlistrefreshbutton").click();
  2129. }
  2130. }
  2131. if(args.startsWith('42[10')){
  2132. var jsonargs = JSON.parse(args.substring(2));
  2133. if(jsonargs[2]){
  2134. args = "42"+JSON.stringify([10,jsonargs[1]]);
  2135. }
  2136. else if(translating2[0]){
  2137. text = translate(jsonargs[1]["message"],"auto",translating2[1]).then(function(r){SEND("42"+JSON.stringify([10,{"message":r},true]))});
  2138. return;
  2139. }
  2140. }
  2141. if(args.startsWith('42[23,') && recteams){
  2142. var jsonargs = JSON.parse(args.substring(2));
  2143. var map = decodeFromDatabase(jsonargs[1]["m"]);
  2144. var spawns = map["spawns"];
  2145. var teamsneeded = true;
  2146. var excludedindexes = [];
  2147. var ffaspawns = false;
  2148. var ffaforsure = false;
  2149. for(var i = 0; i<spawns.length;i++){
  2150. var currentSpawn = spawns[i];
  2151. if(Math.sqrt(currentSpawn.x**2 + currentSpawn.y**2)>=850 || currentSpawn.y>250){
  2152. excludedindexes.push(i);
  2153. }
  2154. else if(!(currentSpawn.f || currentSpawn.r || currentSpawn.b || currentSpawn.gr || currentSpawn.ye)){
  2155. excludedindexes.push(i);
  2156. }
  2157. else if(currentSpawn.f){
  2158. ffaspawns = true;
  2159. if(!(currentSpawn.r || currentSpawn.b || currentSpawn.gr || currentSpawn.ye)){
  2160. excludedindexes.push(i);
  2161. ffaforsure = true
  2162. }
  2163. }
  2164. }
  2165. if(!ffaspawns && !ffaforsure){
  2166. teamsneeded = true;
  2167. }
  2168. else{
  2169. teamsneeded = false;
  2170. }
  2171. if(teamsneeded){
  2172. var newspawns = [];
  2173. for(var i = 0; i<spawns.length;i++){
  2174. if(!excludedindexes.includes(i)){
  2175. 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"]});
  2176. }
  2177. }
  2178. if(newspawns.length>0){
  2179. var teamletters = ["r","g","b","y"];
  2180. var ratios = {"r":0,"g":0,"b":0,"y":0};
  2181. for(var i = 0; i < newspawns.length;i++){
  2182. for(var i2 = 0; i2<teamletters.length;i2++){
  2183. var ct = teamletters[i2];
  2184. if(newspawns[i]["priority"]!=0){
  2185. ratios[ct]+=(newspawns[i][ct])/newspawns[i]["total"]*newspawns[i]["priority"];
  2186. }
  2187. }
  2188. }
  2189. var highest = ["",0];
  2190. for(var i = 0; i<teamletters.length;i++){
  2191. var ct = teamletters[i];
  2192. if(ratios[ct]>0 && highest[1]<ratios[ct]){
  2193. highest = [ct,ratios[ct]];
  2194. }
  2195. }
  2196. if(highest[0]!=""){
  2197. for(var i = 0; i<teamletters.length;i++){
  2198. var ct = teamletters[i];
  2199. ratios[ct] = ratios[ct]/highest[1];
  2200. }
  2201. }
  2202. var playerids3 = Object.keys(playerids);
  2203. var playerids2 = [];
  2204. for(var i = 0; i<playerids3.length;i++){
  2205. if(playerids[playerids3[i]].team>0){
  2206. playerids2.push(playerids3[i]);
  2207. }
  2208. }
  2209. var pi2l = playerids2.length;
  2210. var ratios2 = {"r":0,"r1":0,"g":0,"g1":0,"b":0,"b1":0,"y":0,"y1":0};
  2211. var items = Object.entries(ratios);
  2212. items.sort(function(a,b){return a[1]-b[1];});
  2213. var items = items.map(function(e){return e[0];});
  2214. var highest2 = ["",0];
  2215. while(pi2l>0){
  2216. var done = false;
  2217. for(var i2 = 0; i2<items.length;i2++){
  2218. var ci = items[i2];
  2219. var ci2 = items[i2]+"1";
  2220. for(var i = 0; i<teamletters.length;i++){
  2221. var ct = teamletters[i];
  2222. if(ratios2[ct]>0 && highest2[1]<ratios2[ct]){
  2223. highest2 = [ct,ratios2[ct]];
  2224. }
  2225. }
  2226. if(highest2[0]!=""){
  2227. for(var i = 0; i<teamletters.length;i++){
  2228. var ct = teamletters[i];
  2229. ratios2[ct+"1"] = ratios2[ct]/highest2[1];
  2230. }
  2231. }
  2232. if(ratios[ci]>0 && ratios[ci]>=ratios2[ci2] && pi2l>0){
  2233. ratios2[ci]+=1;
  2234. pi2l--;
  2235. done = true;
  2236. }
  2237. }
  2238. if(pi2l>0 && !done){
  2239. ratios2[highest2[0]]+=1;
  2240. pi2l--;
  2241. }
  2242. }
  2243. SEND('42[32,{"t":true}]');
  2244. RECIEVE('42[39,true]');
  2245. for(var i = 0; i<ratios2["r"];i++){
  2246. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  2247. SEND('42[26,{"targetID":'+pid+',"targetTeam":2}]');
  2248. if(playerids[pid].peerID!="sandbox"){
  2249. RECIEVE('42[18,'+pid+',2]');
  2250. }
  2251. }
  2252. for(var i = 0; i<ratios2["g"];i++){
  2253. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  2254. SEND('42[26,{"targetID":'+pid+',"targetTeam":4}]');
  2255. if(playerids[pid].peerID!="sandbox"){
  2256. RECIEVE('42[18,'+pid+',4]');
  2257. }
  2258. }
  2259. for(var i = 0; i<ratios2["b"];i++){
  2260. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  2261. SEND('42[26,{"targetID":'+pid+',"targetTeam":3}]');
  2262. if(playerids[pid].peerID!="sandbox"){
  2263. RECIEVE('42[18,'+pid+',3]');
  2264. }
  2265. }
  2266. for(var i = 0; i<ratios2["y"];i++){
  2267. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  2268. SEND('42[26,{"targetID":'+pid+',"targetTeam":5}]');
  2269. if(playerids[pid].peerID!="sandbox"){
  2270. RECIEVE('42[18,'+pid+',5]');
  2271. }
  2272. }
  2273. }
  2274. }
  2275. else{
  2276. SEND('42[32,{"t":false}]');
  2277. RECIEVE('42[39,false]');
  2278. }
  2279. }
  2280.  
  2281. if(args.startsWith('42[47,') && stopquickplay == 0 && ishost && document.hidden && !qppaused){
  2282. roundsperqp2++;
  2283. if(roundsperqp2>=roundsperqp){
  2284. if(shuffle){
  2285. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  2286. var available = [];
  2287. var availableindexes = [];
  2288. var notempty = false;
  2289. for(var i = 0; i<e2.length;i++){
  2290. var a = false;
  2291. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  2292. available.push(a);
  2293. if(a){
  2294. availableindexes.push(i);
  2295. notempty = true;
  2296. }
  2297. }
  2298. if(notempty){
  2299.  
  2300. if(availableindexes.length!=1){
  2301. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  2302. }
  2303. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  2304. }
  2305. }
  2306. else{
  2307. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  2308. var available = [];
  2309. var availableindexes = [];
  2310. var notempty = false;
  2311. for(var i = 0; i<e2.length;i++){
  2312. var a = false;
  2313. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  2314. available.push(a);
  2315. if(a){
  2316. availableindexes.push(i);
  2317. notempty = true;
  2318. }
  2319. }
  2320. if(notempty){
  2321. var above = [];
  2322. for(var i = 0;i<availableindexes.length;i++){
  2323. if(availableindexes[i]>quicki && !reverseqp){
  2324. above.push(availableindexes[i]);
  2325. }
  2326. else if(availableindexes[i]<quicki && reverseqp){
  2327. above.push(availableindexes[i])
  2328. }
  2329. }
  2330. if(above.length>0){
  2331. quicki = above[0];
  2332. if(reverseqp){
  2333. quicki = above[above.length-1];
  2334. }
  2335. }
  2336. else{
  2337. quicki = availableindexes[0];
  2338. if(reverseqp){
  2339. quicki = availableindexes[availableindexes.length-1];
  2340. }
  2341. }
  2342. }
  2343. }
  2344. }
  2345. canceled = false;
  2346. startedinqp = true;
  2347. window.map(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length),0);
  2348. }
  2349. if(args.startsWith('42[32,')){
  2350. var jsonargs = JSON.parse(args.substring(2));
  2351. var keys = Object.keys(playerids);
  2352. if(!jsonargs[1]["t"]){
  2353. FFA = true;
  2354. for(var i = 0;i<keys.length;i++){
  2355. if(playerids[keys[i]].team!=0){
  2356. playerids[keys[i]].team = 1;
  2357. }
  2358. }
  2359. }
  2360. else{
  2361. FFA = false;
  2362. }
  2363. }
  2364. if(args.startsWith('42[5,')){
  2365. var jsonargs = JSON.parse(args.substring(2));
  2366. if(stopquickplay!=1 && startedinqp){
  2367. startedinqp = false;
  2368. jsonargs[1]["gs"]["wl"] = 999;
  2369. if(!instaqp){
  2370. var jsonargs2 = decodeIS(jsonargs[1]["is"]);
  2371. jsonargs2["ftu"] = 60;
  2372. if(jsonargs2["mm"]["rxa"] != ""){
  2373. jsonargs2["mm"]["a"] = jsonargs2["mm"]["rxa"];
  2374. jsonargs2["mm"]["n"] = jsonargs2["mm"]["rxn"];
  2375. }
  2376. jsonargs2 = encodeIS(jsonargs2);
  2377. jsonargs[1]["is"] = jsonargs2;
  2378. var jsonargs3 = decodeFromDatabase(jsonargs[1]["gs"]["map"]);
  2379. if(jsonargs3["m"]["rxa"] != ""){
  2380. jsonargs3["m"]["a"] = jsonargs3["m"]["rxa"];
  2381. jsonargs3["m"]["n"] = jsonargs3["m"]["rxn"];
  2382. }
  2383.  
  2384. jsonargs3 = encodeToDatabase(jsonargs3);
  2385. jsonargs[1]["gs"]["map"] = jsonargs3;
  2386. }
  2387. }
  2388.  
  2389. args = "42"+JSON.stringify(jsonargs);
  2390. }
  2391. }
  2392.  
  2393. }
  2394. else{
  2395. if(args.includes("rport")){
  2396. return;
  2397. }
  2398. }
  2399. if(this.url.includes(".bonk.io/socket.io/?EIO=3&transport=websocket&sid=") && !this.injected){
  2400. this.injected = true;
  2401.  
  2402. var originalRecieve = this.onmessage;
  2403. this.onmessage = function(args){
  2404. if(!bonkwssextra.includes(this)){
  2405. wssrecievelog.push(args.data);
  2406. wsssendrecievelog.push([1,args.data]);
  2407. if(typeof(args.data)=="string"){
  2408. args = {"data":RECIEVEFUNCTION(args.data)};
  2409. if(args.data.startsWith('42[1,')){
  2410. var jsonargs = JSON.parse(args.data.substring(2));
  2411. originalSend.call(this,'42[1,{"id":'+jsonargs[2]+'}]');
  2412. }
  2413. if(args.data.startsWith('42[36,')){
  2414. var jsonargs = JSON.parse(args.data.substring(2));
  2415. playerids[jsonargs[1]].playerData2.balance = jsonargs[2];
  2416. }
  2417. if(args.data.startsWith('42[24,')){
  2418. beenKickedTimeStamp = Date.now();
  2419. onlykicked = JSON.parse(args.data.substring(2))[2];
  2420. }
  2421. if(args.data.startsWith('42[21,')){
  2422. recievedinitdata = true;
  2423. }
  2424. if(args.data.startsWith('42[48,')){
  2425. recievedinitdata = true;
  2426. }
  2427. if(args.data.startsWith('42[23,')){
  2428. var jsonargs = JSON.parse(args.data.substring(2));
  2429. if(causelag){
  2430. jsonargs[1]["result"]-=causelag2;
  2431. }
  2432. args.data = '42'+JSON.stringify(jsonargs);
  2433. }
  2434. if(args.data.startsWith('42[16,')){
  2435. var jsonargs = JSON.parse(args.data.substring(2));
  2436. var now = Date.now();
  2437. if(jsonargs[1]=="chat_rate_limit"){
  2438. if(pollactive[1]+100>now){
  2439. pollactive = [false,0,0,[]];
  2440. displayInChat("Your poll failed due to chat rate limit.","#DA0808","#1EBCC1");
  2441. displayInChat("Please try again.","#DA0808","#1EBCC1");
  2442. }
  2443. }
  2444. else if(jsonargs[1]=="room_full"){
  2445. if(!savedrooms.includes(currentroomaddress)){
  2446. savedroombutton.className = "brownButton brownButton_classic buttonShadow";
  2447. }
  2448. }
  2449. }
  2450. if(args.data.startsWith('42[6,')){
  2451. var jsonargs = JSON.parse(args.data.substring(2));
  2452. if(typeof(playerids[jsonargs[1]])!='undefined'){
  2453. delplayerids[jsonargs[1]] = playerids[jsonargs[1]];
  2454. delete playerids[jsonargs[1]];
  2455. }
  2456. hostid = jsonargs[2];
  2457. }
  2458. if(args.data.startsWith('42[39,')){
  2459. var jsonargs = JSON.parse(args.data.substring(2));
  2460. var keys = Object.keys(playerids);
  2461. if(!jsonargs[1]){
  2462. FFA = true;
  2463. for(var i = 0;i<keys.length;i++){
  2464. if(playerids[keys[i]].team!=0){
  2465. playerids[keys[i]].team = 1;
  2466. }
  2467. }
  2468. }
  2469. else{
  2470. FFA = false;
  2471. }
  2472. }
  2473. if(args.data.startsWith('42[41,')){
  2474. var jsonargs = JSON.parse(args.data.substring(2));
  2475. hostid = jsonargs[1]["newHost"];
  2476. }
  2477. if(args.data.startsWith('42[20,')){
  2478. var jsonargs = JSON.parse(args.data.substring(2));
  2479. if(translating[0]){
  2480. translate(jsonargs[2],"auto",translating[1]).then(function(r){displayInChat(playerids[jsonargs[1]].userName+": "+r,"#DA0808","#1EBCC1")});
  2481. }
  2482. if(echo_list.includes(playerids[jsonargs[1]].userName)){
  2483. chat(flag_manage(echotext.replaceAll("username",playerids[jsonargs[1]].userName).replaceAll("message",jsonargs[2])));
  2484. }
  2485. if(randomchat){
  2486. var isin = false;
  2487. for(var i = 0;i<randomchatpriority[1].length;i++){
  2488. if(randomchatpriority[1][i][0] == jsonargs[2]){
  2489. isin = true;
  2490. if(myid!=jsonargs[1]){
  2491. randomchatpriority[1][i][1]+=2;
  2492. randomchatpriority[0]+=2;
  2493. }
  2494. break;
  2495. }
  2496. }
  2497. if(!isin){
  2498. randomchatpriority[1].push([jsonargs[2],Math.min(35-Math.abs(35-jsonargs[2].length),1)]);
  2499. randomchatpriority[0]+=Math.min(35-Math.abs(35-jsonargs[2].length),1);
  2500. }
  2501. }
  2502. if(pollactive[0] || pollactive2[0]){
  2503. var chatmessage = jsonargs[2].toUpperCase().trim().replace(")","");
  2504. var lettersindex = letters.indexOf(chatmessage);
  2505. if(ishost){
  2506. if(pollactive[3].length>0 && lettersindex!=-1 && lettersindex<pollactive[3].length){
  2507. playerids[jsonargs[1]].vote.poll = lettersindex;
  2508. }
  2509. }
  2510. else{
  2511. if(pollactive2[2].length>0 && lettersindex!=-1 && lettersindex<pollactive2[2].length){
  2512. playerids[jsonargs[1]].vote.poll = lettersindex;
  2513. }
  2514. }
  2515. }
  2516. }
  2517. if(args.data.startsWith('42[32')){
  2518. SEND('42[4,{"type":"inactive kick counter"}]');
  2519. }
  2520. if(args.data.startsWith('42[18')){
  2521. var jsonargs = JSON.parse(args.data.substring(2));
  2522. playerids[jsonargs[1]].team = jsonargs[2];
  2523. }
  2524. if(args.data.startsWith('42[40,')){
  2525. recordedTimeStamp = Date.now();
  2526. recordedId = JSON.parse(args.data.substring(2))[1];
  2527. }
  2528. if(args.data.startsWith('42[3,')){
  2529. playerids = {};
  2530. var jsonargs = JSON.parse(args.data.substring(2));
  2531. for(var i = 0; i<jsonargs[3].length;i++){
  2532. if(jsonargs[3][i]!=null){
  2533. playerids[i.toString()] = jsonargs[3][i];
  2534. playerids[i.toString()].commands = false;
  2535. playerids[i.toString()].ratelimit = {"pm":0,"mode":0,"team":0,"poll":0,"join":Date.now(),"style":0};
  2536. playerids[i.toString()].vote = {"poll":-1};
  2537. allstyles[playerids[i.toString()].userName] = [0,0,0];
  2538. }
  2539. }
  2540. if(playerids[jsonargs[1]].userName.startsWith(Gdocument.getElementById("pretty_top_name").textContent)){
  2541. myid = jsonargs[1];
  2542. bonkwss = this;
  2543. playerids[myid].commands = true;
  2544. /*setTimeout(function(){var me = playerids[myid];RECIEVE('42'+JSON.stringify([4,myid,me.peerID,me.userName,me.guest,me.level,me.team,me.avatar]));});*/
  2545. }
  2546. else{
  2547. bonkwssextra.push(this);
  2548. }
  2549. inroom = true;
  2550. hostid = jsonargs[2];
  2551. SEND('42[4,{"type":"commands"}]');
  2552. SEND("42"+JSON.stringify([4,{"type":"style","from":username,"style":mystyle}]));
  2553. allstyles[playerids[myid].userName] = [...mystyle];
  2554. ghostroomwss = bonkwss;
  2555. Gdocument.getElementById("roomlistrefreshbutton").click();
  2556. 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);
  2557.  
  2558. }
  2559. if(args.data.startsWith('42[21,')){
  2560. var jsonargs = JSON.parse(args.data.substring(2));
  2561. mode = jsonargs[1]["mo"];
  2562. FFA = !jsonargs[1]["tea"];
  2563. }
  2564. if(args.data.startsWith('42[48,')){
  2565. var jsonargs = JSON.parse(args.data.substring(2));
  2566. mode = jsonargs[1]["gs"]["mo"];
  2567. FFA = !jsonargs[1]["gs"]["tea"];
  2568. }
  2569. if(args.data.startsWith('42[49,')){
  2570. /*
  2571. var me = playerids[myid];
  2572. RECIEVE('42'+JSON.stringify([4,myid,me.peerID,me.userName,me.guest,me.level,me.team,me.avatar]));
  2573. */
  2574. }
  2575. if(args.data.startsWith('42[15,')){
  2576. var jsonargs = JSON.parse(args.data.substring(2));
  2577. dontswitch = false;
  2578. mode = jsonargs[3]["mo"];
  2579. gameStartTimeStamp = jsonargs[1];
  2580. killedids = [];
  2581. Gdocument.getElementById("newbonklobby").style["z-index"] = "unset";
  2582. Gdocument.getElementById("mapeditorcontainer").style["z-index"] = "unset";
  2583. }
  2584. if(args.data.startsWith('42[33,')){
  2585. var jsonargs = JSON.parse(args.data.substring(2));
  2586. var decodedmap = decodeFromDatabase(jsonargs[1]);
  2587. if(decodedmap!=0){
  2588. requestedmaps = [[decodedmap,jsonargs[1]]].concat(requestedmaps);
  2589. }
  2590. }
  2591. if(args.data.startsWith('42[7,')){
  2592. var jsonargs2 = JSON.parse(args.data.substring(2));
  2593. var idofpacket = jsonargs2[1];
  2594. jsonargs = jsonargs2[2];
  2595. if(typeof(jsonargs["i"]) == "undefined"){
  2596. if(jsonargs["type"]=="private chat" && jsonargs["to"] == username){
  2597. from = jsonargs["from"];
  2598. if(Object.keys(playerids).includes(idofpacket.toString())){
  2599. from = playerids[idofpacket].userName;
  2600. }
  2601. if(!ignorepmlist.includes(from)){
  2602. if(typeof(jsonargs["message"])=="object" && typeof(jsonargs["password"]) == "object"){
  2603. if(public_key[0]==jsonargs["public key"][0] && public_key[1]==jsonargs["public key"][1]){
  2604. var now = Date.now();
  2605. if(jsonargs["password"].length<=25 && playerids[idofpacket].ratelimit.pm+250<now){
  2606. playerids[idofpacket].ratelimit.pm = now;
  2607. var password = CRYPT_MESSAGE(private_key,jsonargs["password"]);
  2608. var decodedtext = jsonargs["message"].slice(0,400);
  2609. var encodedtext = "";
  2610. for(var i=0;i<decodedtext.length;i++){
  2611. if(password[i%password.length]<1000){
  2612. encodedtext+=String.fromCharCode(password[i%password.length]^decodedtext[i]);
  2613. }
  2614. }
  2615. 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);';
  2616. displayInChat('> '+'<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+sanitize(from)+'</a>'+': ',"#DA0808","#1EBCC1",{sanitize:false},encodedtext);
  2617.  
  2618. Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true;
  2619. Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true;
  2620. Laster_message = lastmessage();
  2621. }
  2622. }
  2623. else{
  2624. SEND("42"+JSON.stringify([4,{"type":"public key correction","from":username,"to":private_chat_public_key[0],"public key":public_key}]));
  2625. }
  2626. }
  2627. }
  2628. }
  2629. if(jsonargs["type"]=="request public key" && jsonargs["to"] == username){
  2630. SEND("42"+JSON.stringify([4,{"type":"public key","from":username,"public key":public_key}]));
  2631. }
  2632. if(jsonargs["type"]=="private chat users" && pmuserstimestamp+1500>Date.now()){
  2633. if(typeof(jsonargs["from"])!='undefined'){
  2634. from = jsonargs["from"];
  2635. if(Object.keys(playerids).includes(idofpacket.toString())){
  2636. from = playerids[idofpacket].userName;
  2637. }
  2638. if(!pmusers.includes(from) && username == jsonargs["to"]){
  2639. pmusers.push(from);
  2640. }
  2641. }
  2642. }
  2643. if(jsonargs["type"]=="style" && playerids[idofpacket].ratelimit["style"]+250<Date.now()){
  2644. playerids[idofpacket].ratelimit["style"] = Date.now();
  2645. if(Array.isArray(jsonargs["style"])){
  2646. if(jsonargs["style"].length == 3){
  2647. var valid = true;
  2648. for(var i = 0;i<jsonargs["style"].length;i++){
  2649. if(Number.isInteger(jsonargs["style"][i])){
  2650. if(jsonargs["style"][i]>255 || jsonargs["style"][i]<0){
  2651. valid = false;
  2652. break;
  2653. }
  2654. }
  2655. else{
  2656. valid = false;
  2657. break;
  2658. }
  2659. }
  2660. if(valid){
  2661. allstyles[playerids[idofpacket].userName] = jsonargs["style"];
  2662. }
  2663. }
  2664. }
  2665. }
  2666. if(jsonargs["type"]=="request private chat users"){
  2667. if(typeof(jsonargs["from"])!='undefined'){
  2668. from = jsonargs["from"];
  2669. if(Object.keys(playerids).includes(idofpacket.toString())){
  2670. from = playerids[idofpacket].userName;
  2671. }
  2672. SEND("42"+JSON.stringify([4,{"type":"private chat users","from":username,"to":from}]));
  2673. }
  2674. }
  2675. if(jsonargs["type"]=="public key" && request_public_key_time_stamp+1500>Date.now()){
  2676. from = jsonargs["from"];
  2677. if(Object.keys(playerids).includes(idofpacket.toString())){
  2678. from = playerids[idofpacket].userName;
  2679. }
  2680. if(from == private_chat){
  2681. private_chat_public_key = [private_chat,jsonargs["public key"]];
  2682. displayInChat("Private chatting with "+private_chat+".","#DA0808","#1EBCC1");
  2683. }
  2684. }
  2685. if(jsonargs["type"]=="fakerecieve" && hostid == idofpacket && sandboxon && ((jsonargs["to"].includes(myid) && jsonargs["to"][0]!=-1) || (!jsonargs["to"].includes(myid) && jsonargs["to"][0]==-1))){
  2686. for(var i = 0;i<jsonargs["packet"].length;i++){
  2687. if(!jsonargs["packet"][i].startsWith("42[20,")){
  2688. RECIEVE(jsonargs["packet"][i]);
  2689. }
  2690. }
  2691. }
  2692. if(jsonargs["type"]=="customfakerecieve" && hostid == idofpacket && sandboxon && ((jsonargs["to"].includes(myid) && jsonargs["to"][0]!=-1) || (!jsonargs["to"].includes(myid) && jsonargs["to"][0]==-1))){
  2693. for(var i2 = 0;i2<jsonargs["packet"].length;i2++){
  2694. var keys = Object.keys(sandboxplayerids);
  2695. for(var i = 0;i<keys.length;i++){
  2696. if(jsonargs["packet"][i2].startsWith("42[7,")){
  2697. originalRecieve.call(this,{data:jsonargs["packet"][i2].replace("ID",keys[i].toString()).replace("CVALUE",playerids[keys[i]].movecount.toString())});
  2698. playerids[keys[i]].movecount+=1;
  2699. }
  2700. }
  2701. }
  2702. }
  2703. if(jsonargs["type"]=="commands"){
  2704. playerids[idofpacket].commands = true;
  2705. }
  2706. if(jsonargs["type"]=="sandboxid" && hostid == idofpacket && sandboxon && ((jsonargs["to"].includes(myid) && jsonargs["to"][0]!=-1) || (!jsonargs["to"].includes(myid) && jsonargs["to"][0]==-1))){
  2707. sandboxid = jsonargs["lastid"];
  2708. }
  2709. if(jsonargs["type"]=="sandboxon" && idofpacket == hostid){
  2710. if(!sandboxon){
  2711. displayInChat("This is a sandbox lobby.","#DA0808","#1EBCC1");
  2712. sandboxon = true;
  2713. }
  2714. }
  2715. if(jsonargs["type"]=="vote poll"){
  2716. from = jsonargs["from"];
  2717. if(Object.keys(playerids).includes(idofpacket.toString())){
  2718. from = playerids[idofpacket].userName;
  2719. }
  2720. if(typeof(jsonargs["vote"]) == 'number' && idofpacket!=hostid){
  2721. var now = Date.now();
  2722. if(ishost && pollactive[3].length>1 && pollactive[0]){
  2723. if(jsonargs["vote"]>=0 && jsonargs["vote"]<pollactive[3].length){
  2724. playerids[idofpacket].vote.poll = jsonargs["vote"];
  2725. }
  2726. }
  2727. else if(pollactive2[0] && pollactive2[2].length>1){
  2728. if(jsonargs["vote"]>=0 && jsonargs["vote"]<pollactive2[2].length){
  2729. playerids[idofpacket].vote.poll = jsonargs["vote"];
  2730. }
  2731. }
  2732. }
  2733.  
  2734. }
  2735. if(jsonargs["type"]=="poll end"){
  2736. from = jsonargs["from"];
  2737. if(Object.keys(playerids).includes(idofpacket.toString())){
  2738. from = playerids[idofpacket].userName;
  2739. }
  2740. var now = Date.now();
  2741. if(hostid == idofpacket && playerids[idofpacket].ratelimit.poll+5000<now){
  2742. playerids[idofpacket].ratelimit.poll = now;
  2743. var count = [0,0,0,0];
  2744. var keys = Object.keys(playerids);
  2745. for(var i = 0;i<keys.length;i++){
  2746. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive2[2].length-1){
  2747. count[playerids[keys[i]].vote.poll]++;
  2748. }
  2749. playerids[keys[i]].vote.poll = -1;
  2750. }
  2751. displayInChat("The poll ended.","#DA0808","#1EBCC1");
  2752. for(var i = 0;i<count.length;i++){
  2753. if(count[i]>1){
  2754. displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  2755. }
  2756. if(count[i]==1){
  2757. displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  2758. }
  2759. }
  2760. pollactive2 = [false,0,[]];
  2761. }
  2762.  
  2763. }
  2764. if(jsonargs["type"] == "video player" && idofpacket == hostid && ((jsonargs["to"].includes(myid) && jsonargs["to"][0]!=-1) || (!jsonargs["to"].includes(myid) && jsonargs["to"][0]==-1))){
  2765. changeJukeboxURL(jsonargs["url"],jsonargs["timestamp"]);
  2766. }
  2767. if(jsonargs["type"]=="poll" && idofpacket == hostid){
  2768. from = jsonargs["from"];
  2769. if(Object.keys(playerids).includes(idofpacket.toString())){
  2770. from = playerids[idofpacket].userName;
  2771. }
  2772. if(Array.isArray(jsonargs["poll"])){
  2773. var propperpoll = true;
  2774. var pollifproper = [];
  2775. if(jsonargs["poll"].length>5){
  2776. propperpoll = false;
  2777. }
  2778. else{
  2779. for(var i = 0;i<jsonargs["poll"].length;i++){
  2780. if(typeof(jsonargs["poll"][i]) == 'string'){
  2781. if(jsonargs["poll"][i].length>50){
  2782. propperpoll = false;
  2783. break;
  2784. }
  2785. else{
  2786. pollifproper.push(jsonargs["poll"][i]);
  2787. }
  2788. }
  2789. else{
  2790. propperpoll = false;
  2791. break;
  2792. }
  2793. }
  2794. }
  2795. if(propperpoll){
  2796. var now = Date.now();
  2797. var keys = Object.keys(playerids);
  2798. for(var i = 0;i<keys.length;i++){
  2799. playerids[keys[i]].vote.poll = -1;
  2800. }
  2801. pollactive2 = [true,now,pollifproper];
  2802. playerids[idofpacket].ratelimit.poll = now;
  2803. displayInChat(from+" started a poll:","#DA0808","#1EBCC1");
  2804. for(var i = 0;i<pollifproper.length;i++){
  2805. 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();';
  2806. displayInChat('<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+letters[i]+')</a>',"#DA0808","#1EBCC1",{sanitize:false}," "+pollifproper[i]);
  2807. }
  2808. }
  2809. }
  2810. }
  2811. if(jsonargs["type"]=="request mode" && playerids[idofpacket].ratelimit.mode+1000<Date.now()){
  2812. playerids[idofpacket].ratelimit.mode = Date.now();
  2813. from = jsonargs["from"];
  2814. if(Object.keys(playerids).includes(idofpacket.toString())){
  2815. from = playerids[idofpacket].userName;
  2816. }
  2817. var req_mode = jsonargs["mode"];
  2818. var req_mode2 = "";
  2819. if(req_mode){
  2820. if(req_mode == "b"){
  2821. req_mode2 = "Classic";
  2822. }
  2823. else if(req_mode == "sp"){
  2824. req_mode2 = "Grapple";
  2825. }
  2826. else if(req_mode == "ar"){
  2827. req_mode2 = "Arrows";
  2828. }
  2829. else if(req_mode == "ard"){
  2830. req_mode2 = "Death Arrows";
  2831. }
  2832. }
  2833. if(req_mode2){
  2834. 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+'")}';
  2835. displayInChat('> '+playerids[idofpacket].userName+' requests [<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+req_mode2+'</a>]',"#DA0808","#1EBCC1",{sanitize:false}," mode.");
  2836. }
  2837.  
  2838. }
  2839. if(jsonargs["type"]=="public key correction" && private_chat_public_key[0] == private_chat){
  2840. from = jsonargs["from"];
  2841. if(Object.keys(playerids).includes(idofpacket.toString())){
  2842. from = playerids[idofpacket].userName;
  2843. }
  2844. if(from == private_chat){
  2845. private_chat_public_key = [private_chat,jsonargs["public key"]];
  2846. var text = pmlastmessage;
  2847. var password = [];
  2848. for(var i = 0;i<10;i++){
  2849. password.push(Math.floor(Math.random()*100+50));
  2850. }
  2851. var text2 = [];
  2852. for(var i = 0;i<text.length ;i++){
  2853. text2.push(password[i%password.length]^text.slice(0,400).charCodeAt(i));
  2854. }
  2855. cc
  2856. }
  2857. }
  2858.  
  2859. }
  2860. else{
  2861. var now = Date.now();
  2862. if(playerids[idofpacket.toString()]){
  2863. playerids[idofpacket.toString()].lastmove = now;
  2864. }
  2865. if(idofpacket!=myid){
  2866. playerids[idofpacket.toString()].movecount+=1;
  2867. }
  2868. if(Math.abs(gameStartTimeStamp - (now-1000*jsonargs["f"]/30))>1000 && idofpacket!=myid){
  2869. gameStartTimeStamp = now-1000*jsonargs["f"]/30;
  2870. }
  2871. if(recording){
  2872. if(idofpacket.toString() == recordingid){
  2873. if(recordingdata.length == 0){
  2874. recordingdata.push([jsonargs["i"],jsonargs["f"]]);
  2875. }
  2876. recordingdata.push([jsonargs["i"],jsonargs["f"]-recordingdata[0][1]]);
  2877. }
  2878. }
  2879. if(ishost){
  2880. if(sandboxon && idofpacket == sandboxcopyme){
  2881. var jsonkeys = Object.keys(sandboxplayerids);
  2882. if(!jsonkeys.includes(sandboxcopyme.toString())){
  2883. var jsonargs2 = jsonargs;
  2884. for(var i = 0; i<jsonkeys.length;i++){
  2885. jsonargs2["c"] = playerids[jsonkeys[i]].movecount;
  2886. var packet = '42[7,'+jsonkeys[i].toString()+','+JSON.stringify(jsonargs2)+']';
  2887. RECIEVE(packet);
  2888. }
  2889. jsonargs2["c"] = "CVALUE";
  2890. jsonargs2 = JSON.stringify(jsonargs2).replace('"CVALUE"',"CVALUE");
  2891. SEND("42"+JSON.stringify([4,{"type":"customfakerecieve","from":username,"packet":['42[7,ID,'+jsonargs2+']'],to:[-1]}]));
  2892. }
  2893. }
  2894. for(var i = 0;i<disabledkeys.length;i++){
  2895. var get_keys_var = GET_KEYS(jsonargs["i"]);
  2896. if(get_keys_var[disabledkeys[i]]){
  2897. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden" && !killedids.includes(idofpacket)){
  2898. killedids.push(idofpacket);
  2899. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  2900. SEND('42[25,{"a":{"playersLeft":['+idofpacket.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  2901. RECIEVE('42[31,{"a":{"playersLeft":['+idofpacket.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  2902. break;
  2903. }
  2904. }
  2905. }
  2906. }
  2907. }
  2908. }
  2909.  
  2910. if(args.data.startsWith('42[4,')){
  2911. var jsonargs = JSON.parse(args.data.substring(2));
  2912. 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}};
  2913. if(jsonargs[2]!="sandbox"){
  2914. SEND('42[4,{"type":"commands"}]');
  2915. if(!Object.keys(allstyles).includes(jsonargs[3])){
  2916. allstyles[jsonargs[3]] = [0,0,0];
  2917. SEND("42"+JSON.stringify([4,{"type":"style","from":username,"style":allstyles[playerids[myid].userName]}]));
  2918. }
  2919. }
  2920. if(sandboxon){
  2921. var sandboxkeys = Object.keys(sandboxplayerids);
  2922. if(sandboxkeys.includes(jsonargs[1].toString())){
  2923. delete sandboxplayerids[jsonargs[1]];
  2924. }
  2925. if(jsonargs[2]=="sandbox"){
  2926. sandboxplayerids[jsonargs[1]] = jsonargs[3];
  2927. if(jsonargs[1]>sandboxid){
  2928. sandboxid = parseInt(jsonargs[1])+1;
  2929. }
  2930. }
  2931. else{
  2932. if(ishost){
  2933. SEND('42[4,{"type":"sandboxon"}]');
  2934. var sandboxkeys = Object.keys(sandboxplayerids);
  2935. var packets = [];
  2936. for(var i = 0;i<sandboxkeys.length;i++){
  2937. var p = playerids[sandboxkeys[i]];
  2938. var packet = '42'+JSON.stringify([4,sandboxkeys[i],p.peerID,p.userName,p.guest,p.level,p.team,p.avatar]);
  2939. packets.push(packet);
  2940. }
  2941. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":packets,to:[jsonargs[1]]}]));
  2942. SEND("42"+JSON.stringify([4,{"type":"sandboxid","from":username,"lastid":sandboxid,to:[jsonargs[1]]}]));
  2943. }
  2944. }
  2945. }
  2946. if(ishost){
  2947. if(jointext!="" && jsonargs[2]!="sandbox"){
  2948. chat(flag_manage(jointext.replaceAll("username",jsonargs[3])));
  2949. }
  2950. if(jointeam!=-1 && jsonargs[2]!="sandbox"){
  2951. SEND('42[26,{"targetID":'+jsonargs[1].toString()+',"targetTeam":'+jointeam.toString()+'}]');
  2952. setTimeout(function(){RECIEVE('42[18,'+jsonargs[1].toString()+','+jointeam.toString()+']');});
  2953. }
  2954. if(jukeboxplayer.src!="" && !jukeboxplayer.paused){
  2955. SEND("42"+JSON.stringify([4,{"type":"video player","from":username,"url":jukeboxplayerURL,"timestamp":Date.now()-jukeboxplayer.currentTime*1000,"to":[jsonargs[1]]}]));
  2956. }
  2957. if(freejoin){
  2958. var count = 0;
  2959. var keys = Object.keys(playerids);
  2960. for(var i = 0; i<keys.length;i++){
  2961. if(playerids[keys[i]].team!=0){
  2962. count++;
  2963. }
  2964. }
  2965. if(count <= 2 && jsonargs[6]!=0){
  2966. setTimeout(function(){
  2967. Gdocument.getElementById("newbonklobby_editorbutton").click();
  2968. Gdocument.getElementById("mapeditor_close").click();
  2969. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  2970. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  2971. if(transitioning == true){
  2972. canceled = true;
  2973. }
  2974. },150);
  2975. }
  2976. }
  2977. }
  2978.  
  2979. }
  2980. if(args.data.startsWith('42[5,')){
  2981. var jsonargs = JSON.parse(args.data.substring(2));
  2982. if(typeof(playerids[jsonargs[1]])!='undefined'){
  2983. delplayerids[jsonargs[1]] = playerids[jsonargs[1]];
  2984. delete allstyles[playerids[jsonargs[1]].userName];
  2985. delete playerids[jsonargs[1]];
  2986. }
  2987. if(sandboxon && typeof(sandboxplayerids[jsonargs[1]])!='undefined'){
  2988. delete sandboxplayerids[jsonargs[1]];
  2989. }
  2990. }
  2991. }}
  2992. return originalRecieve.call(this,args);
  2993. };
  2994.  
  2995. var originalClose = this.onclose;
  2996. this.onclose = function () {
  2997. if(bonkwssextra.includes(this)){
  2998. bonkwssextra.splice(bonkwssextra.indexOf(this),1)
  2999. }
  3000. else{
  3001. window.bonkwss = 0;
  3002. }
  3003. return originalClose.call(this);
  3004. }
  3005.  
  3006. }
  3007. return originalSend.call(this,args);
  3008. };
  3009.  
  3010. scope.SEND = function(args){
  3011. if(bonkwss!=0){
  3012. bonkwss.send(args);
  3013. }
  3014. };
  3015. scope.RECIEVE = function(args){
  3016. if(bonkwss!=0){
  3017. bonkwss.onmessage({data:args});
  3018. }
  3019. };
  3020.  
  3021.  
  3022.  
  3023. scope.dontswitch = false;
  3024. scope.username = 0;
  3025. scope.timedelay = 1400;
  3026. scope.ishost = false;
  3027. scope.checkboxhidden = true;
  3028. scope.quicki=0;
  3029. scope.defaultmode = "d";
  3030. scope.recmodebool = false;
  3031. scope.shuffle = false;
  3032. scope.startedinqp = false;
  3033. scope.instaqp = false;
  3034. scope.freejoin = false;
  3035. scope.recordedTimeStamp = 0;
  3036. scope.recordedId = 0;
  3037. scope.smartteams = false;
  3038. scope.beenKickedTimeStamp = 0;
  3039. scope.stopquickplay = 1;
  3040. scope.currentFrame = 0;
  3041. scope.text2speech = false;
  3042. scope.canceled = false;
  3043. scope.wintext = "";
  3044. scope.banned = [];
  3045. scope.transitioning = false;
  3046. scope.echo_list = [];
  3047. scope.echoAppend = "";
  3048. scope.message = "";
  3049. scope.private_chat = "";
  3050. scope.private_chat_public_key = ["",[0,0]];
  3051. scope.disabledkeys = [];
  3052. scope.actuallyhost = false;
  3053. scope.pmusers = [];
  3054. scope.pmlastmessage = "";
  3055. scope.pmuserstimestamp = 0;
  3056. scope.ignorepmlist = [];
  3057. scope.scroll = false;
  3058. scope.elem = Gdocument.getElementById("maploadwindowmapscontainer");
  3059. scope.npermissions = 1;
  3060. scope.space_flag = false;
  3061. scope.rcaps_flag = false;
  3062. scope.number_flag = false;
  3063. scope.reverse_flag = false;
  3064. scope.autocorrect = false;
  3065. scope.request_public_key_time_stamp = 0;
  3066. scope.sandboxcopyme = -1;
  3067. scope.recteams = false;
  3068. scope.chatheight = 128;
  3069. scope.onlykicked = false;
  3070. scope.killedids = [];
  3071. scope.jointext = "";
  3072. scope.randomchat = false;
  3073. scope.randomchatpriority = [0,[]];
  3074. scope.randomchatlastmessage = ["",0];
  3075. scope.afkkill = -1;
  3076. scope.tournament_mode = "";
  3077. scope.tournament_scores = [];
  3078. scope.tournament_in_and_out = {"in":[],"out":[]};
  3079. scope.echotext = "message";
  3080. scope.nextafter = 0;
  3081. scope.nextafterbuffer = -1;
  3082. scope.roundsperqp = 1;
  3083. scope.roundsperqp2 = 0;
  3084. scope.autorecord = false;
  3085. scope.poll = [];
  3086. scope.letters = ["A","B","C","D","E"];
  3087. scope.qppaused = false;
  3088. scope.FollowCam = false;
  3089. scope.autocam = false;
  3090. scope.gravity = 20;
  3091. scope.randomchat = false;
  3092. scope.randomchat_randomtimestamp = 0;
  3093. scope.randomchat_timestamp = 0;
  3094. scope.multiplier = 3.65;
  3095. scope.aimbot = false;
  3096. scope.recievedinitdata = false;
  3097. scope.heavybot = false;
  3098. scope.zoom = 1;
  3099. scope.prediction = 350;
  3100. scope.started = 0;
  3101. scope.holdheavy = 0;
  3102. scope.grappleheld = false;
  3103. scope.grappleheld2 = false;
  3104. scope.heavyheld = false;
  3105. scope.reverseqp = false;
  3106. scope.jointeam = -1;
  3107. scope.heavyheld2 = false;
  3108. scope.heavyid = 3;
  3109. scope.specialid = 0;
  3110. 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};
  3111. scope.leftRight = [37,39];
  3112. scope.upDown = [38,40];
  3113. scope.heavy = 88;
  3114. scope.special = 90;
  3115. scope.newzoom2 = 1;
  3116. scope.staystill = false;
  3117. scope.staystillpos = [0,0];
  3118. scope.zoom2 = 1;
  3119. scope.admins = [["LEGENDBOSS123",[0,0,0,0]],["iNeonz",[0,0,0,0]],["left paren",[0,0,0,0]],["L armee d LS",[0,0,0,0]],["OG_New_Player",[0,0,0,0]],["Pixelmelt",[0,0,0,0]],["pro9905",[0,0,0,0]]];
  3120.  
  3121. scope.autokickban = 0;
  3122. scope.ghostroomwss = -1;
  3123. scope.autokickbantimestamp = 0;
  3124. scope.getroomslastcheck = 0;
  3125. scope.causelag = false;
  3126. scope.causelag2 = 0;
  3127. scope.overideDate = [false,0];
  3128. scope.scale = 1;
  3129. scope.translating = [false,""];
  3130. scope.translating2 = [false,""];
  3131. scope.translatingkeys = {"english":"en","chinese":"zh","hindi":"hi","spanish":"es","portugese":"pt","french":"fr","arabic":"ar","russian":"ru","korean":"ko"};
  3132. scope.translate = function(text,fromL,toL) {
  3133. var fL = fromL || 'en';
  3134. var tL = toL || 'de';
  3135. var url = 'https://translate.googleapis.com/translate_a/single?client=gtx&sl='+ fL + "&tl=" + tL + "&dt=t&q=" + encodeURI(text);
  3136. var parseJSON = txt => JSON.parse(txt.split(',').map( x => x || 'null').join(',')) ;
  3137. var joinSnippets = json => json[0].map( x => x[0] ).join('');
  3138. return fetch(url).then(function(res){
  3139. return res.text();
  3140. }).then(function(text){
  3141. return joinSnippets(parseJSON(text));
  3142. });
  3143. };
  3144. scope.positive = function(angle){
  3145. if(angle<0){
  3146. angle += 2*Math.PI;
  3147. }
  3148. return angle%(Math.PI*2);
  3149. };
  3150. scope.angle_between = function(angle,angle2){
  3151. return Math.min(Math.abs(positive(angle)-positive(angle2)),Math.PI*2-Math.abs(positive(angle)-positive(angle2)));
  3152. };
  3153. scope.angle_between2 = function(angle,angle2){
  3154. if(angle_between(angle,angle2+Math.PI/2)<Math.PI/2){
  3155. return 1;
  3156. }
  3157. return -1;
  3158. };
  3159.  
  3160. scope.stringdistance = function(s1,s2){
  3161. s1 = s1.toLowerCase();
  3162. s2 = s2.toLowerCase();
  3163. var matrix = Array(s1.length+1);
  3164. for(var i = 0;i<matrix.length;i++){
  3165. matrix[i] = Array(s2.length+1);
  3166. matrix[i][0] = i;
  3167. }
  3168. for(var i = 0;i<matrix[0].length;i++){
  3169. matrix[0][i] = i;
  3170. }
  3171. for(var i = 1;i<s1.length+1;i++){
  3172. for(var i2 = 1;i2<s2.length+1;i2++){
  3173. if(s1[i-1]==s2[i2-1]){
  3174. matrix[i][i2] = matrix[i-1][i2-1];
  3175. }
  3176. else{
  3177. matrix[i][i2] = Math.min(matrix[i][i2-1],matrix[i-1][i2],matrix[i-1][i2-1])+1;
  3178. }
  3179. }
  3180. }
  3181. return matrix[s1.length][s2.length];
  3182. };
  3183. scope.closestWord = function(word){
  3184. if(word.length>20 || word.length<2){
  3185. return word;
  3186. }
  3187. var distances = [word.length,""];
  3188. var playernamelist = [];
  3189. var keys = Object.keys(playerids);
  3190. for(var i = 0;i<keys.length;i++){
  3191. playernamelist.push(playerids[keys[i]].userName);
  3192. }
  3193. var wordlist2 = playernamelist.concat(wordlist);
  3194. for(var i = 0;i<wordlist2.length;i++){
  3195. var distance = stringdistance(word,wordlist2[i]);
  3196. if(distance<=distances[0]){
  3197. distances[0] = distance;
  3198. distances[1] = wordlist2[i];
  3199. if(distance == 0){
  3200. return wordlist2[i];
  3201. }
  3202. }
  3203. };
  3204. if(distances[1] == ""){
  3205. return word;
  3206. }
  3207. return distances[1];
  3208. };
  3209.  
  3210.  
  3211.  
  3212. scope.replay = function(){
  3213. var frame = getCurrentFrame();
  3214. /*var replaycounter = 0;
  3215. while(1){
  3216. if(replaycounter != recordingdata.length-1){
  3217. for(var i = 0;i<recordingdata[replaycounter+1][1]-recordingdata[replaycounter][1];i++){
  3218. RECIEVE('42[7,'+myid+',{"i":'+recordingdata[replaycounter][0]+',"f":'+(frame+i+recordingdata[replaycounter][1]).toString()+',"c":'+playerids[myid].movecount+'}]');
  3219. playerids[myid].movecount+=1;
  3220. }
  3221. replaycounter+=1;
  3222. }
  3223. else{
  3224. break;
  3225. }
  3226. }*/
  3227. for(var i = 0;i<recordingdata.length;i++){
  3228. SEND('42[4,{"i":'+recordingdata[i][0]+',"f":'+(frame+recordingdata[i][1]).toString()+',"c":'+playerids[myid].movecount+'}]');
  3229. }
  3230. };
  3231. scope.presskeys = function(x,y){
  3232. if(!x.left && y.left){
  3233. fire("keydown",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  3234. }
  3235. else if(x.left && !y.left){
  3236. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  3237. }
  3238. if(!x.right && y.right){
  3239. fire("keydown",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  3240. }
  3241. else if(x.right && !y.right){
  3242. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  3243. }
  3244. if(!x.up && y.up){
  3245. fire("keydown",{"keyCode":upDown[0]},Gdocument.getElementById("gamerenderer"));
  3246. }
  3247. else if(x.up && !y.up){
  3248. fire("keyup",{"keyCode":upDown[0]},Gdocument.getElementById("gamerenderer"));
  3249. }
  3250. if(!x.down && y.down){
  3251. fire("keydown",{"keyCode":upDown[1]},Gdocument.getElementById("gamerenderer"));
  3252. }
  3253. else if(x.down && !y.down){
  3254. fire("keyup",{"keyCode":upDown[1]},Gdocument.getElementById("gamerenderer"));
  3255. }
  3256. if(!x.heavy && y.heavy){
  3257. fire("keydown",{"keyCode":heavy},Gdocument.getElementById("gamerenderer"));
  3258. }
  3259. else if(x.heavy && !y.heavy){
  3260. fire("keyup",{"keyCode":heavy},Gdocument.getElementById("gamerenderer"));
  3261. }
  3262. if(!x.special && y.special){
  3263. fire("keydown",{"keyCode":special},Gdocument.getElementById("gamerenderer"));
  3264. }
  3265. else if(x.special && !y.special){
  3266. fire("keyup",{"keyCode":special},Gdocument.getElementById("gamerenderer"));
  3267. }
  3268. };
  3269. scope.getplayerkeys = function(){
  3270. var keykeys = Object.keys(keyCodes);
  3271. var keyslist = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[1].children).slice(1);
  3272. var keyslist2 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[2].children).slice(1);
  3273. var keyslist3 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[3].children).slice(1);
  3274. var keyslist4 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[4].children).slice(1);
  3275. var keyslist5 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[5].children).slice(1);
  3276. var keyslist6 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[6].children).slice(1);
  3277. for(var i = 0;i<keyslist.length;i++){
  3278. if(keykeys.includes(keyslist[i].textContent)){
  3279. leftRight[0] = keyCodes[keyslist[i].textContent];
  3280. break;
  3281. }
  3282. else{
  3283. leftRight[0] = keyslist[i].textContent.charCodeAt(0);
  3284. break
  3285. }
  3286. }
  3287. for(var i = 0;i<keyslist2.length;i++){
  3288. if(keykeys.includes(keyslist2[i].textContent)){
  3289. leftRight[1] = keyCodes[keyslist2[i].textContent];
  3290. break;
  3291. }
  3292. else{
  3293. leftRight[1] = keyslist2[i].textContent.charCodeAt(0);
  3294. break
  3295. }
  3296. }
  3297. for(var i = 0;i<keyslist3.length;i++){
  3298. if(keykeys.includes(keyslist3[i].textContent)){
  3299. upDown[0] = keyCodes[keyslist3[i].textContent];
  3300. break;
  3301. }
  3302. else{
  3303. upDown[0] = keyslist3[i].textContent.charCodeAt(0);
  3304. break
  3305. }
  3306. }
  3307. for(var i = 0;i<keyslist4.length;i++){
  3308. if(keykeys.includes(keyslist4[i].textContent)){
  3309. upDown[1] = keyCodes[keyslist4[i].textContent];
  3310. break;
  3311. }
  3312. else{
  3313. upDown[1] = keyslist4[i].textContent.charCodeAt(0);
  3314. break
  3315. }
  3316. }
  3317. for(var i = 0;i<keyslist5.length;i++){
  3318. if(keykeys.includes(keyslist5[i].textContent)){
  3319. heavy = keyCodes[keyslist5[i].textContent];
  3320. break;
  3321. }
  3322. else{
  3323. heavy = keyslist5[i].textContent.charCodeAt(0);
  3324. break
  3325. }
  3326. }
  3327. for(var i = 0;i<keyslist6.length;i++){
  3328. if(keykeys.includes(keyslist6[i].textContent)){
  3329. special = keyCodes[keyslist6[i].textContent];
  3330. break;
  3331. }
  3332. else{
  3333. special = keyslist6[i].textContent.charCodeAt(0);
  3334. break
  3335. }
  3336. }
  3337. };
  3338. scope.changeJukeboxURL = function(url,timestamp = 0){
  3339. if(pipedurllist.length == 0){
  3340. displayInChat("The jukebox is still being set up.","#DA0808","#1EBCC1");
  3341. return;
  3342. }
  3343. if(url == ""){
  3344. jukeboxplayer.pause();
  3345. jukeboxplayer.src = '';
  3346. displayInChat("The jukebox has been paused.","#DA0808","#1EBCC1");
  3347. }
  3348. else if(url == jukeboxplayerURL && Date.now()-timestamp >= 2000){
  3349. jukeboxplayer.volume = jukeboxplayervolume/100;
  3350. displayInChat("The jukebox has been unpaused or reset.","#DA0808","#1EBCC1",{sanitize:false});
  3351. jukeboxplayer.play();
  3352. jukeboxplayer.currentTime = (Date.now()-timestamp)/1000;
  3353. }
  3354. else{
  3355. var id = url.match(/youtu\.?be.com\/watch\?.*v=[a-z|A-Z|0-9|_|-]{11}/)[0].split("?v=");
  3356. id = id[id.length-1];
  3357. var loaded = false;
  3358. var loaded2 = 0;
  3359. for(var inst = 0;inst<pipedindexes.length;inst++){
  3360. checkJukeboxStream(pipedindexes[inst],id).then(function(value){
  3361. loaded2+=1;
  3362. if(value!=-1 && !loaded){
  3363. loaded = true;
  3364. jukeboxplayer.src = value[0];
  3365. jukeboxplayer.volume = jukeboxplayervolume/100;
  3366. jukeboxplayerURL = url;
  3367. jukeboxplayer.oncanplaythrough = function(){
  3368. displayInChat("The jukebox has been changed to: ","#DA0808","#1EBCC1",{sanitize:false},url);
  3369. displayInChat("Jukebox is now playing: "+value[1]+" by "+value[2]+".","#DA0808","#1EBCC1");
  3370. jukeboxplayer.play();
  3371. jukeboxplayer.currentTime = (Date.now()-timestamp)/1000;
  3372. jukeboxplayer.oncanplaythrough = null;
  3373. };
  3374. jukeboxplayer.onerror = function(){
  3375. displayInChat("The jukebox failed to load. Please try again.","#DA0808","#1EBCC1");
  3376. };
  3377. }
  3378. });
  3379. }
  3380. new Promise(function(r){
  3381. var interv = setInterval(function(){
  3382. if(loaded2>=pipedindexes.length){
  3383. if(!loaded){
  3384. displayInChat("The jukebox failed to load. Please try again.","#DA0808","#1EBCC1");
  3385. }
  3386. clearInterval(interv);
  3387. }
  3388. },60)
  3389. });
  3390. }
  3391. };
  3392. 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"];
  3393.  
  3394. scope.adv_help = {"help":"Shows all command names.",
  3395. "?":"Shows all command names.",
  3396. "advhelp":"Shows a command in detail.",
  3397. "space":"Toggles space. When space is on, whatever you type will be spaced apart.",
  3398. "rcaps":"Toggles rcaps. When rcaps is on, each letter will randomly get capitalized.",
  3399. "number":"Toggles number. When number is on, 'a' becomes 4, 'e' becomes 3, 's' becomes 5, 'o' becomes 0, 'l' and 'i' become 1.",
  3400. "speech":"Turns on text to speech for the chat.",
  3401. "savedroom":"Displays all the rooms you have saved, you can remove individual ones from the saved rooms by clicking \"Remove\".",
  3402. "clearsavedroom":"Clears all the saved rooms.",
  3403. "echo":"Echoes a username. It copies the username's chat messages.",
  3404. "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.",
  3405. "remove":"Removes username from echo list. You will not echo that username anymore.",
  3406. "clearecho":"Clears echo list. You will not echo anyone anymore.",
  3407. "chatw":"It private chats with username. Type /msg to message that username.",
  3408. "msg":"Messages with what username you are chatting with. Type /chatw to chat with a username.",
  3409. "ignorepm":"Ignores the username's private chat messages. To unignore, type '/ignorepm [username]'.",
  3410. "pmusers":"Dispays who you can private chat with.",
  3411. "pollstat":"Displays the current poll and its votes.",
  3412. "eval":"Evaluates code. Only use this if you are experienced in javascript.",
  3413. "debugger":"Opens debugger.",
  3414. "style":"Change the color of your username, level, and background. For example, '/style 255 0 0' will make your username red.",
  3415. "translate":"Translates peoples texts to the chosen language.",
  3416. "translateto":"You will now speak the chosen language.",
  3417. "autocorrect":"Fixes spelling mistakes.",
  3418. "randomchat":"Spams random chat messages from the past.",
  3419. "lobby":"Makes lobby visible when you are ingame. Type '/lobby' again to close lobby.",
  3420. "score":"Displays the current score while ingame. Type '/score' again to hide the score.",
  3421. "team":"Joins a specific team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  3422. "scroll":"Toggles a scrollbar in ingame chat.",
  3423. "followcam":"Enables follow camera. Your character will be centered on the screen.",
  3424. "autocam":"Zooms in/out enough for you to see everyone on the screen.",
  3425. "zoom":"Zooms in, out, or resets zoom.",
  3426. "xray":"Removes all shapes that don't have a shadow. This means all non-physics shapes will be hidden.",
  3427. "aimbot":"Toggles aimbot. Aimbot will aim for you in arrows or death arrows mode.",
  3428. "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.",
  3429. "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.",
  3430. "lagbot":"Makes your movements very laggy. Type '/lagbot 0' to turn it off.",
  3431. "hidechat":"Hides ingame chat. Type '/showchat' to show it again.",
  3432. "showchat":"Shows ingame chat. '/hidechat' hides the chat.",
  3433. "notify":"You will be notified if a person types @username",
  3434. "stopnotify":"You will not be notified if a person types @username",
  3435. "support":"Displays all the people who have supported this mod.",
  3436. "startqp":"Starts cycling maps in your map menu.",
  3437. "stopqp":"Stops cycling maps in your map menu.",
  3438. "revqp":"Reverses the order of quickplay. '/next', '/previous' will be inverted.",
  3439. "pauseqp":"Only pauses or unpauses the quickplay cycle due to round end. '/next', '/previous' still work. Type 'pauseqp' to unpause quickplay.",
  3440. "next":"Skips the map. Usable only with '/startqp'.",
  3441. "nextafter":"Skips the map if no one is able to win/draw within a certain amount of time.",
  3442. "previous":"Goes to previous map. Usable only with '/startqp'.",
  3443. "shuffle":"Makes quickplay play random maps instead of in order.",
  3444. "freejoin":"Toggles freejoin. If freejoin is on, starts the game instantly if there are 1 or less players currently playing.",
  3445. "recmode":"In quickplay, it switches mode to recommended mode, according to editor.",
  3446. "recteam":"In quickplay, it sorts people into teams when teams are necessary.",
  3447. "defaultmode":"Switches mode to defaultmode if there is no recmode.",
  3448. "start":"Starts game instantly.",
  3449. "instaqp":"Rounds will instantly start without a countdown.",
  3450. "balanceA":"Balances everyone with balance number.",
  3451. "moveA":"Sets everyones team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  3452. "jointeam":"Sets the team of anyone who joins. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  3453. "moveT":"Sets everyone in one team to another team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  3454. "rounds":"Sets rounds to win.",
  3455. "replay":"Replays the movements that were recorded",
  3456. "record":"Records movements of the username",
  3457. "delrecording":"Deletes the recording with the name.",
  3458. "saverecording":"Saves the recording with the name.",
  3459. "loadrecording":"Loads the recording with the name. Type '/replay' to replay it.",
  3460. "stoprecord":"Stops recording the player. Type '/saverecording [text]' to save it.",
  3461. "jukebox":"Sets the jukebox to a link. That link will play for everyone who has this mod.",
  3462. "volume":"Sets the volume of the jukebox.",
  3463. "pausejukebox":"If the jukebox is playing, it pauses it.",
  3464. "resetjukebox":"Resets the jukebox, so it starts from the very beginning.",
  3465. "playjukebox":"If the jukebox is paused, it plays it.",
  3466. "roundsperqp":"After that many rounds, the map will change. Normally, the map will change after 1 round.",
  3467. "autorecord":"After a round ends, automatically records the last 15 seconds.",
  3468. "mode":"If host, switches mode. Otherwise, it requests the host to switch mode, as long as the host has this mod.",
  3469. "disablekeys":"If anyone presses a disabled key, they get killed. Key options: left right up down heavy special.",
  3470. "jointext":"Chats the jointext whenever someone joins. \"username\" will get replaced by the joining person's username.",
  3471. "wintext":"Chats the wintext whenever someone wins. \"username\" will get replaced by the winning person's username.",
  3472. "afkkill":"If a person stays afk for that many seconds, they get automatically killed.",
  3473. "ban":"Bans username from lobby. If they rejoin, it automatically bans.",
  3474. "kill":"Kills the person ingame.",
  3475. "resetpoll":"Clears the poll.",
  3476. "addoption":"Adds the option to the poll. You can only have 4 maximum options. Type '/deloption [letter]' to remove an option.",
  3477. "deloption":"Removes the option with that letter.",
  3478. "startpoll":"Starts a poll that lasts for at least 10 seconds. Type '/endpoll' to end it early.",
  3479. "endpoll":"Ends the poll early if the poll lasted for at least 10 seconds.",
  3480. "addplayer":"In sandbox, it adds bots.",
  3481. "addname":"Adds a bot with a specific name. If that name already exists, it will copy the skin of that player to the bot.",
  3482. "delplayer":"In sandbox, it deletes bots.",
  3483. "copy":"In sandbox, it makes all bots copy the username's movements.",
  3484. "sandbox":"Turns a normal lobby into a sandbox lobby. You cannot turn a sandbox lobby back into a normal lobby.",
  3485. "autokick":"Automatically kicks everyone who is not using this mod.",
  3486. "autoban":"Automatically bans everyone who is not using this mod.",
  3487. "Alt L":"Makes lobby visible when you are ingame. Press Alt L again to close lobby.",
  3488. "Alt C":"Hides ingame chat. Press Alt C again to show ingame chat.",
  3489. "Alt S":"Starts game instantly.",
  3490. "Alt T":"Toggles teams.",
  3491. "Alt N":"Enables follow camera. Your character will be centered on the screen.",
  3492. "Alt G":"Zooms in.",
  3493. "Alt H":"Resets zoom.",
  3494. "Alt J":"Zooms out.",
  3495. "Alt Y":"Enables xray. Removes all shapes that don't have a shadow. This means all non-physics shapes will be hidden.",
  3496. "Alt E":"Toggles editor.",
  3497. "Alt K":"Exits ingame and returns to lobby.",
  3498. "Alt M":"Switches modes.",
  3499. "Alt V":"Toggles autocam. Autocam zooms in/out enough for you to see everyone on the screen.",
  3500. "Alt Q":"Toggles quickplay.",
  3501. "Alt B":"Displays the current score while ingame. Press Alt B again to hide the score.",
  3502. "Alt A":"Skips the map if quickplay is on.",
  3503. "Alt D":"Goes to previous map if quickplay is on.",
  3504. "Alt F":"Toggles freejoin. If freejoin is on, starts the game instantly if there are 1 or less players currently playing.",
  3505. "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.",
  3506. "Alt U":"Toggles aimbot. Aimbot will aim for you in arrows or death arrows mode.",
  3507. "Alt P":"Only pauses or unpauses the quickplay cycle due to round end. '/next', '/previous' still work. Type 'pauseqp' to unpause quickplay.",
  3508. "Alt R":"In quickplay, it switches mode to recommended mode, according to editor.",
  3509. "Alt I":"Opens debugger.",
  3510. "Alt W":"Saves your position, and tries to reach it constantly. This is useful in parkour if you want to go afk.",
  3511. "Alt <":"Lowers ingame chat height.",
  3512. "Alt >":"Highers ingame chat height."
  3513. };
  3514. scope.displayadvhelp = function(command){
  3515. displayInChat(adv_help[command],"#009398","#DA0808",{sanitize:true},"",true);
  3516. };
  3517. scope.changemode = function(mode){
  3518. SEND('42[20,{"ga":"b","mo":"'+mode+'"}]');
  3519. RECIEVE('42[26,"b","'+mode+'"]');
  3520. };
  3521. Gdocument.getElementById("ingamechatcontent").style["pointer-events"]="all";
  3522. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  3523. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  3524. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  3525.  
  3526. document.getElementById('adboxverticalCurse').style["display"] = "none";
  3527. document.getElementById('adboxverticalleftCurse').style["display"] = "none";
  3528. elem.onclick=function(e){
  3529. if(stopquickplay==0 && ishost == true && e.isTrusted == true){
  3530. quicki = (Array.from(e.target.parentElement.parentNode.children).indexOf(e.target.parentNode)-1)%(Gdocument.getElementById("maploadwindowmapscontainer").children.length);
  3531. if(reverseqp){
  3532. quicki+=2;
  3533. quicki = quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length);
  3534. }
  3535. }
  3536. };
  3537. scope.getCurrentFrame = function(){
  3538. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  3539. return currentFrame;
  3540. };
  3541. scope.urlify = function(text) {
  3542. if(!Gdocument.getElementById('bl_Menu')){
  3543. return text.replace(/[(http(s)?):\/\/(www\.)?a-zA-Z0-9@:;%.\-_\+~#=]{2,256}\.[\-a-z]{2,6}\b([\-a-zA-Z0-9@:;%_\+.~#?&//=]*)/ig, function(url) {
  3544. var extratext = "";
  3545. var matches = url.match(/youtu\.?be.com\/watch\?.*v=[a-z|A-Z|0-9|_|-]{11}/);
  3546. if(matches){
  3547. var button = Gdocument.createElement("a");
  3548. button.style["color"] = "green";
  3549. button.textContent = "Play";
  3550. button.href = "javascript:void(0)";
  3551. button.setAttribute("onclick",function(){
  3552. if(Gwindow.ishost){
  3553. Gwindow.SEND("42"+JSON.stringify([4,{"type":"video player","from":Gwindow.username,"url":"URL INSERT HERE","timestamp":Gwindow.Date.now()+2000,"to":[-1]}]));
  3554. Gwindow.displayInChat("Jukebox is loading... Please wait a few seconds.","#DA0808","#1EBCC1");
  3555. Gwindow.changeJukeboxURL("URL INSERT HERE",Gwindow.Date.now()+2000);
  3556. }
  3557. else{
  3558. Gwindow.displayInChat("You need to be host.","#DA0808","#1EBCC1");
  3559. }
  3560. });
  3561. button.attributes["onclick"].nodeValue = button.attributes["onclick"].nodeValue.slice(11,-1).replaceAll("URL INSERT HERE","https://www."+matches[0]);
  3562. var extratext = ' ['+button.outerHTML+']';
  3563. }
  3564. if(url.startsWith('https://') || url.startsWith('http://')){return '<a href="' + url + '" target="_blank" style = "color:orange">' + sanitize(url) + '</a>'+extratext;}
  3565. else{return '<a href="https://' + url + '" target="_blank" style = "color:orange">' + sanitize(url) + '</a>'+extratext;}
  3566. })}return text;
  3567. };
  3568. scope.fire = function(type,options,d = Gdocument){
  3569. var event= document.createEvent("HTMLEvents");
  3570. event.initEvent(type,true,false);
  3571. for(var p in options){
  3572. event[p]=options[p];
  3573. }
  3574. d.dispatchEvent(event);
  3575. };
  3576.  
  3577. scope.chat = function(message){
  3578. SEND('42[10,{"message":'+JSON.stringify(message)+'}]');
  3579. };
  3580. scope.chat2 = function(message,enteragain=false){
  3581. mess = Gdocument.getElementById("newbonklobby_chat_input").value;
  3582. mess2 = Gdocument.getElementById("ingamechatinputtext").value;
  3583. Gdocument.getElementById("newbonklobby_chat_input").value = message;
  3584. Gdocument.getElementById("ingamechatinputtext").value = message;
  3585. fire("keydown",{keyCode:13});
  3586. if(!enteragain){
  3587. fire("keydown",{keyCode:13});
  3588. }
  3589. Gdocument.getElementById("newbonklobby_chat_input").value = mess;
  3590. Gdocument.getElementById("ingamechatinputtext").value = mess2;
  3591. };
  3592. scope.sanitize = function(message){
  3593. return message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;');
  3594. };
  3595. scope.displayInChat = function(message, LobbyColor, InGameColor, options, message2, BringDown) {
  3596. options = options ?? {};
  3597. BringDown = BringDown ?? false;
  3598. message2 = message2 ?? "";
  3599. LobbyColor = LobbyColor ?? "#8800FF";
  3600. InGameColor = InGameColor ?? "#AA88FF";
  3601. var A = Gdocument.createElement("div");
  3602. var B = Gdocument.createElement("span");
  3603. B.className = "newbonklobby_chat_status";
  3604. B.style.color = LobbyColor;
  3605. A.appendChild(B);
  3606. B.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  3607. B.innerHTML+=urlify(message2.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;'));
  3608. var C = Gdocument.createElement("div");
  3609. var D = Gdocument.createElement("span");
  3610. D.style.color = InGameColor;
  3611. C.appendChild(D);
  3612. D.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  3613. D.innerHTML+=urlify(message2.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;'));
  3614. var a = BringDown;
  3615. if(Gdocument.getElementById("newbonklobby_chat_content").clientHeight + Gdocument.getElementById("newbonklobby_chat_content").scrollTop >= Gdocument.getElementById("newbonklobby_chat_content").scrollHeight-1) {
  3616. a = true;
  3617. }
  3618. var b = BringDown;
  3619. if(Gdocument.getElementById("ingamechatcontent").clientHeight + Gdocument.getElementById("ingamechatcontent").scrollTop >= Gdocument.getElementById("ingamechatcontent").scrollHeight-1) {
  3620. b = true;
  3621. }
  3622. A.style["parsed"] = true;
  3623. C.style["parsed"] = true;
  3624. Gdocument.getElementById("newbonklobby_chat_content").appendChild(A);
  3625. Gdocument.getElementById("ingamechatcontent").appendChild(C);
  3626. if (a) { Gdocument.getElementById("newbonklobby_chat_content").scrollTop = Gdocument.getElementById("newbonklobby_chat_content").scrollHeight;};
  3627. if (b) { Gdocument.getElementById("ingamechatcontent").scrollTop = Gdocument.getElementById("ingamechatcontent").scrollHeight;};
  3628. if(Gdocument.getElementById("newbonklobby_chat_input").style["pointer-events"]!="auto" && !Gdocument.getElementById("ingamechatinputtext").classList.value.includes("ingamechatinputtextbg")){
  3629. chat2("");
  3630. }
  3631. };
  3632.  
  3633. scope.lobby = function(){
  3634. if (Gdocument.getElementById("newbonklobby").style["display"]=="none"){
  3635.  
  3636. Gdocument.getElementById("newbonklobby_editorbutton").click();
  3637. Gdocument.getElementById("mapeditor_close").click();
  3638. if(Gdocument.getElementById("newbonklobby_playerbox_elementcontainer").children.length+Gdocument.getElementById("newbonklobby_specbox_elementcontainer").children.length-3>0){
  3639. Gdocument.getElementById("newbonklobby").style["z-index"]=1;
  3640. Gdocument.getElementById("maploadwindowcontainer").style["z-index"]=1;
  3641. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=1;
  3642. Gdocument.getElementById("pretty_top").style["z-index"]=3;
  3643. Gdocument.getElementById("settingsContainer").style["z-index"]=3;
  3644. Gdocument.getElementById("leaveconfirmwindow").style["z-index"]=3;
  3645. Gdocument.getElementById("hostleaveconfirmwindow").style["z-index"]=3;
  3646. debuggermenu.style["z-index"] = 2;
  3647. }
  3648. else{
  3649. Gdocument.getElementById("newbonklobby").style["opacity"]=0;
  3650. Gdocument.getElementById("newbonklobby").style["display"]="none";
  3651. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
  3652.  
  3653. }
  3654.  
  3655. }
  3656. else if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  3657. Gdocument.getElementById("newbonklobby").style["opacity"]=0;
  3658. Gdocument.getElementById("newbonklobby").style["display"]="none";
  3659. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
  3660.  
  3661. }
  3662. };
  3663.  
  3664. scope.lastmessage = function(){
  3665. if(Gdocument.getElementById("newbonklobby_chat_content").children.length!=0){
  3666. var lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  3667. var lm2 = "";
  3668. for(var i = 0; i<lm.length;i++){
  3669. lm2+=" "+lm[i].textContent.trim();
  3670. }
  3671. lm2 = lm2.trim();
  3672. if(lm2.startsWith("*")){
  3673. return lm2;
  3674. }
  3675. }
  3676. if(Gdocument.getElementById("ingamechatcontent").children.length!=0){
  3677. var lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  3678. var lm2 = "";
  3679. for(var i = 0; i<lm.length;i++){
  3680. lm2+=" "+lm[i].textContent.trim();
  3681. }
  3682. return lm2.trim();
  3683. }
  3684. return "";
  3685.  
  3686. };
  3687. scope.map = function(e,t=timedelay){
  3688. if(e<0){
  3689. displayInChat("There is no previous map.","#DA0808","#1EBCC1");
  3690. quicki = 0;
  3691. return;
  3692. }
  3693. if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
  3694. displayInChat("Click the maps button.","#DA0808","#1EBCC1");
  3695. return;
  3696. }
  3697.  
  3698. setTimeout(function(){if(!canceled){
  3699. startedinqp = true;
  3700. if(roundsperqp2>=roundsperqp){
  3701. roundsperqp2 = 0;
  3702. }
  3703. Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
  3704. Gdocument.getElementById("newbonklobby_editorbutton").click();
  3705. if(recmodebool && ishost){
  3706. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  3707. if(mode == "" && defaultmode!="d"){
  3708. mode = defaultmode;
  3709. }
  3710. if(mode != ""){
  3711. RECIEVE('42[26,"b","'+mode+'"]');
  3712. }
  3713. }
  3714. var displayblock = Gdocument.getElementById("newbonklobby").style["display"] == "block";
  3715. Gdocument.getElementById("mapeditorcontainer").style["display"] = "none";
  3716. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  3717. if(displayblock){
  3718. Gdocument.getElementById("newbonklobby").style["display"] = "block";
  3719. }
  3720. Gdocument.getElementById("mapeditor_midbox_testbutton").click();}
  3721. canceled = false;
  3722. transitioning = false;
  3723. },t);
  3724.  
  3725. };
  3726.  
  3727. scope.gotonextmap = function(e){
  3728. if(e<0){
  3729. displayInChat("There is no previous map.","#DA0808","#1EBCC1");
  3730. quicki = 0;
  3731. return;
  3732. }
  3733. if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
  3734. displayInChat("Click the maps button.","#DA0808","#1EBCC1");
  3735. return;
  3736. }
  3737. Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
  3738. Gdocument.getElementById("newbonklobby_editorbutton").click();
  3739. if(recmodebool && ishost){
  3740. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  3741. if(mode == "" && defaultmode!="d"){
  3742. mode = defaultmode;
  3743. }
  3744. if(mode != ""){
  3745. RECIEVE('42[26,"b","'+mode+'"]');
  3746. }
  3747. }
  3748. startedinqp = true;
  3749. if(roundsperqp2>=roundsperqp){
  3750. roundsperqp2 = 0;
  3751. }
  3752. var displayblock = Gdocument.getElementById("newbonklobby").style["display"] == "block";
  3753. Gdocument.getElementById("mapeditorcontainer").style["display"] = "none";
  3754. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  3755. if(displayblock){
  3756. Gdocument.getElementById("newbonklobby").style["display"] = "block";
  3757. }
  3758. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  3759. Gdocument.getElementById("newbonklobby").style["visibility"] = "visible";
  3760. };
  3761. scope.commandhandle = function(chat_val){
  3762. if (chat_val.substring(1,6)=="echo " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  3763. if (chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"")==username){
  3764. displayInChat("You cannot echo yourself.","#DA0808","#1EBCC1");
  3765. return "";
  3766. }
  3767. else if (echo_list.indexOf(chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',""))===-1) {
  3768.  
  3769. echo_list.push(chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',""));
  3770. displayInChat(chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"") + " is being echoed.","#DA0808","#1EBCC1");
  3771. return "";
  3772. }
  3773. else{
  3774. displayInChat(chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"") + " is already being echoed.","#DA0808","#1EBCC1");
  3775. return "";
  3776. }
  3777. }
  3778. else if (chat_val.substring(1,8)=="remove " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  3779. if (echo_list.indexOf(chat_val.substring(7).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',""))!==-1){
  3780. echo_list.splice(echo_list.indexOf(chat_val.substring(7).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"")),1);
  3781. displayInChat(chat_val.substring(7).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"")+" is not being echoed.","#DA0808","#1EBCC1");
  3782. return "";
  3783. }
  3784. else{
  3785. displayInChat("You cannot remove someone that you didn't echo.","#DA0808","#1EBCC1");
  3786. return "";
  3787. }
  3788.  
  3789. }
  3790. else if (chat_val.substring(1,10)=="echotext " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  3791. echotext = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  3792. displayInChat("Set echotext as: "+echotext,"#DA0808","#1EBCC1");
  3793. displayInChat("Type '/echotext' to reset echotext.","#DA0808","#1EBCC1");
  3794. return "";
  3795.  
  3796. }
  3797. else if (chat_val.substring(1,9)=="echotext"){
  3798. echotext = "message";
  3799. displayInChat("Reset echotext.","#DA0808","#1EBCC1");
  3800. return "";
  3801.  
  3802. }
  3803. else if (chat_val.substring(1,10)=="clearecho"){
  3804. echo_list = [];
  3805. displayInChat("Cleared the echo list.","#DA0808","#1EBCC1");
  3806. return "";
  3807. }
  3808. else if (chat_val.substring(1,11)=="randomchat"){
  3809. if(randomchat == true){
  3810. displayInChat("Random chat is now off.","#DA0808","#1EBCC1");
  3811. randomchat = false;
  3812. }
  3813. else{
  3814. displayInChat("Random chat is now on.","#DA0808","#1EBCC1");
  3815. randomchat = true;
  3816. }
  3817. return "";
  3818. }
  3819. else if (chat_val.substring(1,12)=="autocorrect"){
  3820. if(autocorrect == true){
  3821. displayInChat("Autocorrect is now off.","#DA0808","#1EBCC1");
  3822. autocorrect = false;
  3823. }
  3824. else{
  3825. displayInChat("Autocorrect is now on.","#DA0808","#1EBCC1");
  3826. autocorrect = true;
  3827. }
  3828. return "";
  3829. }
  3830. else if (chat_val.substring(1,13)=="translateto " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  3831. var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '').toLowerCase();
  3832. var keys = Object.keys(translatingkeys);
  3833. if(keys.includes(text)){
  3834. translating2 = [true,translatingkeys[text]];
  3835. displayInChat("You will now speak the "+text+" language.","#DA0808","#1EBCC1");
  3836. }
  3837. else{
  3838. displayInChat("Invalid language. Here are the current language options:","#DA0808","#1EBCC1");
  3839. for(var i = 0;i<keys.length;i++){
  3840. displayInChat(keys[i],"#DA0808","#1EBCC1");
  3841. }
  3842. }
  3843. return "";
  3844. }
  3845. else if (chat_val.substring(1,12)=="translateto"){
  3846. translating2 = [false,""];
  3847. displayInChat("You will not speak another language anymore.","#DA0808","#1EBCC1");
  3848. return "";
  3849. }
  3850. else if (chat_val.substring(1,11)=="translate " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  3851. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '').toLowerCase();
  3852. var keys = Object.keys(translatingkeys);
  3853. if(keys.includes(text)){
  3854. translating = [true,translatingkeys[text]];
  3855. displayInChat("Translator has been set to the "+text+" language.","#DA0808","#1EBCC1");
  3856. }
  3857. else{
  3858. displayInChat("Invalid language. Here are the current language options:","#DA0808","#1EBCC1");
  3859. for(var i = 0;i<keys.length;i++){
  3860. displayInChat(keys[i],"#DA0808","#1EBCC1");
  3861. }
  3862. }
  3863. return "";
  3864. }
  3865. else if (chat_val.substring(1,10)=="translate"){
  3866. translating = [false,""];
  3867. displayInChat("Translator has been turned off.","#DA0808","#1EBCC1");
  3868. return "";
  3869. }
  3870. else if (chat_val.substring(1,6)=="space"){
  3871. if(space_flag == true){
  3872. displayInChat("Space is now off.","#DA0808","#1EBCC1");
  3873. space_flag = false;
  3874. }
  3875. else{
  3876. displayInChat("Space is now on.","#DA0808","#1EBCC1");
  3877. space_flag = true;
  3878. }
  3879. return "";
  3880. }
  3881. else if (chat_val.substring(1,6)=="rcaps"){
  3882. if(rcaps_flag == true){
  3883. displayInChat("Rcaps is now off.","#DA0808","#1EBCC1");
  3884. rcaps_flag = false;
  3885. }
  3886. else{
  3887. displayInChat("Rcaps is now on.","#DA0808","#1EBCC1");
  3888. rcaps_flag = true;
  3889. }
  3890.  
  3891. return "";
  3892. }
  3893. else if (chat_val.substring(1,7)=="number"){
  3894. if(number_flag == true){
  3895. displayInChat("Number is now off.","#DA0808","#1EBCC1");
  3896. number_flag = false;
  3897. }
  3898. else{
  3899. displayInChat("Number is now on.","#DA0808","#1EBCC1");
  3900. number_flag = true;
  3901. }
  3902.  
  3903. return "";
  3904. }
  3905. else if (chat_val.substring(1,8)=="reverse"){
  3906. if(reverse_flag == true){
  3907. displayInChat("Reverse is now off.","#DA0808","#1EBCC1");
  3908. reverse_flag = false;
  3909. }
  3910. else{
  3911. displayInChat("Reverse is now on.","#DA0808","#1EBCC1");
  3912. reverse_flag = true;
  3913. }
  3914.  
  3915. return "";
  3916. }
  3917. else if (chat_val.substring(1,7)=="speech"){
  3918. if(text2speech == true){
  3919. displayInChat("Text to speech is now off.","#DA0808","#1EBCC1");
  3920. text2speech = false;
  3921. }
  3922. else{
  3923. displayInChat("Text to speech is now on.","#DA0808","#1EBCC1");
  3924. text2speech = true;
  3925. }
  3926.  
  3927. return "";
  3928. }
  3929. else if (chat_val.substring(1,6)=="eval " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  3930. var ev = "";
  3931. try{
  3932. ev = eval(chat_val.substring(6).replace(/^\s+|\s+$/g, ''));
  3933. }
  3934. catch(e){
  3935. displayInChat(e.message,"#DA0808","#1EBCC1");
  3936. }
  3937. try{
  3938. displayInChat(ev.toString(),"#DA0808","#1EBCC1");
  3939. }
  3940. catch{
  3941. }
  3942.  
  3943. return "";
  3944.  
  3945. }
  3946. else if (chat_val.substring(1,10)=="savedroom"){
  3947. if(savedrooms.length == 0){
  3948. displayInChat("You do not have any saved rooms.","#DA0808","#1EBCC1");
  3949. return "";
  3950. }
  3951. else{
  3952. var keys = Object.keys(savedroomsdata);
  3953. for(var i = 0;i<keys.length;i++){
  3954. var code = 'this.parentElement.remove();delete Gwindow.savedroomsdata["'+keys[i]+'"];Gwindow.savedrooms.splice(Gwindow.savedrooms.indexOf('+keys[i]+'),1);';
  3955. 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.");
  3956.  
  3957. Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true;
  3958. Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true;
  3959. Laster_message = lastmessage();
  3960. }
  3961. }
  3962. return "";
  3963. }
  3964. else if (chat_val.substring(1,15)=="clearsavedroom"){
  3965. if(savedrooms.length == 0){
  3966. displayInChat("You do not have any saved rooms.","#DA0808","#1EBCC1");
  3967. return "";
  3968. }
  3969. else{
  3970. var keys = Object.keys(savedroomsdata);
  3971. for(var i = 0;i<keys.length;i++){
  3972. savedrooms.splice(savedrooms.indexOf(parseInt(keys[i])),1);
  3973. delete savedroomsdata[keys[i]];
  3974. }
  3975. }
  3976. return "";
  3977. }
  3978. else if (chat_val.substring(1,10)=="followcam"){
  3979. if(FollowCam == true){
  3980. displayInChat("Follow Camera is now off.","#DA0808","#1EBCC1");
  3981. FollowCam = false;
  3982. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  3983. var addto = {"children":[]};
  3984. for(var i = 0;i<parentDraw.children.length;i++){
  3985. if(parentDraw.children[i].constructor.name == "e"){
  3986. addto = parentDraw.children[i];
  3987. break;
  3988. }
  3989. }
  3990. var canv = 0;
  3991. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  3992. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  3993. canv = Gdocument.getElementById("gamerenderer").children[i];
  3994. break;
  3995. }
  3996. }
  3997. var width = parseInt(canv.style["width"]);
  3998. var height = parseInt(canv.style["height"]);
  3999. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  4000. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  4001. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  4002. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  4003. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999){
  4004. pixiCircle.visible = false;
  4005. }
  4006. else{
  4007. pixiCircle.visible = true;
  4008. }
  4009. }
  4010. }
  4011. else{
  4012. displayInChat("Follow Camera is now on.","#DA0808","#1EBCC1");
  4013. FollowCam = true;
  4014. }
  4015.  
  4016. return "";
  4017. }
  4018. else if (chat_val.substring(1,8)=="autocam"){
  4019. if(autocam == true){
  4020. displayInChat("Auto Cam is now off.","#DA0808","#1EBCC1");
  4021. autocam = false
  4022. }
  4023. else{
  4024. displayInChat("Auto Cam is now on.","#DA0808","#1EBCC1");
  4025. autocam = true;
  4026. }
  4027.  
  4028. return "";
  4029. }
  4030. else if (chat_val.substring(1,7)=="aimbot"){
  4031. if(aimbot == true){
  4032. displayInChat("Aimbot is now off.","#DA0808","#1EBCC1");
  4033. aimbot = false;
  4034. }
  4035. else{
  4036. displayInChat("Aimbot is now on.","#DA0808","#1EBCC1");
  4037. aimbot = true;
  4038. getplayerkeys();
  4039. }
  4040.  
  4041. return "";
  4042. }
  4043. else if (chat_val.substring(1,8)=="volume " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  4044. var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '');
  4045. if(!isNaN(parseInt(text))){
  4046. int_text = parseInt(text);
  4047. if(int_text>=0 && int_text<=100){
  4048. jukeboxplayer.volume = int_text/100;
  4049. jukeboxplayervolume = int_text;
  4050. displayInChat("Jukebox volume set to: "+int_text.toString()+" percent.","#DA0808","#1EBCC1");
  4051. }
  4052. else{
  4053. displayInChat("Volume must be between 0 and 100 percent.","#DA0808","#1EBCC1");
  4054. }
  4055. }
  4056. return "";
  4057. }
  4058. else if (chat_val.substring(1,6)=="still"){
  4059. if(staystill == true){
  4060. displayInChat("Still is now off.","#DA0808","#1EBCC1");
  4061. staystill = false;
  4062. staystillpos = [0,0];
  4063. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  4064. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  4065. }
  4066. else{
  4067. if(playerids[myid].playerData?.transform){
  4068. displayInChat("Still is now on.","#DA0808","#1EBCC1");
  4069. staystill = true;
  4070. staystillpos = [playerids[myid].playerData.transform.position.x/scale,playerids[myid].playerData.transform.position.y/scale];
  4071. getplayerkeys();
  4072. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  4073. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  4074. }
  4075. else{
  4076. displayInChat("You have to be alive to use this command.","#DA0808","#1EBCC1");
  4077. }
  4078. }
  4079.  
  4080. return "";
  4081. }
  4082. else if (chat_val.substring(1,9)=="heavybot"){
  4083. if(heavybot == true){
  4084. displayInChat("Heavy bot is now off.","#DA0808","#1EBCC1");
  4085. heavybot = false;
  4086. }
  4087. else{
  4088. displayInChat("Heavy bot is now on.","#DA0808","#1EBCC1");
  4089. heavybot = true;
  4090. getplayerkeys();
  4091. }
  4092.  
  4093. return "";
  4094. }
  4095. else if (chat_val.substring(1,5)=="xray"){
  4096. Gdocument.getElementById("pretty_top_settings").click();
  4097. Gdocument.getElementById("settings_close").click();
  4098. if(Gdocument.getElementById("settings_graphicsquality").value==1){
  4099. displayInChat("You must have medium or high quality enabled to use this feature.","#DA0808","#1EBCC1");
  4100. return "";
  4101. }
  4102.  
  4103.  
  4104. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  4105. var addto = {"children":[]};
  4106. for(var i = 0;i<parentDraw.children.length;i++){
  4107. if(parentDraw.children[i].constructor.name == "e"){
  4108. addto = parentDraw.children[i];
  4109. break;
  4110. }
  4111. }
  4112. var addto2 = {"children":[]};
  4113. for(var i = 0;i<addto.children.length;i++){
  4114. if(addto.children[i].constructor.name == "e"){
  4115. addto2 = addto.children[i];
  4116. break;
  4117. }
  4118. }
  4119. var checkxray = addto2.children[0];
  4120. var addto3 = addto2.children[0].children;
  4121. if(addto3.length==1){
  4122. checkxray = checkxray.children[0];
  4123. addto3 = addto3[0].children;
  4124. }
  4125. var xrayon = false;
  4126. if(checkxray.xrayon){
  4127. checkxray.xrayon = false;
  4128. xrayon = false;
  4129. }
  4130. else{
  4131. checkxray.xrayon = true;
  4132. xrayon = true;
  4133. }
  4134. if(xrayon){
  4135. displayInChat("Xray is now on.","#DA0808","#1EBCC1");
  4136. for(var i = 0;i<addto3.length;i++){
  4137. if(addto3[i].children.length>0){
  4138. var ids = [];
  4139. var ids2 = [];
  4140. for(var i3 = 0;i3<addto3[i].children.length;i3++){
  4141. addto3[i].children[i3].visible = false;
  4142. if(addto3[i].children[i3].children.length>0){
  4143. for(var i4 = 0;i4<addto3[i].children[i3].children.length;i4++){
  4144. if(addto3[i].children[i3].children[i4].geometry?.id){
  4145. ids.push(addto3[i].children[i3].children[i4].geometry.id);
  4146. }
  4147. else if(addto3[i].children[i3].children[i4].texture?.baseTexture?.uid){
  4148. ids2.push(addto3[i].children[i3].children[i4].texture.baseTexture.uid);
  4149. }
  4150. }
  4151. }
  4152. }
  4153. for(var i3 = 0;i3<addto3[i].children.length;i3++){
  4154. if(addto3[i].children[i3].children.length==0){
  4155. if(addto3[i].children[i3].geometry?.id){
  4156. if(ids.includes(addto3[i].children[i3].geometry.id+1)){
  4157. addto3[i].children[i3].visible = true;
  4158. addto3[i].children[i3].alpha = 0.5;
  4159. }
  4160. }
  4161. else if(addto3[i].children[i3].texture?.baseTexture?.uid){
  4162. if(ids2.includes(addto3[i].children[i3].texture.baseTexture.uid+1)){
  4163. addto3[i].children[i3].visible = true;
  4164. addto3[i].children[i3].alpha = 0.5;
  4165. }
  4166. }
  4167. }
  4168. }
  4169. }
  4170. }
  4171.  
  4172. }
  4173. else{
  4174. displayInChat("Xray is now off.","#DA0808","#1EBCC1");
  4175. for(var i = 0;i<addto3.length;i++){
  4176. for(var i2 = 0;i2<addto3[i].children.length;i2++){
  4177. addto3[i].children[i2].visible = true;
  4178. addto3[i].children[i2].alpha = 1;
  4179. }
  4180. }
  4181. }
  4182. }
  4183.  
  4184. return "";
  4185. }
  4186. else if (chat_val.substring(1,6)=="zoom "){
  4187. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  4188. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  4189. var addto = 0;
  4190. for(var i = 0;i<parentDraw.children.length;i++){
  4191. if(parentDraw.children[i].constructor.name == "e"){
  4192. addto = parentDraw.children[i];
  4193. break;
  4194. }
  4195. }
  4196. var canv = 0;
  4197. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  4198. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  4199. canv = Gdocument.getElementById("gamerenderer").children[i];
  4200. break;
  4201. }
  4202. }
  4203. var width = parseInt(canv.style["width"]);
  4204. var height = parseInt(canv.style["height"]);
  4205. if(addto){
  4206. if(text == "in"){
  4207. zoom *= 1.1;
  4208. }
  4209. else if(text == "out"){
  4210. zoom /= 1.1;
  4211. }
  4212. else if(text == "reset"){
  4213. zoom = 1;
  4214. }
  4215. else{
  4216. displayInChat("Options for zooming:","#DA0808","#1EBCC1");
  4217. displayInChat("in","#DA0808","#1EBCC1");
  4218. displayInChat("out","#DA0808","#1EBCC1");
  4219. displayInChat("reset","#DA0808","#1EBCC1");
  4220. return "";
  4221. }
  4222. addto.scale.x=zoom;
  4223. addto.scale.y=zoom;
  4224. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  4225. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  4226. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  4227. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  4228. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999 && !FollowCam){
  4229. pixiCircle.visible = false;
  4230. }
  4231. else{
  4232. pixiCircle.visible = true;
  4233. }
  4234. }
  4235. }
  4236. return "";
  4237. }
  4238. else if (chat_val.substring(1,9)=="hidechat"){
  4239. Gdocument.getElementById("ingamechatcontent").style["max-height"]="0px";
  4240. return "";
  4241. }
  4242. else if (chat_val.substring(1,9)=="showchat"){
  4243. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  4244. return "";
  4245. }
  4246. else if (chat_val.substring(1,6)=="score"){
  4247. var element = Gdocument.getElementById("ingamewinner_scores");
  4248. if(element.style["opacity"]<1){
  4249. element.style["opacity"] = 1;
  4250. element.style["visibility"] = "visible";
  4251. }
  4252. else{
  4253. element.style["opacity"] = 0;
  4254. element.style["visibility"] = "unset";
  4255. }
  4256. return "";
  4257. }
  4258.  
  4259. else if (chat_val.substring(1,7)=="scroll"){
  4260. if(scroll==false){
  4261. scroll = true;
  4262. Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="scroll";
  4263. Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
  4264. }
  4265. else if(scroll==true){
  4266. scroll = false;
  4267. Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="hidden";
  4268. Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
  4269. }
  4270.  
  4271. return "";
  4272. }
  4273.  
  4274. else if (chat_val.substring(1,7)=="chatw "){
  4275. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  4276.  
  4277. if(username == text){
  4278. displayInChat("You cannot private chat with yourself.","#DA0808","#1EBCC1");
  4279. return "";
  4280. }
  4281. private_chat = text;
  4282.  
  4283. SEND("42"+JSON.stringify([4,{"type":"request public key","from":username,"to":private_chat}]));
  4284. request_public_key_time_stamp = Date.now();
  4285. 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);
  4286. return "";
  4287. }
  4288. else if (chat_val.substring(1,8)=="lagbot " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  4289. var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '');
  4290. if(!isNaN(parseInt(text))){
  4291. int_text = parseInt(text);
  4292. if(int_text == 0){
  4293. causelag = false;
  4294. causelag2 = 0;
  4295. displayInChat("Lagbot is now off.","#DA0808","#1EBCC1");
  4296. displayInChat("To enable lagbot, type '/lagbot [number]' with a number between 1 and 10.","#DA0808","#1EBCC1");
  4297. }
  4298. else if(int_text>0 && int_text<=10){
  4299. causelag = true;
  4300. causelag2 = 45*int_text;
  4301. displayInChat("Lagbot is now on with a lag setting of "+int_text.toString()+" (~"+(45*int_text).toString()+"MS).","#DA0808","#1EBCC1");
  4302. displayInChat("Type '/lagbot 0' to turn off lagbot.","#DA0808","#1EBCC1");
  4303. }
  4304. else{
  4305. displayInChat("To enable lagbot, type '/lagbot [number]' with a number between 1 and 10.","#DA0808","#1EBCC1");
  4306. displayInChat("Type '/lagbot 0' to turn off lagbot.","#DA0808","#1EBCC1");
  4307. }
  4308. }
  4309. return "";
  4310. }
  4311. else if (chat_val.substring(1,8)=="record " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  4312. var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  4313. var keys = Object.keys(playerids);
  4314. var recordingid2 = -1;
  4315. for(var i = 0;i<keys.length;i++){
  4316. if(playerids[keys[i]].userName == text){
  4317. recordingid2 = keys[i];
  4318. }
  4319. }
  4320. if(recordingid2 == -1){
  4321. displayInChat("Player not found. Please type a valid username.","#DA0808","#1EBCC1");
  4322. return "";
  4323. }
  4324. else{
  4325. recording = true;
  4326. recordingid = recordingid2;
  4327. displayInChat(playerids[recordingid].userName+" is now being recorded.","#DA0808","#1EBCC1");
  4328. if(recordingdata.length>0){
  4329. displayInChat("Any unsaved recording data is now cleared.","#DA0808","#1EBCC1");
  4330. }
  4331. recordingdata = [];
  4332. }
  4333. return "";
  4334. }
  4335. else if (chat_val.substring(1,11)=="stoprecord"){
  4336. if(recording){
  4337. displayInChat(playerids[recordingid].userName+" is not being recorded anymore.","#DA0808","#1EBCC1");
  4338. displayInChat("Type '/saverecording [text]' to save this recording.","#DA0808","#1EBCC1");
  4339. recording = false;
  4340. recordingid = -1;
  4341. recordingdata[0][1] = 0;
  4342. }
  4343. else{
  4344. displayInChat("No one is being recorded.","#DA0808","#1EBCC1");
  4345. }
  4346. return "";
  4347. }
  4348. else if (chat_val.substring(1,15)=="saverecording " && chat_val.replace(/^\s+|\s+$/g, '').length>=16){
  4349. var text = chat_val.substring(15).replace(/^\s+|\s+$/g, '');
  4350. if(Object.keys(recorddata).includes(text)){
  4351. displayInChat("This recording already exists. Please use a different name or type '/delrecording "+text+"'.","#DA0808","#1EBCC1");
  4352. }
  4353. else if(recordingdata.length>0){
  4354. recorddata[text] = JSON.parse(JSON.stringify(recordingdata));
  4355. displayInChat("Recording saved as: "+text,"#DA0808","#1EBCC1");
  4356. }
  4357. else{
  4358. displayInChat("There is no recording data to save. Please record data using '/record [username]'","#DA0808","#1EBCC1");
  4359. }
  4360. return "";
  4361. }
  4362. else if (chat_val.substring(1,14)=="delrecording " && chat_val.replace(/^\s+|\s+$/g, '').length>=15){
  4363. var text = chat_val.substring(14).replace(/^\s+|\s+$/g, '');
  4364. if(Object.keys(recorddata).includes(text)){
  4365. displayInChat("Recording deleted.","#DA0808","#1EBCC1");
  4366. delete recorddata[text];
  4367. }
  4368. else{
  4369. displayInChat("This recording does not exist.","#DA0808","#1EBCC1");
  4370. }
  4371. return "";
  4372. }
  4373. else if (chat_val.substring(1,15)=="loadrecording " && chat_val.replace(/^\s+|\s+$/g, '').length>=16){
  4374. var text = chat_val.substring(15).replace(/^\s+|\s+$/g, '');
  4375. if(!Object.keys(recorddata).includes(text)){
  4376. displayInChat("This recording does not exist.","#DA0808","#1EBCC1");
  4377. }
  4378. else{
  4379. if(recordingdata.length>0){
  4380. displayInChat("Any unsaved recording data is now cleared.","#DA0808","#1EBCC1");
  4381. }
  4382. recordingdata = JSON.parse(JSON.stringify(recorddata[text]));
  4383. displayInChat("Recording data is now loaded.","#DA0808","#1EBCC1");
  4384. }
  4385. return "";
  4386. }
  4387. else if (chat_val.substring(1,7)=="replay"){
  4388. if(recording){
  4389. displayInChat(playerids[recordingid].userName+" is not being recorded anymore.","#DA0808","#1EBCC1");
  4390. displayInChat("Type '/saverecording [text]' to save this recording.","#DA0808","#1EBCC1");
  4391. recordingid = -1;
  4392. recording = false;
  4393. recordingdata[0][1] = 0;
  4394. }
  4395. replay();
  4396. return "";
  4397. }
  4398. else if (chat_val.substring(1,5)=="msg " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  4399. if(private_chat_public_key[1][0] != 0 && private_chat_public_key[1][1] != 0 && private_chat_public_key[0] == private_chat){
  4400. var text = chat_val.substring(5).replace(/^\s+|\s+$/g, '');
  4401. var password = [];
  4402. for(var i = 0;i<10;i++){
  4403. password.push(Math.floor(Math.random()*100+50));
  4404. }
  4405. var text2 = [];
  4406. for(var i = 0;i<text.slice(0,400).length ;i++){
  4407. text2.push(password[i%password.length]^text.slice(0,400).charCodeAt(i));
  4408. }
  4409. pmlastmessage = text.slice(0,400);
  4410. 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)}]));
  4411. displayInChat("> "+username+": ","#DA0808","#1EBCC1",{sanitize:false},text,false);
  4412. Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true;
  4413. Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true;
  4414. Laster_message = lastmessage();
  4415.  
  4416. }
  4417. return "";
  4418. }
  4419. else if (chat_val.substring(1,10)=="ignorepm " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  4420. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  4421. if(ignorepmlist.includes(text)){
  4422. var index = ignorepmlist.indexOf(text);
  4423. ignorepmlist.splice(index,1);
  4424. displayInChat("You are not ignoring private messages from "+text+".","#DA0808","#1EBCC1");
  4425.  
  4426. }
  4427. else{
  4428. ignorepmlist.push(text);
  4429. displayInChat("You are now ignoring private messages from "+text+".","#DA0808","#1EBCC1");
  4430. }
  4431. return "";
  4432. }
  4433. else if (chat_val.substring(1,8)=="pmusers"){
  4434. pmusers = [];
  4435. SEND("42"+JSON.stringify([4,{"type":"request private chat users","from":username}]));
  4436. pmuserstimestamp = Date.now();
  4437. setTimeout(function(){if(pmusers.length == 0){displayInChat("You cannot private chat with anyone.","#DA0808","#1EBCC1");
  4438. }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);
  4439. return "";
  4440. }
  4441. else if (chat_val.substring(1,6)=="lobby"){
  4442. lobby();
  4443. return "";
  4444. }
  4445. else if (chat_val.substring(1,7)=="style " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  4446. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '');
  4447. var text2 = text.split(" ");
  4448. var array = [];
  4449. for(var i = 0;i<text2.length;i++){
  4450. var parsed = parseInt(text2[i]);
  4451. if(!isNaN(parsed)){
  4452. array.push(parsed);
  4453. }
  4454. }
  4455. if(array[0]+array[1]+array[2] == 0){
  4456. array = [1,1,1];
  4457. }
  4458. if(array.length == 3){
  4459. SEND("42"+JSON.stringify([4,{"type":"style","from":username,"style":array}]));
  4460. allstyles[username] = array;
  4461. mystyle = [...array];
  4462. displayInChat("Set style to ("+array.toString()+"). Type '/style' to reset style.","#DA0808","#1EBCC1");
  4463. }
  4464. else{
  4465. displayInChat("Please enter a valid RGB color code seperated by space. For example, white = '/style 255 255 255'. Type '/style' to reset style.","#DA0808","#1EBCC1");
  4466. }
  4467. return "";
  4468. }
  4469. else if (chat_val.substring(1,6)=="style"){
  4470. SEND("42"+JSON.stringify([4,{"type":"style","from":username,"style":[0,0,0]}]));
  4471. allstyles[username] = [0,0,0];
  4472. mystyle = [0,0,0];
  4473. displayInChat("Reset style.","#DA0808","#1EBCC1");
  4474. return "";
  4475. }
  4476. else if (chat_val.substring(1,6)=="lobby"){
  4477. lobby();
  4478. return "";
  4479. }
  4480. else if (chat_val.substring(1,9)=="debugger"){
  4481. if(Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"] == "none"){
  4482. debuggeropen = true;
  4483. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="block";
  4484. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="none";
  4485. Gdocument.getElementById("ingamechatinputtext").style["display"] = "none";
  4486. }
  4487. else{
  4488. debuggeropen = false;
  4489. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="none";
  4490. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  4491. Gdocument.getElementById("ingamechatinputtext").style["display"] = "";
  4492. }
  4493. return "";
  4494. }
  4495. else if (chat_val.substring(1,6)=="team " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  4496. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  4497. if(text == "r"){Gdocument.getElementById("newbonklobby_redbutton").click();}
  4498. else if(text == "g"){Gdocument.getElementById("newbonklobby_greenbutton").click();}
  4499. else if(text == "y"){Gdocument.getElementById("newbonklobby_yellowbutton").click();}
  4500. else if(text == "b"){Gdocument.getElementById("newbonklobby_bluebutton").click();}
  4501. else if(text == "s"){Gdocument.getElementById("newbonklobby_specbutton").click();}
  4502. else if(text == "f"){Gdocument.getElementById("newbonklobby_ffabutton").click();}
  4503. return "";
  4504. }
  4505. else if (chat_val.substring(1,7)=="notify"){
  4506. npermissions = 1;
  4507. return "";
  4508. }
  4509. else if (chat_val.substring(1,11)=="stopnotify"){
  4510. npermissions = 0;
  4511. return "";
  4512. }
  4513. else if (chat_val.substring(1,8)=="support"){
  4514. displayInChat("Thanks everyone for helping me make this mod - LEGENDBOSS123","#0000FF","#FFFFFF");
  4515. displayInChat("mastery3","#0000FF","#FFFFFF");
  4516. displayInChat("UnmatchedBracket aka Left Paren","#0000FF","#FFFFFF");
  4517. displayInChat("iNeonz","#0000FF","#FFFFFF");
  4518. return "";
  4519. }
  4520. else if (chat_val.substring(1,9)=="pollstat"){
  4521. if(pollactive[0] || pollactive2[0]){
  4522. var count = [0,0,0,0];
  4523. var keys = Object.keys(playerids);
  4524. for(var i = 0;i<keys.length;i++){
  4525. if(ishost){
  4526. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive[3].length-1){
  4527. count[playerids[keys[i]].vote.poll]++;
  4528. }
  4529. }
  4530. else{
  4531. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive2[2].length-1){
  4532. count[playerids[keys[i]].vote.poll]++;
  4533. }
  4534. }
  4535. }
  4536. for(var i = 0;i<count.length;i++){
  4537. if(count[i]>1){
  4538. displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  4539. }
  4540. if(count[i]==1){
  4541. displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  4542. }
  4543. }
  4544. if(ishost){
  4545. displayInChat("The poll will end in: "+((pollactive[2]-Date.now())/1000).toString()+" seconds.","#DA0808","#1EBCC1");
  4546. }
  4547. displayInChat("The poll is:","#DA0808","#1EBCC1");
  4548. if(ishost){
  4549. for(var i = 0;i<pollactive[3].length;i++){
  4550. displayInChat(letters[i]+") "+pollactive[3][i],"#DA0808","#1EBCC1");
  4551. }
  4552. }
  4553. else{
  4554. for(var i = 0;i<pollactive2[2].length;i++){
  4555. displayInChat(letters[i]+") "+pollactive2[2][i],"#DA0808","#1EBCC1");
  4556. }
  4557. }
  4558. }
  4559. else{
  4560. displayInChat("No poll has been started.","#DA0808","#1EBCC1");
  4561. if(ishost){
  4562. displayInChat("Type '/startpoll [seconds]' to start a poll.","#DA0808","#1EBCC1");
  4563. if(poll.length>0){
  4564. displayInChat("The poll is:","#DA0808","#1EBCC1");
  4565. for(var i = 0;i<poll.length;i++){
  4566. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  4567. }
  4568. }
  4569. }
  4570. }
  4571. return "";
  4572. }
  4573. else if (chat_val.substring(1,5)=="help" || chat_val.substring(1,2)=="?"){
  4574. for(var i = 0;i<help.length;i++){
  4575. if(help[i].startsWith("/")){
  4576. var splitted = help[i].substring(1).split(" ");
  4577. var command = splitted[0];
  4578. var rest = "";
  4579. if(splitted.length>1){
  4580. rest = " "+splitted.slice(1).join(" ");
  4581. }
  4582. displayInChat("/"+'<a onclick = \'Gwindow.displayadvhelp("'+command+'");\' style = "color:green;" href = "javascript:void(0);">'+command+'</a>'+rest,"#DA0808","#1EBCC1",{sanitize:false},"",false);
  4583. }
  4584. else if(help[i].startsWith("Alt ")){
  4585. displayInChat('<a onclick = \'Gwindow.displayadvhelp("'+help[i]+'");\' style = "color:green;" href = "javascript:void(0);">'+help[i]+'</a>',"#DA0808","#1EBCC1",{sanitize:false},"",false);
  4586. }
  4587. else{
  4588. displayInChat(help[i],"#DA0808","#1EBCC1");
  4589. }
  4590.  
  4591. }
  4592. return "";
  4593. }
  4594. else if (chat_val.substring(1,9)=="advhelp " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  4595. var text = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  4596. if(typeof(adv_help[text])!='undefined'){
  4597. displayInChat(adv_help[text],"#DA0808","#1EBCC1");
  4598. }
  4599. return "";
  4600. }
  4601. else if (chat_val.substring(1,6)=="mode " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  4602. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  4603. var mode = "";
  4604. var text2 = text;
  4605. if(text == "arrows"){
  4606. text2 = "Arrows";
  4607. mode = "ar";
  4608. }
  4609. else if(text == "death arrows"){
  4610. mode = "ard";
  4611. text2 = "Death Arrows";
  4612. }
  4613. else if(text == "grapple"){
  4614. mode = "sp";
  4615. text2 = "Grapple";
  4616. }
  4617. else if(text == "classic"){
  4618. mode = "b";
  4619. text2 = "Classic";
  4620. }
  4621. else{
  4622. displayInChat("Mode options:","#DA0808","#1EBCC1");
  4623. displayInChat("classic","#DA0808","#1EBCC1");
  4624. displayInChat("arrows","#DA0808","#1EBCC1");
  4625. displayInChat("death arrows","#DA0808","#1EBCC1");
  4626. displayInChat("grapple","#DA0808","#1EBCC1");
  4627. }
  4628. if(mode != ""){
  4629. if(ishost){
  4630. SEND('42[20,{"ga":"b","mo":"'+mode+'"}]');
  4631. RECIEVE('42[26,"b","'+mode+'"]');
  4632. displayInChat("Changed mode to "+text+".","#DA0808","#1EBCC1");
  4633. }
  4634. else{
  4635. if(playerids[myid].ratelimit.mode+1000<Date.now()){
  4636. playerids[myid].ratelimit.mode=Date.now();
  4637. SEND("42"+JSON.stringify([4,{"type":"request mode","from":username,"mode":mode}]));
  4638. var code = 'if(!Gwindow.ishost){Gwindow.displayInChat("You must be host to change the mode.","#DA0808","#1EBCC1",{sanitize:false},"",true)}else{Gwindow.changemode("'+mode+'")}';
  4639. displayInChat('> '+username+' requests [<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+text2+'</a>]',"#DA0808","#1EBCC1",{sanitize:false}," mode.");
  4640.  
  4641. }
  4642. else{
  4643. displayInChat("You are requesting modes too quickly.","#DA0808","#1EBCC1");
  4644. }
  4645. }
  4646. }
  4647. return "";
  4648.  
  4649. }
  4650. else if(ishost){
  4651. if (chat_val.substring(1,11)=="nextafter " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  4652. var text = parseFloat(chat_val.substring(11).replace(/^\s+|\s+$/g, ''));
  4653. if(isNaN(text)){
  4654. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  4655. return "";
  4656. }
  4657. else if(text<=0){
  4658. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  4659. return "";
  4660. }
  4661. nextafter = text;
  4662. displayInChat("Set next after to: " + text.toString()+" seconds.","#DA0808","#1EBCC1");
  4663. displayInChat("Type '/nextafter' to reset next after.","#DA0808","#1EBCC1");
  4664. return "";
  4665.  
  4666. }
  4667. else if (chat_val.substring(1,10)=="nextafter"){
  4668. nextafter = 0;
  4669. displayInChat("Reset next after.","#DA0808","#1EBCC1");
  4670. return "";
  4671.  
  4672. }
  4673. else if (chat_val.substring(1,5)=="next" && stopquickplay == 0){
  4674. roundsperqp2 = 0;
  4675. if(shuffle){
  4676. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4677. var available = [];
  4678. var availableindexes = [];
  4679. var notempty = false;
  4680. for(var i = 0; i<e.length;i++){
  4681. var a = false;
  4682. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4683. available.push(a);
  4684. if(a){
  4685. availableindexes.push(i);
  4686. notempty = true;
  4687. }
  4688. }
  4689. if(notempty){
  4690.  
  4691. if(availableindexes.length!=1){
  4692. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  4693. }
  4694. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  4695. }
  4696. }
  4697. else{
  4698. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4699. var available = [];
  4700. var availableindexes = [];
  4701. var notempty = false;
  4702. for(var i = 0; i<e.length;i++){
  4703. var a = false;
  4704. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4705. available.push(a);
  4706. if(a){
  4707. availableindexes.push(i);
  4708. notempty = true;
  4709. }
  4710. }
  4711. if(notempty){
  4712. var above = [];
  4713. for(var i = 0;i<availableindexes.length;i++){
  4714. if(availableindexes[i]>quicki && !reverseqp){
  4715. above.push(availableindexes[i]);
  4716. }
  4717. else if(availableindexes[i]<quicki && reverseqp){
  4718. above.push(availableindexes[i])
  4719. }
  4720. }
  4721. if(above.length>0){
  4722. quicki = above[0];
  4723. if(reverseqp){
  4724. quicki = above[above.length-1];
  4725. }
  4726. }
  4727. else{
  4728. quicki = availableindexes[0];
  4729. if(reverseqp){
  4730. quicki = availableindexes[availableindexes.length-1];
  4731. }
  4732. }
  4733. }
  4734. }
  4735. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  4736. displayInChat("Switched to next map.","#DA0808","#1EBCC1");
  4737. return "";
  4738.  
  4739. }
  4740. else if (chat_val.substring(1,9)=="freejoin"){
  4741. if(freejoin == false){
  4742. freejoin = true;
  4743. displayInChat("Freejoin is now on.","#DA0808","#1EBCC1");
  4744.  
  4745. }
  4746. else{
  4747. freejoin = false;
  4748. displayInChat("Freejoin is now off.","#DA0808","#1EBCC1");
  4749. }
  4750.  
  4751. return "";
  4752.  
  4753. }
  4754. else if (chat_val.substring(1,8)=="instaqp"){
  4755. if(instaqp == false){
  4756. instaqp = true;
  4757. displayInChat("Instaqp is now on.","#DA0808","#1EBCC1");
  4758.  
  4759. }
  4760. else{
  4761. instaqp = false;
  4762. displayInChat("Instaqp is now off.","#DA0808","#1EBCC1");
  4763. }
  4764.  
  4765. return "";
  4766.  
  4767. }
  4768.  
  4769. else if (chat_val.substring(1,9)=="previous" && stopquickplay == 0){
  4770. roundsperqp2 = 0;
  4771. if(shuffle){
  4772. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4773. var available = [];
  4774. var availableindexes = [];
  4775. var notempty = false;
  4776. for(var i = 0; i<e.length;i++){
  4777. var a = false;
  4778. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4779. available.push(a);
  4780. if(a){
  4781. availableindexes.push(i);
  4782. notempty = true;
  4783. }
  4784. }
  4785. if(notempty){
  4786.  
  4787. if(availableindexes.length!=1){
  4788. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  4789. }
  4790. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  4791. }
  4792. }
  4793. else{
  4794. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4795. var available = [];
  4796. var availableindexes = [];
  4797. var notempty = false;
  4798. for(var i = 0; i<e.length;i++){
  4799. var a = false;
  4800. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4801. available.push(a);
  4802. if(a){
  4803. availableindexes.push(i);
  4804. notempty = true;
  4805. }
  4806. }
  4807. if(notempty){
  4808. var above = [];
  4809. for(var i = 0;i<availableindexes.length;i++){
  4810. if(availableindexes[i]<quicki && !reverseqp){
  4811. above.push(availableindexes[i]);
  4812. }
  4813. else if(availableindexes[i]>quicki && reverseqp){
  4814. above.push(availableindexes[i])
  4815. }
  4816. }
  4817. if(above.length>0){
  4818. quicki = above[above.length-1];
  4819. if(reverseqp){
  4820. quicki = above[0];
  4821. }
  4822. }
  4823. else{
  4824. quicki = availableindexes[availableindexes.length-1];
  4825. if(reverseqp){
  4826. quicki = availableindexes[0];
  4827. }
  4828. }
  4829. }
  4830. }
  4831. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  4832.  
  4833. displayInChat("Switched to previous map.","#DA0808","#1EBCC1");
  4834. return "";
  4835. }
  4836. else if (chat_val.substring(1,6)=="start" && chat_val.length == 6){
  4837. if(Gdocument.getElementById("mapeditorcontainer").style["display"]!="block"){
  4838. Gdocument.getElementById("newbonklobby_editorbutton").click();
  4839. }
  4840. if(recmodebool && ishost){
  4841. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  4842. if(mode == "" && defaultmode!="d"){
  4843. mode = defaultmode;
  4844. }
  4845. if(mode != ""){
  4846. RECIEVE('42[26,"b","'+mode+'"]');
  4847. }
  4848. }
  4849. Gdocument.getElementById("mapeditor_close").click();
  4850. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  4851. roundsperqp2 = 0;
  4852. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  4853.  
  4854. return "";
  4855. }
  4856.  
  4857. else if (chat_val.substring(1,8)=="startqp" && stopquickplay == 1){
  4858. stopquickplay = 0;
  4859. quicki = 0;
  4860. qppaused = false;
  4861. displayInChat("Enabled quickplay.","#DA0808","#1EBCC1");
  4862. return "";
  4863. }
  4864. else if (chat_val.substring(1,7)=="stopqp" && stopquickplay == 0){
  4865. stopquickplay = 1;
  4866. quicki = 0;
  4867. qppaused = false;
  4868. displayInChat("Disabled quickplay.","#DA0808","#1EBCC1");
  4869. return "";
  4870. }
  4871. else if (chat_val.substring(1,8)=="pauseqp" && stopquickplay == 0){
  4872. if(qppaused == false){
  4873. qppaused = true;
  4874. displayInChat("Paused quickplay.","#DA0808","#1EBCC1");
  4875. }
  4876. else{
  4877. qppaused = false;
  4878. displayInChat("Unpaused quickplay.","#DA0808","#1EBCC1");
  4879. }
  4880. return "";
  4881. }
  4882. else if (chat_val.substring(1,6)=="revqp" && stopquickplay == 0){
  4883. if(reverseqp == false){
  4884. reverseqp = true;
  4885. displayInChat("Reverseqp is now on..","#DA0808","#1EBCC1");
  4886. }
  4887. else{
  4888. reverseqp = false;
  4889. displayInChat("Reverseqp is now off.","#DA0808","#1EBCC1");
  4890. }
  4891. return "";
  4892. }
  4893. else if (chat_val.substring(1,9)=="jukebox " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  4894. var text = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  4895. SEND("42"+JSON.stringify([4,{"type":"video player","from":username,"url":text,"timestamp":Date.now()+2000,"to":[-1]}]));
  4896. displayInChat("Jukebox is loading... Please wait a few seconds.","#DA0808","#1EBCC1");
  4897. changeJukeboxURL(text,Date.now()+2000);
  4898. return "";
  4899. }
  4900. else if (chat_val.substring(1,13)=="pausejukebox"){
  4901. if(jukeboxplayer.src!="" && !jukeboxplayer.paused){
  4902. displayInChat("Jukebox is now paused.","#DA0808","#1EBCC1");
  4903. jukeboxplayer.pause();
  4904. SEND("42"+JSON.stringify([4,{"type":"video player","from":username,"url":"","timestamp":Date.now(),"to":[-1]}]));
  4905. }
  4906. return "";
  4907. }
  4908. else if (chat_val.substring(1,13)=="resetjukebox"){
  4909. if(jukeboxplayer.src!=""){
  4910. jukeboxplayer.currentTime = 0;
  4911. displayInChat("Jukebox has reset.","#DA0808","#1EBCC1");
  4912. changeJukeboxURL(jukeboxplayerURL,Date.now()+2000);
  4913. SEND("42"+JSON.stringify([4,{"type":"video player","from":username,"url":jukeboxplayerURL,"timestamp":Date.now()+2000,"to":[-1]}]));
  4914. }
  4915. return "";
  4916. }
  4917. else if (chat_val.substring(1,12)=="playjukebox"){
  4918. if(jukeboxplayer.src!="" && jukeboxplayer.paused){
  4919. changeJukeboxURL(jukeboxplayerURL,Date.now()-jukeboxplayer.currentTime*1000);
  4920. SEND("42"+JSON.stringify([4,{"type":"video player","from":username,"url":jukeboxplayerURL,"timestamp":Date.now()-jukeboxplayer.currentTime*1000,"to":[-1]}]));
  4921. }
  4922. return "";
  4923. }
  4924. else if (chat_val.substring(1,5)=="ban " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  4925. banned.push(chat_val.substring(5).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',""));
  4926. displayInChat("Banned "+chat_val.substring(5).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"")+".","#DA0808","#1EBCC1");
  4927. return "/kick '" + chat_val.substring(5).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"") + "'";
  4928. }
  4929. else if (chat_val.substring(1,6)=="kill " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  4930. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  4931. var keys = Object.keys(playerids);
  4932. var killid = undefined;
  4933. for(var i = 0; i<keys.length; i++){
  4934. if(playerids[keys[i]].userName == text){
  4935. killid = keys[i];
  4936. }
  4937. }
  4938. if(typeof(killid)!="undefined" && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden" && !killedids.includes(killid)){
  4939. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  4940. killedids.push(killid);
  4941. SEND('42[25,{"a":{"playersLeft":['+killid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  4942. RECIEVE('42[31,{"a":{"playersLeft":['+killid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  4943. }
  4944. return "";
  4945. }
  4946. else if (chat_val.substring(1,10)=="balanceA " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  4947. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  4948. if(!isNaN(parseInt(text))){
  4949. if(parseInt(text)>=-100 && parseInt(text)<=100){
  4950. var keys = Object.keys(playerids);
  4951. for(var i = 0; i<keys.length;i++){
  4952. SEND('42[29,{"sid":'+keys[i]+',"bal":'+text+'}]');
  4953. RECIEVE('42[36,'+keys[i]+','+text+']');
  4954. }
  4955. }
  4956. }
  4957. return "";
  4958.  
  4959. }
  4960. else if (chat_val.substring(1,10)=="resetpoll"){
  4961. poll = [];
  4962. displayInChat("The poll has been reset.","#DA0808","#1EBCC1");
  4963. return "";
  4964. }
  4965. else if (chat_val.substring(1,11)=="addoption " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  4966. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  4967. if(text.length>50){
  4968. displayInChat("Your option is greater than 50 characters.","#DA0808","#1EBCC1");
  4969. return "";
  4970. }
  4971. if(poll.includes(text)){
  4972. displayInChat("This option already exists.","#DA0808","#1EBCC1");
  4973. }
  4974. else if(poll.length>=4){
  4975. displayInChat("Your poll already has the max 4 amounts of options.","#DA0808","#1EBCC1");
  4976. displayInChat("Type '/deloption [letter]' to remove a option.","#DA0808","#1EBCC1");
  4977. displayInChat("The poll is:","#DA0808","#1EBCC1");
  4978. for(var i = 0;i<poll.length;i++){
  4979. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  4980. }
  4981. }
  4982. else{
  4983. poll.push(text);
  4984. displayInChat("The poll is now:","#DA0808","#1EBCC1");
  4985. for(var i = 0;i<poll.length;i++){
  4986. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  4987. }
  4988. }
  4989. return "";
  4990. }
  4991. else if (chat_val.substring(1,11)=="deloption " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  4992. var text = letters.indexOf(chat_val.substring(11).replace(/^\s+|\s+$/g, ''));
  4993. if(text==-1 || text>=poll.length){
  4994. if(poll.length>0){
  4995. displayInChat("Available options are:","#DA0808","#1EBCC1");
  4996. for(var i = 0;i<poll.length;i++){
  4997. displayInChat(letters[i],"#DA0808","#1EBCC1");
  4998. }
  4999. }
  5000. else{
  5001. displayInChat("Your poll is empty.","#DA0808","#1EBCC1");
  5002. displayInChat("Type '/addoption [text]' to add an option.","#DA0808","#1EBCC1");
  5003. }
  5004. }
  5005. else{
  5006. poll.splice(text,1);
  5007. displayInChat("The poll is now:","#DA0808","#1EBCC1");
  5008. for(var i = 0;i<poll.length;i++){
  5009. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  5010. }
  5011. }
  5012. return "";
  5013. }
  5014. else if (chat_val.substring(1,11)=="startpoll " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  5015. var text = parseFloat(chat_val.substring(11).replace(/^\s+|\s+$/g, ''));
  5016. if(isNaN(text)){
  5017. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  5018. return "";
  5019. }
  5020. else if(text<=0){
  5021. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  5022. return "";
  5023. }
  5024. else if(text<10){
  5025. displayInChat("Your poll has to last for at least 10 seconds.","#DA0808","#1EBCC1");
  5026. return "";
  5027. }
  5028. if(pollactive[0]){
  5029. displayInChat("There is already an ongoing poll.","#DA0808","#1EBCC1");
  5030. displayInChat("Type '/endpoll' to end the poll.","#DA0808","#1EBCC1");
  5031. return "";
  5032. }
  5033. if(poll.length<2){
  5034. displayInChat("Your poll needs at least 2 options.","#DA0808","#1EBCC1");
  5035. displayInChat("Type '/addoption' to add to the poll.","#DA0808","#1EBCC1");
  5036. return "";
  5037. }
  5038. var now = Date.now();
  5039. pollactive = [true,now,now+text*1000,[...poll]];
  5040. playerids[myid].ratelimit.poll = now;
  5041. var chatpoll = [...poll];
  5042. chatpoll.push("Cancel vote.");
  5043. pollactive[3].push("Cancel vote.");
  5044. for(var i = 0;i<chatpoll.length;i++){
  5045. chatpoll[i] = letters[i]+") "+chatpoll[i];
  5046. }
  5047. chat(chatpoll.join("     "));
  5048. setTimeout(function(){
  5049. if(pollactive[0]){
  5050. SEND("42"+JSON.stringify([4,{"type":"poll","from":username,"poll":pollactive[3]}]));
  5051. var keys = Object.keys(playerids);
  5052. for(var i = 0;i<keys.length;i++){
  5053. playerids[keys[i]].vote.poll = -1;
  5054. }
  5055. displayInChat("The poll will end in: " + text.toString()+" seconds.","#DA0808","#1EBCC1");
  5056. displayInChat("Type '/endpoll' to end the poll early.","#DA0808","#1EBCC1");
  5057. }
  5058. },200);
  5059. return "";
  5060. }
  5061. else if (chat_val.substring(1,8)=="endpoll"){
  5062. if(pollactive[0]){
  5063. if(playerids[myid].ratelimit.poll+10000>Date.now()){
  5064. displayInChat("Your poll has to be at least 10 seconds.","#DA0808","#1EBCC1");
  5065. displayInChat("There are "+((playerids[myid].ratelimit.poll+10000-Date.now())/1000).toString()+" seconds left until you can end the poll early.","#DA0808","#1EBCC1");
  5066. return "";
  5067. }
  5068. playerids[myid].ratelimit.poll = Date.now();
  5069. SEND("42"+JSON.stringify([4,{"type":"poll end","from":username}]));
  5070. displayInChat("The poll ended.","#DA0808","#1EBCC1");
  5071. var count = [0,0,0,0];
  5072. var keys = Object.keys(playerids);
  5073. for(var i = 0;i<keys.length;i++){
  5074. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive[3].length-1){
  5075. count[playerids[keys[i]].vote.poll]++;
  5076. }
  5077. playerids[keys[i]].vote.poll = -1;
  5078. }
  5079. for(var i = 0;i<count.length;i++){
  5080. if(count[i]>1){
  5081. displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  5082. }
  5083. if(count[i]==1){
  5084. displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  5085. }
  5086. }
  5087. displayInChat("The poll was:","#DA0808","#1EBCC1");
  5088. for(var i = 0;i<pollactive[3].length;i++){
  5089. displayInChat(letters[i]+") "+pollactive[3][i],"#DA0808","#1EBCC1");
  5090. }
  5091. pollactive = [false,0,0,[]];
  5092. }
  5093. else{
  5094. displayInChat("No poll has been started","#DA0808","#1EBCC1");
  5095. displayInChat("Type '/startpoll [seconds]' to start a poll.","#DA0808","#1EBCC1");
  5096. }
  5097. return "";
  5098. }
  5099. else if (chat_val.substring(1,7)=="moveA " && chat_val.replace(/^\s+|\s+$/g, '').length>=8){
  5100. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '');
  5101. var keys = Object.keys(playerids);
  5102. var t = -1;
  5103. if(text == "f"){
  5104. t = 1;
  5105. }
  5106. else if(text == "b"){
  5107. t = 3;
  5108. }
  5109. else if(text == "g"){
  5110. t = 4;
  5111. }
  5112. else if(text == "r"){
  5113. t = 2;
  5114. }
  5115. else if(text == "y"){
  5116. t = 5;
  5117. }
  5118. else if(text == "s"){
  5119. t = 0;
  5120. }
  5121. if(t == -1){
  5122. displayInChat("The format for this command is:","#DA0808","#1EBCC1");
  5123. displayInChat("/moveA [letter]","#DA0808","#1EBCC1");
  5124. displayInChat("For example: '/moveA r' would move everyone to red team.","#DA0808","#1EBCC1");
  5125. return "";
  5126. }
  5127. for(var i = 0;i<keys.length;i++){
  5128. SEND('42[26,{"targetID":'+keys[i].toString()+',"targetTeam":'+t.toString()+'}]');
  5129. if(playerids[keys[i]].peerID!="sandbox"){
  5130. RECIEVE('42[18,'+keys[i].toString()+','+t.toString()+']');
  5131. }
  5132. }
  5133. return "";
  5134. }
  5135. else if (chat_val.substring(1,7)=="moveT " && chat_val.replace(/^\s+|\s+$/g, '').length>=8){
  5136. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '').split(" ").filter(function(i){if(i==""){return false}else{return true}});
  5137. if(text.length == 2){
  5138. var firstteam = -1;
  5139. var secondteam = -1;
  5140. for(var i = 0;i<2;i++){
  5141. var t = -1;
  5142. if(text[i] == "f"){
  5143. t = 1;
  5144. }
  5145. else if(text[i] == "b"){
  5146. t = 3;
  5147. }
  5148. else if(text[i] == "g"){
  5149. t = 4;
  5150. }
  5151. else if(text[i] == "r"){
  5152. t = 2;
  5153. }
  5154. else if(text[i] == "y"){
  5155. t = 5;
  5156. }
  5157. else if(text[i] == "s"){
  5158. t = 0;
  5159. }
  5160. if(t==-1){
  5161. displayInChat("The format for this command is:","#DA0808","#1EBCC1");
  5162. displayInChat("/moveT [letter] [letter]","#DA0808","#1EBCC1");
  5163. displayInChat("For example: '/moveT s r' would move everyone in spectate to red team.","#DA0808","#1EBCC1");
  5164. return "";
  5165. }
  5166. else{
  5167. if(i == 0){
  5168. firstteam = t;
  5169. }
  5170. else{
  5171. secondteam = t;
  5172. }
  5173. }
  5174. }
  5175. var keys = Object.keys(playerids);
  5176. for(var i = 0;i<keys.length;i++){
  5177. if(playerids[keys[i]].team == firstteam){
  5178. SEND('42[26,{"targetID":'+keys[i].toString()+',"targetTeam":'+secondteam.toString()+'}]');
  5179. if(playerids[keys[i]].peerID!="sandbox"){
  5180. RECIEVE('42[18,'+keys[i].toString()+','+secondteam.toString()+']');
  5181. }
  5182. }
  5183. }
  5184. }
  5185. else{
  5186. displayInChat("The format for this command is:","#DA0808","#1EBCC1");
  5187. displayInChat("/moveT [team] [team]","#DA0808","#1EBCC1");
  5188. displayInChat("For example: '/moveT s r' would move everyone in spectate to red team.","#DA0808","#1EBCC1");
  5189. return "";
  5190. }
  5191. return "";
  5192. }
  5193. if (chat_val.substring(1,13)=="roundsperqp " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  5194. var text = parseInt(chat_val.substring(13).replace(/^\s+|\s+$/g, ''));
  5195. if(isNaN(text)){
  5196. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  5197. return "";
  5198. }
  5199. else if(text<=0){
  5200. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  5201. return "";
  5202. }
  5203. roundsperqp = text;
  5204. roundsperqp2 = 0;
  5205. displayInChat("Set rounds per quickplay to: " + text.toString(),"#DA0808","#1EBCC1");
  5206. displayInChat("Type '/roundsperqp' to reset rounds per quickplay.","#DA0808","#1EBCC1");
  5207. return "";
  5208.  
  5209. }
  5210. else if (chat_val.substring(1,12)=="roundsperqp"){
  5211. roundsperqp = 1;
  5212. roundsperqp2 = 0;
  5213. displayInChat("Reset rounds per quickplay.","#DA0808","#1EBCC1");
  5214. return "";
  5215.  
  5216. }
  5217. else if (chat_val.substring(1,8)=="rounds " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  5218. var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '');
  5219. if(!isNaN(parseInt(text))){
  5220. text = parseInt(text).toString();
  5221. SEND('42[21,{"w":'+text+'}]');
  5222. RECIEVE('42[27,'+text+']');
  5223. }
  5224. return "";
  5225.  
  5226. }
  5227. else if (chat_val.substring(1,13)=="disablekeys " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  5228. var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '');
  5229. var keys = text.split(" ");
  5230. var disabledkeys2 = [];
  5231. var possiblekeys = ["left","right","up","down","heavy","special"];
  5232. for(var i = 0; i<keys.length; i++){
  5233. if(keys[i]!="" && !disabledkeys2.includes(keys[i])){
  5234. if(possiblekeys.includes(keys[i])){
  5235. disabledkeys2.push(keys[i]);
  5236. }
  5237. else{
  5238. displayInChat("Key options: " + possiblekeys.join(" ") + ".","#DA0808","#1EBCC1");
  5239. return "";
  5240. }
  5241. }
  5242. }
  5243. disabledkeys = disabledkeys2;
  5244. displayInChat("Set disabled keys to: " + disabledkeys.join(" ") + ".","#DA0808","#1EBCC1");
  5245. displayInChat("Type '/disablekeys' to reset disabled keys.","#DA0808","#1EBCC1");
  5246. return "";
  5247.  
  5248. }
  5249. else if (chat_val.substring(1,12)=="disablekeys"){
  5250. displayInChat("Reset disabled keys.","#DA0808","#1EBCC1");
  5251. disabledkeys = [];
  5252. return "";
  5253.  
  5254. }
  5255. else if (chat_val.substring(1,10)=="jointext " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  5256. jointext = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  5257. displayInChat("Set jointext to: " + jointext,"#DA0808","#1EBCC1");
  5258. displayInChat("Type '/jointext' to reset jointext.","#DA0808","#1EBCC1");
  5259. return "";
  5260.  
  5261. }
  5262. else if (chat_val.substring(1,9)=="jointext"){
  5263. jointext = "";
  5264. displayInChat("Reset jointext.","#DA0808","#1EBCC1");
  5265. return "";
  5266.  
  5267. }
  5268. else if (chat_val.substring(1,10)=="jointeam " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  5269. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  5270. var keys = Object.keys(playerids);
  5271. var t = -1;
  5272. if(text == "f"){
  5273. t = 1;
  5274. displayInChat("Set jointeam to FFA.","#DA0808","#1EBCC1");
  5275. }
  5276. else if(text == "b"){
  5277. t = 3;
  5278. displayInChat("Set jointeam to blue team.","#DA0808","#1EBCC1");
  5279. }
  5280. else if(text == "g"){
  5281. t = 4;
  5282. displayInChat("Set jointeam to green team.","#DA0808","#1EBCC1");
  5283. }
  5284. else if(text == "r"){
  5285. t = 2;
  5286. displayInChat("Set jointeam to red team.","#DA0808","#1EBCC1");
  5287. }
  5288. else if(text == "y"){
  5289. t = 5;
  5290. displayInChat("Set jointeam to yellow team.","#DA0808","#1EBCC1");
  5291. }
  5292. else if(text == "s"){
  5293. t = 0;
  5294. displayInChat("Set jointeam to spectate.","#DA0808","#1EBCC1");
  5295. }
  5296. if(t == -1){
  5297. displayInChat("The format for this command is:","#DA0808","#1EBCC1");
  5298. displayInChat("/jointeam [letter]","#DA0808","#1EBCC1");
  5299. displayInChat("For example: '/jointeam r' would move every joined person to red team.","#DA0808","#1EBCC1");
  5300. return "";
  5301. }
  5302. displayInChat("Type '/jointeam' to reset jointeam.","#DA0808","#1EBCC1");
  5303. jointeam = t;
  5304. return "";
  5305. }
  5306. else if (chat_val.substring(1,9)=="jointeam"){
  5307. jointeam = -1;
  5308. displayInChat("Reset jointeam.","#DA0808","#1EBCC1");
  5309. return "";
  5310.  
  5311. }
  5312. else if (chat_val.substring(1,9)=="wintext " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  5313. wintext = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  5314. displayInChat("Set wintext to: " + wintext,"#DA0808","#1EBCC1");
  5315. displayInChat("Type '/wintext' to reset wintext.","#DA0808","#1EBCC1");
  5316. return "";
  5317.  
  5318. }
  5319. else if (chat_val.substring(1,8)=="wintext"){
  5320. wintext = "";
  5321. displayInChat("Reset wintext.","#DA0808","#1EBCC1");
  5322. return "";
  5323.  
  5324. }
  5325. else if (chat_val.substring(1,11)=="autorecord"){
  5326. if(autorecord){
  5327. autorecord = false;
  5328. displayInChat("Autorecord is now off.","#DA0808","#1EBCC1");
  5329. }
  5330. else{
  5331. autorecord = true;
  5332. displayInChat("Autorecord is now on.","#DA0808","#1EBCC1");
  5333. }
  5334. return "";
  5335.  
  5336. }
  5337. else if (chat_val.substring(1,9)=="afkkill " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  5338. var text = parseFloat(chat_val.substring(9).replace(/^\s+|\s+$/g, ''));
  5339. if(!isNaN(text)){
  5340. if(text>0){
  5341. displayInChat("Set afk kill to: " + text.toString()+" seconds.","#DA0808","#1EBCC1");
  5342. displayInChat("Type '/afkkill' to reset afk kill.","#DA0808","#1EBCC1");
  5343. var keys = Object.keys(playerids);
  5344. var now = Date.now();
  5345. for(var i = 0;i<keys.length;i++){
  5346. playerids[keys[i]].lastmove = now;
  5347. }
  5348. afkkill = text;
  5349. }
  5350. else{
  5351. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  5352. }
  5353. }
  5354. else{
  5355. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  5356. }
  5357. return "";
  5358.  
  5359. }
  5360. else if (chat_val.substring(1,9)=="afkkill"){
  5361. afkkill = -1;
  5362. displayInChat("Reset afk kill.","#DA0808","#1EBCC1");
  5363. return "";
  5364.  
  5365. }
  5366. else if (chat_val.substring(1,13)=="defaultmode " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  5367. var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '');
  5368. if(text == "default"){
  5369. defaultmode = "";
  5370. displayInChat("Changed default mode to default.","#DA0808","#1EBCC1");
  5371. }
  5372. else if(text == "arrows"){
  5373. defaultmode = "ar";
  5374. displayInChat("Changed default mode to arrows.","#DA0808","#1EBCC1");
  5375. }
  5376. else if(text == "death arrows"){
  5377. defaultmode = "ard";
  5378. displayInChat("Changed default mode to death arrows.","#DA0808","#1EBCC1");
  5379. }
  5380. else if(text == "grapple"){
  5381. defaultmode = "sp";
  5382. displayInChat("Changed default mode to grapple.","#DA0808","#1EBCC1");
  5383. }
  5384. else if(text == "classic"){
  5385. defaultmode = "b";
  5386. displayInChat("Changed default mode to classic.","#DA0808","#1EBCC1");
  5387.  
  5388. }
  5389. else{
  5390. displayInChat("Default mode options:","#DA0808","#1EBCC1");
  5391. displayInChat("default","#DA0808","#1EBCC1");
  5392. displayInChat("classic","#DA0808","#1EBCC1");
  5393. displayInChat("arrows","#DA0808","#1EBCC1");
  5394. displayInChat("death arrows","#DA0808","#1EBCC1");
  5395. displayInChat("grapple","#DA0808","#1EBCC1");
  5396. }
  5397. return "";
  5398.  
  5399. }
  5400. else if (chat_val.substring(1,8)=="recmode"){
  5401. if(recmodebool == true){
  5402. recmodebool = false;
  5403. displayInChat("Recmode is now off.","#DA0808","#1EBCC1");
  5404.  
  5405. }
  5406. else{
  5407. recmodebool = true;
  5408. displayInChat("Recmode is now on.","#DA0808","#1EBCC1");
  5409.  
  5410. }
  5411.  
  5412. return "";
  5413.  
  5414. }
  5415. else if (chat_val.substring(1,8)=="recteam"){
  5416. if(recteams == true){
  5417. recteams = false;
  5418. displayInChat("Recteam is now off.","#DA0808","#1EBCC1");
  5419.  
  5420. }
  5421. else{
  5422. recteams = true;
  5423. displayInChat("Recteam is now on.","#DA0808","#1EBCC1");
  5424.  
  5425. }
  5426. return "";
  5427. }
  5428. else if (chat_val.substring(1,8)=="shuffle"){
  5429. if(shuffle == true){
  5430. shuffle = false;
  5431. displayInChat("Shuffle is now off.","#DA0808","#1EBCC1");
  5432.  
  5433. }
  5434. else{
  5435. shuffle = true;
  5436. displayInChat("Shuffle is now on.","#DA0808","#1EBCC1");
  5437.  
  5438. }
  5439.  
  5440. return "";
  5441.  
  5442. }
  5443. else if (chat_val.substring(1,9)=="autokick"){
  5444. if(autokickban == 0){
  5445. displayInChat("Autokick is now on.","#DA0808","#1EBCC1");
  5446. autokickban = 1;
  5447. }
  5448. else if(autokickban == 1){
  5449. autokickban = 0;
  5450. displayInChat("Autokick is now off.","#DA0808","#1EBCC1");
  5451. }
  5452. else{
  5453. autokickban = 1;
  5454. displayInChat("Autokick is now on, and Autoban is now off.","#DA0808","#1EBCC1");
  5455. }
  5456.  
  5457. return "";
  5458. }
  5459. else if (chat_val.substring(1,8)=="autoban"){
  5460. if(autokickban == 0){
  5461. displayInChat("Autoban is now on.","#DA0808","#1EBCC1");
  5462. autokickban = 2;
  5463. }
  5464. else if(autokickban == 2){
  5465. autokickban = 0;
  5466. displayInChat("Autoban is now off.","#DA0808","#1EBCC1");
  5467. }
  5468. else{
  5469. autokickban = 2;
  5470. displayInChat("Autoban is now on, and Autokick is now off.","#DA0808","#1EBCC1");
  5471. }
  5472.  
  5473. return "";
  5474. }
  5475. else if (chat_val.substring(1,8)=="sandbox"){
  5476. if(sandboxon == false){
  5477. displayInChat("This room is now a sandbox room.","#DA0808","#1EBCC1");
  5478. sandboxon = true;
  5479. SEND('42[4,{"type":"sandboxon"}]');
  5480. var sandboxkeys = Object.keys(sandboxplayerids);
  5481. var packets = [];
  5482. for(var i = 0;i<sandboxkeys.length;i++){
  5483. var p = playerids[sandboxkeys[i]];
  5484. var packet = '42'+JSON.stringify([4,sandboxkeys[i],p.peerID,p.userName,p.guest,p.level,p.team,p.avatar]);
  5485. packets.push(packet);
  5486. }
  5487. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":packets,to:[-1]}]));
  5488. SEND("42"+JSON.stringify([4,{"type":"sandboxid","from":username,"lastid":sandboxid,to:[-1]}]));
  5489. }
  5490. else{
  5491. displayInChat("You cannot turn a sandbox room back into a normal room.","#DA0808","#1EBCC1");
  5492. }
  5493.  
  5494. return "";
  5495. }
  5496. else if(sandboxon){
  5497. if (chat_val.substring(1,11)=="addplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  5498. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  5499. if(!isNaN(parseInt(text))){
  5500. var text2 = parseInt(text);
  5501. if(text2>0){
  5502. for(var i = 0;i<text2;i++){
  5503. while(playerids[sandboxid]){
  5504. sandboxid+=1;
  5505. }
  5506. var color = Math.floor(Math.random() * 16777215).toString();
  5507. var packet = '42'+JSON.stringify([4,sandboxid,"sandbox",sandboxid.toString(),true,0,0,{"layers":[],"bc":color}]);
  5508. RECIEVE(packet);
  5509. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  5510. sandboxplayerids[sandboxid] = sandboxid.toString();
  5511. sandboxid+=1;
  5512. }
  5513.  
  5514. }
  5515. }
  5516. return "";
  5517.  
  5518. }
  5519. if (chat_val.substring(1,9)=="addname " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  5520. var text = chat_val.substring(9).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  5521. while(playerids[sandboxid]){
  5522. sandboxid+=1;
  5523. }
  5524. var keys = Object.keys(playerids);
  5525. var addon = "";
  5526. var escape = false;
  5527. var keysi = -1;
  5528. while(!escape){
  5529. escape = true;
  5530. for(var i = 0;i<keys.length;i++){
  5531. if(playerids[keys[i]].userName == text+addon){
  5532. addon+="‎";
  5533. var escape = false;
  5534. }
  5535. if(playerids[keys[i]].userName == text){
  5536. keysi = keys[i];
  5537. }
  5538. }
  5539. }
  5540. if(keysi!=-1){
  5541. var packet = '42'+JSON.stringify([4,sandboxid,"sandbox",text+addon,playerids[keysi].guest,playerids[keysi].level,0,playerids[keysi].avatar]);
  5542. RECIEVE(packet);
  5543. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  5544. }
  5545. else{
  5546. var color = Math.floor(Math.random() * 16777215).toString();
  5547. var packet = '42'+JSON.stringify([4,sandboxid,"sandbox",text+addon,true,0,0,{"layers":[],"bc":color}]);
  5548. RECIEVE(packet);
  5549. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  5550. }
  5551. sandboxplayerids[sandboxid] = sandboxid.toString();
  5552. sandboxid+=1;
  5553. return "";
  5554.  
  5555. }
  5556. else if (chat_val.substring(1,11)=="delplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  5557. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  5558. if(!isNaN(parseInt(text))){
  5559. var text2 = parseInt(text);
  5560. if(text2>0){
  5561. if(Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden"){
  5562. var jsonkeys = Object.keys(sandboxplayerids).reverse();
  5563. var packets = [];
  5564. for(var i = 0;i<text2 && i<jsonkeys.length;i++){
  5565. var packet = '42[5,'+jsonkeys[i]+',0]';
  5566. RECIEVE(packet);
  5567. packets.push(packet);
  5568. delete sandboxplayerids[jsonkeys[i]];
  5569. }
  5570. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":packets,to:[-1]}]));
  5571. }
  5572. else{
  5573. displayInChat("Cannot delete players while ingame.","#DA0808","#1EBCC1");
  5574. }
  5575.  
  5576. }
  5577. }
  5578. return "";
  5579. }
  5580. else if (chat_val.substring(1,6)=="copy " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  5581. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  5582. var keys = Object.keys(playerids);
  5583. var keys2 = Object.keys(sandboxplayerids);
  5584. var copiedperson = -1;
  5585. for(var i = 0;i<keys.length;i++){
  5586. if(playerids[keys[i]].userName==text){
  5587. copiedperson = keys[i];
  5588. }
  5589. }
  5590. if(copiedperson==-1){
  5591. displayInChat(playerids[copiedperson].userName + " was not found in this room.","#DA0808","#1EBCC1");
  5592. return "";
  5593. }
  5594. if(keys2.includes(copiedperson.toString())){
  5595. displayInChat("Bots cannot copy a bot.","#DA0808","#1EBCC1");
  5596. return "";
  5597. }
  5598. displayInChat("All bots will now copy "+playerids[copiedperson].userName+".","#DA0808","#1EBCC1");
  5599. displayInChat("To reset copy, type '/copy'.","#DA0808","#1EBCC1");
  5600. sandboxcopyme = copiedperson;
  5601.  
  5602. return "";
  5603. }
  5604. else if (chat_val.substring(1,5)=="copy"){
  5605. sandboxcopyme = -1;
  5606. displayInChat("Copy is now off.","#DA0808","#1EBCC1");
  5607. return "";
  5608. }
  5609. }
  5610. }
  5611. return chat_val;
  5612. };
  5613.  
  5614. scope.flag_manage = function(t){
  5615. var text = t;
  5616. if(autocorrect == true){
  5617. var text2 = text.split(" ");
  5618. for(var i = 0;i<text2.length;i++){
  5619. text2[i] = closestWord(text2[i]);
  5620. }
  5621. text = text2.join(" ");
  5622. }
  5623. if(reverse_flag == true){
  5624. text = text.split("").reverse().join("")
  5625. }
  5626. if(rcaps_flag == true){
  5627. text = text.split('');
  5628. for(var i = 0; i<text.length;i++){
  5629. if(Math.floor(Math.random()*2)){
  5630. text[i] = text[i].toUpperCase();
  5631. }
  5632. else{
  5633. text[i] = text[i].toLowerCase();
  5634. }
  5635. }
  5636. text = text.join('');
  5637. }
  5638. if(space_flag == true){
  5639. text = text.split('').join(' ')
  5640. }
  5641. if(number_flag == true){
  5642. text = text.replace(/[t|T][Oo]+/g,"2");
  5643. text = text.replace(/[f|F][o|O][r|R]/g,"4");
  5644. text = text.replace(/[a|A][t|T][e|E]/g,"8");
  5645. text = text.replace(/[e|E]/g,"3");
  5646. text = text.replace(/[a|A]/g,"4");
  5647. text = text.replace(/[o|O]/g,"0");
  5648. text = text.replace(/[s|S]/g,"5");
  5649. text = text.replace(/[i|I|l|L]/g,"1");
  5650. }
  5651. return text;
  5652. };
  5653. Gdocument.getElementById("newbonklobby_chat_input").onkeydown = function(e){
  5654. if(e.keyCode==13){
  5655.  
  5656. var chat_val = Gdocument.getElementById("newbonklobby_chat_input").value;
  5657.  
  5658. if (chat_val!="" && chat_val[0]=="/"){
  5659.  
  5660. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  5661. chat2(commandhandle(chat_val));
  5662. }
  5663. else{
  5664. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  5665. chat2(flag_manage(chat_val));
  5666. }
  5667.  
  5668. }
  5669. };
  5670. Gdocument.getElementById("ingamechatinputtext").onkeydown = function(e){
  5671. if(e.keyCode==13){
  5672.  
  5673. var chat_val = Gdocument.getElementById("ingamechatinputtext").value;
  5674.  
  5675. if (chat_val!="" && chat_val[0]=="/"){
  5676.  
  5677. Gdocument.getElementById("ingamechatinputtext").value = "";
  5678. chat2(commandhandle(chat_val));
  5679. }
  5680. else{
  5681. Gdocument.getElementById("ingamechatinputtext").value = "";
  5682. chat2(flag_manage(chat_val));
  5683. }
  5684. }
  5685. };
  5686. scope.Last_message = "";
  5687. scope.Laster_message = "";
  5688. scope.new_message = false;
  5689. scope.changed_chat = false;
  5690. scope.injectedBonkCommandsScript = setInterval(timeout123,60);
  5691.  
  5692. scope.hotkeys = function(e){
  5693. var keycode = e.code;
  5694. if(e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  5695. if(keycode == "Period"){
  5696. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]!="0px"){
  5697. chatheight+=5;
  5698. if(chatheight>600){chatheight = 600;}
  5699. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  5700. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  5701. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  5702. }
  5703. e.preventDefault();
  5704. }
  5705. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  5706. if(keycode == "KeyG"){
  5707. var addto = 0;
  5708. for(var i = 0;i<parentDraw.children.length;i++){
  5709. if(parentDraw.children[i].constructor.name == "e"){
  5710. addto = parentDraw.children[i];
  5711. break;
  5712. }
  5713. }
  5714. var canv = 0;
  5715. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  5716. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  5717. canv = Gdocument.getElementById("gamerenderer").children[i];
  5718. break;
  5719. }
  5720. }
  5721. var width = parseInt(canv.style["width"]);
  5722. var height = parseInt(canv.style["height"]);
  5723. if(addto){
  5724. zoom *= 1.1;
  5725. }
  5726. addto.scale.x = zoom;
  5727. addto.scale.y = zoom;
  5728. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  5729. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  5730. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  5731. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  5732. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999 && !FollowCam){
  5733. pixiCircle.visible = false;
  5734. }
  5735. else{
  5736. pixiCircle.visible = true;
  5737. }
  5738. e.preventDefault();
  5739. }
  5740. if(keycode == "KeyH"){
  5741. var addto = 0;
  5742. for(var i = 0;i<parentDraw.children.length;i++){
  5743. if(parentDraw.children[i].constructor.name == "e"){
  5744. addto = parentDraw.children[i];
  5745. break;
  5746. }
  5747. }
  5748. var canv = 0;
  5749. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  5750. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  5751. canv = Gdocument.getElementById("gamerenderer").children[i];
  5752. break;
  5753. }
  5754. }
  5755. var width = parseInt(canv.style["width"]);
  5756. var height = parseInt(canv.style["height"]);
  5757. if(addto){
  5758. zoom = 1;
  5759. }
  5760. addto.scale.x = zoom;
  5761. addto.scale.y = zoom;
  5762. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  5763. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  5764. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  5765. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  5766. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999 && !FollowCam){
  5767. pixiCircle.visible = false;
  5768. }
  5769. else{
  5770. pixiCircle.visible = true;
  5771. }
  5772. e.preventDefault();
  5773. }
  5774. if(keycode == "KeyJ"){
  5775. var addto = 0;
  5776. for(var i = 0;i<parentDraw.children.length;i++){
  5777. if(parentDraw.children[i].constructor.name == "e"){
  5778. addto = parentDraw.children[i];
  5779. break;
  5780. }
  5781. }
  5782. var canv = 0;
  5783. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  5784. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  5785. canv = Gdocument.getElementById("gamerenderer").children[i];
  5786. break;
  5787. }
  5788. }
  5789. var width = parseInt(canv.style["width"]);
  5790. var height = parseInt(canv.style["height"]);
  5791. if(addto){
  5792. zoom /= 1.1;
  5793. }
  5794. addto.scale.x = zoom;
  5795. addto.scale.y = zoom;
  5796. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  5797. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  5798. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  5799. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  5800. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999 && !FollowCam){
  5801. pixiCircle.visible = false;
  5802. }
  5803. else{
  5804. pixiCircle.visible = true;
  5805. }
  5806. e.preventDefault();
  5807. }
  5808. }
  5809. if(keycode == "Comma"){
  5810. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]!="0px"){
  5811. chatheight-=5;
  5812. if(chatheight<100){chatheight = 100;}
  5813. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  5814. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  5815. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  5816. }
  5817. e.preventDefault();
  5818. }
  5819. }
  5820. if(e.repeat){return;}
  5821. if(e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  5822. if(ishost){
  5823. if(keycode == "KeyE"){
  5824. if(Gdocument.getElementById("newbonklobby").style["display"] == "block"){
  5825. Gdocument.getElementById("newbonklobby_editorbutton").click();
  5826. }
  5827. else if(Gdocument.getElementById("mapeditorcontainer").style["display"] == "block"){
  5828. Gdocument.getElementById("mapeditor_close").click();
  5829. }
  5830. e.preventDefault();
  5831.  
  5832. }
  5833. else if(keycode == "KeyT"){
  5834. Gdocument.getElementById("newbonklobby_teamsbutton").click();
  5835. e.preventDefault();
  5836. }
  5837. else if(keycode == "KeyM"){
  5838. Gdocument.getElementById("newbonklobby_modebutton").click();
  5839. e.preventDefault();
  5840. }
  5841. else if(keycode == "KeyK"){
  5842. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  5843. Gdocument.getElementById("pretty_top_exit").click();
  5844. }
  5845. e.preventDefault();
  5846. }
  5847. else if(keycode == "KeyS"){
  5848. if(Gdocument.getElementById("mapeditorcontainer").style["display"]!="block"){
  5849. Gdocument.getElementById("newbonklobby_editorbutton").click();
  5850. }
  5851. if(recmodebool && ishost){
  5852. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  5853. if(mode == "" && defaultmode!="d"){
  5854. mode = defaultmode;
  5855. }
  5856. if(mode != ""){
  5857. RECIEVE('42[26,"b","'+mode+'"]');
  5858. }
  5859. }
  5860. Gdocument.getElementById("mapeditor_close").click();
  5861. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  5862. roundsperqp2 = 0;
  5863. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  5864. e.preventDefault();
  5865. }
  5866. else if(keycode == "KeyD"){
  5867. roundsperqp2 = 0;
  5868. if(stopquickplay == 0){
  5869. if(shuffle){
  5870. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  5871. var available = [];
  5872. var availableindexes = [];
  5873. var notempty = false;
  5874. for(var i = 0; i<e2.length;i++){
  5875. var a = false;
  5876. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  5877. available.push(a);
  5878. if(a){
  5879. availableindexes.push(i);
  5880. notempty = true;
  5881. }
  5882. }
  5883. if(notempty){
  5884.  
  5885. if(availableindexes.length!=1){
  5886. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  5887. }
  5888. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  5889. }
  5890. }
  5891. else{
  5892. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  5893. var available = [];
  5894. var availableindexes = [];
  5895. var notempty = false;
  5896. for(var i = 0; i<e2.length;i++){
  5897. var a = false;
  5898. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  5899. available.push(a);
  5900. if(a){
  5901. availableindexes.push(i);
  5902. notempty = true;
  5903. }
  5904. }
  5905. if(notempty){
  5906. var above = [];
  5907. for(var i = 0;i<availableindexes.length;i++){
  5908. if(availableindexes[i]>quicki && !reverseqp){
  5909. above.push(availableindexes[i]);
  5910. }
  5911. else if(availableindexes[i]<quicki && reverseqp){
  5912. above.push(availableindexes[i])
  5913. }
  5914. }
  5915. if(above.length>0){
  5916. quicki = above[0];
  5917. if(reverseqp){
  5918. quicki = above[above.length-1];
  5919. }
  5920. }
  5921. else{
  5922. quicki = availableindexes[0];
  5923. if(reverseqp){
  5924. quicki = availableindexes[availableindexes.length-1];
  5925. }
  5926. }
  5927. }
  5928. }
  5929. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  5930. }
  5931. e.preventDefault();
  5932. }
  5933. else if(keycode == "KeyA"){
  5934. if(stopquickplay == 0){
  5935. roundsperqp2 = 0;
  5936. if(shuffle){
  5937. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  5938. var available = [];
  5939. var availableindexes = [];
  5940. var notempty = false;
  5941. for(var i = 0; i<e2.length;i++){
  5942. var a = false;
  5943. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  5944. available.push(a);
  5945. if(a){
  5946. availableindexes.push(i);
  5947. notempty = true;
  5948. }
  5949. }
  5950. if(notempty){
  5951.  
  5952. if(availableindexes.length!=1){
  5953. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  5954. }
  5955. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  5956. }
  5957. }
  5958. else{
  5959. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  5960. var available = [];
  5961. var availableindexes = [];
  5962. var notempty = false;
  5963. for(var i = 0; i<e2.length;i++){
  5964. var a = false;
  5965. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  5966. available.push(a);
  5967. if(a){
  5968. availableindexes.push(i);
  5969. notempty = true;
  5970. }
  5971. }
  5972. if(notempty){
  5973. var above = [];
  5974. for(var i = 0;i<availableindexes.length;i++){
  5975. if(availableindexes[i]<quicki && !reverseqp){
  5976. above.push(availableindexes[i]);
  5977. }
  5978. else if(availableindexes[i]>quicki && reverseqp){
  5979. above.push(availableindexes[i])
  5980. }
  5981. }
  5982. if(above.length>0){
  5983. quicki = above[above.length-1];
  5984. if(reverseqp){
  5985. quicki = above[0];
  5986. }
  5987. }
  5988. else{
  5989. quicki = availableindexes[availableindexes.length-1];
  5990. if(reverseqp){
  5991. quicki = availableindexes[0];
  5992. }
  5993. }
  5994. }
  5995. }
  5996. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  5997. }
  5998. e.preventDefault();
  5999. }
  6000. else if(keycode == "KeyQ"){
  6001. if(stopquickplay == 1){
  6002. stopquickplay = 0;
  6003. quicki = 0;
  6004. qppaused = false;
  6005. displayInChat("Enabled quickplay.","#DA0808","#1EBCC1");
  6006. }
  6007. else{
  6008. stopquickplay = 1;
  6009. quicki = 0;
  6010. qppaused = false;
  6011. displayInChat("Disabled quickplay.","#DA0808","#1EBCC1");
  6012. }
  6013. e.preventDefault();
  6014. }
  6015. else if(keycode == "KeyP" && stopquickplay==0){
  6016. if(qppaused == true){
  6017. qppaused = false;
  6018. displayInChat("Unpaused quickplay.","#DA0808","#1EBCC1");
  6019. }
  6020. else{
  6021. qppaused = true;
  6022. displayInChat("Paused quickplay.","#DA0808","#1EBCC1");
  6023. }
  6024. e.preventDefault();
  6025. }
  6026. else if(keycode == "KeyR"){
  6027. if(recmodebool == true){
  6028. recmodebool = false;
  6029. displayInChat("Recmode is now off.","#DA0808","#1EBCC1");
  6030.  
  6031. }
  6032. else{
  6033. recmodebool = true;
  6034. displayInChat("Recmode is now on.","#DA0808","#1EBCC1");
  6035.  
  6036. }
  6037. }
  6038. else if(keycode == "KeyF"){
  6039. if(freejoin == false){
  6040. freejoin = true;
  6041. displayInChat("Freejoin is now on.","#DA0808","#1EBCC1");
  6042.  
  6043. }
  6044. else{
  6045. freejoin = false;
  6046. displayInChat("Freejoin is now off.","#DA0808","#1EBCC1");
  6047. }
  6048. e.preventDefault();
  6049. }
  6050. }
  6051. else{
  6052. if(keycode == "KeyE"){
  6053. e.preventDefault();
  6054. }
  6055. else if(keycode == "KeyT"){
  6056. e.preventDefault();
  6057. }
  6058. else if(keycode == "KeyM"){
  6059. e.preventDefault();
  6060. }
  6061. else if(keycode == "KeyK"){
  6062. e.preventDefault();
  6063. }
  6064. else if(keycode == "KeyS"){
  6065. e.preventDefault();
  6066. }
  6067. else if(keycode == "KeyD"){
  6068. e.preventDefault();
  6069. }
  6070. else if(keycode == "KeyA"){
  6071. e.preventDefault();
  6072. }
  6073. else if(keycode == "KeyQ"){
  6074. e.preventDefault();
  6075. }
  6076. else if(keycode == "KeyP"){
  6077. e.preventDefault();
  6078. }
  6079. else if(keycode == "KeyF"){
  6080. e.preventDefault();
  6081. }
  6082. else if(keycode == "KeyR"){
  6083. e.preventDefault();
  6084. }
  6085.  
  6086. }
  6087. if(keycode == "KeyL"){
  6088. lobby();
  6089. e.preventDefault();
  6090. }
  6091. if(keycode == "KeyC"){
  6092. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  6093. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]=="0px"){
  6094. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  6095. }
  6096. else{
  6097. Gdocument.getElementById("ingamechatcontent").style["max-height"]="0px";
  6098. }
  6099. }
  6100. e.preventDefault();
  6101. }
  6102. if(keycode == "KeyI"){
  6103. if(Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"] == "none"){
  6104. debuggeropen = true;
  6105. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="block";
  6106. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="none";
  6107. Gdocument.getElementById("ingamechatinputtext").style["display"] = "none";
  6108. }
  6109. else{
  6110. debuggeropen = false;
  6111. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="none";
  6112. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  6113. Gdocument.getElementById("ingamechatinputtext").style["display"] = "";
  6114. }
  6115. e.preventDefault();
  6116. }
  6117. if(keycode == "KeyB"){
  6118. var element = Gdocument.getElementById("ingamewinner_scores");
  6119. if(element.style["opacity"]<1){
  6120. element.style["opacity"] = 1;
  6121. element.style["visibility"] = "visible";
  6122. }
  6123. else{
  6124. element.style["opacity"] = 0;
  6125. element.style["visibility"] = "unset";
  6126. }
  6127. e.preventDefault();
  6128. }
  6129. if(keycode == "KeyY"){
  6130. Gdocument.getElementById("pretty_top_settings").click();
  6131. Gdocument.getElementById("settings_close").click();
  6132. if(Gdocument.getElementById("settings_graphicsquality").value==1){
  6133. displayInChat("You must have medium or high quality enabled to use this feature.","#DA0808","#1EBCC1");
  6134. return "";
  6135. }
  6136.  
  6137.  
  6138. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  6139. var addto = {"children":[]};
  6140. for(var i = 0;i<parentDraw.children.length;i++){
  6141. if(parentDraw.children[i].constructor.name == "e"){
  6142. addto = parentDraw.children[i];
  6143. break;
  6144. }
  6145. }
  6146. var addto2 = {"children":[]};
  6147. for(var i = 0;i<addto.children.length;i++){
  6148. if(addto.children[i].constructor.name == "e"){
  6149. addto2 = addto.children[i];
  6150. break;
  6151. }
  6152. }
  6153. var checkxray = addto2.children[0];
  6154. var addto3 = addto2.children[0].children;
  6155. if(addto3.length==1){
  6156. checkxray = checkxray.children[0];
  6157. addto3 = addto3[0].children;
  6158. }
  6159. var xrayon = false;
  6160. if(checkxray.xrayon){
  6161. checkxray.xrayon = false;
  6162. xrayon = false;
  6163. }
  6164. else{
  6165. checkxray.xrayon = true;
  6166. xrayon = true;
  6167. }
  6168. if(xrayon){
  6169. displayInChat("Xray is now on.","#DA0808","#1EBCC1");
  6170. for(var i = 0;i<addto3.length;i++){
  6171. if(addto3[i].children.length>0){
  6172. var ids = [];
  6173. var ids2 = [];
  6174. for(var i3 = 0;i3<addto3[i].children.length;i3++){
  6175. addto3[i].children[i3].visible = false;
  6176. if(addto3[i].children[i3].children.length>0){
  6177. for(var i4 = 0;i4<addto3[i].children[i3].children.length;i4++){
  6178. if(addto3[i].children[i3].children[i4].geometry?.id){
  6179. ids.push(addto3[i].children[i3].children[i4].geometry.id);
  6180. }
  6181. else if(addto3[i].children[i3].children[i4].texture?.baseTexture?.uid){
  6182. ids2.push(addto3[i].children[i3].children[i4].texture.baseTexture.uid);
  6183. }
  6184. }
  6185. }
  6186. }
  6187. for(var i3 = 0;i3<addto3[i].children.length;i3++){
  6188. if(addto3[i].children[i3].children.length==0){
  6189. if(addto3[i].children[i3].geometry?.id){
  6190. if(ids.includes(addto3[i].children[i3].geometry.id+1)){
  6191. addto3[i].children[i3].visible = true;
  6192. addto3[i].children[i3].alpha = 0.5;
  6193. }
  6194. }
  6195. else if(addto3[i].children[i3].texture?.baseTexture?.uid){
  6196. if(ids2.includes(addto3[i].children[i3].texture.baseTexture.uid+1)){
  6197. addto3[i].children[i3].visible = true;
  6198. addto3[i].children[i3].alpha = 0.5;
  6199. }
  6200. }
  6201. }
  6202. }
  6203. }
  6204. }
  6205.  
  6206. }
  6207. else{
  6208. displayInChat("Xray is now off.","#DA0808","#1EBCC1");
  6209. for(var i = 0;i<addto3.length;i++){
  6210. for(var i2 = 0;i2<addto3[i].children.length;i2++){
  6211. addto3[i].children[i2].visible = true;
  6212. addto3[i].children[i2].alpha = 1;
  6213. }
  6214. }
  6215. }
  6216. }
  6217. e.preventDefault();
  6218. }
  6219. if(keycode == "KeyN"){
  6220. if(FollowCam == true){
  6221. displayInChat("Follow Camera is now off.","#DA0808","#1EBCC1");
  6222. FollowCam = false;
  6223. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  6224. var addto = {"children":[]};
  6225. for(var i = 0;i<parentDraw.children.length;i++){
  6226. if(parentDraw.children[i].constructor.name == "e"){
  6227. addto = parentDraw.children[i];
  6228. break;
  6229. }
  6230. }
  6231. var canv = 0;
  6232. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  6233. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  6234. canv = Gdocument.getElementById("gamerenderer").children[i];
  6235. break;
  6236. }
  6237. }
  6238. var width = parseInt(canv.style["width"]);
  6239. var height = parseInt(canv.style["height"]);
  6240. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  6241. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  6242. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  6243. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  6244. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999){
  6245. pixiCircle.visible = false;
  6246. }
  6247. else{
  6248. pixiCircle.visible = true;
  6249. }
  6250. }
  6251. }
  6252. else{
  6253. displayInChat("Follow Camera is now on.","#DA0808","#1EBCC1");
  6254. FollowCam = true;
  6255. }
  6256. e.preventDefault();
  6257. }
  6258. if(keycode == "KeyV"){
  6259. if(autocam == true){
  6260. displayInChat("Auto Cam is now off.","#DA0808","#1EBCC1");
  6261. autocam = false
  6262. }
  6263. else{
  6264. displayInChat("Auto Cam is now on.","#DA0808","#1EBCC1");
  6265. autocam = true;
  6266. }
  6267. e.preventDefault();
  6268. }
  6269. if(keycode == "KeyO"){
  6270. if(heavybot == true){
  6271. displayInChat("Heavy bot is now off.","#DA0808","#1EBCC1");
  6272. heavybot = false;
  6273. }
  6274. else{
  6275. displayInChat("Heavy bot is now on.","#DA0808","#1EBCC1");
  6276. heavybot = true;
  6277. getplayerkeys();
  6278. }
  6279. e.preventDefault();
  6280. }
  6281. if(keycode == "KeyU"){
  6282. if(aimbot == true){
  6283. displayInChat("Aimbot is now off.","#DA0808","#1EBCC1");
  6284. aimbot = false;
  6285. }
  6286. else{
  6287. displayInChat("Aimbot is now on.","#DA0808","#1EBCC1");
  6288. aimbot = true;
  6289. getplayerkeys();
  6290. }
  6291. e.preventDefault();
  6292. }
  6293. if(keycode == "KeyW"){
  6294. if(staystill == true){
  6295. displayInChat("Still is now off.","#DA0808","#1EBCC1");
  6296. staystill = false;
  6297. staystillpos = [0,0];
  6298. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  6299. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  6300. }
  6301. else{
  6302. if(playerids[myid].playerData?.transform){
  6303. displayInChat("Still is now on.","#DA0808","#1EBCC1");
  6304. staystill = true;
  6305. staystillpos = [playerids[myid].playerData.transform.position.x/scale,playerids[myid].playerData.transform.position.y/scale];
  6306. getplayerkeys();
  6307. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  6308. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  6309. }
  6310. else{
  6311. displayInChat("You have to be alive to use this command.","#DA0808","#1EBCC1");
  6312. }
  6313. }
  6314. e.preventDefault();
  6315. }
  6316. }
  6317. if(!e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  6318. if(keycode == "Slash" && !(Gdocument.getElementById("gmeditor")?.style["transform"] == "scale(1)")){
  6319. 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"]==""){
  6320. Gdocument.getElementById("newbonklobby_chat_input").value = "/";
  6321. if(Gdocument.getElementById("newbonklobby_chat_input").style["pointer-events"] == "none"){
  6322. fire("keydown",{keyCode:13});
  6323. }
  6324. else{
  6325. Gdocument.getElementById("newbonklobby_chat_input").focus();
  6326. }
  6327. e.preventDefault();
  6328.  
  6329. }
  6330. else if(Gdocument.getElementById("ingamechatinputtext").style["visibility"]=="visible" && Gdocument.getElementById("ingamechatinputtext").style["display"]=="" && Gdocument.getElementById("mapeditorcontainer").style["display"]!="block" && Gdocument.getElementById("ingamechatinputtext").value == ""){
  6331. Gdocument.getElementById("ingamechatinputtext").value = "/";
  6332. if(!Gdocument.getElementById("ingamechatinputtext").classList.value.includes("ingamechatinputtextbg")){
  6333. fire("keydown",{keyCode:13});
  6334. }
  6335. else{
  6336. Gdocument.getElementById("ingamechatinputtext").focus();
  6337. }
  6338. e.preventDefault();
  6339.  
  6340. }
  6341. }
  6342. }
  6343. };
  6344.  
  6345. Gdocument.onkeydown = hotkeys;
  6346.  
  6347. Gwindow.addEventListener('resize',function(e){
  6348. debuggermenu.style["width"] = Gdocument.getElementById("bonkiocontainer").style["width"];
  6349. debuggermenu.style["height"] = Gdocument.getElementById("bonkiocontainer").style["height"];
  6350. scope.width = parseInt(Gdocument.getElementById("bonkiocontainer").style["width"])-20;
  6351. scope.height = parseInt(Gdocument.getElementById("bonkiocontainer").style["height"])-210;
  6352. logmenu.style["width"] = width.toString()+"px";
  6353. logmenu.style["height"] = height.toString()+"px";
  6354. logmenutopleft.style["width"] = (width/2).toString()+"px";
  6355. logmenutopright.style["width"] = (width/2).toString()+"px";
  6356. logmenutopright.style["left"] = (width/2).toString()+"px";
  6357. debuggerinput.style["width"] = width.toString()+"px";
  6358. debuggerinput.style["top"] = (height+90).toString()+"px";
  6359. debuggersendrecieve.style["top"] = (height+120).toString()+"px";
  6360. debuggerpausebutton.style["top"] = (height+150).toString()+"px";
  6361. debuggereval.style["width"] = (width-150).toString()+"px";
  6362. debuggereval.style["top"] = (height+120).toString()+"px";},true);
  6363.  
  6364.  
  6365. function timeout123() {
  6366. updateWssLog();
  6367. EVENTLOOPFUNCTION();
  6368. var now = Date.now();
  6369. var keys = Object.keys(playerids);
  6370. if(getroomslastcheck+3000<now){
  6371. getroomslastcheck = now;
  6372. if(inroom && savedrooms.length>0){
  6373. Gdocument.getElementById("roomlistrefreshbutton").click();
  6374. }
  6375. }
  6376. var namelist = Gdocument.getElementsByClassName("newbonklobby_playerentry_name");
  6377. for(var i = 0;i<namelist.length;i++){
  6378. var level = 0;
  6379. var levelelement = 0;
  6380. var pingelement = 0;
  6381. var avatarelement = 0;
  6382. var children = namelist[i].parentElement.children;
  6383. for(var i2 = 0;i2<children.length;i2++){
  6384. if(children[i2].className == "newbonklobby_playerentry_level"){
  6385. levelelement = children[i2];
  6386. level = parseInt(children[i2].textContent.slice(6));
  6387. }
  6388. else if(children[i2].className == "newbonklobby_playerentry_pingtext"){
  6389. pingelement = children[i2];
  6390. }
  6391. else if(children[i2].className == "newbonklobby_playerentry_avatar"){
  6392. avatarelement = children[i2];
  6393. }
  6394. }
  6395. var isadmin = [false,0];
  6396. for(var i3 = 0;i3<admins.length;i3++){
  6397. if(admins[i3][0] == namelist[i].textContent){
  6398. isadmin = [true,i3];
  6399. break;
  6400. }
  6401. }
  6402. if(level){
  6403. if(isadmin[0]){
  6404. namelist[i].style["color"] = "rgb("+admins[isadmin[1]][1].slice(0,-1).toString()+")";
  6405. if(isadmin[1]<=2){
  6406. var rotatevalue = 0;
  6407. if(admins[isadmin[1]][1][3]<90){
  6408. rotatevalue = admins[isadmin[1]][1][3]/2;
  6409. }
  6410. else if(admins[isadmin[1]][1][3]<270){
  6411. rotatevalue =(180-admins[isadmin[1]][1][3])/2;
  6412. }
  6413. else if(admins[isadmin[1]][1][3]<360){
  6414. rotatevalue = (-360+admins[isadmin[1]][1][3])/2;
  6415. }
  6416. namelist[i].parentElement.style["filter"] = "hue-rotate("+rotatevalue.toString()+"deg)";
  6417. namelist[i].parentElement.style["font-size"] = "17px";
  6418. 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()+")";
  6419. if(levelelement){
  6420. levelelement.style["color"] = "rgb("+admins[isadmin[1]][1].slice(0,-1).toString()+")";
  6421. }
  6422. if(pingelement){
  6423. pingelement.style["color"] = "rgb("+admins[isadmin[1]][1].slice(0,-1).toString()+")";
  6424. }
  6425. if(avatarelement){
  6426. avatarelement.style["filter"] = "hue-rotate("+rotatevalue.toString()+"deg)";
  6427. }
  6428. }
  6429. }
  6430. }
  6431. var stylekeys = Object.keys(allstyles);
  6432. for(var i3 = 0;i3<stylekeys.length;i3++){
  6433. if(stylekeys[i3] == namelist[i].textContent){
  6434. 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])){
  6435. var rgbvalue = [allstyles[stylekeys[i3]][0],allstyles[stylekeys[i3]][1],allstyles[stylekeys[i3]][2]];
  6436. namelist[i].style["color"] = "rgb("+rgbvalue.toString()+")";
  6437. if(!isadmin[0]){
  6438. var n = 255;
  6439. namelist[i].parentElement.style["background"] = "rgb("+[(203+rgbvalue[0])%n,(212+rgbvalue[1])%n,(215+rgbvalue[2])%n].toString()+")";
  6440. }
  6441. if(levelelement){
  6442. levelelement.style["color"] = "rgb("+rgbvalue.toString()+")";
  6443. }
  6444. if(pingelement){
  6445. pingelement.style["color"] = "rgb("+rgbvalue.toString()+")";
  6446. }
  6447. }
  6448. }
  6449. }
  6450. }
  6451. for(var i3 = 0;i3<admins.length;i3++){
  6452. if(admins[i3][1][0]==0 && admins[i3][1][1]==0 && admins[i3][1][2]==0){
  6453. admins[i3][1][2] = 180;
  6454. admins[i3][1][1] = 0;
  6455. admins[i3][1][0] = 0;
  6456. }
  6457. var rate = 5;
  6458. var lowest = 0;
  6459. var number = 360;
  6460. admins[i3][1][3] = (admins[i3][1][3]%number+4+number)%number;
  6461. if(admins[i3][1][0]>lowest && admins[i3][1][1] == lowest){
  6462. admins[i3][1][0]-=rate;
  6463. admins[i3][1][2]+=rate;
  6464. }
  6465. if(admins[i3][1][2]>lowest && admins[i3][1][0] == lowest){
  6466. admins[i3][1][2]-=rate;
  6467. admins[i3][1][1]+=rate;
  6468. }
  6469. if(admins[i3][1][1]>lowest && admins[i3][1][2] == lowest){
  6470. admins[i3][1][0]+=rate;
  6471. admins[i3][1][1]-=rate;
  6472. }
  6473. for(var i4 = 0;i4<3;i4++){
  6474. if(admins[i3][1][i4]<lowest){
  6475. admins[i3][1][i4]=lowest;
  6476. }
  6477. else if(admins[i3][1][i4]>255){
  6478. admins[i3][1][i4]=255;
  6479. }
  6480. }
  6481. }
  6482. if(randomchat){
  6483. if(randomchat_timestamp+randomchat_randomtimestamp<now){
  6484. randomchat_timestamp = now;
  6485. randomchat_randomtimestamp = 2000+Math.random()*2000;
  6486. var randnumber = Math.floor(Math.random()*randomchatpriority[0])-randomchatlastmessage[1];
  6487. for(var i = 0;i<randomchatpriority[1].length;i++){
  6488. if(randomchatpriority[1][i][0]!=randomchatlastmessage[0] && randomchatpriority[1][i][1]!=randomchatlastmessage[1]){
  6489. randnumber-=randomchatpriority[1][i][1];
  6490. if(randnumber<=0){
  6491. chat(flag_manage(randomchatpriority[1][i][0]));
  6492. randomchatpriority[1][i][1]+=2;
  6493. randomchatpriority[0]+=2;
  6494. randomchatlastmessage = randomchatpriority[1][i];
  6495. break;
  6496. }
  6497. }
  6498. }
  6499. }
  6500. }
  6501. for(var i = 0;i<keys.length;i++){
  6502. 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){
  6503. SEND('42[9,{"banshortid":'+keys[i].toString()+',"kickonly":'+(autokickban == 1).toString()+'}]');
  6504. autokickbantimestamp = now;
  6505. }
  6506. if(playerids[keys[i]].playerData){
  6507. if(playerids[keys[i]].playerData2){
  6508. if(playerids[keys[i]].playerData.transform){
  6509. playerids[keys[i]].playerData2.alive = true;
  6510. if(playerids[keys[i]].playerData2.timeStamp == 0){
  6511. playerids[keys[i]].playerData2.px = playerids[keys[i]].playerData.transform.position.x;
  6512. playerids[keys[i]].playerData2.py = playerids[keys[i]].playerData.transform.position.y;
  6513. playerids[keys[i]].playerData2.timeStamp = now;
  6514. }
  6515. else{
  6516. playerids[keys[i]].playerData2.xvel = (playerids[keys[i]].playerData2.px - playerids[keys[i]].playerData.transform.position.x)/(playerids[keys[i]].playerData2.timeStamp-now);
  6517. playerids[keys[i]].playerData2.yvel = (playerids[keys[i]].playerData2.py - playerids[keys[i]].playerData.transform.position.y)/(playerids[keys[i]].playerData2.timeStamp-now);
  6518. playerids[keys[i]].playerData2.px = playerids[keys[i]].playerData.transform.position.x;
  6519. playerids[keys[i]].playerData2.py = playerids[keys[i]].playerData.transform.position.y;
  6520. playerids[keys[i]].playerData2.timeStamp = now;
  6521. }
  6522. if(playerids[keys[i]].playerData2.timeStamp2 == 0){
  6523. playerids[keys[i]].playerData2.pvx = playerids[keys[i]].playerData2.xvel;
  6524. playerids[keys[i]].playerData2.pvy = playerids[keys[i]].playerData2.yvel;
  6525. playerids[keys[i]].playerData2.timeStamp2 = now;
  6526. }
  6527. else{
  6528. playerids[keys[i]].playerData2.xacc = (playerids[keys[i]].playerData2.pvx - playerids[keys[i]].playerData2.xvel)/((playerids[keys[i]].playerData2.timeStamp2-now));
  6529. playerids[keys[i]].playerData2.yacc = (playerids[keys[i]].playerData2.pvy - playerids[keys[i]].playerData2.yvel)/((playerids[keys[i]].playerData2.timeStamp2-now));
  6530. playerids[keys[i]].playerData2.pvx = playerids[keys[i]].playerData2.xvel;
  6531. playerids[keys[i]].playerData2.pvy = playerids[keys[i]].playerData2.yvel;
  6532. playerids[keys[i]].playerData2.timeStamp2 = now;
  6533. }
  6534. }
  6535. else{
  6536. if(playerids[keys[i]].playerData2.alive){
  6537.  
  6538. }
  6539. playerids[keys[i]].playerData2.alive = false;
  6540. }
  6541. }
  6542. else{
  6543. 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};
  6544. }
  6545. }
  6546. }
  6547. for(var i = 0;i<keys.length;i++){
  6548. if(!playerids[keys[i]].playerData2){
  6549. 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};
  6550. }
  6551. }
  6552. if(Gdocument.getElementById("redefineControls_table").children[0].children.length<=1 && keys.length>0){
  6553. Gdocument.getElementById("pretty_top_settings").click();
  6554. Gdocument.getElementById("settings_close").click();
  6555. }
  6556. if(pollactive[0] && pollactive[2]<now && ishost){
  6557. playerids[myid].ratelimit.poll = Date.now();
  6558. SEND("42"+JSON.stringify([4,{"type":"poll end","from":username}]));
  6559. var count = [0,0,0,0];
  6560. var keys = Object.keys(playerids);
  6561. for(var i = 0;i<keys.length;i++){
  6562. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive[3].length-1){
  6563. count[playerids[keys[i]].vote.poll]++;
  6564. }
  6565. playerids[keys[i]].vote.poll = -1;
  6566. }
  6567. displayInChat("The poll ended due to time.","#DA0808","#1EBCC1");
  6568. for(var i = 0;i<count.length;i++){
  6569. if(count[i]>1){
  6570. displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  6571. }
  6572. if(count[i]==1){
  6573. displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  6574. }
  6575. }
  6576. displayInChat("The poll was:","#DA0808","#1EBCC1");
  6577. for(var i = 0;i<pollactive[3].length;i++){
  6578. displayInChat(letters[i]+") "+pollactive[3][i],"#DA0808","#1EBCC1");
  6579. }
  6580. pollactive = [false,0,0,[]];
  6581. }
  6582. if(!ishost && sandboxcopyme!=-1){
  6583. sandboxcopyme = -1;
  6584. }
  6585. if(afkkill>0 && ishost){
  6586. var keys = Object.keys(playerids);
  6587. currentFrame = Math.floor((now - gameStartTimeStamp)/1000*30);
  6588. for(var i = 0; i<keys.length;i++){
  6589. if(typeof(playerids[keys[i]].lastmove)=="undefined"){
  6590. playerids[keys[i]].lastmove = now;
  6591. }
  6592. else{
  6593. if(playerids[keys[i]].playerData2?.alive && now-playerids[keys[i]].lastmove>=afkkill*1000 && now-gameStartTimeStamp>=afkkill*1000 && !killedids.includes(keys[i])){
  6594. killedids.push(keys[i]);
  6595. SEND('42[25,{"a":{"playersLeft":['+keys[i]+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  6596. RECIEVE('42[31,{"a":{"playersLeft":['+keys[i]+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  6597. break;
  6598. }
  6599. }
  6600. }
  6601. }
  6602. if(ishost && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS"){
  6603. clearmaprequests.style["display"] = "block";
  6604. refreshmaprequests.style["display"] = "block";
  6605. }
  6606. else{
  6607. clearmaprequests.style["display"] = "none";
  6608. refreshmaprequests.style["display"] = "none";
  6609. }
  6610. if(Gdocument.getElementById("gamerenderer").style["visibility"]=="hidden"){
  6611. Gdocument.getElementById("ingamewinner_scores").style["visibility"] = "unset";
  6612. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  6613. }
  6614. if(Gdocument.getElementById("maploadwindowmapscontainer").children.length>0 && maponclick == 0){
  6615. maponclick = Gdocument.getElementById("maploadwindowmapscontainer").children[0].onclick;
  6616. }
  6617. 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"] == "")){
  6618. var chatbox = Gdocument.getElementById("newbonklobby_chat_content");
  6619. while (chatbox.firstChild) {
  6620. chatbox.removeChild(chatbox.firstChild);
  6621. }
  6622. chatbox = Gdocument.getElementById("ingamechatcontent");
  6623. while (chatbox.firstChild) {
  6624. chatbox.removeChild(chatbox.firstChild);
  6625. }
  6626. rcaps_flag = false;
  6627. space_flag = false;
  6628. number_flag = false;
  6629. reverse_flag = false;
  6630. autocorrect = false;
  6631. translating2 = [false,""];
  6632. translating = [false,""];
  6633. echo_list = [];
  6634. scroll = false;
  6635. FollowCam = false;
  6636. autocam = false;
  6637. aimbot = false;
  6638. recievedinitdata = false;
  6639. zoom = 1;
  6640. zoom2 = 1;
  6641. newzoom = 1;
  6642. newzoom2 = 1;
  6643. FFA = true;
  6644. mode = "b";
  6645. ghostroomwss = -1;
  6646. heavybot = false;
  6647. stopquickplay = 1;
  6648. roundsperqp = 1;
  6649. roundsperqp2 = 0;
  6650. staystill = false;
  6651. staystillpos = [0,0];
  6652. recording = false;
  6653. recordingid = -1;
  6654. reverseqp = false;
  6655. jointeam = -1;
  6656. currentroomaddress = -1;
  6657. checkboxhidden = false;
  6658. freejoin = false;
  6659. shuffle = false;
  6660. defaultmode = "";
  6661. recmodebool = false;
  6662. recteams = false;
  6663. autorecord = false;
  6664. pollactive = [false,0,0,[]];
  6665. pollactive2 = [false,0,[]];
  6666. afkkill = -1;
  6667. nextafter = 0;
  6668. jointext = "";
  6669. ishost = false;
  6670. parentDraw = 0;
  6671. sandboxplayerids = {};
  6672. sandboxcopyme = -1;
  6673. wintext = "";
  6674. sandboxon = false;
  6675. sandboxid = 200;
  6676. disabledkeys = [];
  6677. myid = -1;
  6678. randomchat = false;
  6679. savedroombutton.className = "brownButton brownButton_classic buttonShadow brownButtonDisabled";
  6680. randomchatpriority = [0,[]];
  6681. randomchatlastmessage = ["",0];
  6682. autokickbantimestamp = 0;
  6683. autokickban = 0;
  6684. inroom = false;
  6685. causelag = false;
  6686. causelag2 = 0;
  6687. jukeboxplayerURL = "";
  6688. jukeboxplayer.src = "";
  6689. jukeboxplayervolume = 20;
  6690. allstyles = {};
  6691. if(!bonkwss){
  6692. playerids = {};
  6693. }
  6694.  
  6695. qppaused = false;
  6696. nextafterbuffer = -1;
  6697. hostid = -1;
  6698. if(chatlog[chatlog.length-1]!="ROOM END"){
  6699. chatlog.push("ROOM END");
  6700. }
  6701. }
  6702. else{
  6703. if(chatlog[chatlog.length-1]=="ROOM END"){
  6704. chatlog.push("ROOM START");
  6705. }
  6706. }
  6707.  
  6708. if(Gdocument.getElementById("newbonklobby").style["display"]=="block"){
  6709. Gdocument.getElementById("ingamechatinputtext").style["visibility"]="hidden";
  6710. }
  6711. else{
  6712. Gdocument.getElementById("ingamechatinputtext").style["visibility"]="visible";
  6713.  
  6714. }
  6715. if(Gdocument.getElementsByClassName('newbonklobby_settings_button brownButton brownButton_classic buttonShadow brownButtonDisabled').length == 0){
  6716. ishost = true;
  6717. }
  6718. else{
  6719. ishost = actuallyhost;
  6720. }
  6721.  
  6722. if(Gdocument.getElementById("pretty_top_name")!=null){
  6723. username = Gdocument.getElementById("pretty_top_name").textContent;
  6724. if(myid!=-1){
  6725. username = playerids[myid].userName;
  6726. }
  6727. }
  6728. try{
  6729. Last_message = lastmessage()
  6730. } catch{
  6731. Last_message = "";
  6732. }
  6733. if (Laster_message != Last_message){
  6734. Laster_message = Last_message;
  6735. if(changed_chat==false){
  6736. new_message = true;
  6737. }
  6738. else{
  6739. changed_chat = false;
  6740. }
  6741. }
  6742. if(new_message){
  6743. chatlog.push(Last_message);
  6744. var lm = "";
  6745. try{
  6746. lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  6747. if(typeof(lm[0].parentElement.style["parsed"]) == 'undefined'){
  6748. if (lm[0].className == "newbonklobby_chat_msg_colorbox"){
  6749. lm[2].innerHTML = urlify(lm[2].innerHTML);
  6750. Laster_message = lastmessage();
  6751. lm[0].parentElement.style["parsed"] = true;
  6752. }
  6753. if (lm[0].className == "newbonklobby_chat_status"){
  6754. lm[0].innerHTML = urlify(lm[0].innerHTML);
  6755. Laster_message = lastmessage();
  6756. lm[0].parentElement.style["parsed"] = true;
  6757. }
  6758. }
  6759. }
  6760. catch{
  6761. lm = "";
  6762. }
  6763.  
  6764. if(Last_message.indexOf("@"+username)!=-1 && npermissions == 1){
  6765. if(Notification.requestPermission()){
  6766. var n = new Notification(Last_message);
  6767. }
  6768. }
  6769.  
  6770. try{
  6771. lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  6772. if(typeof(lm[0].parentElement.style["parsed"])=='undefined'){
  6773. if(lm[0].className == "ingamechatname"){
  6774. lm[1].innerHTML = urlify(lm[1].innerHTML);
  6775. Laster_message = lastmessage();
  6776. lm[0].parentElement.style["parsed"] = true;
  6777. }
  6778. if(lm[0].className == ""){
  6779. lm[0].innerHTML = urlify(lm[0].innerHTML);
  6780. Laster_message = lastmessage();
  6781. lm[0].parentElement.style["parsed"] = true;
  6782. }
  6783. }
  6784. }
  6785. catch{
  6786. lm = "";
  6787. }
  6788. if(text2speech){
  6789. if(!sayer.speaking){
  6790. if(Last_message.includes(": ")){
  6791. speech.text = Last_message.substring(0,Last_message.indexOf(":")).toLowerCase();
  6792. speech.rate = 2.25;
  6793. sayer.speak(speech);
  6794. speech.text = Last_message.substring(Last_message.indexOf(": ")+3).toLowerCase();
  6795. speech.rate = 1.25;
  6796. sayer.speak(speech);
  6797. }
  6798. else{
  6799. speech.text = Last_message.toLowerCase();
  6800. sayer.speak(speech);
  6801. }
  6802. }
  6803. }
  6804. }
  6805. if (ishost==true && new_message){
  6806. for(i=0;i<banned.length;i++){
  6807. if(Last_message.startsWith("* "+banned[i]+" has joined the game")){
  6808. chat2("/kick '"+banned[i]+"'");
  6809. }
  6810. }
  6811. }
  6812. if(Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden" && ishost){
  6813. roundsperqp2 = 0;
  6814. }
  6815. if(Gdocument.getElementById("ingamewinner").style["visibility"]=="inherit" && ishost){
  6816. if(Gdocument.getElementById("ingamewinner").style["parsed"] != true){
  6817. if(stopquickplay!=1){
  6818. roundsperqp2++;
  6819. }
  6820. if(autorecord){
  6821. Gdocument.getElementById("pretty_top_replay").click();
  6822. }
  6823. }
  6824. if(Gdocument.getElementById("ingamewinner").style["parsed"] != true && wintext!="" && Gdocument.getElementById("ingamewinner_bottom").textContent!="DRAW"){
  6825. chat(flag_manage(wintext.replaceAll("username",Gdocument.getElementById("ingamewinner_top").textContent)));
  6826. }
  6827. Gdocument.getElementById("ingamewinner").style["parsed"] = true;
  6828. }
  6829. else{
  6830. Gdocument.getElementById("ingamewinner").style["parsed"] = false;
  6831. }
  6832. if(ishost && stopquickplay == 0){
  6833. if(checkboxhidden){
  6834. checkboxhidden = false;
  6835. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  6836. for(var i = 0; i<classes.length;i++){
  6837. classes[i].style["display"] = "block";
  6838. classes[i].className = "quickplaycheckbox quickplaychecked";
  6839. }
  6840. Gdocument.getElementById('clearallcheckboxes').style["display"] = "block";
  6841.  
  6842. }
  6843. if(nextafter>0 && gameStartTimeStamp+nextafter*1000<=now && Gdocument.getElementById("gamerenderer").style["visibility"] != "hidden" && dontswitch == false && Gdocument.getElementById("ingamewinner").style["visibility"]!="inherit" && !qppaused){
  6844. roundsperqp2 = 0;
  6845. if(shuffle){
  6846. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  6847. var available = [];
  6848. var availableindexes = [];
  6849. var notempty = false;
  6850. for(var i = 0; i<e.length;i++){
  6851. var a = false;
  6852. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  6853. available.push(a);
  6854. if(a){
  6855. availableindexes.push(i);
  6856. notempty = true;
  6857. }
  6858. }
  6859. if(notempty){
  6860. if(availableindexes.length!=1){
  6861. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  6862. }
  6863. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  6864. }
  6865. }
  6866. else{
  6867. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  6868. var available = [];
  6869. var availableindexes = [];
  6870. var notempty = false;
  6871. for(var i = 0; i<e.length;i++){
  6872. var a = false;
  6873. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  6874. available.push(a);
  6875. if(a){
  6876. availableindexes.push(i);
  6877. notempty = true;
  6878. }
  6879. }
  6880. if(notempty){
  6881. var above = [];
  6882. for(var i = 0;i<availableindexes.length;i++){
  6883. if(availableindexes[i]>quicki && !reverseqp){
  6884. above.push(availableindexes[i]);
  6885. }
  6886. else if(availableindexes[i]<quicki && reverseqp){
  6887. above.push(availableindexes[i]);
  6888. }
  6889. }
  6890. if(above.length>0){
  6891. quicki = above[0];
  6892. if(reverseqp){
  6893. above[above.length-1];
  6894. }
  6895. }
  6896. else{
  6897. quicki = availableindexes[0];
  6898. if(reverseqp){
  6899. quicki = availableindexes[availableindexes.length-1];
  6900. }
  6901. }
  6902. }
  6903. }
  6904. startedinqp = true;
  6905. dontswitch = true;
  6906. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  6907. }
  6908. if(Gdocument.getElementById("ingamewinner").style["visibility"]=="inherit" && dontswitch == false && !document.hidden && !qppaused){
  6909. if(roundsperqp2>=roundsperqp){
  6910. if(shuffle){
  6911. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  6912. var available = [];
  6913. var availableindexes = [];
  6914. var notempty = false;
  6915. for(var i = 0; i<e.length;i++){
  6916. var a = false;
  6917. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  6918. available.push(a);
  6919. if(a){
  6920. availableindexes.push(i);
  6921. notempty = true;
  6922. }
  6923. }
  6924. if(notempty){
  6925.  
  6926. if(availableindexes.length!=1){
  6927. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  6928. }
  6929. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  6930. }
  6931. }
  6932. else{
  6933. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  6934. var available = [];
  6935. var availableindexes = [];
  6936. var notempty = false;
  6937. for(var i = 0; i<e.length;i++){
  6938. var a = false;
  6939. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  6940. available.push(a);
  6941. if(a){
  6942. availableindexes.push(i);
  6943. notempty = true;
  6944. }
  6945. }
  6946. if(notempty){
  6947. var above = [];
  6948. for(var i = 0;i<availableindexes.length;i++){
  6949. if(availableindexes[i]>quicki && !reverseqp){
  6950. above.push(availableindexes[i]);
  6951. }
  6952. else if(availableindexes[i]<quicki && reverseqp){
  6953. above.push(availableindexes[i])
  6954. }
  6955. }
  6956. if(above.length>0){
  6957. quicki = above[0];
  6958. if(reverseqp){
  6959. quicki = above[above.length-1];
  6960. }
  6961. }
  6962. else{
  6963. quicki = availableindexes[0];
  6964. if(reverseqp){
  6965. quicki = availableindexes[availableindexes.length-1];
  6966. }
  6967.  
  6968. }
  6969. }
  6970. }
  6971. }
  6972. transitioning = true;
  6973. startedinqp = true;
  6974. map(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  6975. dontswitch = true;
  6976. setTimeout(function(){Gdocument.getElementById("ingamewinner").style["visibility"]="hidden"; dontswitch = false;},timedelay);
  6977. }
  6978. }
  6979. else{
  6980. if(!checkboxhidden){
  6981. checkboxhidden = true;
  6982. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  6983. for(var i = 0; i<classes.length;i++){
  6984. classes[i].style["display"] = "none";
  6985. classes[i].className = "quickplaycheckbox quickplayunchecked";
  6986. }
  6987. Gdocument.getElementById('clearallcheckboxes').style["display"] = "none";
  6988. }
  6989. }
  6990. new_message = false;
  6991. };
  6992. });