Bonk Commands

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

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

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