Bonk Commands

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

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

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

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址