Bonk Commands

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

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

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