Bonk Commands

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

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

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

QingJ © 2025

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