Bonk Commands

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

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

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

QingJ © 2025

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