Bonk Commands

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

当前为 2023-09-02 提交的版本,查看 最新版本

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

QingJ © 2025

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