Bonk Commands

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

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

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

QingJ © 2025

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