Bonk Commands

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

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

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