Bonk Commands

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

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

  1. // ==UserScript==
  2. // @name Bonk Commands
  3. // @namespace https://gf.qytechs.cn/en/scripts/451341-bonk-commands
  4. // @version 17.3
  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. }
  1697. }
  1698. for(var i = 0;i<keys.length;i++){
  1699. var isadmin = [false,0];
  1700. for(var i3 = 0;i3<admins.length;i3++){
  1701. if(admins[i3][0] == playerids[keys[i]].userName && !playerids[keys[i].guest]){
  1702. isadmin = [true,i3];
  1703. break;
  1704. }
  1705. }
  1706. if(playerids[keys[i]].playerData?.children){
  1707. for(var i2 = 0;i2<playerids[keys[i]].playerData.children.length;i2++){
  1708. if(playerids[keys[i]].playerData.children[i2].text){
  1709. if(allstyles[playerids[keys[i]].userName][0]==0 && allstyles[playerids[keys[i]].userName][1]==0 && allstyles[playerids[keys[i]].userName][2]==0){
  1710. playerids[keys[i]].playerData.children[i2].tint = 255*256**3-1;
  1711. }
  1712. else{
  1713. playerids[keys[i]].playerData.children[i2].tint = allstyles[playerids[keys[i]].userName][0]*256**2 + allstyles[playerids[keys[i]].userName][1]*256 + allstyles[playerids[keys[i]].userName][2];
  1714. }
  1715. }
  1716. }
  1717. }
  1718. if(isadmin[0]){
  1719. if(playerids[keys[i]].playerData?.children){
  1720. for(var i2 = 0;i2<playerids[keys[i]].playerData.children.length;i2++){
  1721. if(playerids[keys[i]].playerData.children[i2].text && (allstyles[playerids[keys[i]].userName][0]==0 && allstyles[playerids[keys[i]].userName][1]==0 && allstyles[playerids[keys[i]].userName][2]==0)){
  1722. playerids[keys[i]].playerData.children[i2].tint = (75+Math.abs(180-admins[isadmin[1]][1][0]))*256**2 + (75+Math.abs(180-admins[isadmin[1]][1][1]))*256 + 75+Math.abs(180-admins[isadmin[1]][1][2]);
  1723. }
  1724. if(i2>-1){
  1725. if(!Array.isArray(playerids[keys[i]].playerData.children[i2].filters)){
  1726. playerids[keys[i]].playerData.children[i2].filters = [new Gwindow.PIXI.filters.ColorMatrixFilter()];
  1727. }
  1728. var rotatevalue = 0;
  1729. if(admins[isadmin[1]][1][3]<90){
  1730. rotatevalue = admins[isadmin[1]][1][3]/2;
  1731. }
  1732. else if(admins[isadmin[1]][1][3]<270){
  1733. rotatevalue =(180-admins[isadmin[1]][1][3])/2;
  1734. }
  1735. else if(admins[isadmin[1]][1][3]<360){
  1736. rotatevalue = (-360+admins[isadmin[1]][1][3])/2;
  1737. }
  1738. playerids[keys[i]].playerData.children[i2].filters[0].hue(rotatevalue);
  1739. }
  1740. }
  1741. }
  1742. }
  1743. }
  1744. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  1745. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  1746. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  1747. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  1748. if(canvasWidth!=width){
  1749. canvasWidth = width;
  1750. pixiCircle.clear();
  1751. pixiCircle.x = parseInt(canv.style["width"])/2;
  1752. pixiCircle.y = parseInt(canv.style["height"])/2;
  1753. pixiCircle.lineStyle(3, 0x8B8000);
  1754. pixiCircle.drawRect(-parseInt(canv.style["width"])/2,-parseInt(canv.style["height"])/2,parseInt(canv.style["width"]),parseInt(canv.style["height"]));
  1755. pixiCircle.lineStyle(3, 0xFF0000);
  1756. pixiCircle.arc(0, 0, 850*scale,Math.atan2(250,-100*Math.sqrt(66)),Math.atan2(250,100*Math.sqrt(66)));
  1757. pixiCircle.lineTo(-100*Math.sqrt(66)*scale,250*scale);
  1758. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  1759. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  1760. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  1761. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  1762. }
  1763.  
  1764. if(!addto.children.includes(container)){
  1765. addto.addChild(container);
  1766. }
  1767. if(keys.length>0){
  1768. if(playerids[myid].playerData && playerids[myid].playerData2){
  1769. if(aimbot || heavybot || staystill){
  1770. var targetid = -1;
  1771. var distances = {};
  1772. if(Gdocument.getElementById("ingamecountdown").style["visibility"] == "hidden"){
  1773. if(playerids[myid].playerData.transform){
  1774. var teamok = true;
  1775. if(playerids[myid].team>1){
  1776. teamok = false;
  1777. }
  1778. for(var i = 0;i<keys.length;i++){
  1779. if(playerids[keys[i]].playerData && playerids[keys[i]].playerData2 && keys[i]!=myid){
  1780. if(playerids[keys[i]].playerData.transform && (playerids[keys[i]].team != playerids[myid].team || teamok || FFA)){
  1781. 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);
  1782. }
  1783. }
  1784. }
  1785. }
  1786. }
  1787. var lowestD = [-1,-1];
  1788. var keys2 = Object.keys(distances);
  1789. for(var i = 0;i<keys2.length;i++){
  1790. if(myid != keys2[i]){
  1791. if(lowestD[1] == -1){
  1792. lowestD[1] = distances[keys2[i]];
  1793. lowestD[0] = keys2[i];
  1794. }
  1795. else if(distances[keys2[i]]<lowestD[1]){
  1796. lowestD[1] = distances[keys2[i]];
  1797. lowestD[0] = keys2[i];
  1798. }
  1799. }
  1800. }
  1801. targetid = lowestD[0];
  1802. if(playerids[myid].playerData?.transform && playerids[myid].playerData2){
  1803. if(staystill & staystillpos[0]!=null){
  1804. var playerpos = playerids[myid].playerData.transform.position;
  1805. if(Math.abs(staystillpos[0]-playerpos.x/scale)<3){
  1806. if(playerids[myid].playerData2.xvel/scale>0){
  1807. fire("keydown",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1808. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1809. }
  1810. else if(playerids[myid].playerData2.xvel/scale<0){
  1811. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1812. fire("keydown",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1813. }
  1814. else{
  1815. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1816. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1817. }
  1818. }
  1819. else{
  1820. if(staystillpos[0]>playerpos.x/scale){
  1821. if(playerids[myid].playerData2.xvel/scale>10){
  1822. fire("keydown",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1823. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1824. }
  1825. else{
  1826. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1827. fire("keydown",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1828. }
  1829. }
  1830. else if(staystillpos[0]<playerpos.x/scale){
  1831. if(playerids[myid].playerData2.xvel/scale<-10){
  1832. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1833. fire("keydown",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1834. }
  1835. else{
  1836. fire("keydown",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1837. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1838. }
  1839. }
  1840. }
  1841. }
  1842. }
  1843. if(targetid != -1 && playerids[myid].playerData?.transform){
  1844. if(playerids[myid].playerData.children.length >= 7 && playerids[targetid].playerData && playerids[targetid].playerData.transform && playerids[targetid].playerData2 && aimbot){
  1845. var indexE = -1;
  1846. for(var i = 0;i<playerids[myid].playerData.children.length;i++){
  1847. if(playerids[myid].playerData.children[i].constructor.name == "e"){
  1848. indexE = i;
  1849. break;
  1850. }
  1851. }
  1852. if(indexE != -1 && playerids[myid].playerData.children[indexE].visible){
  1853. if(started == 0){
  1854. started = now;
  1855. }
  1856. var scale2=1/(parseInt(canv.style["width"])/730);
  1857. scale2 /= scale/(1 + playerids[myid].playerData2.balance*0.0088)*(playerids[myid].playerData2.radius/12);
  1858. var Dstarted = (Math.min((now-started)/1000,10/3)/(10/3));
  1859. var v = multiplier * (Dstarted*100+15)*scale2;
  1860. var g = gravity;
  1861. var mypos = playerids[myid].playerData.transform.position;
  1862. var targetpos = playerids[targetid].playerData.transform.position;
  1863. var deltapos = [(targetpos.x-mypos.x)*scale2,(targetpos.y-mypos.y)*scale2];
  1864. var dis = (Math.sqrt(deltapos[0]**2 + deltapos[1]**2))/v*prediction;
  1865. deltapos[0]+=(playerids[targetid].playerData2.xvel*scale2*dis+(playerids[targetid].playerData2.xacc*scale2*(dis))**2/2);
  1866. deltapos[1]+=(playerids[targetid].playerData2.yvel*scale2*dis+(playerids[targetid].playerData2.yacc*scale2*(dis))**2/2);
  1867. deltapos[1] = -deltapos[1];
  1868. var angle = positive(-Math.atan2(deltapos[1],deltapos[0]));
  1869. var rot = playerids[myid].playerData.children[indexE].transform.rotation;
  1870. rot = positive(rot);
  1871. angle = positive(angle);
  1872.  
  1873. var alpha = deltapos[0];
  1874. var beta = deltapos[1];
  1875. var v_squared = v**2;
  1876. var eff = 2*v_squared/g;
  1877. var rootterm = eff*(eff-2*beta)-2*alpha**2;
  1878. if(rootterm < 0) {
  1879. } else {
  1880. gamma_first = (eff + Math.sqrt(rootterm));
  1881. gamma_second = (eff - Math.sqrt(rootterm));
  1882. theta_first = positive(-Math.atan2(gamma_first, alpha));
  1883. theta_second = positive(-Math.atan2(gamma_second, alpha));
  1884. if(angle_between(angle,theta_first)<angle_between(angle,theta_second)){
  1885. angle = theta_first;
  1886. }
  1887. else{
  1888. angle = theta_second;
  1889. }
  1890. }
  1891. var min = angle_between(angle,rot);
  1892. if(angle_between2(angle,rot)<0){
  1893. fire("keydown",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1894. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1895. }
  1896. else{
  1897. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1898. fire("keydown",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1899. }
  1900. if(min<0.05){
  1901. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1902. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1903. }
  1904. }
  1905. else if(started>0){
  1906. started = 0;
  1907. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1908. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1909. }
  1910. }
  1911. }
  1912. if(playerids[myid].playerData?.transform && heavybot && mode!="f" && mode!="bs"){
  1913. var myradius = playerids[myid].playerData2.radius / scale;
  1914. var mypos = playerids[myid].playerData.transform.position;
  1915. var breakout = false;
  1916. for(var i = 0;i<keys2.length;i++){
  1917. var targetradius = playerids[keys2[i]].playerData2.radius / scale;
  1918. var targetpos = playerids[keys2[i]].playerData.transform.position;
  1919. var deltapos = [(targetpos.x-mypos.x)/scale,(targetpos.y-mypos.y)/scale];
  1920. for(var i2 = 0;i2<160;i2++){
  1921. deltapos2 = [...deltapos];
  1922. var i3 = i2*0.5;
  1923. deltapos2[0]+=((playerids[keys2[i]].playerData2.xvel-playerids[myid].playerData2.xvel)/scale*i3);
  1924. deltapos2[1]+=((playerids[keys2[i]].playerData2.yvel-playerids[myid].playerData2.yvel)/scale*i3);
  1925. var dis = Math.sqrt(deltapos2[0]**2+deltapos2[1]**2);
  1926. if(dis<myradius+targetradius){
  1927. breakout = true;
  1928. holdheavy = 20;
  1929. break;
  1930. }
  1931. }
  1932. if(breakout){
  1933. break;
  1934. }
  1935. }
  1936. if(holdheavy>0){
  1937. if(!heavyheld2){
  1938. heavyheld = playerids[myid].playerData.children[heavyid].alpha>0;
  1939. }
  1940. fire("keydown",{"keyCode":heavy},Gdocument.getElementById("gamerenderer"));
  1941. heavyheld2 = true;
  1942. if(mode == "sp"){
  1943. if(!grappleheld2){
  1944. grappleheld = playerids[myid].playerData.children[specialid].vertexData?.length>0;
  1945. }
  1946. if(grappleheld){
  1947. fire("keyup",{"keyCode":special},Gdocument.getElementById("gamerenderer"));
  1948. }
  1949. grappleheld2 = true;
  1950. }
  1951. }
  1952. else if(holdheavy<0){
  1953. holdheavy = 0;
  1954. heavyheld2 = false;
  1955. grappleheld2 = false;
  1956. if(!heavyheld){
  1957. heavyheld = false;
  1958. fire("keyup",{"keyCode":heavy},Gdocument.getElementById("gamerenderer"));
  1959. }
  1960. if(grappleheld && mode == "sp"){
  1961. grappleheld = false;
  1962. fire("keydown",{"keyCode":special},Gdocument.getElementById("gamerenderer"));
  1963. }
  1964. }
  1965. else{
  1966. heavyheld2 = false;
  1967. heavyheld = false;
  1968. grappleheld2 = false;
  1969. grappleheld = false;
  1970. }
  1971. }
  1972.  
  1973. }
  1974. if(FollowCam){
  1975. if(playerids[myid].playerData?.transform){
  1976.  
  1977. pixiCircle.visible = true;
  1978.  
  1979. parentDraw.x = -playerids[myid].playerData.x*addto.scale.x+parseInt(width)/2;
  1980. parentDraw.y = -playerids[myid].playerData.y*addto.scale.y+parseInt(height)/2;
  1981. parentDraw.children[0].x = playerids[myid].playerData.x*addto.scale.x-parseInt(width)/2;
  1982. parentDraw.children[0].y = playerids[myid].playerData.y*addto.scale.y-parseInt(height)/2;
  1983. }
  1984. else{
  1985. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  1986. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  1987. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  1988. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  1989. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999){
  1990. pixiCircle.visible = false;
  1991. }
  1992. else{
  1993. pixiCircle.visible = true;
  1994. }
  1995. }
  1996. }
  1997. }
  1998. }
  1999. if(!FollowCam){
  2000. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999){
  2001. pixiCircle.visible = false;
  2002. }
  2003. else{
  2004. pixiCircle.visible = true;
  2005. }
  2006. }
  2007. }
  2008. return requestAnimationFrameOriginal.call(this,...args);
  2009. };
  2010. scope.SENDFUNCTION = function(args){return args;};
  2011. scope.RECIEVEFUNCTION = function(args){return args;};
  2012. scope.EVENTLOOPFUNCTION = function(){};
  2013.  
  2014. Gwindow.WebSocket.prototype.send = function(args) {
  2015. if(this.url.includes(".bonk.io/socket.io/?EIO=3&transport=websocket&sid=")){
  2016. if(typeof(args) == "string" && !bonkwssextra.includes(this)){
  2017. args = SENDFUNCTION(args);
  2018. wsssendlog.push(args);
  2019. wsssendrecievelog.push([0,args]);
  2020. if(!bonkwss){
  2021. bonkwss = this;
  2022. }
  2023. if(args.startsWith('42[26,')){
  2024. var jsonargs = JSON.parse(args.substring(2));
  2025. if(sandboxon){
  2026. if(typeof(sandboxplayerids[jsonargs[1]["targetID"]])!='undefined'){
  2027. var packet = '42[18,'+jsonargs[1]["targetID"]+','+jsonargs[1]["targetTeam"]+']';
  2028. RECIEVE(packet);
  2029. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  2030. }
  2031. }
  2032. }
  2033. if(args.startsWith('42[9,')){
  2034. var jsonargs = JSON.parse(args.substring(2));
  2035. if(sandboxon){
  2036. if(typeof(sandboxplayerids[jsonargs[1]["banshortid"]])!='undefined'){
  2037. if(Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden"){
  2038. var packet = '42[24,'+jsonargs[1]["banshortid"].toString()+','+jsonargs[1]["kickonly"]+']';
  2039. var packet2 = '42[5,'+jsonargs[1]["banshortid"].toString()+',0]';
  2040. RECIEVE(packet);
  2041. RECIEVE(packet2);
  2042. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet,packet2],to:[-1]}]));
  2043. }
  2044. else{
  2045. displayInChat("Cannot delete players while ingame.","#DA0808","#1EBCC1");
  2046. }
  2047. }
  2048. }
  2049. }
  2050. if(args.startsWith('42[1,')){
  2051. return;
  2052. }
  2053.  
  2054. if(args.startsWith('42[4,')){
  2055. var jsonargs = JSON.parse(args.substring(2));
  2056. if(sandboxcopyme==myid && typeof(jsonargs[1]["i"])!="undefined"){
  2057. var jsonkeys = Object.keys(sandboxplayerids);
  2058. var jsonargs2 = jsonargs[1];
  2059. for(var i = 0; i<jsonkeys.length;i++){
  2060. jsonargs2["c"] = playerids[jsonkeys[i]].movecount;
  2061. var packet = '42[7,'+jsonkeys[i].toString()+','+JSON.stringify(jsonargs2)+']';
  2062. RECIEVE(packet);
  2063. }
  2064. jsonargs2["c"] = "CVALUE";
  2065. jsonargs2 = JSON.stringify(jsonargs2).replace('"CVALUE"',"CVALUE");
  2066. SEND("42"+JSON.stringify([4,{"type":"customfakerecieve","from":username,"packet":['42[7,ID,'+jsonargs2+']'],to:[-1]}]));
  2067. }
  2068. if(typeof(jsonargs[1]["i"]) != "undefined"){
  2069. if(playerids[myid].movecount>=jsonargs[1]["c"]){
  2070. jsonargs[1]["c"] = playerids[myid].movecount;
  2071. playerids[myid].movecount+=1;
  2072. }
  2073. else{
  2074. playerids[myid].movecount = jsonargs[1]["c"]+1;
  2075. }
  2076. }
  2077. if(recording && typeof(jsonargs[1]["i"])!="undefined"){
  2078. if(myid.toString() == recordingid){
  2079. if(recordingdata.length == 0){
  2080. recordingdata.push([jsonargs[1]["i"],jsonargs[1]["f"]]);
  2081. }
  2082. else{
  2083. recordingdata.push([jsonargs[1]["i"],jsonargs[1]["f"]-recordingdata[0][1]]);
  2084. }
  2085. }
  2086. }
  2087. playerids[myid].lastmove = Date.now();
  2088. if(ishost && typeof(jsonargs[1]["i"])!="undefined"){
  2089. for(var i = 0;i<disabledkeys.length;i++){
  2090. if(GET_KEYS(jsonargs[1]["i"])[disabledkeys[i]]){
  2091. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden" && !killedids.includes(myid)){
  2092. killedids.push(myid);
  2093. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  2094. SEND('42[25,{"a":{"playersLeft":['+myid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  2095. RECIEVE('42[31,{"a":{"playersLeft":['+myid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  2096. break;
  2097. }
  2098. }
  2099. }
  2100. }
  2101. args = "42"+JSON.stringify(jsonargs);
  2102. }
  2103. if(args.startsWith('42[29,')){
  2104. var jsonargs = JSON.parse(args.substring(2));
  2105. playerids[jsonargs[1]["sid"]].playerData2.balance = jsonargs[1]["bal"];
  2106. if(sandboxon){
  2107. if(typeof(sandboxplayerids[jsonargs[1]["sid"]])!='undefined'){
  2108. var packet = '42[36,'+jsonargs[1]["sid"]+','+jsonargs[1]["bal"]+']';
  2109. RECIEVE(packet);
  2110. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  2111. }
  2112. }
  2113. }
  2114. if(args.startsWith('42[12,')){
  2115. playerids = {};
  2116. var jsonargs2 = JSON.parse(args.substring(2));
  2117. var jsonargs = jsonargs2[1];
  2118. 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}};
  2119. allstyles[username] = [0,0,0];
  2120. myid = 0;
  2121. bonkwss = this;
  2122. hostid = 0;
  2123. inroom = true;
  2124. if(savedrooms.length>0){
  2125. Gdocument.getElementById("roomlistrefreshbutton").click();
  2126. }
  2127. }
  2128. if(args.startsWith('42[10')){
  2129. var jsonargs = JSON.parse(args.substring(2));
  2130. if(jsonargs[2]){
  2131. args = "42"+JSON.stringify([10,jsonargs[1]]);
  2132. }
  2133. else if(translating2[0]){
  2134. text = translate(jsonargs[1]["message"],"auto",translating2[1]).then(function(r){SEND("42"+JSON.stringify([10,{"message":r},true]))});
  2135. return;
  2136. }
  2137. }
  2138. if(args.startsWith('42[23,') && recteams){
  2139. var jsonargs = JSON.parse(args.substring(2));
  2140. var map = decodeFromDatabase(jsonargs[1]["m"]);
  2141. var spawns = map["spawns"];
  2142. var teamsneeded = true;
  2143. var excludedindexes = [];
  2144. var ffaspawns = false;
  2145. var ffaforsure = false;
  2146. for(var i = 0; i<spawns.length;i++){
  2147. var currentSpawn = spawns[i];
  2148. if(Math.sqrt(currentSpawn.x**2 + currentSpawn.y**2)>=850 || currentSpawn.y>250){
  2149. excludedindexes.push(i);
  2150. }
  2151. else if(!(currentSpawn.f || currentSpawn.r || currentSpawn.b || currentSpawn.gr || currentSpawn.ye)){
  2152. excludedindexes.push(i);
  2153. }
  2154. else if(currentSpawn.f){
  2155. ffaspawns = true;
  2156. if(!(currentSpawn.r || currentSpawn.b || currentSpawn.gr || currentSpawn.ye)){
  2157. excludedindexes.push(i);
  2158. ffaforsure = true
  2159. }
  2160. }
  2161. }
  2162. if(!ffaspawns && !ffaforsure){
  2163. teamsneeded = true;
  2164. }
  2165. else{
  2166. teamsneeded = false;
  2167. }
  2168. if(teamsneeded){
  2169. var newspawns = [];
  2170. for(var i = 0; i<spawns.length;i++){
  2171. if(!excludedindexes.includes(i)){
  2172. 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"]});
  2173. }
  2174. }
  2175. if(newspawns.length>0){
  2176. var teamletters = ["r","g","b","y"];
  2177. var ratios = {"r":0,"g":0,"b":0,"y":0};
  2178. for(var i = 0; i < newspawns.length;i++){
  2179. for(var i2 = 0; i2<teamletters.length;i2++){
  2180. var ct = teamletters[i2];
  2181. if(newspawns[i]["priority"]!=0){
  2182. ratios[ct]+=(newspawns[i][ct])/newspawns[i]["total"]*newspawns[i]["priority"];
  2183. }
  2184. }
  2185. }
  2186. var highest = ["",0];
  2187. for(var i = 0; i<teamletters.length;i++){
  2188. var ct = teamletters[i];
  2189. if(ratios[ct]>0 && highest[1]<ratios[ct]){
  2190. highest = [ct,ratios[ct]];
  2191. }
  2192. }
  2193. if(highest[0]!=""){
  2194. for(var i = 0; i<teamletters.length;i++){
  2195. var ct = teamletters[i];
  2196. ratios[ct] = ratios[ct]/highest[1];
  2197. }
  2198. }
  2199. var playerids3 = Object.keys(playerids);
  2200. var playerids2 = [];
  2201. for(var i = 0; i<playerids3.length;i++){
  2202. if(playerids[playerids3[i]].team>0){
  2203. playerids2.push(playerids3[i]);
  2204. }
  2205. }
  2206. var pi2l = playerids2.length;
  2207. var ratios2 = {"r":0,"r1":0,"g":0,"g1":0,"b":0,"b1":0,"y":0,"y1":0};
  2208. var items = Object.entries(ratios);
  2209. items.sort(function(a,b){return a[1]-b[1];});
  2210. var items = items.map(function(e){return e[0];});
  2211. var highest2 = ["",0];
  2212. while(pi2l>0){
  2213. var done = false;
  2214. for(var i2 = 0; i2<items.length;i2++){
  2215. var ci = items[i2];
  2216. var ci2 = items[i2]+"1";
  2217. for(var i = 0; i<teamletters.length;i++){
  2218. var ct = teamletters[i];
  2219. if(ratios2[ct]>0 && highest2[1]<ratios2[ct]){
  2220. highest2 = [ct,ratios2[ct]];
  2221. }
  2222. }
  2223. if(highest2[0]!=""){
  2224. for(var i = 0; i<teamletters.length;i++){
  2225. var ct = teamletters[i];
  2226. ratios2[ct+"1"] = ratios2[ct]/highest2[1];
  2227. }
  2228. }
  2229. if(ratios[ci]>0 && ratios[ci]>=ratios2[ci2] && pi2l>0){
  2230. ratios2[ci]+=1;
  2231. pi2l--;
  2232. done = true;
  2233. }
  2234. }
  2235. if(pi2l>0 && !done){
  2236. ratios2[highest2[0]]+=1;
  2237. pi2l--;
  2238. }
  2239. }
  2240. SEND('42[32,{"t":true}]');
  2241. RECIEVE('42[39,true]');
  2242. for(var i = 0; i<ratios2["r"];i++){
  2243. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  2244. SEND('42[26,{"targetID":'+pid+',"targetTeam":2}]');
  2245. if(playerids[pid].peerID!="sandbox"){
  2246. RECIEVE('42[18,'+pid+',2]');
  2247. }
  2248. }
  2249. for(var i = 0; i<ratios2["g"];i++){
  2250. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  2251. SEND('42[26,{"targetID":'+pid+',"targetTeam":4}]');
  2252. if(playerids[pid].peerID!="sandbox"){
  2253. RECIEVE('42[18,'+pid+',4]');
  2254. }
  2255. }
  2256. for(var i = 0; i<ratios2["b"];i++){
  2257. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  2258. SEND('42[26,{"targetID":'+pid+',"targetTeam":3}]');
  2259. if(playerids[pid].peerID!="sandbox"){
  2260. RECIEVE('42[18,'+pid+',3]');
  2261. }
  2262. }
  2263. for(var i = 0; i<ratios2["y"];i++){
  2264. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  2265. SEND('42[26,{"targetID":'+pid+',"targetTeam":5}]');
  2266. if(playerids[pid].peerID!="sandbox"){
  2267. RECIEVE('42[18,'+pid+',5]');
  2268. }
  2269. }
  2270. }
  2271. }
  2272. else{
  2273. SEND('42[32,{"t":false}]');
  2274. RECIEVE('42[39,false]');
  2275. }
  2276. }
  2277.  
  2278. if(args.startsWith('42[47,') && stopquickplay == 0 && ishost && document.hidden && !qppaused){
  2279. roundsperqp2++;
  2280. if(roundsperqp2>=roundsperqp){
  2281. if(shuffle){
  2282. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  2283. var available = [];
  2284. var availableindexes = [];
  2285. var notempty = false;
  2286. for(var i = 0; i<e2.length;i++){
  2287. var a = false;
  2288. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  2289. available.push(a);
  2290. if(a){
  2291. availableindexes.push(i);
  2292. notempty = true;
  2293. }
  2294. }
  2295. if(notempty){
  2296.  
  2297. if(availableindexes.length!=1){
  2298. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  2299. }
  2300. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  2301. }
  2302. }
  2303. else{
  2304. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  2305. var available = [];
  2306. var availableindexes = [];
  2307. var notempty = false;
  2308. for(var i = 0; i<e2.length;i++){
  2309. var a = false;
  2310. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  2311. available.push(a);
  2312. if(a){
  2313. availableindexes.push(i);
  2314. notempty = true;
  2315. }
  2316. }
  2317. if(notempty){
  2318. var above = [];
  2319. for(var i = 0;i<availableindexes.length;i++){
  2320. if(availableindexes[i]>quicki && !reverseqp){
  2321. above.push(availableindexes[i]);
  2322. }
  2323. else if(availableindexes[i]<quicki && reverseqp){
  2324. above.push(availableindexes[i])
  2325. }
  2326. }
  2327. if(above.length>0){
  2328. quicki = above[0];
  2329. if(reverseqp){
  2330. quicki = above[above.length-1];
  2331. }
  2332. }
  2333. else{
  2334. quicki = availableindexes[0];
  2335. if(reverseqp){
  2336. quicki = availableindexes[availableindexes.length-1];
  2337. }
  2338. }
  2339. }
  2340. }
  2341. }
  2342. canceled = false;
  2343. startedinqp = true;
  2344. window.map(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length),0);
  2345. }
  2346. if(args.startsWith('42[32,')){
  2347. var jsonargs = JSON.parse(args.substring(2));
  2348. var keys = Object.keys(playerids);
  2349. if(!jsonargs[1]["t"]){
  2350. FFA = true;
  2351. for(var i = 0;i<keys.length;i++){
  2352. if(playerids[keys[i]].team!=0){
  2353. playerids[keys[i]].team = 1;
  2354. }
  2355. }
  2356. }
  2357. else{
  2358. FFA = false;
  2359. }
  2360. }
  2361. if(args.startsWith('42[5,')){
  2362. var jsonargs = JSON.parse(args.substring(2));
  2363. if(stopquickplay!=1 && startedinqp){
  2364. startedinqp = false;
  2365. jsonargs[1]["gs"]["wl"] = 999;
  2366. if(!instaqp){
  2367. var jsonargs2 = decodeIS(jsonargs[1]["is"]);
  2368. jsonargs2["ftu"] = 60;
  2369. if(jsonargs2["mm"]["rxa"] != ""){
  2370. jsonargs2["mm"]["a"] = jsonargs2["mm"]["rxa"];
  2371. jsonargs2["mm"]["n"] = jsonargs2["mm"]["rxn"];
  2372. }
  2373. jsonargs2 = encodeIS(jsonargs2);
  2374. jsonargs[1]["is"] = jsonargs2;
  2375. var jsonargs3 = decodeFromDatabase(jsonargs[1]["gs"]["map"]);
  2376. if(jsonargs3["m"]["rxa"] != ""){
  2377. jsonargs3["m"]["a"] = jsonargs3["m"]["rxa"];
  2378. jsonargs3["m"]["n"] = jsonargs3["m"]["rxn"];
  2379. }
  2380.  
  2381. jsonargs3 = encodeToDatabase(jsonargs3);
  2382. jsonargs[1]["gs"]["map"] = jsonargs3;
  2383. }
  2384. }
  2385.  
  2386. args = "42"+JSON.stringify(jsonargs);
  2387. }
  2388. }
  2389.  
  2390. }
  2391. else{
  2392. if(args.includes("rport")){
  2393. return;
  2394. }
  2395. }
  2396. if(this.url.includes(".bonk.io/socket.io/?EIO=3&transport=websocket&sid=") && !this.injected){
  2397. this.injected = true;
  2398.  
  2399. var originalRecieve = this.onmessage;
  2400. this.onmessage = function(args){
  2401. if(!bonkwssextra.includes(this)){
  2402. wssrecievelog.push(args.data);
  2403. wsssendrecievelog.push([1,args.data]);
  2404. if(typeof(args.data)=="string"){
  2405. args = {"data":RECIEVEFUNCTION(args.data)};
  2406. if(args.data.startsWith('42[1,')){
  2407. var jsonargs = JSON.parse(args.data.substring(2));
  2408. originalSend.call(this,'42[1,{"id":'+jsonargs[2]+'}]');
  2409. }
  2410. if(args.data.startsWith('42[36,')){
  2411. var jsonargs = JSON.parse(args.data.substring(2));
  2412. playerids[jsonargs[1]].playerData2.balance = jsonargs[2];
  2413. }
  2414. if(args.data.startsWith('42[24,')){
  2415. beenKickedTimeStamp = Date.now();
  2416. onlykicked = JSON.parse(args.data.substring(2))[2];
  2417. }
  2418. if(args.data.startsWith('42[21,')){
  2419. recievedinitdata = true;
  2420. }
  2421. if(args.data.startsWith('42[48,')){
  2422. recievedinitdata = true;
  2423. }
  2424. if(args.data.startsWith('42[23,')){
  2425. var jsonargs = JSON.parse(args.data.substring(2));
  2426. if(causelag){
  2427. jsonargs[1]["result"]-=causelag2;
  2428. }
  2429. args.data = '42'+JSON.stringify(jsonargs);
  2430. }
  2431. if(args.data.startsWith('42[16,')){
  2432. var jsonargs = JSON.parse(args.data.substring(2));
  2433. var now = Date.now();
  2434. if(jsonargs[1]=="chat_rate_limit"){
  2435. if(pollactive[1]+100>now){
  2436. pollactive = [false,0,0,[]];
  2437. displayInChat("Your poll failed due to chat rate limit.","#DA0808","#1EBCC1");
  2438. displayInChat("Please try again.","#DA0808","#1EBCC1");
  2439. }
  2440. }
  2441. else if(jsonargs[1]=="room_full"){
  2442. if(!savedrooms.includes(currentroomaddress)){
  2443. savedroombutton.className = "brownButton brownButton_classic buttonShadow";
  2444. }
  2445. }
  2446. }
  2447. if(args.data.startsWith('42[6,')){
  2448. var jsonargs = JSON.parse(args.data.substring(2));
  2449. if(typeof(playerids[jsonargs[1]])!='undefined'){
  2450. delplayerids[jsonargs[1]] = playerids[jsonargs[1]];
  2451. delete playerids[jsonargs[1]];
  2452. }
  2453. hostid = jsonargs[2];
  2454. }
  2455. if(args.data.startsWith('42[39,')){
  2456. var jsonargs = JSON.parse(args.data.substring(2));
  2457. var keys = Object.keys(playerids);
  2458. if(!jsonargs[1]){
  2459. FFA = true;
  2460. for(var i = 0;i<keys.length;i++){
  2461. if(playerids[keys[i]].team!=0){
  2462. playerids[keys[i]].team = 1;
  2463. }
  2464. }
  2465. }
  2466. else{
  2467. FFA = false;
  2468. }
  2469. }
  2470. if(args.data.startsWith('42[41,')){
  2471. var jsonargs = JSON.parse(args.data.substring(2));
  2472. hostid = jsonargs[1]["newHost"];
  2473. }
  2474. if(args.data.startsWith('42[20,')){
  2475. var jsonargs = JSON.parse(args.data.substring(2));
  2476. if(translating[0]){
  2477. translate(jsonargs[2],"auto",translating[1]).then(function(r){displayInChat(playerids[jsonargs[1]].userName+": "+r,"#DA0808","#1EBCC1")});
  2478. }
  2479. if(echo_list.includes(playerids[jsonargs[1]].userName)){
  2480. chat(flag_manage(echotext.replaceAll("username",playerids[jsonargs[1]].userName).replaceAll("message",jsonargs[2])));
  2481. }
  2482. if(randomchat){
  2483. var isin = false;
  2484. for(var i = 0;i<randomchatpriority[1].length;i++){
  2485. if(randomchatpriority[1][i][0] == jsonargs[2]){
  2486. isin = true;
  2487. if(myid!=jsonargs[1]){
  2488. randomchatpriority[1][i][1]+=2;
  2489. randomchatpriority[0]+=2;
  2490. }
  2491. break;
  2492. }
  2493. }
  2494. if(!isin){
  2495. randomchatpriority[1].push([jsonargs[2],Math.min(35-Math.abs(35-jsonargs[2].length),1)]);
  2496. randomchatpriority[0]+=Math.min(35-Math.abs(35-jsonargs[2].length),1);
  2497. }
  2498. }
  2499. if(pollactive[0] || pollactive2[0]){
  2500. var chatmessage = jsonargs[2].toUpperCase().trim().replace(")","");
  2501. var lettersindex = letters.indexOf(chatmessage);
  2502. if(ishost){
  2503. if(pollactive[3].length>0 && lettersindex!=-1 && lettersindex<pollactive[3].length){
  2504. playerids[jsonargs[1]].vote.poll = lettersindex;
  2505. }
  2506. }
  2507. else{
  2508. if(pollactive2[2].length>0 && lettersindex!=-1 && lettersindex<pollactive2[2].length){
  2509. playerids[jsonargs[1]].vote.poll = lettersindex;
  2510. }
  2511. }
  2512. }
  2513. }
  2514. if(args.data.startsWith('42[32')){
  2515. SEND('42[4,{"type":"inactive kick counter"}]');
  2516. }
  2517. if(args.data.startsWith('42[18')){
  2518. var jsonargs = JSON.parse(args.data.substring(2));
  2519. playerids[jsonargs[1]].team = jsonargs[2];
  2520. }
  2521. if(args.data.startsWith('42[40,')){
  2522. recordedTimeStamp = Date.now();
  2523. recordedId = JSON.parse(args.data.substring(2))[1];
  2524. }
  2525. if(args.data.startsWith('42[3,')){
  2526. playerids = {};
  2527. var jsonargs = JSON.parse(args.data.substring(2));
  2528. for(var i = 0; i<jsonargs[3].length;i++){
  2529. if(jsonargs[3][i]!=null){
  2530. playerids[i.toString()] = jsonargs[3][i];
  2531. playerids[i.toString()].commands = false;
  2532. playerids[i.toString()].ratelimit = {"pm":0,"mode":0,"team":0,"poll":0,"join":Date.now(),"style":0};
  2533. playerids[i.toString()].vote = {"poll":-1};
  2534. allstyles[playerids[i.toString()].userName] = [0,0,0];
  2535. }
  2536. }
  2537. if(playerids[jsonargs[1]].userName.startsWith(Gdocument.getElementById("pretty_top_name").textContent)){
  2538. myid = jsonargs[1];
  2539. bonkwss = this;
  2540. playerids[myid].commands = true;
  2541. /*setTimeout(function(){var me = playerids[myid];RECIEVE('42'+JSON.stringify([4,myid,me.peerID,me.userName,me.guest,me.level,me.team,me.avatar]));});*/
  2542. }
  2543. else{
  2544. bonkwssextra.push(this);
  2545. }
  2546. inroom = true;
  2547. hostid = jsonargs[2];
  2548. SEND('42[4,{"type":"commands"}]');
  2549. SEND("42"+JSON.stringify([4,{"type":"style","from":username,"style":mystyle}]));
  2550. allstyles[playerids[myid].userName] = [...mystyle];
  2551. ghostroomwss = bonkwss;
  2552. Gdocument.getElementById("roomlistrefreshbutton").click();
  2553. 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);
  2554.  
  2555. }
  2556. if(args.data.startsWith('42[21,')){
  2557. var jsonargs = JSON.parse(args.data.substring(2));
  2558. mode = jsonargs[1]["mo"];
  2559. FFA = !jsonargs[1]["tea"];
  2560. }
  2561. if(args.data.startsWith('42[48,')){
  2562. var jsonargs = JSON.parse(args.data.substring(2));
  2563. mode = jsonargs[1]["gs"]["mo"];
  2564. FFA = !jsonargs[1]["gs"]["tea"];
  2565. }
  2566. if(args.data.startsWith('42[49,')){
  2567. /*
  2568. var me = playerids[myid];
  2569. RECIEVE('42'+JSON.stringify([4,myid,me.peerID,me.userName,me.guest,me.level,me.team,me.avatar]));
  2570. */
  2571. }
  2572. if(args.data.startsWith('42[15,')){
  2573. var jsonargs = JSON.parse(args.data.substring(2));
  2574. dontswitch = false;
  2575. mode = jsonargs[3]["mo"];
  2576. gameStartTimeStamp = jsonargs[1];
  2577. killedids = [];
  2578. Gdocument.getElementById("newbonklobby").style["z-index"] = "unset";
  2579. Gdocument.getElementById("mapeditorcontainer").style["z-index"] = "unset";
  2580. }
  2581. if(args.data.startsWith('42[33,')){
  2582. var jsonargs = JSON.parse(args.data.substring(2));
  2583. var decodedmap = decodeFromDatabase(jsonargs[1]);
  2584. if(decodedmap!=0){
  2585. requestedmaps = [[decodedmap,jsonargs[1]]].concat(requestedmaps);
  2586. }
  2587. }
  2588. if(args.data.startsWith('42[7,')){
  2589. var jsonargs2 = JSON.parse(args.data.substring(2));
  2590. var idofpacket = jsonargs2[1];
  2591. jsonargs = jsonargs2[2];
  2592. if(typeof(jsonargs["i"]) == "undefined"){
  2593. if(jsonargs["type"]=="private chat" && jsonargs["to"] == username){
  2594. from = jsonargs["from"];
  2595. if(Object.keys(playerids).includes(idofpacket.toString())){
  2596. from = playerids[idofpacket].userName;
  2597. }
  2598. if(!ignorepmlist.includes(from)){
  2599. if(typeof(jsonargs["message"])=="object" && typeof(jsonargs["password"]) == "object"){
  2600. if(public_key[0]==jsonargs["public key"][0] && public_key[1]==jsonargs["public key"][1]){
  2601. var now = Date.now();
  2602. if(jsonargs["password"].length<=25 && playerids[idofpacket].ratelimit.pm+250<now){
  2603. playerids[idofpacket].ratelimit.pm = now;
  2604. var password = CRYPT_MESSAGE(private_key,jsonargs["password"]);
  2605. var decodedtext = jsonargs["message"].slice(0,400);
  2606. var encodedtext = "";
  2607. for(var i=0;i<decodedtext.length;i++){
  2608. if(password[i%password.length]<1000){
  2609. encodedtext+=String.fromCharCode(password[i%password.length]^decodedtext[i]);
  2610. }
  2611. }
  2612. 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);';
  2613. displayInChat('> '+'<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+sanitize(from)+'</a>'+': ',"#DA0808","#1EBCC1",{sanitize:false},encodedtext);
  2614.  
  2615. Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true;
  2616. Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true;
  2617. Laster_message = lastmessage();
  2618. }
  2619. }
  2620. else{
  2621. SEND("42"+JSON.stringify([4,{"type":"public key correction","from":username,"to":private_chat_public_key[0],"public key":public_key}]));
  2622. }
  2623. }
  2624. }
  2625. }
  2626. if(jsonargs["type"]=="request public key" && jsonargs["to"] == username){
  2627. SEND("42"+JSON.stringify([4,{"type":"public key","from":username,"public key":public_key}]));
  2628. }
  2629. if(jsonargs["type"]=="private chat users" && pmuserstimestamp+1500>Date.now()){
  2630. if(typeof(jsonargs["from"])!='undefined'){
  2631. from = jsonargs["from"];
  2632. if(Object.keys(playerids).includes(idofpacket.toString())){
  2633. from = playerids[idofpacket].userName;
  2634. }
  2635. if(!pmusers.includes(from) && username == jsonargs["to"]){
  2636. pmusers.push(from);
  2637. }
  2638. }
  2639. }
  2640. if(jsonargs["type"]=="style" && playerids[idofpacket].ratelimit["style"]+250<Date.now()){
  2641. playerids[idofpacket].ratelimit["style"] = Date.now();
  2642. if(Array.isArray(jsonargs["style"])){
  2643. if(jsonargs["style"].length == 3){
  2644. var valid = true;
  2645. for(var i = 0;i<jsonargs["style"].length;i++){
  2646. if(Number.isInteger(jsonargs["style"][i])){
  2647. if(jsonargs["style"][i]>255 || jsonargs["style"][i]<0){
  2648. valid = false;
  2649. break;
  2650. }
  2651. }
  2652. else{
  2653. valid = false;
  2654. break;
  2655. }
  2656. }
  2657. if(valid){
  2658. allstyles[playerids[idofpacket].userName] = jsonargs["style"];
  2659. }
  2660. }
  2661. }
  2662. }
  2663. if(jsonargs["type"]=="request private chat users"){
  2664. if(typeof(jsonargs["from"])!='undefined'){
  2665. from = jsonargs["from"];
  2666. if(Object.keys(playerids).includes(idofpacket.toString())){
  2667. from = playerids[idofpacket].userName;
  2668. }
  2669. SEND("42"+JSON.stringify([4,{"type":"private chat users","from":username,"to":from}]));
  2670. }
  2671. }
  2672. if(jsonargs["type"]=="public key" && request_public_key_time_stamp+1500>Date.now()){
  2673. from = jsonargs["from"];
  2674. if(Object.keys(playerids).includes(idofpacket.toString())){
  2675. from = playerids[idofpacket].userName;
  2676. }
  2677. if(from == private_chat){
  2678. private_chat_public_key = [private_chat,jsonargs["public key"]];
  2679. displayInChat("Private chatting with "+private_chat+".","#DA0808","#1EBCC1");
  2680. }
  2681. }
  2682. if(jsonargs["type"]=="fakerecieve" && hostid == idofpacket && sandboxon && ((jsonargs["to"].includes(myid) && jsonargs["to"][0]!=-1) || (!jsonargs["to"].includes(myid) && jsonargs["to"][0]==-1))){
  2683. for(var i = 0;i<jsonargs["packet"].length;i++){
  2684. if(!jsonargs["packet"][i].startsWith("42[20,")){
  2685. RECIEVE(jsonargs["packet"][i]);
  2686. }
  2687. }
  2688. }
  2689. if(jsonargs["type"]=="customfakerecieve" && hostid == idofpacket && sandboxon && ((jsonargs["to"].includes(myid) && jsonargs["to"][0]!=-1) || (!jsonargs["to"].includes(myid) && jsonargs["to"][0]==-1))){
  2690. for(var i2 = 0;i2<jsonargs["packet"].length;i2++){
  2691. var keys = Object.keys(sandboxplayerids);
  2692. for(var i = 0;i<keys.length;i++){
  2693. if(jsonargs["packet"][i2].startsWith("42[7,")){
  2694. originalRecieve.call(this,{data:jsonargs["packet"][i2].replace("ID",keys[i].toString()).replace("CVALUE",playerids[keys[i]].movecount.toString())});
  2695. playerids[keys[i]].movecount+=1;
  2696. }
  2697. }
  2698. }
  2699. }
  2700. if(jsonargs["type"]=="commands"){
  2701. playerids[idofpacket].commands = true;
  2702. }
  2703. if(jsonargs["type"]=="sandboxid" && hostid == idofpacket && sandboxon && ((jsonargs["to"].includes(myid) && jsonargs["to"][0]!=-1) || (!jsonargs["to"].includes(myid) && jsonargs["to"][0]==-1))){
  2704. sandboxid = jsonargs["lastid"];
  2705. }
  2706. if(jsonargs["type"]=="sandboxon" && idofpacket == hostid){
  2707. if(!sandboxon){
  2708. displayInChat("This is a sandbox lobby.","#DA0808","#1EBCC1");
  2709. sandboxon = true;
  2710. }
  2711. }
  2712. if(jsonargs["type"]=="vote poll"){
  2713. from = jsonargs["from"];
  2714. if(Object.keys(playerids).includes(idofpacket.toString())){
  2715. from = playerids[idofpacket].userName;
  2716. }
  2717. if(typeof(jsonargs["vote"]) == 'number' && idofpacket!=hostid){
  2718. var now = Date.now();
  2719. if(ishost && pollactive[3].length>1 && pollactive[0]){
  2720. if(jsonargs["vote"]>=0 && jsonargs["vote"]<pollactive[3].length){
  2721. playerids[idofpacket].vote.poll = jsonargs["vote"];
  2722. }
  2723. }
  2724. else if(pollactive2[0] && pollactive2[2].length>1){
  2725. if(jsonargs["vote"]>=0 && jsonargs["vote"]<pollactive2[2].length){
  2726. playerids[idofpacket].vote.poll = jsonargs["vote"];
  2727. }
  2728. }
  2729. }
  2730.  
  2731. }
  2732. if(jsonargs["type"]=="poll end"){
  2733. from = jsonargs["from"];
  2734. if(Object.keys(playerids).includes(idofpacket.toString())){
  2735. from = playerids[idofpacket].userName;
  2736. }
  2737. var now = Date.now();
  2738. if(hostid == idofpacket && playerids[idofpacket].ratelimit.poll+5000<now){
  2739. playerids[idofpacket].ratelimit.poll = now;
  2740. var count = [0,0,0,0];
  2741. var keys = Object.keys(playerids);
  2742. for(var i = 0;i<keys.length;i++){
  2743. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive2[2].length-1){
  2744. count[playerids[keys[i]].vote.poll]++;
  2745. }
  2746. playerids[keys[i]].vote.poll = -1;
  2747. }
  2748. displayInChat("The poll ended.","#DA0808","#1EBCC1");
  2749. for(var i = 0;i<count.length;i++){
  2750. if(count[i]>1){
  2751. displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  2752. }
  2753. if(count[i]==1){
  2754. displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  2755. }
  2756. }
  2757. pollactive2 = [false,0,[]];
  2758. }
  2759.  
  2760. }
  2761. if(jsonargs["type"] == "video player" && idofpacket == hostid && ((jsonargs["to"].includes(myid) && jsonargs["to"][0]!=-1) || (!jsonargs["to"].includes(myid) && jsonargs["to"][0]==-1))){
  2762. changeJukeboxURL(jsonargs["url"],jsonargs["timestamp"]);
  2763. }
  2764. if(jsonargs["type"]=="poll" && idofpacket == hostid){
  2765. from = jsonargs["from"];
  2766. if(Object.keys(playerids).includes(idofpacket.toString())){
  2767. from = playerids[idofpacket].userName;
  2768. }
  2769. if(Array.isArray(jsonargs["poll"])){
  2770. var propperpoll = true;
  2771. var pollifproper = [];
  2772. if(jsonargs["poll"].length>5){
  2773. propperpoll = false;
  2774. }
  2775. else{
  2776. for(var i = 0;i<jsonargs["poll"].length;i++){
  2777. if(typeof(jsonargs["poll"][i]) == 'string'){
  2778. if(jsonargs["poll"][i].length>50){
  2779. propperpoll = false;
  2780. break;
  2781. }
  2782. else{
  2783. pollifproper.push(jsonargs["poll"][i]);
  2784. }
  2785. }
  2786. else{
  2787. propperpoll = false;
  2788. break;
  2789. }
  2790. }
  2791. }
  2792. if(propperpoll){
  2793. var now = Date.now();
  2794. var keys = Object.keys(playerids);
  2795. for(var i = 0;i<keys.length;i++){
  2796. playerids[keys[i]].vote.poll = -1;
  2797. }
  2798. pollactive2 = [true,now,pollifproper];
  2799. playerids[idofpacket].ratelimit.poll = now;
  2800. displayInChat(from+" started a poll:","#DA0808","#1EBCC1");
  2801. for(var i = 0;i<pollifproper.length;i++){
  2802. 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();';
  2803. displayInChat('<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+letters[i]+')</a>',"#DA0808","#1EBCC1",{sanitize:false}," "+pollifproper[i]);
  2804. }
  2805. }
  2806. }
  2807. }
  2808. if(jsonargs["type"]=="request mode" && playerids[idofpacket].ratelimit.mode+1000<Date.now()){
  2809. playerids[idofpacket].ratelimit.mode = Date.now();
  2810. from = jsonargs["from"];
  2811. if(Object.keys(playerids).includes(idofpacket.toString())){
  2812. from = playerids[idofpacket].userName;
  2813. }
  2814. var req_mode = jsonargs["mode"];
  2815. var req_mode2 = "";
  2816. if(req_mode){
  2817. if(req_mode == "b"){
  2818. req_mode2 = "Classic";
  2819. }
  2820. else if(req_mode == "sp"){
  2821. req_mode2 = "Grapple";
  2822. }
  2823. else if(req_mode == "ar"){
  2824. req_mode2 = "Arrows";
  2825. }
  2826. else if(req_mode == "ard"){
  2827. req_mode2 = "Death Arrows";
  2828. }
  2829. }
  2830. if(req_mode2){
  2831. 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+'")}';
  2832. displayInChat('> '+playerids[idofpacket].userName+' requests [<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+req_mode2+'</a>]',"#DA0808","#1EBCC1",{sanitize:false}," mode.");
  2833. }
  2834.  
  2835. }
  2836. if(jsonargs["type"]=="public key correction" && private_chat_public_key[0] == private_chat){
  2837. from = jsonargs["from"];
  2838. if(Object.keys(playerids).includes(idofpacket.toString())){
  2839. from = playerids[idofpacket].userName;
  2840. }
  2841. if(from == private_chat){
  2842. private_chat_public_key = [private_chat,jsonargs["public key"]];
  2843. var text = pmlastmessage;
  2844. var password = [];
  2845. for(var i = 0;i<10;i++){
  2846. password.push(Math.floor(Math.random()*100+50));
  2847. }
  2848. var text2 = [];
  2849. for(var i = 0;i<text.length ;i++){
  2850. text2.push(password[i%password.length]^text.slice(0,400).charCodeAt(i));
  2851. }
  2852. cc
  2853. }
  2854. }
  2855.  
  2856. }
  2857. else{
  2858. var now = Date.now();
  2859. if(playerids[idofpacket.toString()]){
  2860. playerids[idofpacket.toString()].lastmove = now;
  2861. }
  2862. if(idofpacket!=myid){
  2863. playerids[idofpacket.toString()].movecount+=1;
  2864. }
  2865. if(Math.abs(gameStartTimeStamp - (now-1000*jsonargs["f"]/30))>1000 && idofpacket!=myid){
  2866. gameStartTimeStamp = now-1000*jsonargs["f"]/30;
  2867. }
  2868. if(recording){
  2869. if(idofpacket.toString() == recordingid){
  2870. if(recordingdata.length == 0){
  2871. recordingdata.push([jsonargs["i"],jsonargs["f"]]);
  2872. }
  2873. recordingdata.push([jsonargs["i"],jsonargs["f"]-recordingdata[0][1]]);
  2874. }
  2875. }
  2876. if(ishost){
  2877. if(sandboxon && idofpacket == sandboxcopyme){
  2878. var jsonkeys = Object.keys(sandboxplayerids);
  2879. if(!jsonkeys.includes(sandboxcopyme.toString())){
  2880. var jsonargs2 = jsonargs;
  2881. for(var i = 0; i<jsonkeys.length;i++){
  2882. jsonargs2["c"] = playerids[jsonkeys[i]].movecount;
  2883. var packet = '42[7,'+jsonkeys[i].toString()+','+JSON.stringify(jsonargs2)+']';
  2884. RECIEVE(packet);
  2885. }
  2886. jsonargs2["c"] = "CVALUE";
  2887. jsonargs2 = JSON.stringify(jsonargs2).replace('"CVALUE"',"CVALUE");
  2888. SEND("42"+JSON.stringify([4,{"type":"customfakerecieve","from":username,"packet":['42[7,ID,'+jsonargs2+']'],to:[-1]}]));
  2889. }
  2890. }
  2891. for(var i = 0;i<disabledkeys.length;i++){
  2892. var get_keys_var = GET_KEYS(jsonargs["i"]);
  2893. if(get_keys_var[disabledkeys[i]]){
  2894. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden" && !killedids.includes(idofpacket)){
  2895. killedids.push(idofpacket);
  2896. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  2897. SEND('42[25,{"a":{"playersLeft":['+idofpacket.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  2898. RECIEVE('42[31,{"a":{"playersLeft":['+idofpacket.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  2899. break;
  2900. }
  2901. }
  2902. }
  2903. }
  2904. }
  2905. }
  2906.  
  2907. if(args.data.startsWith('42[4,')){
  2908. var jsonargs = JSON.parse(args.data.substring(2));
  2909. 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}};
  2910. if(jsonargs[2]!="sandbox"){
  2911. SEND('42[4,{"type":"commands"}]');
  2912. if(!Object.keys(allstyles).includes(jsonargs[3])){
  2913. allstyles[jsonargs[3]] = [0,0,0];
  2914. SEND("42"+JSON.stringify([4,{"type":"style","from":username,"style":allstyles[playerids[myid].userName]}]));
  2915. }
  2916. }
  2917. if(sandboxon){
  2918. var sandboxkeys = Object.keys(sandboxplayerids);
  2919. if(sandboxkeys.includes(jsonargs[1].toString())){
  2920. delete sandboxplayerids[jsonargs[1]];
  2921. }
  2922. if(jsonargs[2]=="sandbox"){
  2923. sandboxplayerids[jsonargs[1]] = jsonargs[3];
  2924. if(jsonargs[1]>sandboxid){
  2925. sandboxid = parseInt(jsonargs[1])+1;
  2926. }
  2927. }
  2928. else{
  2929. if(ishost){
  2930. SEND('42[4,{"type":"sandboxon"}]');
  2931. var sandboxkeys = Object.keys(sandboxplayerids);
  2932. var packets = [];
  2933. for(var i = 0;i<sandboxkeys.length;i++){
  2934. var p = playerids[sandboxkeys[i]];
  2935. var packet = '42'+JSON.stringify([4,sandboxkeys[i],p.peerID,p.userName,p.guest,p.level,p.team,p.avatar]);
  2936. packets.push(packet);
  2937. }
  2938. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":packets,to:[jsonargs[1]]}]));
  2939. SEND("42"+JSON.stringify([4,{"type":"sandboxid","from":username,"lastid":sandboxid,to:[jsonargs[1]]}]));
  2940. }
  2941. }
  2942. }
  2943. if(ishost){
  2944. if(jointext!="" && jsonargs[2]!="sandbox"){
  2945. chat(flag_manage(jointext.replaceAll("username",jsonargs[3])));
  2946. }
  2947. if(jointeam!=-1 && jsonargs[2]!="sandbox"){
  2948. SEND('42[26,{"targetID":'+jsonargs[1].toString()+',"targetTeam":'+jointeam.toString()+'}]');
  2949. setTimeout(function(){RECIEVE('42[18,'+jsonargs[1].toString()+','+jointeam.toString()+']');});
  2950. }
  2951. if(jukeboxplayer.src!="" && !jukeboxplayer.paused){
  2952. SEND("42"+JSON.stringify([4,{"type":"video player","from":username,"url":jukeboxplayerURL,"timestamp":Date.now()-jukeboxplayer.currentTime*1000,"to":[jsonargs[1]]}]));
  2953. }
  2954. if(freejoin){
  2955. var count = 0;
  2956. var keys = Object.keys(playerids);
  2957. for(var i = 0; i<keys.length;i++){
  2958. if(playerids[keys[i]].team!=0){
  2959. count++;
  2960. }
  2961. }
  2962. if(count <= 2 && jsonargs[6]!=0){
  2963. setTimeout(function(){
  2964. Gdocument.getElementById("newbonklobby_editorbutton").click();
  2965. Gdocument.getElementById("mapeditor_close").click();
  2966. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  2967. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  2968. if(transitioning == true){
  2969. canceled = true;
  2970. }
  2971. },150);
  2972. }
  2973. }
  2974. }
  2975.  
  2976. }
  2977. if(args.data.startsWith('42[5,')){
  2978. var jsonargs = JSON.parse(args.data.substring(2));
  2979. if(typeof(playerids[jsonargs[1]])!='undefined'){
  2980. delplayerids[jsonargs[1]] = playerids[jsonargs[1]];
  2981. delete allstyles[playerids[jsonargs[1]].userName];
  2982. delete playerids[jsonargs[1]];
  2983. }
  2984. if(sandboxon && typeof(sandboxplayerids[jsonargs[1]])!='undefined'){
  2985. delete sandboxplayerids[jsonargs[1]];
  2986. }
  2987. }
  2988. }}
  2989. return originalRecieve.call(this,args);
  2990. };
  2991.  
  2992. var originalClose = this.onclose;
  2993. this.onclose = function () {
  2994. if(bonkwssextra.includes(this)){
  2995. bonkwssextra.splice(bonkwssextra.indexOf(this),1)
  2996. }
  2997. else{
  2998. window.bonkwss = 0;
  2999. }
  3000. return originalClose.call(this);
  3001. }
  3002.  
  3003. }
  3004. return originalSend.call(this,args);
  3005. };
  3006.  
  3007. scope.SEND = function(args){
  3008. if(bonkwss!=0){
  3009. bonkwss.send(args);
  3010. }
  3011. };
  3012. scope.RECIEVE = function(args){
  3013. if(bonkwss!=0){
  3014. bonkwss.onmessage({data:args});
  3015. }
  3016. };
  3017.  
  3018.  
  3019.  
  3020. scope.dontswitch = false;
  3021. scope.username = 0;
  3022. scope.timedelay = 1400;
  3023. scope.ishost = false;
  3024. scope.checkboxhidden = true;
  3025. scope.quicki=0;
  3026. scope.defaultmode = "d";
  3027. scope.recmodebool = false;
  3028. scope.shuffle = false;
  3029. scope.startedinqp = false;
  3030. scope.instaqp = false;
  3031. scope.freejoin = false;
  3032. scope.recordedTimeStamp = 0;
  3033. scope.recordedId = 0;
  3034. scope.smartteams = false;
  3035. scope.beenKickedTimeStamp = 0;
  3036. scope.stopquickplay = 1;
  3037. scope.currentFrame = 0;
  3038. scope.text2speech = false;
  3039. scope.canceled = false;
  3040. scope.wintext = "";
  3041. scope.banned = [];
  3042. scope.transitioning = false;
  3043. scope.echo_list = [];
  3044. scope.echoAppend = "";
  3045. scope.message = "";
  3046. scope.private_chat = "";
  3047. scope.private_chat_public_key = ["",[0,0]];
  3048. scope.disabledkeys = [];
  3049. scope.actuallyhost = false;
  3050. scope.pmusers = [];
  3051. scope.pmlastmessage = "";
  3052. scope.pmuserstimestamp = 0;
  3053. scope.ignorepmlist = [];
  3054. scope.scroll = false;
  3055. scope.elem = Gdocument.getElementById("maploadwindowmapscontainer");
  3056. scope.npermissions = 1;
  3057. scope.space_flag = false;
  3058. scope.rcaps_flag = false;
  3059. scope.number_flag = false;
  3060. scope.reverse_flag = false;
  3061. scope.autocorrect = false;
  3062. scope.request_public_key_time_stamp = 0;
  3063. scope.sandboxcopyme = -1;
  3064. scope.recteams = false;
  3065. scope.chatheight = 128;
  3066. scope.onlykicked = false;
  3067. scope.killedids = [];
  3068. scope.jointext = "";
  3069. scope.randomchat = false;
  3070. scope.randomchatpriority = [0,[]];
  3071. scope.randomchatlastmessage = ["",0];
  3072. scope.afkkill = -1;
  3073. scope.tournament_mode = "";
  3074. scope.tournament_scores = [];
  3075. scope.tournament_in_and_out = {"in":[],"out":[]};
  3076. scope.echotext = "message";
  3077. scope.nextafter = 0;
  3078. scope.nextafterbuffer = -1;
  3079. scope.roundsperqp = 1;
  3080. scope.roundsperqp2 = 0;
  3081. scope.autorecord = false;
  3082. scope.poll = [];
  3083. scope.letters = ["A","B","C","D","E"];
  3084. scope.qppaused = false;
  3085. scope.FollowCam = false;
  3086. scope.autocam = false;
  3087. scope.gravity = 20;
  3088. scope.randomchat = false;
  3089. scope.randomchat_randomtimestamp = 0;
  3090. scope.randomchat_timestamp = 0;
  3091. scope.multiplier = 3.65;
  3092. scope.aimbot = false;
  3093. scope.recievedinitdata = false;
  3094. scope.heavybot = false;
  3095. scope.zoom = 1;
  3096. scope.prediction = 350;
  3097. scope.started = 0;
  3098. scope.holdheavy = 0;
  3099. scope.grappleheld = false;
  3100. scope.grappleheld2 = false;
  3101. scope.heavyheld = false;
  3102. scope.reverseqp = false;
  3103. scope.jointeam = -1;
  3104. scope.heavyheld2 = false;
  3105. scope.heavyid = 3;
  3106. scope.specialid = 0;
  3107. 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};
  3108. scope.leftRight = [37,39];
  3109. scope.upDown = [38,40];
  3110. scope.heavy = 88;
  3111. scope.special = 90;
  3112. scope.newzoom2 = 1;
  3113. scope.staystill = false;
  3114. scope.staystillpos = [0,0];
  3115. scope.zoom2 = 1;
  3116. scope.admins = [["LEGENDBOSS123",[0,0,0,0]],["iNeonz",[0,0,0,0]],["left paren",[0,0,0,0]]];
  3117.  
  3118. scope.autokickban = 0;
  3119. scope.ghostroomwss = -1;
  3120. scope.autokickbantimestamp = 0;
  3121. scope.getroomslastcheck = 0;
  3122. scope.causelag = false;
  3123. scope.causelag2 = 0;
  3124. scope.overideDate = [false,0];
  3125. scope.scale = 1;
  3126. scope.translating = [false,""];
  3127. scope.translating2 = [false,""];
  3128. scope.translatingkeys = {"english":"en","chinese":"zh","hindi":"hi","spanish":"es","portugese":"pt","french":"fr","arabic":"ar","russian":"ru","korean":"ko"};
  3129. scope.translate = function(text,fromL,toL) {
  3130. var fL = fromL || 'en';
  3131. var tL = toL || 'de';
  3132. var url = 'https://translate.googleapis.com/translate_a/single?client=gtx&sl='+ fL + "&tl=" + tL + "&dt=t&q=" + encodeURI(text);
  3133. var parseJSON = txt => JSON.parse(txt.split(',').map( x => x || 'null').join(',')) ;
  3134. var joinSnippets = json => json[0].map( x => x[0] ).join('');
  3135. return fetch(url).then(function(res){
  3136. return res.text();
  3137. }).then(function(text){
  3138. return joinSnippets(parseJSON(text));
  3139. });
  3140. };
  3141. scope.positive = function(angle){
  3142. if(angle<0){
  3143. angle += 2*Math.PI;
  3144. }
  3145. return angle%(Math.PI*2);
  3146. };
  3147. scope.angle_between = function(angle,angle2){
  3148. return Math.min(Math.abs(positive(angle)-positive(angle2)),Math.PI*2-Math.abs(positive(angle)-positive(angle2)));
  3149. };
  3150. scope.angle_between2 = function(angle,angle2){
  3151. if(angle_between(angle,angle2+Math.PI/2)<Math.PI/2){
  3152. return 1;
  3153. }
  3154. return -1;
  3155. };
  3156.  
  3157. scope.stringdistance = function(s1,s2){
  3158. s1 = s1.toLowerCase();
  3159. s2 = s2.toLowerCase();
  3160. var matrix = Array(s1.length+1);
  3161. for(var i = 0;i<matrix.length;i++){
  3162. matrix[i] = Array(s2.length+1);
  3163. matrix[i][0] = i;
  3164. }
  3165. for(var i = 0;i<matrix[0].length;i++){
  3166. matrix[0][i] = i;
  3167. }
  3168. for(var i = 1;i<s1.length+1;i++){
  3169. for(var i2 = 1;i2<s2.length+1;i2++){
  3170. if(s1[i-1]==s2[i2-1]){
  3171. matrix[i][i2] = matrix[i-1][i2-1];
  3172. }
  3173. else{
  3174. matrix[i][i2] = Math.min(matrix[i][i2-1],matrix[i-1][i2],matrix[i-1][i2-1])+1;
  3175. }
  3176. }
  3177. }
  3178. return matrix[s1.length][s2.length];
  3179. };
  3180. scope.closestWord = function(word){
  3181. if(word.length>20 || word.length<2){
  3182. return word;
  3183. }
  3184. var distances = [word.length,""];
  3185. var playernamelist = [];
  3186. var keys = Object.keys(playerids);
  3187. for(var i = 0;i<keys.length;i++){
  3188. playernamelist.push(playerids[keys[i]].userName);
  3189. }
  3190. var wordlist2 = playernamelist.concat(wordlist);
  3191. for(var i = 0;i<wordlist2.length;i++){
  3192. var distance = stringdistance(word,wordlist2[i]);
  3193. if(distance<=distances[0]){
  3194. distances[0] = distance;
  3195. distances[1] = wordlist2[i];
  3196. if(distance == 0){
  3197. return wordlist2[i];
  3198. }
  3199. }
  3200. };
  3201. if(distances[1] == ""){
  3202. return word;
  3203. }
  3204. return distances[1];
  3205. };
  3206.  
  3207.  
  3208.  
  3209. scope.replay = function(){
  3210. var frame = getCurrentFrame();
  3211. /*var replaycounter = 0;
  3212. while(1){
  3213. if(replaycounter != recordingdata.length-1){
  3214. for(var i = 0;i<recordingdata[replaycounter+1][1]-recordingdata[replaycounter][1];i++){
  3215. RECIEVE('42[7,'+myid+',{"i":'+recordingdata[replaycounter][0]+',"f":'+(frame+i+recordingdata[replaycounter][1]).toString()+',"c":'+playerids[myid].movecount+'}]');
  3216. playerids[myid].movecount+=1;
  3217. }
  3218. replaycounter+=1;
  3219. }
  3220. else{
  3221. break;
  3222. }
  3223. }*/
  3224. for(var i = 0;i<recordingdata.length;i++){
  3225. SEND('42[4,{"i":'+recordingdata[i][0]+',"f":'+(frame+recordingdata[i][1]).toString()+',"c":'+playerids[myid].movecount+'}]');
  3226. }
  3227. };
  3228. scope.presskeys = function(x,y){
  3229. if(!x.left && y.left){
  3230. fire("keydown",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  3231. }
  3232. else if(x.left && !y.left){
  3233. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  3234. }
  3235. if(!x.right && y.right){
  3236. fire("keydown",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  3237. }
  3238. else if(x.right && !y.right){
  3239. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  3240. }
  3241. if(!x.up && y.up){
  3242. fire("keydown",{"keyCode":upDown[0]},Gdocument.getElementById("gamerenderer"));
  3243. }
  3244. else if(x.up && !y.up){
  3245. fire("keyup",{"keyCode":upDown[0]},Gdocument.getElementById("gamerenderer"));
  3246. }
  3247. if(!x.down && y.down){
  3248. fire("keydown",{"keyCode":upDown[1]},Gdocument.getElementById("gamerenderer"));
  3249. }
  3250. else if(x.down && !y.down){
  3251. fire("keyup",{"keyCode":upDown[1]},Gdocument.getElementById("gamerenderer"));
  3252. }
  3253. if(!x.heavy && y.heavy){
  3254. fire("keydown",{"keyCode":heavy},Gdocument.getElementById("gamerenderer"));
  3255. }
  3256. else if(x.heavy && !y.heavy){
  3257. fire("keyup",{"keyCode":heavy},Gdocument.getElementById("gamerenderer"));
  3258. }
  3259. if(!x.special && y.special){
  3260. fire("keydown",{"keyCode":special},Gdocument.getElementById("gamerenderer"));
  3261. }
  3262. else if(x.special && !y.special){
  3263. fire("keyup",{"keyCode":special},Gdocument.getElementById("gamerenderer"));
  3264. }
  3265. };
  3266. scope.getplayerkeys = function(){
  3267. var keykeys = Object.keys(keyCodes);
  3268. var keyslist = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[1].children).slice(1);
  3269. var keyslist2 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[2].children).slice(1);
  3270. var keyslist3 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[3].children).slice(1);
  3271. var keyslist4 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[4].children).slice(1);
  3272. var keyslist5 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[5].children).slice(1);
  3273. var keyslist6 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[6].children).slice(1);
  3274. for(var i = 0;i<keyslist.length;i++){
  3275. if(keykeys.includes(keyslist[i].textContent)){
  3276. leftRight[0] = keyCodes[keyslist[i].textContent];
  3277. break;
  3278. }
  3279. else{
  3280. leftRight[0] = keyslist[i].textContent.charCodeAt(0);
  3281. break
  3282. }
  3283. }
  3284. for(var i = 0;i<keyslist2.length;i++){
  3285. if(keykeys.includes(keyslist2[i].textContent)){
  3286. leftRight[1] = keyCodes[keyslist2[i].textContent];
  3287. break;
  3288. }
  3289. else{
  3290. leftRight[1] = keyslist2[i].textContent.charCodeAt(0);
  3291. break
  3292. }
  3293. }
  3294. for(var i = 0;i<keyslist3.length;i++){
  3295. if(keykeys.includes(keyslist3[i].textContent)){
  3296. upDown[0] = keyCodes[keyslist3[i].textContent];
  3297. break;
  3298. }
  3299. else{
  3300. upDown[0] = keyslist3[i].textContent.charCodeAt(0);
  3301. break
  3302. }
  3303. }
  3304. for(var i = 0;i<keyslist4.length;i++){
  3305. if(keykeys.includes(keyslist4[i].textContent)){
  3306. upDown[1] = keyCodes[keyslist4[i].textContent];
  3307. break;
  3308. }
  3309. else{
  3310. upDown[1] = keyslist4[i].textContent.charCodeAt(0);
  3311. break
  3312. }
  3313. }
  3314. for(var i = 0;i<keyslist5.length;i++){
  3315. if(keykeys.includes(keyslist5[i].textContent)){
  3316. heavy = keyCodes[keyslist5[i].textContent];
  3317. break;
  3318. }
  3319. else{
  3320. heavy = keyslist5[i].textContent.charCodeAt(0);
  3321. break
  3322. }
  3323. }
  3324. for(var i = 0;i<keyslist6.length;i++){
  3325. if(keykeys.includes(keyslist6[i].textContent)){
  3326. special = keyCodes[keyslist6[i].textContent];
  3327. break;
  3328. }
  3329. else{
  3330. special = keyslist6[i].textContent.charCodeAt(0);
  3331. break
  3332. }
  3333. }
  3334. };
  3335. scope.changeJukeboxURL = function(url,timestamp = 0){
  3336. if(pipedurllist.length == 0){
  3337. displayInChat("The jukebox is still being set up.","#DA0808","#1EBCC1");
  3338. return;
  3339. }
  3340. if(url == ""){
  3341. jukeboxplayer.pause();
  3342. jukeboxplayer.src = '';
  3343. displayInChat("The jukebox has been paused.","#DA0808","#1EBCC1");
  3344. }
  3345. else if(url == jukeboxplayerURL && Date.now()-timestamp >= 2000){
  3346. jukeboxplayer.volume = jukeboxplayervolume/100;
  3347. displayInChat("The jukebox has been unpaused.","#DA0808","#1EBCC1",{sanitize:false});
  3348. jukeboxplayer.play();
  3349. jukeboxplayer.currentTime = (Date.now()-timestamp)/1000;
  3350. }
  3351. else{
  3352. var id = url.match(/youtu\.?be.com\/watch\?.*v=[a-z|A-Z|0-9|_|-]{11}/)[0].split("?v=");
  3353. id = id[id.length-1];
  3354. var loaded = false;
  3355. var loaded2 = 0;
  3356. for(var inst = 0;inst<pipedindexes.length;inst++){
  3357. checkJukeboxStream(pipedindexes[inst],id).then(function(value){
  3358. loaded2+=1;
  3359. if(value!=-1 && !loaded){
  3360. loaded = true;
  3361. jukeboxplayer.src = value[0];
  3362. jukeboxplayer.volume = jukeboxplayervolume/100;
  3363. jukeboxplayerURL = url;
  3364. jukeboxplayer.oncanplaythrough = function(){
  3365. displayInChat("The jukebox has been changed to: ","#DA0808","#1EBCC1",{sanitize:false},url);
  3366. displayInChat("Jukebox is now playing: "+value[1]+" by "+value[2]+".","#DA0808","#1EBCC1");
  3367. jukeboxplayer.play();
  3368. jukeboxplayer.currentTime = (Date.now()-timestamp)/1000;
  3369. jukeboxplayer.oncanplaythrough = null;
  3370. };
  3371. jukeboxplayer.onerror = function(){
  3372. displayInChat("The jukebox failed to load. Please try again.","#DA0808","#1EBCC1");
  3373. };
  3374. }
  3375. });
  3376. }
  3377. new Promise(function(r){
  3378. var interv = setInterval(function(){
  3379. if(loaded2>=pipedindexes.length){
  3380. if(!loaded){
  3381. displayInChat("The jukebox failed to load. Please try again.","#DA0808","#1EBCC1");
  3382. }
  3383. clearInterval(interv);
  3384. }
  3385. },60)
  3386. });
  3387. }
  3388. };
  3389. 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"];
  3390.  
  3391. scope.adv_help = {"help":"Shows all command names.",
  3392. "?":"Shows all command names.",
  3393. "advhelp":"Shows a command in detail.",
  3394. "space":"Toggles space. When space is on, whatever you type will be spaced apart.",
  3395. "rcaps":"Toggles rcaps. When rcaps is on, each letter will randomly get capitalized.",
  3396. "number":"Toggles number. When number is on, 'a' becomes 4, 'e' becomes 3, 's' becomes 5, 'o' becomes 0, 'l' and 'i' become 1.",
  3397. "speech":"Turns on text to speech for the chat.",
  3398. "savedroom":"Displays all the rooms you have saved, you can remove individual ones from the saved rooms by clicking \"Remove\".",
  3399. "clearsavedroom":"Clears all the saved rooms.",
  3400. "echo":"Echoes a username. It copies the username's chat messages.",
  3401. "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.",
  3402. "remove":"Removes username from echo list. You will not echo that username anymore.",
  3403. "clearecho":"Clears echo list. You will not echo anyone anymore.",
  3404. "chatw":"It private chats with username. Type /msg to message that username.",
  3405. "msg":"Messages with what username you are chatting with. Type /chatw to chat with a username.",
  3406. "ignorepm":"Ignores the username's private chat messages. To unignore, type '/ignorepm [username]'.",
  3407. "pmusers":"Dispays who you can private chat with.",
  3408. "pollstat":"Displays the current poll and its votes.",
  3409. "eval":"Evaluates code. Only use this if you are experienced in javascript.",
  3410. "debugger":"Opens debugger.",
  3411. "style":"Change the color of your username, level, and background. For example, '/style 255 0 0' will make your username red.",
  3412. "translate":"Translates peoples texts to the chosen language.",
  3413. "translateto":"You will now speak the chosen language.",
  3414. "autocorrect":"Fixes spelling mistakes.",
  3415. "randomchat":"Spams random chat messages from the past.",
  3416. "lobby":"Makes lobby visible when you are ingame. Type '/lobby' again to close lobby.",
  3417. "score":"Displays the current score while ingame. Type '/score' again to hide the score.",
  3418. "team":"Joins a specific team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  3419. "scroll":"Toggles a scrollbar in ingame chat.",
  3420. "followcam":"Enables follow camera. Your character will be centered on the screen.",
  3421. "autocam":"Zooms in/out enough for you to see everyone on the screen.",
  3422. "zoom":"Zooms in, out, or resets zoom.",
  3423. "xray":"Removes all shapes that don't have a shadow. This means all non-physics shapes will be hidden.",
  3424. "aimbot":"Toggles aimbot. Aimbot will aim for you in arrows or death arrows mode.",
  3425. "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.",
  3426. "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.",
  3427. "lagbot":"Makes your movements very laggy. Type '/lagbot 0' to turn it off.",
  3428. "hidechat":"Hides ingame chat. Type '/showchat' to show it again.",
  3429. "showchat":"Shows ingame chat. '/hidechat' hides the chat.",
  3430. "notify":"You will be notified if a person types @username",
  3431. "stopnotify":"You will not be notified if a person types @username",
  3432. "support":"Displays all the people who have supported this mod.",
  3433. "startqp":"Starts cycling maps in your map menu.",
  3434. "stopqp":"Stops cycling maps in your map menu.",
  3435. "revqp":"Reverses the order of quickplay. '/next', '/previous' will be inverted.",
  3436. "pauseqp":"Only pauses or unpauses the quickplay cycle due to round end. '/next', '/previous' still work. Type 'pauseqp' to unpause quickplay.",
  3437. "next":"Skips the map. Usable only with '/startqp'.",
  3438. "nextafter":"Skips the map if no one is able to win/draw within a certain amount of time.",
  3439. "previous":"Goes to previous map. Usable only with '/startqp'.",
  3440. "shuffle":"Makes quickplay play random maps instead of in order.",
  3441. "freejoin":"Toggles freejoin. If freejoin is on, starts the game instantly if there are 1 or less players currently playing.",
  3442. "recmode":"In quickplay, it switches mode to recommended mode, according to editor.",
  3443. "recteam":"In quickplay, it sorts people into teams when teams are necessary.",
  3444. "defaultmode":"Switches mode to defaultmode if there is no recmode.",
  3445. "start":"Starts game instantly.",
  3446. "instaqp":"Rounds will instantly start without a countdown.",
  3447. "balanceA":"Balances everyone with balance number.",
  3448. "moveA":"Sets everyones team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  3449. "jointeam":"Sets the team of anyone who joins. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  3450. "moveT":"Sets everyone in one team to another team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  3451. "rounds":"Sets rounds to win.",
  3452. "replay":"Replays the movements that were recorded",
  3453. "record":"Records movements of the username",
  3454. "delrecording":"Deletes the recording with the name.",
  3455. "saverecording":"Saves the recording with the name.",
  3456. "loadrecording":"Loads the recording with the name. Type '/replay' to replay it.",
  3457. "stoprecord":"Stops recording the player. Type '/saverecording [text]' to save it.",
  3458. "jukebox":"Sets the jukebox to a link. That link will play for everyone who has this mod.",
  3459. "volume":"Sets the volume of the jukebox.",
  3460. "pausejukebox":"If the jukebox is playing, it pauses it.",
  3461. "resetjukebox":"Resets the jukebox, so it starts from the very beginning.",
  3462. "playjukebox":"If the jukebox is paused, it plays it.",
  3463. "roundsperqp":"After that many rounds, the map will change. Normally, the map will change after 1 round.",
  3464. "autorecord":"After a round ends, automatically records the last 15 seconds.",
  3465. "mode":"If host, switches mode. Otherwise, it requests the host to switch mode, as long as the host has this mod.",
  3466. "disablekeys":"If anyone presses a disabled key, they get killed. Key options: left right up down heavy special.",
  3467. "jointext":"Chats the jointext whenever someone joins. \"username\" will get replaced by the joining person's username.",
  3468. "wintext":"Chats the wintext whenever someone wins. \"username\" will get replaced by the winning person's username.",
  3469. "afkkill":"If a person stays afk for that many seconds, they get automatically killed.",
  3470. "ban":"Bans username from lobby. If they rejoin, it automatically bans.",
  3471. "kill":"Kills the person ingame.",
  3472. "resetpoll":"Clears the poll.",
  3473. "addoption":"Adds the option to the poll. You can only have 4 maximum options. Type '/deloption [letter]' to remove an option.",
  3474. "deloption":"Removes the option with that letter.",
  3475. "startpoll":"Starts a poll that lasts for at least 10 seconds. Type '/endpoll' to end it early.",
  3476. "endpoll":"Ends the poll early if the poll lasted for at least 10 seconds.",
  3477. "addplayer":"In sandbox, it adds bots.",
  3478. "addname":"Adds a bot with a specific name. If that name already exists, it will copy the skin of that player to the bot.",
  3479. "delplayer":"In sandbox, it deletes bots.",
  3480. "copy":"In sandbox, it makes all bots copy the username's movements.",
  3481. "sandbox":"Turns a normal lobby into a sandbox lobby. You cannot turn a sandbox lobby back into a normal lobby.",
  3482. "autokick":"Automatically kicks everyone who is not using this mod.",
  3483. "autoban":"Automatically bans everyone who is not using this mod.",
  3484. "Alt L":"Makes lobby visible when you are ingame. Press Alt L again to close lobby.",
  3485. "Alt C":"Hides ingame chat. Press Alt C again to show ingame chat.",
  3486. "Alt S":"Starts game instantly.",
  3487. "Alt T":"Toggles teams.",
  3488. "Alt N":"Enables follow camera. Your character will be centered on the screen.",
  3489. "Alt G":"Zooms in.",
  3490. "Alt H":"Resets zoom.",
  3491. "Alt J":"Zooms out.",
  3492. "Alt Y":"Enables xray. Removes all shapes that don't have a shadow. This means all non-physics shapes will be hidden.",
  3493. "Alt E":"Toggles editor.",
  3494. "Alt K":"Exits ingame and returns to lobby.",
  3495. "Alt M":"Switches modes.",
  3496. "Alt V":"Toggles autocam. Autocam zooms in/out enough for you to see everyone on the screen.",
  3497. "Alt Q":"Toggles quickplay.",
  3498. "Alt B":"Displays the current score while ingame. Press Alt B again to hide the score.",
  3499. "Alt A":"Skips the map if quickplay is on.",
  3500. "Alt D":"Goes to previous map if quickplay is on.",
  3501. "Alt F":"Toggles freejoin. If freejoin is on, starts the game instantly if there are 1 or less players currently playing.",
  3502. "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.",
  3503. "Alt U":"Toggles aimbot. Aimbot will aim for you in arrows or death arrows mode.",
  3504. "Alt P":"Only pauses or unpauses the quickplay cycle due to round end. '/next', '/previous' still work. Type 'pauseqp' to unpause quickplay.",
  3505. "Alt R":"In quickplay, it switches mode to recommended mode, according to editor.",
  3506. "Alt I":"Opens debugger.",
  3507. "Alt W":"Saves your position, and tries to reach it constantly. This is useful in parkour if you want to go afk.",
  3508. "Alt <":"Lowers ingame chat height.",
  3509. "Alt >":"Highers ingame chat height."
  3510. };
  3511. scope.displayadvhelp = function(command){
  3512. displayInChat(adv_help[command],"#009398","#DA0808",{sanitize:true},"",true);
  3513. };
  3514. scope.changemode = function(mode){
  3515. SEND('42[20,{"ga":"b","mo":"'+mode+'"}]');
  3516. RECIEVE('42[26,"b","'+mode+'"]');
  3517. };
  3518. Gdocument.getElementById("ingamechatcontent").style["pointer-events"]="all";
  3519. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  3520. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  3521. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  3522.  
  3523. document.getElementById('adboxverticalCurse').style["display"] = "none";
  3524. document.getElementById('adboxverticalleftCurse').style["display"] = "none";
  3525. elem.onclick=function(e){
  3526. if(stopquickplay==0 && ishost == true && e.isTrusted == true){
  3527. quicki = (Array.from(e.target.parentElement.parentNode.children).indexOf(e.target.parentNode)-1)%(Gdocument.getElementById("maploadwindowmapscontainer").children.length);
  3528. if(reverseqp){
  3529. quicki+=2;
  3530. quicki = quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length);
  3531. }
  3532. }
  3533. };
  3534. scope.getCurrentFrame = function(){
  3535. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  3536. return currentFrame;
  3537. };
  3538. scope.urlify = function(text) {
  3539. if(!Gdocument.getElementById('bl_Menu')){
  3540. return text.replace(/[(http(s)?):\/\/(www\.)?a-zA-Z0-9@:;%.\-_\+~#=]{2,256}\.[\-a-z]{2,6}\b([\-a-zA-Z0-9@:;%_\+.~#?&//=]*)/ig, function(url) {
  3541. var extratext = "";
  3542. var matches = url.match(/youtu\.?be.com\/watch\?.*v=[a-z|A-Z|0-9|_|-]{11}/);
  3543. if(matches){
  3544. var button = Gdocument.createElement("a");
  3545. button.style["color"] = "green";
  3546. button.textContent = "Play";
  3547. button.href = "javascript:void(0)";
  3548. button.setAttribute("onclick",function(){
  3549. if(Gwindow.ishost){
  3550. Gwindow.SEND("42"+JSON.stringify([4,{"type":"video player","from":Gwindow.username,"url":"URL INSERT HERE","timestamp":Gwindow.Date.now()+2000,"to":[-1]}]));
  3551. Gwindow.displayInChat("Jukebox is loading... Please wait a few seconds.","#DA0808","#1EBCC1");
  3552. Gwindow.changeJukeboxURL("URL INSERT HERE",Gwindow.Date.now()+2000);
  3553. }
  3554. else{
  3555. Gwindow.displayInChat("You need to be host.","#DA0808","#1EBCC1");
  3556. }
  3557. });
  3558. button.attributes["onclick"].nodeValue = button.attributes["onclick"].nodeValue.slice(11,-1).replaceAll("URL INSERT HERE","https://www."+matches[0]);
  3559. var extratext = ' ['+button.outerHTML+']';
  3560. }
  3561. if(url.startsWith('https://') || url.startsWith('http://')){return '<a href="' + url + '" target="_blank" style = "color:orange">' + sanitize(url) + '</a>'+extratext;}
  3562. else{return '<a href="https://' + url + '" target="_blank" style = "color:orange">' + sanitize(url) + '</a>'+extratext;}
  3563. })}return text;
  3564. };
  3565. scope.fire = function(type,options,d = Gdocument){
  3566. var event= document.createEvent("HTMLEvents");
  3567. event.initEvent(type,true,false);
  3568. for(var p in options){
  3569. event[p]=options[p];
  3570. }
  3571. d.dispatchEvent(event);
  3572. };
  3573.  
  3574. scope.chat = function(message){
  3575. SEND('42[10,{"message":'+JSON.stringify(message)+'}]');
  3576. };
  3577. scope.chat2 = function(message,enteragain=false){
  3578. mess = Gdocument.getElementById("newbonklobby_chat_input").value;
  3579. mess2 = Gdocument.getElementById("ingamechatinputtext").value;
  3580. Gdocument.getElementById("newbonklobby_chat_input").value = message;
  3581. Gdocument.getElementById("ingamechatinputtext").value = message;
  3582. fire("keydown",{keyCode:13});
  3583. if(!enteragain){
  3584. fire("keydown",{keyCode:13});
  3585. }
  3586. Gdocument.getElementById("newbonklobby_chat_input").value = mess;
  3587. Gdocument.getElementById("ingamechatinputtext").value = mess2;
  3588. };
  3589. scope.sanitize = function(message){
  3590. return message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;');
  3591. };
  3592. scope.displayInChat = function(message, LobbyColor, InGameColor, options, message2, BringDown) {
  3593. options = options ?? {};
  3594. BringDown = BringDown ?? false;
  3595. message2 = message2 ?? "";
  3596. LobbyColor = LobbyColor ?? "#8800FF";
  3597. InGameColor = InGameColor ?? "#AA88FF";
  3598. var A = Gdocument.createElement("div");
  3599. var B = Gdocument.createElement("span");
  3600. B.className = "newbonklobby_chat_status";
  3601. B.style.color = LobbyColor;
  3602. A.appendChild(B);
  3603. B.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  3604. B.innerHTML+=urlify(message2.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;'));
  3605. var C = Gdocument.createElement("div");
  3606. var D = Gdocument.createElement("span");
  3607. D.style.color = InGameColor;
  3608. C.appendChild(D);
  3609. D.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  3610. D.innerHTML+=urlify(message2.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;'));
  3611. var a = BringDown;
  3612. if(Gdocument.getElementById("newbonklobby_chat_content").clientHeight + Gdocument.getElementById("newbonklobby_chat_content").scrollTop >= Gdocument.getElementById("newbonklobby_chat_content").scrollHeight-1) {
  3613. a = true;
  3614. }
  3615. var b = BringDown;
  3616. if(Gdocument.getElementById("ingamechatcontent").clientHeight + Gdocument.getElementById("ingamechatcontent").scrollTop >= Gdocument.getElementById("ingamechatcontent").scrollHeight-1) {
  3617. b = 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 = Gdocument.getElementById("newbonklobby_chat_content").scrollHeight;};
  3624. if (b) { Gdocument.getElementById("ingamechatcontent").scrollTop = Gdocument.getElementById("ingamechatcontent").scrollHeight;};
  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[0]+array[1]+array[2] == 0){
  4453. array = [1,1,1];
  4454. }
  4455. if(array.length == 3){
  4456. SEND("42"+JSON.stringify([4,{"type":"style","from":username,"style":array}]));
  4457. allstyles[username] = array;
  4458. mystyle = [...array];
  4459. displayInChat("Set style to ("+array.toString()+"). Type '/style' to reset style.","#DA0808","#1EBCC1");
  4460. }
  4461. else{
  4462. displayInChat("Please enter a valid RGB color code seperated by space. For example, white = '/style 255 255 255'. Type '/style' to reset style.","#DA0808","#1EBCC1");
  4463. }
  4464. return "";
  4465. }
  4466. else if (chat_val.substring(1,6)=="style"){
  4467. SEND("42"+JSON.stringify([4,{"type":"style","from":username,"style":[0,0,0]}]));
  4468. allstyles[username] = [0,0,0];
  4469. mystyle = [0,0,0];
  4470. displayInChat("Reset style.","#DA0808","#1EBCC1");
  4471. return "";
  4472. }
  4473. else if (chat_val.substring(1,6)=="lobby"){
  4474. lobby();
  4475. return "";
  4476. }
  4477. else if (chat_val.substring(1,9)=="debugger"){
  4478. if(Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"] == "none"){
  4479. debuggeropen = true;
  4480. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="block";
  4481. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="none";
  4482. Gdocument.getElementById("ingamechatinputtext").style["display"] = "none";
  4483. }
  4484. else{
  4485. debuggeropen = false;
  4486. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="none";
  4487. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  4488. Gdocument.getElementById("ingamechatinputtext").style["display"] = "";
  4489. }
  4490. return "";
  4491. }
  4492. else if (chat_val.substring(1,6)=="team " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  4493. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  4494. if(text == "r"){Gdocument.getElementById("newbonklobby_redbutton").click();}
  4495. else if(text == "g"){Gdocument.getElementById("newbonklobby_greenbutton").click();}
  4496. else if(text == "y"){Gdocument.getElementById("newbonklobby_yellowbutton").click();}
  4497. else if(text == "b"){Gdocument.getElementById("newbonklobby_bluebutton").click();}
  4498. else if(text == "s"){Gdocument.getElementById("newbonklobby_specbutton").click();}
  4499. else if(text == "f"){Gdocument.getElementById("newbonklobby_ffabutton").click();}
  4500. return "";
  4501. }
  4502. else if (chat_val.substring(1,7)=="notify"){
  4503. npermissions = 1;
  4504. return "";
  4505. }
  4506. else if (chat_val.substring(1,11)=="stopnotify"){
  4507. npermissions = 0;
  4508. return "";
  4509. }
  4510. else if (chat_val.substring(1,8)=="support"){
  4511. displayInChat("Thanks everyone for helping me make this mod - LEGENDBOSS123","#0000FF","#FFFFFF");
  4512. displayInChat("mastery3","#0000FF","#FFFFFF");
  4513. displayInChat("UnmatchedBracket aka Left Paren","#0000FF","#FFFFFF");
  4514. displayInChat("iNeonz","#0000FF","#FFFFFF");
  4515. return "";
  4516. }
  4517. else if (chat_val.substring(1,9)=="pollstat"){
  4518. if(pollactive[0] || pollactive2[0]){
  4519. var count = [0,0,0,0];
  4520. var keys = Object.keys(playerids);
  4521. for(var i = 0;i<keys.length;i++){
  4522. if(ishost){
  4523. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive[3].length-1){
  4524. count[playerids[keys[i]].vote.poll]++;
  4525. }
  4526. }
  4527. else{
  4528. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive2[2].length-1){
  4529. count[playerids[keys[i]].vote.poll]++;
  4530. }
  4531. }
  4532. }
  4533. for(var i = 0;i<count.length;i++){
  4534. if(count[i]>1){
  4535. displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  4536. }
  4537. if(count[i]==1){
  4538. displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  4539. }
  4540. }
  4541. if(ishost){
  4542. displayInChat("The poll will end in: "+((pollactive[2]-Date.now())/1000).toString()+" seconds.","#DA0808","#1EBCC1");
  4543. }
  4544. displayInChat("The poll is:","#DA0808","#1EBCC1");
  4545. if(ishost){
  4546. for(var i = 0;i<pollactive[3].length;i++){
  4547. displayInChat(letters[i]+") "+pollactive[3][i],"#DA0808","#1EBCC1");
  4548. }
  4549. }
  4550. else{
  4551. for(var i = 0;i<pollactive2[2].length;i++){
  4552. displayInChat(letters[i]+") "+pollactive2[2][i],"#DA0808","#1EBCC1");
  4553. }
  4554. }
  4555. }
  4556. else{
  4557. displayInChat("No poll has been started.","#DA0808","#1EBCC1");
  4558. if(ishost){
  4559. displayInChat("Type '/startpoll [seconds]' to start a poll.","#DA0808","#1EBCC1");
  4560. if(poll.length>0){
  4561. displayInChat("The poll is:","#DA0808","#1EBCC1");
  4562. for(var i = 0;i<poll.length;i++){
  4563. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  4564. }
  4565. }
  4566. }
  4567. }
  4568. return "";
  4569. }
  4570. else if (chat_val.substring(1,5)=="help" || chat_val.substring(1,2)=="?"){
  4571. for(var i = 0;i<help.length;i++){
  4572. if(help[i].startsWith("/")){
  4573. var splitted = help[i].substring(1).split(" ");
  4574. var command = splitted[0];
  4575. var rest = "";
  4576. if(splitted.length>1){
  4577. rest = " "+splitted.slice(1).join(" ");
  4578. }
  4579. displayInChat("/"+'<a onclick = \'Gwindow.displayadvhelp("'+command+'");\' style = "color:green;" href = "javascript:void(0);">'+command+'</a>'+rest,"#DA0808","#1EBCC1",{sanitize:false},"",false);
  4580. }
  4581. else if(help[i].startsWith("Alt ")){
  4582. displayInChat('<a onclick = \'Gwindow.displayadvhelp("'+help[i]+'");\' style = "color:green;" href = "javascript:void(0);">'+help[i]+'</a>',"#DA0808","#1EBCC1",{sanitize:false},"",false);
  4583. }
  4584. else{
  4585. displayInChat(help[i],"#DA0808","#1EBCC1");
  4586. }
  4587.  
  4588. }
  4589. return "";
  4590. }
  4591. else if (chat_val.substring(1,9)=="advhelp " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  4592. var text = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  4593. if(typeof(adv_help[text])!='undefined'){
  4594. displayInChat(adv_help[text],"#DA0808","#1EBCC1");
  4595. }
  4596. return "";
  4597. }
  4598. else if (chat_val.substring(1,6)=="mode " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  4599. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  4600. var mode = "";
  4601. var text2 = text;
  4602. if(text == "arrows"){
  4603. text2 = "Arrows";
  4604. mode = "ar";
  4605. }
  4606. else if(text == "death arrows"){
  4607. mode = "ard";
  4608. text2 = "Death Arrows";
  4609. }
  4610. else if(text == "grapple"){
  4611. mode = "sp";
  4612. text2 = "Grapple";
  4613. }
  4614. else if(text == "classic"){
  4615. mode = "b";
  4616. text2 = "Classic";
  4617. }
  4618. else{
  4619. displayInChat("Mode options:","#DA0808","#1EBCC1");
  4620. displayInChat("classic","#DA0808","#1EBCC1");
  4621. displayInChat("arrows","#DA0808","#1EBCC1");
  4622. displayInChat("death arrows","#DA0808","#1EBCC1");
  4623. displayInChat("grapple","#DA0808","#1EBCC1");
  4624. }
  4625. if(mode != ""){
  4626. if(ishost){
  4627. SEND('42[20,{"ga":"b","mo":"'+mode+'"}]');
  4628. RECIEVE('42[26,"b","'+mode+'"]');
  4629. displayInChat("Changed mode to "+text+".","#DA0808","#1EBCC1");
  4630. }
  4631. else{
  4632. if(playerids[myid].ratelimit.mode+1000<Date.now()){
  4633. playerids[myid].ratelimit.mode=Date.now();
  4634. SEND("42"+JSON.stringify([4,{"type":"request mode","from":username,"mode":mode}]));
  4635. var code = 'if(!Gwindow.ishost){Gwindow.displayInChat("You must be host to change the mode.","#DA0808","#1EBCC1",{sanitize:false},"",true)}else{Gwindow.changemode("'+mode+'")}';
  4636. displayInChat('> '+username+' requests [<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+text2+'</a>]',"#DA0808","#1EBCC1",{sanitize:false}," mode.");
  4637.  
  4638. }
  4639. else{
  4640. displayInChat("You are requesting modes too quickly.","#DA0808","#1EBCC1");
  4641. }
  4642. }
  4643. }
  4644. return "";
  4645.  
  4646. }
  4647. else if(ishost){
  4648. if (chat_val.substring(1,11)=="nextafter " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  4649. var text = parseFloat(chat_val.substring(11).replace(/^\s+|\s+$/g, ''));
  4650. if(isNaN(text)){
  4651. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  4652. return "";
  4653. }
  4654. else if(text<=0){
  4655. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  4656. return "";
  4657. }
  4658. nextafter = text;
  4659. displayInChat("Set next after to: " + text.toString()+" seconds.","#DA0808","#1EBCC1");
  4660. displayInChat("Type '/nextafter' to reset next after.","#DA0808","#1EBCC1");
  4661. return "";
  4662.  
  4663. }
  4664. else if (chat_val.substring(1,10)=="nextafter"){
  4665. nextafter = 0;
  4666. displayInChat("Reset next after.","#DA0808","#1EBCC1");
  4667. return "";
  4668.  
  4669. }
  4670. else if (chat_val.substring(1,5)=="next" && stopquickplay == 0){
  4671. roundsperqp2 = 0;
  4672. if(shuffle){
  4673. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4674. var available = [];
  4675. var availableindexes = [];
  4676. var notempty = false;
  4677. for(var i = 0; i<e.length;i++){
  4678. var a = false;
  4679. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4680. available.push(a);
  4681. if(a){
  4682. availableindexes.push(i);
  4683. notempty = true;
  4684. }
  4685. }
  4686. if(notempty){
  4687.  
  4688. if(availableindexes.length!=1){
  4689. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  4690. }
  4691. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  4692. }
  4693. }
  4694. else{
  4695. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4696. var available = [];
  4697. var availableindexes = [];
  4698. var notempty = false;
  4699. for(var i = 0; i<e.length;i++){
  4700. var a = false;
  4701. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4702. available.push(a);
  4703. if(a){
  4704. availableindexes.push(i);
  4705. notempty = true;
  4706. }
  4707. }
  4708. if(notempty){
  4709. var above = [];
  4710. for(var i = 0;i<availableindexes.length;i++){
  4711. if(availableindexes[i]>quicki && !reverseqp){
  4712. above.push(availableindexes[i]);
  4713. }
  4714. else if(availableindexes[i]<quicki && reverseqp){
  4715. above.push(availableindexes[i])
  4716. }
  4717. }
  4718. if(above.length>0){
  4719. quicki = above[0];
  4720. if(reverseqp){
  4721. quicki = above[above.length-1];
  4722. }
  4723. }
  4724. else{
  4725. quicki = availableindexes[0];
  4726. if(reverseqp){
  4727. quicki = availableindexes[availableindexes.length-1];
  4728. }
  4729. }
  4730. }
  4731. }
  4732. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  4733. displayInChat("Switched to next map.","#DA0808","#1EBCC1");
  4734. return "";
  4735.  
  4736. }
  4737. else if (chat_val.substring(1,9)=="freejoin"){
  4738. if(freejoin == false){
  4739. freejoin = true;
  4740. displayInChat("Freejoin is now on.","#DA0808","#1EBCC1");
  4741.  
  4742. }
  4743. else{
  4744. freejoin = false;
  4745. displayInChat("Freejoin is now off.","#DA0808","#1EBCC1");
  4746. }
  4747.  
  4748. return "";
  4749.  
  4750. }
  4751. else if (chat_val.substring(1,8)=="instaqp"){
  4752. if(instaqp == false){
  4753. instaqp = true;
  4754. displayInChat("Instaqp is now on.","#DA0808","#1EBCC1");
  4755.  
  4756. }
  4757. else{
  4758. instaqp = false;
  4759. displayInChat("Instaqp is now off.","#DA0808","#1EBCC1");
  4760. }
  4761.  
  4762. return "";
  4763.  
  4764. }
  4765.  
  4766. else if (chat_val.substring(1,9)=="previous" && stopquickplay == 0){
  4767. roundsperqp2 = 0;
  4768. if(shuffle){
  4769. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4770. var available = [];
  4771. var availableindexes = [];
  4772. var notempty = false;
  4773. for(var i = 0; i<e.length;i++){
  4774. var a = false;
  4775. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4776. available.push(a);
  4777. if(a){
  4778. availableindexes.push(i);
  4779. notempty = true;
  4780. }
  4781. }
  4782. if(notempty){
  4783.  
  4784. if(availableindexes.length!=1){
  4785. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  4786. }
  4787. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  4788. }
  4789. }
  4790. else{
  4791. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4792. var available = [];
  4793. var availableindexes = [];
  4794. var notempty = false;
  4795. for(var i = 0; i<e.length;i++){
  4796. var a = false;
  4797. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4798. available.push(a);
  4799. if(a){
  4800. availableindexes.push(i);
  4801. notempty = true;
  4802. }
  4803. }
  4804. if(notempty){
  4805. var above = [];
  4806. for(var i = 0;i<availableindexes.length;i++){
  4807. if(availableindexes[i]<quicki && !reverseqp){
  4808. above.push(availableindexes[i]);
  4809. }
  4810. else if(availableindexes[i]>quicki && reverseqp){
  4811. above.push(availableindexes[i])
  4812. }
  4813. }
  4814. if(above.length>0){
  4815. quicki = above[above.length-1];
  4816. if(reverseqp){
  4817. quicki = above[0];
  4818. }
  4819. }
  4820. else{
  4821. quicki = availableindexes[availableindexes.length-1];
  4822. if(reverseqp){
  4823. quicki = availableindexes[0];
  4824. }
  4825. }
  4826. }
  4827. }
  4828. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  4829.  
  4830. displayInChat("Switched to previous map.","#DA0808","#1EBCC1");
  4831. return "";
  4832. }
  4833. else if (chat_val.substring(1,6)=="start" && chat_val.length == 6){
  4834. if(Gdocument.getElementById("mapeditorcontainer").style["display"]!="block"){
  4835. Gdocument.getElementById("newbonklobby_editorbutton").click();
  4836. }
  4837. if(recmodebool && ishost){
  4838. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  4839. if(mode == "" && defaultmode!="d"){
  4840. mode = defaultmode;
  4841. }
  4842. if(mode != ""){
  4843. RECIEVE('42[26,"b","'+mode+'"]');
  4844. }
  4845. }
  4846. Gdocument.getElementById("mapeditor_close").click();
  4847. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  4848. roundsperqp2 = 0;
  4849. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  4850.  
  4851. return "";
  4852. }
  4853.  
  4854. else if (chat_val.substring(1,8)=="startqp" && stopquickplay == 1){
  4855. stopquickplay = 0;
  4856. quicki = 0;
  4857. qppaused = false;
  4858. displayInChat("Enabled quickplay.","#DA0808","#1EBCC1");
  4859. return "";
  4860. }
  4861. else if (chat_val.substring(1,7)=="stopqp" && stopquickplay == 0){
  4862. stopquickplay = 1;
  4863. quicki = 0;
  4864. qppaused = false;
  4865. displayInChat("Disabled quickplay.","#DA0808","#1EBCC1");
  4866. return "";
  4867. }
  4868. else if (chat_val.substring(1,8)=="pauseqp" && stopquickplay == 0){
  4869. if(qppaused == false){
  4870. qppaused = true;
  4871. displayInChat("Paused quickplay.","#DA0808","#1EBCC1");
  4872. }
  4873. else{
  4874. qppaused = false;
  4875. displayInChat("Unpaused quickplay.","#DA0808","#1EBCC1");
  4876. }
  4877. return "";
  4878. }
  4879. else if (chat_val.substring(1,6)=="revqp" && stopquickplay == 0){
  4880. if(reverseqp == false){
  4881. reverseqp = true;
  4882. displayInChat("Reverseqp is now on..","#DA0808","#1EBCC1");
  4883. }
  4884. else{
  4885. reverseqp = false;
  4886. displayInChat("Reverseqp is now off.","#DA0808","#1EBCC1");
  4887. }
  4888. return "";
  4889. }
  4890. else if (chat_val.substring(1,9)=="jukebox " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  4891. var text = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  4892. SEND("42"+JSON.stringify([4,{"type":"video player","from":username,"url":text,"timestamp":Date.now()+2000,"to":[-1]}]));
  4893. displayInChat("Jukebox is loading... Please wait a few seconds.","#DA0808","#1EBCC1");
  4894. changeJukeboxURL(text,Date.now()+2000);
  4895. return "";
  4896. }
  4897. else if (chat_val.substring(1,13)=="pausejukebox"){
  4898. if(jukeboxplayer.src!="" && !jukeboxplayer.paused){
  4899. displayInChat("Jukebox is now paused.","#DA0808","#1EBCC1");
  4900. jukeboxplayer.pause();
  4901. SEND("42"+JSON.stringify([4,{"type":"video player","from":username,"url":"","timestamp":Date.now(),"to":[-1]}]));
  4902. }
  4903. return "";
  4904. }
  4905. else if (chat_val.substring(1,13)=="resetjukebox"){
  4906. if(jukeboxplayer.src!=""){
  4907. jukeboxplayer.currentTime = 0;
  4908. displayInChat("Jukebox has reset.","#DA0808","#1EBCC1");
  4909. changeJukeboxURL(jukeboxplayerURL,Date.now()+2000);
  4910. SEND("42"+JSON.stringify([4,{"type":"video player","from":username,"url":jukeboxplayerURL,"timestamp":Date.now()+2000,"to":[-1]}]));
  4911. }
  4912. return "";
  4913. }
  4914. else if (chat_val.substring(1,12)=="playjukebox"){
  4915. if(jukeboxplayer.src!="" && jukeboxplayer.paused){
  4916. changeJukeboxURL(jukeboxplayerURL,Date.now()-jukeboxplayer.currentTime*1000);
  4917. SEND("42"+JSON.stringify([4,{"type":"video player","from":username,"url":jukeboxplayerURL,"timestamp":Date.now()-jukeboxplayer.currentTime*1000,"to":[-1]}]));
  4918. }
  4919. return "";
  4920. }
  4921. else if (chat_val.substring(1,5)=="ban " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  4922. banned.push(chat_val.substring(5).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',""));
  4923. displayInChat("Banned "+chat_val.substring(5).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"")+".","#DA0808","#1EBCC1");
  4924. return "/kick '" + chat_val.substring(5).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"") + "'";
  4925. }
  4926. else if (chat_val.substring(1,6)=="kill " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  4927. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  4928. var keys = Object.keys(playerids);
  4929. var killid = undefined;
  4930. for(var i = 0; i<keys.length; i++){
  4931. if(playerids[keys[i]].userName == text){
  4932. killid = keys[i];
  4933. }
  4934. }
  4935. if(typeof(killid)!="undefined" && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden" && !killedids.includes(killid)){
  4936. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  4937. killedids.push(killid);
  4938. SEND('42[25,{"a":{"playersLeft":['+killid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  4939. RECIEVE('42[31,{"a":{"playersLeft":['+killid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  4940. }
  4941. return "";
  4942. }
  4943. else if (chat_val.substring(1,10)=="balanceA " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  4944. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  4945. if(!isNaN(parseInt(text))){
  4946. if(parseInt(text)>=-100 && parseInt(text)<=100){
  4947. var keys = Object.keys(playerids);
  4948. for(var i = 0; i<keys.length;i++){
  4949. SEND('42[29,{"sid":'+keys[i]+',"bal":'+text+'}]');
  4950. RECIEVE('42[36,'+keys[i]+','+text+']');
  4951. }
  4952. }
  4953. }
  4954. return "";
  4955.  
  4956. }
  4957. else if (chat_val.substring(1,10)=="resetpoll"){
  4958. poll = [];
  4959. displayInChat("The poll has been reset.","#DA0808","#1EBCC1");
  4960. return "";
  4961. }
  4962. else if (chat_val.substring(1,11)=="addoption " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  4963. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  4964. if(text.length>50){
  4965. displayInChat("Your option is greater than 50 characters.","#DA0808","#1EBCC1");
  4966. return "";
  4967. }
  4968. if(poll.includes(text)){
  4969. displayInChat("This option already exists.","#DA0808","#1EBCC1");
  4970. }
  4971. else if(poll.length>=4){
  4972. displayInChat("Your poll already has the max 4 amounts of options.","#DA0808","#1EBCC1");
  4973. displayInChat("Type '/deloption [letter]' to remove a option.","#DA0808","#1EBCC1");
  4974. displayInChat("The poll is:","#DA0808","#1EBCC1");
  4975. for(var i = 0;i<poll.length;i++){
  4976. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  4977. }
  4978. }
  4979. else{
  4980. poll.push(text);
  4981. displayInChat("The poll is now:","#DA0808","#1EBCC1");
  4982. for(var i = 0;i<poll.length;i++){
  4983. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  4984. }
  4985. }
  4986. return "";
  4987. }
  4988. else if (chat_val.substring(1,11)=="deloption " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  4989. var text = letters.indexOf(chat_val.substring(11).replace(/^\s+|\s+$/g, ''));
  4990. if(text==-1 || text>=poll.length){
  4991. if(poll.length>0){
  4992. displayInChat("Available options are:","#DA0808","#1EBCC1");
  4993. for(var i = 0;i<poll.length;i++){
  4994. displayInChat(letters[i],"#DA0808","#1EBCC1");
  4995. }
  4996. }
  4997. else{
  4998. displayInChat("Your poll is empty.","#DA0808","#1EBCC1");
  4999. displayInChat("Type '/addoption [text]' to add an option.","#DA0808","#1EBCC1");
  5000. }
  5001. }
  5002. else{
  5003. poll.splice(text,1);
  5004. displayInChat("The poll is now:","#DA0808","#1EBCC1");
  5005. for(var i = 0;i<poll.length;i++){
  5006. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  5007. }
  5008. }
  5009. return "";
  5010. }
  5011. else if (chat_val.substring(1,11)=="startpoll " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  5012. var text = parseFloat(chat_val.substring(11).replace(/^\s+|\s+$/g, ''));
  5013. if(isNaN(text)){
  5014. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  5015. return "";
  5016. }
  5017. else if(text<=0){
  5018. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  5019. return "";
  5020. }
  5021. else if(text<10){
  5022. displayInChat("Your poll has to last for at least 10 seconds.","#DA0808","#1EBCC1");
  5023. return "";
  5024. }
  5025. if(pollactive[0]){
  5026. displayInChat("There is already an ongoing poll.","#DA0808","#1EBCC1");
  5027. displayInChat("Type '/endpoll' to end the poll.","#DA0808","#1EBCC1");
  5028. return "";
  5029. }
  5030. if(poll.length<2){
  5031. displayInChat("Your poll needs at least 2 options.","#DA0808","#1EBCC1");
  5032. displayInChat("Type '/addoption' to add to the poll.","#DA0808","#1EBCC1");
  5033. return "";
  5034. }
  5035. var now = Date.now();
  5036. pollactive = [true,now,now+text*1000,[...poll]];
  5037. playerids[myid].ratelimit.poll = now;
  5038. var chatpoll = [...poll];
  5039. chatpoll.push("Cancel vote.");
  5040. pollactive[3].push("Cancel vote.");
  5041. for(var i = 0;i<chatpoll.length;i++){
  5042. chatpoll[i] = letters[i]+") "+chatpoll[i];
  5043. }
  5044. chat(chatpoll.join("     "));
  5045. setTimeout(function(){
  5046. if(pollactive[0]){
  5047. SEND("42"+JSON.stringify([4,{"type":"poll","from":username,"poll":pollactive[3]}]));
  5048. var keys = Object.keys(playerids);
  5049. for(var i = 0;i<keys.length;i++){
  5050. playerids[keys[i]].vote.poll = -1;
  5051. }
  5052. displayInChat("The poll will end in: " + text.toString()+" seconds.","#DA0808","#1EBCC1");
  5053. displayInChat("Type '/endpoll' to end the poll early.","#DA0808","#1EBCC1");
  5054. }
  5055. },200);
  5056. return "";
  5057. }
  5058. else if (chat_val.substring(1,8)=="endpoll"){
  5059. if(pollactive[0]){
  5060. if(playerids[myid].ratelimit.poll+10000>Date.now()){
  5061. displayInChat("Your poll has to be at least 10 seconds.","#DA0808","#1EBCC1");
  5062. displayInChat("There are "+((playerids[myid].ratelimit.poll+10000-Date.now())/1000).toString()+" seconds left until you can end the poll early.","#DA0808","#1EBCC1");
  5063. return "";
  5064. }
  5065. playerids[myid].ratelimit.poll = Date.now();
  5066. SEND("42"+JSON.stringify([4,{"type":"poll end","from":username}]));
  5067. displayInChat("The poll ended.","#DA0808","#1EBCC1");
  5068. var count = [0,0,0,0];
  5069. var keys = Object.keys(playerids);
  5070. for(var i = 0;i<keys.length;i++){
  5071. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive[3].length-1){
  5072. count[playerids[keys[i]].vote.poll]++;
  5073. }
  5074. playerids[keys[i]].vote.poll = -1;
  5075. }
  5076. for(var i = 0;i<count.length;i++){
  5077. if(count[i]>1){
  5078. displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  5079. }
  5080. if(count[i]==1){
  5081. displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  5082. }
  5083. }
  5084. displayInChat("The poll was:","#DA0808","#1EBCC1");
  5085. for(var i = 0;i<pollactive[3].length;i++){
  5086. displayInChat(letters[i]+") "+pollactive[3][i],"#DA0808","#1EBCC1");
  5087. }
  5088. pollactive = [false,0,0,[]];
  5089. }
  5090. else{
  5091. displayInChat("No poll has been started","#DA0808","#1EBCC1");
  5092. displayInChat("Type '/startpoll [seconds]' to start a poll.","#DA0808","#1EBCC1");
  5093. }
  5094. return "";
  5095. }
  5096. else if (chat_val.substring(1,7)=="moveA " && chat_val.replace(/^\s+|\s+$/g, '').length>=8){
  5097. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '');
  5098. var keys = Object.keys(playerids);
  5099. var t = -1;
  5100. if(text == "f"){
  5101. t = 1;
  5102. }
  5103. else if(text == "b"){
  5104. t = 3;
  5105. }
  5106. else if(text == "g"){
  5107. t = 4;
  5108. }
  5109. else if(text == "r"){
  5110. t = 2;
  5111. }
  5112. else if(text == "y"){
  5113. t = 5;
  5114. }
  5115. else if(text == "s"){
  5116. t = 0;
  5117. }
  5118. if(t == -1){
  5119. displayInChat("The format for this command is:","#DA0808","#1EBCC1");
  5120. displayInChat("/moveA [letter]","#DA0808","#1EBCC1");
  5121. displayInChat("For example: '/moveA r' would move everyone to red team.","#DA0808","#1EBCC1");
  5122. return "";
  5123. }
  5124. for(var i = 0;i<keys.length;i++){
  5125. SEND('42[26,{"targetID":'+keys[i].toString()+',"targetTeam":'+t.toString()+'}]');
  5126. if(playerids[keys[i]].peerID!="sandbox"){
  5127. RECIEVE('42[18,'+keys[i].toString()+','+t.toString()+']');
  5128. }
  5129. }
  5130. return "";
  5131. }
  5132. else if (chat_val.substring(1,7)=="moveT " && chat_val.replace(/^\s+|\s+$/g, '').length>=8){
  5133. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '').split(" ").filter(function(i){if(i==""){return false}else{return true}});
  5134. if(text.length == 2){
  5135. var firstteam = -1;
  5136. var secondteam = -1;
  5137. for(var i = 0;i<2;i++){
  5138. var t = -1;
  5139. if(text[i] == "f"){
  5140. t = 1;
  5141. }
  5142. else if(text[i] == "b"){
  5143. t = 3;
  5144. }
  5145. else if(text[i] == "g"){
  5146. t = 4;
  5147. }
  5148. else if(text[i] == "r"){
  5149. t = 2;
  5150. }
  5151. else if(text[i] == "y"){
  5152. t = 5;
  5153. }
  5154. else if(text[i] == "s"){
  5155. t = 0;
  5156. }
  5157. if(t==-1){
  5158. displayInChat("The format for this command is:","#DA0808","#1EBCC1");
  5159. displayInChat("/moveT [letter] [letter]","#DA0808","#1EBCC1");
  5160. displayInChat("For example: '/moveT s r' would move everyone in spectate to red team.","#DA0808","#1EBCC1");
  5161. return "";
  5162. }
  5163. else{
  5164. if(i == 0){
  5165. firstteam = t;
  5166. }
  5167. else{
  5168. secondteam = t;
  5169. }
  5170. }
  5171. }
  5172. var keys = Object.keys(playerids);
  5173. for(var i = 0;i<keys.length;i++){
  5174. if(playerids[keys[i]].team == firstteam){
  5175. SEND('42[26,{"targetID":'+keys[i].toString()+',"targetTeam":'+secondteam.toString()+'}]');
  5176. if(playerids[keys[i]].peerID!="sandbox"){
  5177. RECIEVE('42[18,'+keys[i].toString()+','+secondteam.toString()+']');
  5178. }
  5179. }
  5180. }
  5181. }
  5182. else{
  5183. displayInChat("The format for this command is:","#DA0808","#1EBCC1");
  5184. displayInChat("/moveT [team] [team]","#DA0808","#1EBCC1");
  5185. displayInChat("For example: '/moveT s r' would move everyone in spectate to red team.","#DA0808","#1EBCC1");
  5186. return "";
  5187. }
  5188. return "";
  5189. }
  5190. if (chat_val.substring(1,13)=="roundsperqp " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  5191. var text = parseInt(chat_val.substring(13).replace(/^\s+|\s+$/g, ''));
  5192. if(isNaN(text)){
  5193. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  5194. return "";
  5195. }
  5196. else if(text<=0){
  5197. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  5198. return "";
  5199. }
  5200. roundsperqp = text;
  5201. roundsperqp2 = 0;
  5202. displayInChat("Set rounds per quickplay to: " + text.toString(),"#DA0808","#1EBCC1");
  5203. displayInChat("Type '/roundsperqp' to reset rounds per quickplay.","#DA0808","#1EBCC1");
  5204. return "";
  5205.  
  5206. }
  5207. else if (chat_val.substring(1,12)=="roundsperqp"){
  5208. roundsperqp = 1;
  5209. roundsperqp2 = 0;
  5210. displayInChat("Reset rounds per quickplay.","#DA0808","#1EBCC1");
  5211. return "";
  5212.  
  5213. }
  5214. else if (chat_val.substring(1,8)=="rounds " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  5215. var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '');
  5216. if(!isNaN(parseInt(text))){
  5217. text = parseInt(text).toString();
  5218. SEND('42[21,{"w":'+text+'}]');
  5219. RECIEVE('42[27,'+text+']');
  5220. }
  5221. return "";
  5222.  
  5223. }
  5224. else if (chat_val.substring(1,13)=="disablekeys " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  5225. var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '');
  5226. var keys = text.split(" ");
  5227. var disabledkeys2 = [];
  5228. var possiblekeys = ["left","right","up","down","heavy","special"];
  5229. for(var i = 0; i<keys.length; i++){
  5230. if(keys[i]!="" && !disabledkeys2.includes(keys[i])){
  5231. if(possiblekeys.includes(keys[i])){
  5232. disabledkeys2.push(keys[i]);
  5233. }
  5234. else{
  5235. displayInChat("Key options: " + possiblekeys.join(" ") + ".","#DA0808","#1EBCC1");
  5236. return "";
  5237. }
  5238. }
  5239. }
  5240. disabledkeys = disabledkeys2;
  5241. displayInChat("Set disabled keys to: " + disabledkeys.join(" ") + ".","#DA0808","#1EBCC1");
  5242. displayInChat("Type '/disablekeys' to reset disabled keys.","#DA0808","#1EBCC1");
  5243. return "";
  5244.  
  5245. }
  5246. else if (chat_val.substring(1,12)=="disablekeys"){
  5247. displayInChat("Reset disabled keys.","#DA0808","#1EBCC1");
  5248. disabledkeys = [];
  5249. return "";
  5250.  
  5251. }
  5252. else if (chat_val.substring(1,10)=="jointext " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  5253. jointext = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  5254. displayInChat("Set jointext to: " + jointext,"#DA0808","#1EBCC1");
  5255. displayInChat("Type '/jointext' to reset jointext.","#DA0808","#1EBCC1");
  5256. return "";
  5257.  
  5258. }
  5259. else if (chat_val.substring(1,9)=="jointext"){
  5260. jointext = "";
  5261. displayInChat("Reset jointext.","#DA0808","#1EBCC1");
  5262. return "";
  5263.  
  5264. }
  5265. else if (chat_val.substring(1,10)=="jointeam " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  5266. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  5267. var keys = Object.keys(playerids);
  5268. var t = -1;
  5269. if(text == "f"){
  5270. t = 1;
  5271. displayInChat("Set jointeam to FFA.","#DA0808","#1EBCC1");
  5272. }
  5273. else if(text == "b"){
  5274. t = 3;
  5275. displayInChat("Set jointeam to blue team.","#DA0808","#1EBCC1");
  5276. }
  5277. else if(text == "g"){
  5278. t = 4;
  5279. displayInChat("Set jointeam to green team.","#DA0808","#1EBCC1");
  5280. }
  5281. else if(text == "r"){
  5282. t = 2;
  5283. displayInChat("Set jointeam to red team.","#DA0808","#1EBCC1");
  5284. }
  5285. else if(text == "y"){
  5286. t = 5;
  5287. displayInChat("Set jointeam to yellow team.","#DA0808","#1EBCC1");
  5288. }
  5289. else if(text == "s"){
  5290. t = 0;
  5291. displayInChat("Set jointeam to spectate.","#DA0808","#1EBCC1");
  5292. }
  5293. if(t == -1){
  5294. displayInChat("The format for this command is:","#DA0808","#1EBCC1");
  5295. displayInChat("/jointeam [letter]","#DA0808","#1EBCC1");
  5296. displayInChat("For example: '/jointeam r' would move every joined person to red team.","#DA0808","#1EBCC1");
  5297. return "";
  5298. }
  5299. displayInChat("Type '/jointeam' to reset jointeam.","#DA0808","#1EBCC1");
  5300. jointeam = t;
  5301. return "";
  5302. }
  5303. else if (chat_val.substring(1,9)=="jointeam"){
  5304. jointeam = -1;
  5305. displayInChat("Reset jointeam.","#DA0808","#1EBCC1");
  5306. return "";
  5307.  
  5308. }
  5309. else if (chat_val.substring(1,9)=="wintext " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  5310. wintext = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  5311. displayInChat("Set wintext to: " + wintext,"#DA0808","#1EBCC1");
  5312. displayInChat("Type '/wintext' to reset wintext.","#DA0808","#1EBCC1");
  5313. return "";
  5314.  
  5315. }
  5316. else if (chat_val.substring(1,8)=="wintext"){
  5317. wintext = "";
  5318. displayInChat("Reset wintext.","#DA0808","#1EBCC1");
  5319. return "";
  5320.  
  5321. }
  5322. else if (chat_val.substring(1,11)=="autorecord"){
  5323. if(autorecord){
  5324. autorecord = false;
  5325. displayInChat("Autorecord is now off.","#DA0808","#1EBCC1");
  5326. }
  5327. else{
  5328. autorecord = true;
  5329. displayInChat("Autorecord is now on.","#DA0808","#1EBCC1");
  5330. }
  5331. return "";
  5332.  
  5333. }
  5334. else if (chat_val.substring(1,9)=="afkkill " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  5335. var text = parseFloat(chat_val.substring(9).replace(/^\s+|\s+$/g, ''));
  5336. if(!isNaN(text)){
  5337. if(text>0){
  5338. displayInChat("Set afk kill to: " + text.toString()+" seconds.","#DA0808","#1EBCC1");
  5339. displayInChat("Type '/afkkill' to reset afk kill.","#DA0808","#1EBCC1");
  5340. var keys = Object.keys(playerids);
  5341. var now = Date.now();
  5342. for(var i = 0;i<keys.length;i++){
  5343. playerids[keys[i]].lastmove = now;
  5344. }
  5345. afkkill = text;
  5346. }
  5347. else{
  5348. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  5349. }
  5350. }
  5351. else{
  5352. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  5353. }
  5354. return "";
  5355.  
  5356. }
  5357. else if (chat_val.substring(1,9)=="afkkill"){
  5358. afkkill = -1;
  5359. displayInChat("Reset afk kill.","#DA0808","#1EBCC1");
  5360. return "";
  5361.  
  5362. }
  5363. else if (chat_val.substring(1,13)=="defaultmode " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  5364. var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '');
  5365. if(text == "default"){
  5366. defaultmode = "";
  5367. displayInChat("Changed default mode to default.","#DA0808","#1EBCC1");
  5368. }
  5369. else if(text == "arrows"){
  5370. defaultmode = "ar";
  5371. displayInChat("Changed default mode to arrows.","#DA0808","#1EBCC1");
  5372. }
  5373. else if(text == "death arrows"){
  5374. defaultmode = "ard";
  5375. displayInChat("Changed default mode to death arrows.","#DA0808","#1EBCC1");
  5376. }
  5377. else if(text == "grapple"){
  5378. defaultmode = "sp";
  5379. displayInChat("Changed default mode to grapple.","#DA0808","#1EBCC1");
  5380. }
  5381. else if(text == "classic"){
  5382. defaultmode = "b";
  5383. displayInChat("Changed default mode to classic.","#DA0808","#1EBCC1");
  5384.  
  5385. }
  5386. else{
  5387. displayInChat("Default mode options:","#DA0808","#1EBCC1");
  5388. displayInChat("default","#DA0808","#1EBCC1");
  5389. displayInChat("classic","#DA0808","#1EBCC1");
  5390. displayInChat("arrows","#DA0808","#1EBCC1");
  5391. displayInChat("death arrows","#DA0808","#1EBCC1");
  5392. displayInChat("grapple","#DA0808","#1EBCC1");
  5393. }
  5394. return "";
  5395.  
  5396. }
  5397. else if (chat_val.substring(1,8)=="recmode"){
  5398. if(recmodebool == true){
  5399. recmodebool = false;
  5400. displayInChat("Recmode is now off.","#DA0808","#1EBCC1");
  5401.  
  5402. }
  5403. else{
  5404. recmodebool = true;
  5405. displayInChat("Recmode is now on.","#DA0808","#1EBCC1");
  5406.  
  5407. }
  5408.  
  5409. return "";
  5410.  
  5411. }
  5412. else if (chat_val.substring(1,8)=="recteam"){
  5413. if(recteams == true){
  5414. recteams = false;
  5415. displayInChat("Recteam is now off.","#DA0808","#1EBCC1");
  5416.  
  5417. }
  5418. else{
  5419. recteams = true;
  5420. displayInChat("Recteam is now on.","#DA0808","#1EBCC1");
  5421.  
  5422. }
  5423. return "";
  5424. }
  5425. else if (chat_val.substring(1,8)=="shuffle"){
  5426. if(shuffle == true){
  5427. shuffle = false;
  5428. displayInChat("Shuffle is now off.","#DA0808","#1EBCC1");
  5429.  
  5430. }
  5431. else{
  5432. shuffle = true;
  5433. displayInChat("Shuffle is now on.","#DA0808","#1EBCC1");
  5434.  
  5435. }
  5436.  
  5437. return "";
  5438.  
  5439. }
  5440. else if (chat_val.substring(1,9)=="autokick"){
  5441. if(autokickban == 0){
  5442. displayInChat("Autokick is now on.","#DA0808","#1EBCC1");
  5443. autokickban = 1;
  5444. }
  5445. else if(autokickban == 1){
  5446. autokickban = 0;
  5447. displayInChat("Autokick is now off.","#DA0808","#1EBCC1");
  5448. }
  5449. else{
  5450. autokickban = 1;
  5451. displayInChat("Autokick is now on, and Autoban is now off.","#DA0808","#1EBCC1");
  5452. }
  5453.  
  5454. return "";
  5455. }
  5456. else if (chat_val.substring(1,8)=="autoban"){
  5457. if(autokickban == 0){
  5458. displayInChat("Autoban is now on.","#DA0808","#1EBCC1");
  5459. autokickban = 2;
  5460. }
  5461. else if(autokickban == 2){
  5462. autokickban = 0;
  5463. displayInChat("Autoban is now off.","#DA0808","#1EBCC1");
  5464. }
  5465. else{
  5466. autokickban = 2;
  5467. displayInChat("Autoban is now on, and Autokick is now off.","#DA0808","#1EBCC1");
  5468. }
  5469.  
  5470. return "";
  5471. }
  5472. else if (chat_val.substring(1,8)=="sandbox"){
  5473. if(sandboxon == false){
  5474. displayInChat("This room is now a sandbox room.","#DA0808","#1EBCC1");
  5475. sandboxon = true;
  5476. SEND('42[4,{"type":"sandboxon"}]');
  5477. var sandboxkeys = Object.keys(sandboxplayerids);
  5478. var packets = [];
  5479. for(var i = 0;i<sandboxkeys.length;i++){
  5480. var p = playerids[sandboxkeys[i]];
  5481. var packet = '42'+JSON.stringify([4,sandboxkeys[i],p.peerID,p.userName,p.guest,p.level,p.team,p.avatar]);
  5482. packets.push(packet);
  5483. }
  5484. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":packets,to:[-1]}]));
  5485. SEND("42"+JSON.stringify([4,{"type":"sandboxid","from":username,"lastid":sandboxid,to:[-1]}]));
  5486. }
  5487. else{
  5488. displayInChat("You cannot turn a sandbox room back into a normal room.","#DA0808","#1EBCC1");
  5489. }
  5490.  
  5491. return "";
  5492. }
  5493. else if(sandboxon){
  5494. if (chat_val.substring(1,11)=="addplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  5495. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  5496. if(!isNaN(parseInt(text))){
  5497. var text2 = parseInt(text);
  5498. if(text2>0){
  5499. for(var i = 0;i<text2;i++){
  5500. while(playerids[sandboxid]){
  5501. sandboxid+=1;
  5502. }
  5503. var color = Math.floor(Math.random() * 16777215).toString();
  5504. var packet = '42'+JSON.stringify([4,sandboxid,"sandbox",sandboxid.toString(),true,0,0,{"layers":[],"bc":color}]);
  5505. RECIEVE(packet);
  5506. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  5507. sandboxplayerids[sandboxid] = sandboxid.toString();
  5508. sandboxid+=1;
  5509. }
  5510.  
  5511. }
  5512. }
  5513. return "";
  5514.  
  5515. }
  5516. if (chat_val.substring(1,9)=="addname " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  5517. var text = chat_val.substring(9).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  5518. while(playerids[sandboxid]){
  5519. sandboxid+=1;
  5520. }
  5521. var keys = Object.keys(playerids);
  5522. var addon = "";
  5523. var escape = false;
  5524. var keysi = -1;
  5525. while(!escape){
  5526. escape = true;
  5527. for(var i = 0;i<keys.length;i++){
  5528. if(playerids[keys[i]].userName == text+addon){
  5529. addon+="‎";
  5530. var escape = false;
  5531. }
  5532. if(playerids[keys[i]].userName == text){
  5533. keysi = keys[i];
  5534. }
  5535. }
  5536. }
  5537. if(keysi!=-1){
  5538. var packet = '42'+JSON.stringify([4,sandboxid,"sandbox",text+addon,playerids[keysi].guest,playerids[keysi].level,0,playerids[keysi].avatar]);
  5539. RECIEVE(packet);
  5540. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  5541. }
  5542. else{
  5543. var color = Math.floor(Math.random() * 16777215).toString();
  5544. var packet = '42'+JSON.stringify([4,sandboxid,"sandbox",text+addon,true,0,0,{"layers":[],"bc":color}]);
  5545. RECIEVE(packet);
  5546. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  5547. }
  5548. sandboxplayerids[sandboxid] = sandboxid.toString();
  5549. sandboxid+=1;
  5550. return "";
  5551.  
  5552. }
  5553. else if (chat_val.substring(1,11)=="delplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  5554. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  5555. if(!isNaN(parseInt(text))){
  5556. var text2 = parseInt(text);
  5557. if(text2>0){
  5558. if(Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden"){
  5559. var jsonkeys = Object.keys(sandboxplayerids).reverse();
  5560. var packets = [];
  5561. for(var i = 0;i<text2 && i<jsonkeys.length;i++){
  5562. var packet = '42[5,'+jsonkeys[i]+',0]';
  5563. RECIEVE(packet);
  5564. packets.push(packet);
  5565. delete sandboxplayerids[jsonkeys[i]];
  5566. }
  5567. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":packets,to:[-1]}]));
  5568. }
  5569. else{
  5570. displayInChat("Cannot delete players while ingame.","#DA0808","#1EBCC1");
  5571. }
  5572.  
  5573. }
  5574. }
  5575. return "";
  5576. }
  5577. else if (chat_val.substring(1,6)=="copy " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  5578. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  5579. var keys = Object.keys(playerids);
  5580. var keys2 = Object.keys(sandboxplayerids);
  5581. var copiedperson = -1;
  5582. for(var i = 0;i<keys.length;i++){
  5583. if(playerids[keys[i]].userName==text){
  5584. copiedperson = keys[i];
  5585. }
  5586. }
  5587. if(copiedperson==-1){
  5588. displayInChat(playerids[copiedperson].userName + " was not found in this room.","#DA0808","#1EBCC1");
  5589. return "";
  5590. }
  5591. if(keys2.includes(copiedperson.toString())){
  5592. displayInChat("Bots cannot copy a bot.","#DA0808","#1EBCC1");
  5593. return "";
  5594. }
  5595. displayInChat("All bots will now copy "+playerids[copiedperson].userName+".","#DA0808","#1EBCC1");
  5596. displayInChat("To reset copy, type '/copy'.","#DA0808","#1EBCC1");
  5597. sandboxcopyme = copiedperson;
  5598.  
  5599. return "";
  5600. }
  5601. else if (chat_val.substring(1,5)=="copy"){
  5602. sandboxcopyme = -1;
  5603. displayInChat("Copy is now off.","#DA0808","#1EBCC1");
  5604. return "";
  5605. }
  5606. }
  5607. }
  5608. return chat_val;
  5609. };
  5610.  
  5611. scope.flag_manage = function(t){
  5612. var text = t;
  5613. if(autocorrect == true){
  5614. var text2 = text.split(" ");
  5615. for(var i = 0;i<text2.length;i++){
  5616. text2[i] = closestWord(text2[i]);
  5617. }
  5618. text = text2.join(" ");
  5619. }
  5620. if(reverse_flag == true){
  5621. text = text.split("").reverse().join("")
  5622. }
  5623. if(rcaps_flag == true){
  5624. text = text.split('');
  5625. for(var i = 0; i<text.length;i++){
  5626. if(Math.floor(Math.random()*2)){
  5627. text[i] = text[i].toUpperCase();
  5628. }
  5629. else{
  5630. text[i] = text[i].toLowerCase();
  5631. }
  5632. }
  5633. text = text.join('');
  5634. }
  5635. if(space_flag == true){
  5636. text = text.split('').join(' ')
  5637. }
  5638. if(number_flag == true){
  5639. text = text.replace(/[t|T][Oo]+/g,"2");
  5640. text = text.replace(/[f|F][o|O][r|R]/g,"4");
  5641. text = text.replace(/[a|A][t|T][e|E]/g,"8");
  5642. text = text.replace(/[e|E]/g,"3");
  5643. text = text.replace(/[a|A]/g,"4");
  5644. text = text.replace(/[o|O]/g,"0");
  5645. text = text.replace(/[s|S]/g,"5");
  5646. text = text.replace(/[i|I|l|L]/g,"1");
  5647. }
  5648. return text;
  5649. };
  5650. Gdocument.getElementById("newbonklobby_chat_input").onkeydown = function(e){
  5651. if(e.keyCode==13){
  5652.  
  5653. var chat_val = Gdocument.getElementById("newbonklobby_chat_input").value;
  5654.  
  5655. if (chat_val!="" && chat_val[0]=="/"){
  5656.  
  5657. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  5658. chat2(commandhandle(chat_val));
  5659. }
  5660. else{
  5661. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  5662. chat2(flag_manage(chat_val));
  5663. }
  5664.  
  5665. }
  5666. };
  5667. Gdocument.getElementById("ingamechatinputtext").onkeydown = function(e){
  5668. if(e.keyCode==13){
  5669.  
  5670. var chat_val = Gdocument.getElementById("ingamechatinputtext").value;
  5671.  
  5672. if (chat_val!="" && chat_val[0]=="/"){
  5673.  
  5674. Gdocument.getElementById("ingamechatinputtext").value = "";
  5675. chat2(commandhandle(chat_val));
  5676. }
  5677. else{
  5678. Gdocument.getElementById("ingamechatinputtext").value = "";
  5679. chat2(flag_manage(chat_val));
  5680. }
  5681. }
  5682. };
  5683. scope.Last_message = "";
  5684. scope.Laster_message = "";
  5685. scope.new_message = false;
  5686. scope.changed_chat = false;
  5687. scope.injectedBonkCommandsScript = setInterval(timeout123,60);
  5688.  
  5689. scope.hotkeys = function(e){
  5690. var keycode = e.code;
  5691. if(e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  5692. if(keycode == "Period"){
  5693. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]!="0px"){
  5694. chatheight+=5;
  5695. if(chatheight>600){chatheight = 600;}
  5696. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  5697. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  5698. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  5699. }
  5700. e.preventDefault();
  5701. }
  5702. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  5703. if(keycode == "KeyG"){
  5704. var addto = 0;
  5705. for(var i = 0;i<parentDraw.children.length;i++){
  5706. if(parentDraw.children[i].constructor.name == "e"){
  5707. addto = parentDraw.children[i];
  5708. break;
  5709. }
  5710. }
  5711. var canv = 0;
  5712. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  5713. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  5714. canv = Gdocument.getElementById("gamerenderer").children[i];
  5715. break;
  5716. }
  5717. }
  5718. var width = parseInt(canv.style["width"]);
  5719. var height = parseInt(canv.style["height"]);
  5720. if(addto){
  5721. zoom *= 1.1;
  5722. }
  5723. addto.scale.x = zoom;
  5724. addto.scale.y = zoom;
  5725. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  5726. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  5727. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  5728. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  5729. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999 && !FollowCam){
  5730. pixiCircle.visible = false;
  5731. }
  5732. else{
  5733. pixiCircle.visible = true;
  5734. }
  5735. e.preventDefault();
  5736. }
  5737. if(keycode == "KeyH"){
  5738. var addto = 0;
  5739. for(var i = 0;i<parentDraw.children.length;i++){
  5740. if(parentDraw.children[i].constructor.name == "e"){
  5741. addto = parentDraw.children[i];
  5742. break;
  5743. }
  5744. }
  5745. var canv = 0;
  5746. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  5747. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  5748. canv = Gdocument.getElementById("gamerenderer").children[i];
  5749. break;
  5750. }
  5751. }
  5752. var width = parseInt(canv.style["width"]);
  5753. var height = parseInt(canv.style["height"]);
  5754. if(addto){
  5755. zoom = 1;
  5756. }
  5757. addto.scale.x = zoom;
  5758. addto.scale.y = zoom;
  5759. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  5760. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  5761. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  5762. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  5763. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999 && !FollowCam){
  5764. pixiCircle.visible = false;
  5765. }
  5766. else{
  5767. pixiCircle.visible = true;
  5768. }
  5769. e.preventDefault();
  5770. }
  5771. if(keycode == "KeyJ"){
  5772. var addto = 0;
  5773. for(var i = 0;i<parentDraw.children.length;i++){
  5774. if(parentDraw.children[i].constructor.name == "e"){
  5775. addto = parentDraw.children[i];
  5776. break;
  5777. }
  5778. }
  5779. var canv = 0;
  5780. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  5781. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  5782. canv = Gdocument.getElementById("gamerenderer").children[i];
  5783. break;
  5784. }
  5785. }
  5786. var width = parseInt(canv.style["width"]);
  5787. var height = parseInt(canv.style["height"]);
  5788. if(addto){
  5789. zoom /= 1.1;
  5790. }
  5791. addto.scale.x = zoom;
  5792. addto.scale.y = zoom;
  5793. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  5794. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  5795. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  5796. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  5797. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999 && !FollowCam){
  5798. pixiCircle.visible = false;
  5799. }
  5800. else{
  5801. pixiCircle.visible = true;
  5802. }
  5803. e.preventDefault();
  5804. }
  5805. }
  5806. if(keycode == "Comma"){
  5807. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]!="0px"){
  5808. chatheight-=5;
  5809. if(chatheight<100){chatheight = 100;}
  5810. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  5811. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  5812. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  5813. }
  5814. e.preventDefault();
  5815. }
  5816. }
  5817. if(e.repeat){return;}
  5818. if(e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  5819. if(ishost){
  5820. if(keycode == "KeyE"){
  5821. if(Gdocument.getElementById("newbonklobby").style["display"] == "block"){
  5822. Gdocument.getElementById("newbonklobby_editorbutton").click();
  5823. }
  5824. else if(Gdocument.getElementById("mapeditorcontainer").style["display"] == "block"){
  5825. Gdocument.getElementById("mapeditor_close").click();
  5826. }
  5827. e.preventDefault();
  5828.  
  5829. }
  5830. else if(keycode == "KeyT"){
  5831. Gdocument.getElementById("newbonklobby_teamsbutton").click();
  5832. e.preventDefault();
  5833. }
  5834. else if(keycode == "KeyM"){
  5835. Gdocument.getElementById("newbonklobby_modebutton").click();
  5836. e.preventDefault();
  5837. }
  5838. else if(keycode == "KeyK"){
  5839. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  5840. Gdocument.getElementById("pretty_top_exit").click();
  5841. }
  5842. e.preventDefault();
  5843. }
  5844. else if(keycode == "KeyS"){
  5845. if(Gdocument.getElementById("mapeditorcontainer").style["display"]!="block"){
  5846. Gdocument.getElementById("newbonklobby_editorbutton").click();
  5847. }
  5848. if(recmodebool && ishost){
  5849. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  5850. if(mode == "" && defaultmode!="d"){
  5851. mode = defaultmode;
  5852. }
  5853. if(mode != ""){
  5854. RECIEVE('42[26,"b","'+mode+'"]');
  5855. }
  5856. }
  5857. Gdocument.getElementById("mapeditor_close").click();
  5858. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  5859. roundsperqp2 = 0;
  5860. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  5861. e.preventDefault();
  5862. }
  5863. else if(keycode == "KeyD"){
  5864. roundsperqp2 = 0;
  5865. if(stopquickplay == 0){
  5866. if(shuffle){
  5867. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  5868. var available = [];
  5869. var availableindexes = [];
  5870. var notempty = false;
  5871. for(var i = 0; i<e2.length;i++){
  5872. var a = false;
  5873. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  5874. available.push(a);
  5875. if(a){
  5876. availableindexes.push(i);
  5877. notempty = true;
  5878. }
  5879. }
  5880. if(notempty){
  5881.  
  5882. if(availableindexes.length!=1){
  5883. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  5884. }
  5885. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  5886. }
  5887. }
  5888. else{
  5889. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  5890. var available = [];
  5891. var availableindexes = [];
  5892. var notempty = false;
  5893. for(var i = 0; i<e2.length;i++){
  5894. var a = false;
  5895. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  5896. available.push(a);
  5897. if(a){
  5898. availableindexes.push(i);
  5899. notempty = true;
  5900. }
  5901. }
  5902. if(notempty){
  5903. var above = [];
  5904. for(var i = 0;i<availableindexes.length;i++){
  5905. if(availableindexes[i]>quicki && !reverseqp){
  5906. above.push(availableindexes[i]);
  5907. }
  5908. else if(availableindexes[i]<quicki && reverseqp){
  5909. above.push(availableindexes[i])
  5910. }
  5911. }
  5912. if(above.length>0){
  5913. quicki = above[0];
  5914. if(reverseqp){
  5915. quicki = above[above.length-1];
  5916. }
  5917. }
  5918. else{
  5919. quicki = availableindexes[0];
  5920. if(reverseqp){
  5921. quicki = availableindexes[availableindexes.length-1];
  5922. }
  5923. }
  5924. }
  5925. }
  5926. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  5927. }
  5928. e.preventDefault();
  5929. }
  5930. else if(keycode == "KeyA"){
  5931. if(stopquickplay == 0){
  5932. roundsperqp2 = 0;
  5933. if(shuffle){
  5934. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  5935. var available = [];
  5936. var availableindexes = [];
  5937. var notempty = false;
  5938. for(var i = 0; i<e2.length;i++){
  5939. var a = false;
  5940. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  5941. available.push(a);
  5942. if(a){
  5943. availableindexes.push(i);
  5944. notempty = true;
  5945. }
  5946. }
  5947. if(notempty){
  5948.  
  5949. if(availableindexes.length!=1){
  5950. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  5951. }
  5952. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  5953. }
  5954. }
  5955. else{
  5956. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  5957. var available = [];
  5958. var availableindexes = [];
  5959. var notempty = false;
  5960. for(var i = 0; i<e2.length;i++){
  5961. var a = false;
  5962. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  5963. available.push(a);
  5964. if(a){
  5965. availableindexes.push(i);
  5966. notempty = true;
  5967. }
  5968. }
  5969. if(notempty){
  5970. var above = [];
  5971. for(var i = 0;i<availableindexes.length;i++){
  5972. if(availableindexes[i]<quicki && !reverseqp){
  5973. above.push(availableindexes[i]);
  5974. }
  5975. else if(availableindexes[i]>quicki && reverseqp){
  5976. above.push(availableindexes[i])
  5977. }
  5978. }
  5979. if(above.length>0){
  5980. quicki = above[above.length-1];
  5981. if(reverseqp){
  5982. quicki = above[0];
  5983. }
  5984. }
  5985. else{
  5986. quicki = availableindexes[availableindexes.length-1];
  5987. if(reverseqp){
  5988. quicki = availableindexes[0];
  5989. }
  5990. }
  5991. }
  5992. }
  5993. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  5994. }
  5995. e.preventDefault();
  5996. }
  5997. else if(keycode == "KeyQ"){
  5998. if(stopquickplay == 1){
  5999. stopquickplay = 0;
  6000. quicki = 0;
  6001. qppaused = false;
  6002. displayInChat("Enabled quickplay.","#DA0808","#1EBCC1");
  6003. }
  6004. else{
  6005. stopquickplay = 1;
  6006. quicki = 0;
  6007. qppaused = false;
  6008. displayInChat("Disabled quickplay.","#DA0808","#1EBCC1");
  6009. }
  6010. e.preventDefault();
  6011. }
  6012. else if(keycode == "KeyP" && stopquickplay==0){
  6013. if(qppaused == true){
  6014. qppaused = false;
  6015. displayInChat("Unpaused quickplay.","#DA0808","#1EBCC1");
  6016. }
  6017. else{
  6018. qppaused = true;
  6019. displayInChat("Paused quickplay.","#DA0808","#1EBCC1");
  6020. }
  6021. e.preventDefault();
  6022. }
  6023. else if(keycode == "KeyR"){
  6024. if(recmodebool == true){
  6025. recmodebool = false;
  6026. displayInChat("Recmode is now off.","#DA0808","#1EBCC1");
  6027.  
  6028. }
  6029. else{
  6030. recmodebool = true;
  6031. displayInChat("Recmode is now on.","#DA0808","#1EBCC1");
  6032.  
  6033. }
  6034. }
  6035. else if(keycode == "KeyF"){
  6036. if(freejoin == false){
  6037. freejoin = true;
  6038. displayInChat("Freejoin is now on.","#DA0808","#1EBCC1");
  6039.  
  6040. }
  6041. else{
  6042. freejoin = false;
  6043. displayInChat("Freejoin is now off.","#DA0808","#1EBCC1");
  6044. }
  6045. e.preventDefault();
  6046. }
  6047. }
  6048. else{
  6049. if(keycode == "KeyE"){
  6050. e.preventDefault();
  6051. }
  6052. else if(keycode == "KeyT"){
  6053. e.preventDefault();
  6054. }
  6055. else if(keycode == "KeyM"){
  6056. e.preventDefault();
  6057. }
  6058. else if(keycode == "KeyK"){
  6059. e.preventDefault();
  6060. }
  6061. else if(keycode == "KeyS"){
  6062. e.preventDefault();
  6063. }
  6064. else if(keycode == "KeyD"){
  6065. e.preventDefault();
  6066. }
  6067. else if(keycode == "KeyA"){
  6068. e.preventDefault();
  6069. }
  6070. else if(keycode == "KeyQ"){
  6071. e.preventDefault();
  6072. }
  6073. else if(keycode == "KeyP"){
  6074. e.preventDefault();
  6075. }
  6076. else if(keycode == "KeyF"){
  6077. e.preventDefault();
  6078. }
  6079. else if(keycode == "KeyR"){
  6080. e.preventDefault();
  6081. }
  6082.  
  6083. }
  6084. if(keycode == "KeyL"){
  6085. lobby();
  6086. e.preventDefault();
  6087. }
  6088. if(keycode == "KeyC"){
  6089. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  6090. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]=="0px"){
  6091. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  6092. }
  6093. else{
  6094. Gdocument.getElementById("ingamechatcontent").style["max-height"]="0px";
  6095. }
  6096. }
  6097. e.preventDefault();
  6098. }
  6099. if(keycode == "KeyI"){
  6100. if(Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"] == "none"){
  6101. debuggeropen = true;
  6102. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="block";
  6103. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="none";
  6104. Gdocument.getElementById("ingamechatinputtext").style["display"] = "none";
  6105. }
  6106. else{
  6107. debuggeropen = false;
  6108. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="none";
  6109. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  6110. Gdocument.getElementById("ingamechatinputtext").style["display"] = "";
  6111. }
  6112. e.preventDefault();
  6113. }
  6114. if(keycode == "KeyB"){
  6115. var element = Gdocument.getElementById("ingamewinner_scores");
  6116. if(element.style["opacity"]<1){
  6117. element.style["opacity"] = 1;
  6118. element.style["visibility"] = "visible";
  6119. }
  6120. else{
  6121. element.style["opacity"] = 0;
  6122. element.style["visibility"] = "unset";
  6123. }
  6124. e.preventDefault();
  6125. }
  6126. if(keycode == "KeyY"){
  6127. Gdocument.getElementById("pretty_top_settings").click();
  6128. Gdocument.getElementById("settings_close").click();
  6129. if(Gdocument.getElementById("settings_graphicsquality").value==1){
  6130. displayInChat("You must have medium or high quality enabled to use this feature.","#DA0808","#1EBCC1");
  6131. return "";
  6132. }
  6133.  
  6134.  
  6135. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  6136. var addto = {"children":[]};
  6137. for(var i = 0;i<parentDraw.children.length;i++){
  6138. if(parentDraw.children[i].constructor.name == "e"){
  6139. addto = parentDraw.children[i];
  6140. break;
  6141. }
  6142. }
  6143. var addto2 = {"children":[]};
  6144. for(var i = 0;i<addto.children.length;i++){
  6145. if(addto.children[i].constructor.name == "e"){
  6146. addto2 = addto.children[i];
  6147. break;
  6148. }
  6149. }
  6150. var checkxray = addto2.children[0];
  6151. var addto3 = addto2.children[0].children;
  6152. if(addto3.length==1){
  6153. checkxray = checkxray.children[0];
  6154. addto3 = addto3[0].children;
  6155. }
  6156. var xrayon = false;
  6157. if(checkxray.xrayon){
  6158. checkxray.xrayon = false;
  6159. xrayon = false;
  6160. }
  6161. else{
  6162. checkxray.xrayon = true;
  6163. xrayon = true;
  6164. }
  6165. if(xrayon){
  6166. displayInChat("Xray is now on.","#DA0808","#1EBCC1");
  6167. for(var i = 0;i<addto3.length;i++){
  6168. if(addto3[i].children.length>0){
  6169. var ids = [];
  6170. var ids2 = [];
  6171. for(var i3 = 0;i3<addto3[i].children.length;i3++){
  6172. addto3[i].children[i3].visible = false;
  6173. if(addto3[i].children[i3].children.length>0){
  6174. for(var i4 = 0;i4<addto3[i].children[i3].children.length;i4++){
  6175. if(addto3[i].children[i3].children[i4].geometry?.id){
  6176. ids.push(addto3[i].children[i3].children[i4].geometry.id);
  6177. }
  6178. else if(addto3[i].children[i3].children[i4].texture?.baseTexture?.uid){
  6179. ids2.push(addto3[i].children[i3].children[i4].texture.baseTexture.uid);
  6180. }
  6181. }
  6182. }
  6183. }
  6184. for(var i3 = 0;i3<addto3[i].children.length;i3++){
  6185. if(addto3[i].children[i3].children.length==0){
  6186. if(addto3[i].children[i3].geometry?.id){
  6187. if(ids.includes(addto3[i].children[i3].geometry.id+1)){
  6188. addto3[i].children[i3].visible = true;
  6189. addto3[i].children[i3].alpha = 0.5;
  6190. }
  6191. }
  6192. else if(addto3[i].children[i3].texture?.baseTexture?.uid){
  6193. if(ids2.includes(addto3[i].children[i3].texture.baseTexture.uid+1)){
  6194. addto3[i].children[i3].visible = true;
  6195. addto3[i].children[i3].alpha = 0.5;
  6196. }
  6197. }
  6198. }
  6199. }
  6200. }
  6201. }
  6202.  
  6203. }
  6204. else{
  6205. displayInChat("Xray is now off.","#DA0808","#1EBCC1");
  6206. for(var i = 0;i<addto3.length;i++){
  6207. for(var i2 = 0;i2<addto3[i].children.length;i2++){
  6208. addto3[i].children[i2].visible = true;
  6209. addto3[i].children[i2].alpha = 1;
  6210. }
  6211. }
  6212. }
  6213. }
  6214. e.preventDefault();
  6215. }
  6216. if(keycode == "KeyN"){
  6217. if(FollowCam == true){
  6218. displayInChat("Follow Camera is now off.","#DA0808","#1EBCC1");
  6219. FollowCam = false;
  6220. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  6221. var addto = {"children":[]};
  6222. for(var i = 0;i<parentDraw.children.length;i++){
  6223. if(parentDraw.children[i].constructor.name == "e"){
  6224. addto = parentDraw.children[i];
  6225. break;
  6226. }
  6227. }
  6228. var canv = 0;
  6229. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  6230. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  6231. canv = Gdocument.getElementById("gamerenderer").children[i];
  6232. break;
  6233. }
  6234. }
  6235. var width = parseInt(canv.style["width"]);
  6236. var height = parseInt(canv.style["height"]);
  6237. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  6238. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  6239. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  6240. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  6241. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999){
  6242. pixiCircle.visible = false;
  6243. }
  6244. else{
  6245. pixiCircle.visible = true;
  6246. }
  6247. }
  6248. }
  6249. else{
  6250. displayInChat("Follow Camera is now on.","#DA0808","#1EBCC1");
  6251. FollowCam = true;
  6252. }
  6253. e.preventDefault();
  6254. }
  6255. if(keycode == "KeyV"){
  6256. if(autocam == true){
  6257. displayInChat("Auto Cam is now off.","#DA0808","#1EBCC1");
  6258. autocam = false
  6259. }
  6260. else{
  6261. displayInChat("Auto Cam is now on.","#DA0808","#1EBCC1");
  6262. autocam = true;
  6263. }
  6264. e.preventDefault();
  6265. }
  6266. if(keycode == "KeyO"){
  6267. if(heavybot == true){
  6268. displayInChat("Heavy bot is now off.","#DA0808","#1EBCC1");
  6269. heavybot = false;
  6270. }
  6271. else{
  6272. displayInChat("Heavy bot is now on.","#DA0808","#1EBCC1");
  6273. heavybot = true;
  6274. getplayerkeys();
  6275. }
  6276. e.preventDefault();
  6277. }
  6278. if(keycode == "KeyU"){
  6279. if(aimbot == true){
  6280. displayInChat("Aimbot is now off.","#DA0808","#1EBCC1");
  6281. aimbot = false;
  6282. }
  6283. else{
  6284. displayInChat("Aimbot is now on.","#DA0808","#1EBCC1");
  6285. aimbot = true;
  6286. getplayerkeys();
  6287. }
  6288. e.preventDefault();
  6289. }
  6290. if(keycode == "KeyW"){
  6291. if(staystill == true){
  6292. displayInChat("Still is now off.","#DA0808","#1EBCC1");
  6293. staystill = false;
  6294. staystillpos = [0,0];
  6295. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  6296. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  6297. }
  6298. else{
  6299. if(playerids[myid].playerData?.transform){
  6300. displayInChat("Still is now on.","#DA0808","#1EBCC1");
  6301. staystill = true;
  6302. staystillpos = [playerids[myid].playerData.transform.position.x/scale,playerids[myid].playerData.transform.position.y/scale];
  6303. getplayerkeys();
  6304. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  6305. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  6306. }
  6307. else{
  6308. displayInChat("You have to be alive to use this command.","#DA0808","#1EBCC1");
  6309. }
  6310. }
  6311. e.preventDefault();
  6312. }
  6313. }
  6314. if(!e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  6315. if(keycode == "Slash" && !(Gdocument.getElementById("gmeditor")?.style["transform"] == "scale(1)")){
  6316. 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"]==""){
  6317. Gdocument.getElementById("newbonklobby_chat_input").value = "/";
  6318. if(Gdocument.getElementById("newbonklobby_chat_input").style["pointer-events"] == "none"){
  6319. fire("keydown",{keyCode:13});
  6320. }
  6321. else{
  6322. Gdocument.getElementById("newbonklobby_chat_input").focus();
  6323. }
  6324. e.preventDefault();
  6325.  
  6326. }
  6327. else if(Gdocument.getElementById("ingamechatinputtext").style["visibility"]=="visible" && Gdocument.getElementById("ingamechatinputtext").style["display"]=="" && Gdocument.getElementById("mapeditorcontainer").style["display"]!="block" && Gdocument.getElementById("ingamechatinputtext").value == ""){
  6328. Gdocument.getElementById("ingamechatinputtext").value = "/";
  6329. if(!Gdocument.getElementById("ingamechatinputtext").classList.value.includes("ingamechatinputtextbg")){
  6330. fire("keydown",{keyCode:13});
  6331. }
  6332. else{
  6333. Gdocument.getElementById("ingamechatinputtext").focus();
  6334. }
  6335. e.preventDefault();
  6336.  
  6337. }
  6338. }
  6339. }
  6340. };
  6341.  
  6342. Gdocument.onkeydown = hotkeys;
  6343.  
  6344. Gwindow.addEventListener('resize',function(e){
  6345. debuggermenu.style["width"] = Gdocument.getElementById("bonkiocontainer").style["width"];
  6346. debuggermenu.style["height"] = Gdocument.getElementById("bonkiocontainer").style["height"];
  6347. scope.width = parseInt(Gdocument.getElementById("bonkiocontainer").style["width"])-20;
  6348. scope.height = parseInt(Gdocument.getElementById("bonkiocontainer").style["height"])-210;
  6349. logmenu.style["width"] = width.toString()+"px";
  6350. logmenu.style["height"] = height.toString()+"px";
  6351. logmenutopleft.style["width"] = (width/2).toString()+"px";
  6352. logmenutopright.style["width"] = (width/2).toString()+"px";
  6353. logmenutopright.style["left"] = (width/2).toString()+"px";
  6354. debuggerinput.style["width"] = width.toString()+"px";
  6355. debuggerinput.style["top"] = (height+90).toString()+"px";
  6356. debuggersendrecieve.style["top"] = (height+120).toString()+"px";
  6357. debuggerpausebutton.style["top"] = (height+150).toString()+"px";
  6358. debuggereval.style["width"] = (width-150).toString()+"px";
  6359. debuggereval.style["top"] = (height+120).toString()+"px";},true);
  6360.  
  6361.  
  6362. function timeout123() {
  6363. updateWssLog();
  6364. EVENTLOOPFUNCTION();
  6365. var now = Date.now();
  6366. var keys = Object.keys(playerids);
  6367. if(getroomslastcheck+3000<now){
  6368. getroomslastcheck = now;
  6369. if(inroom && savedrooms.length>0){
  6370. Gdocument.getElementById("roomlistrefreshbutton").click();
  6371. }
  6372. }
  6373. var namelist = Gdocument.getElementsByClassName("newbonklobby_playerentry_name");
  6374. for(var i = 0;i<namelist.length;i++){
  6375. var level = 0;
  6376. var levelelement = 0;
  6377. var pingelement = 0;
  6378. var avatarelement = 0;
  6379. var children = namelist[i].parentElement.children;
  6380. for(var i2 = 0;i2<children.length;i2++){
  6381. if(children[i2].className == "newbonklobby_playerentry_level"){
  6382. levelelement = children[i2];
  6383. level = parseInt(children[i2].textContent.slice(6));
  6384. }
  6385. else if(children[i2].className == "newbonklobby_playerentry_pingtext"){
  6386. pingelement = children[i2];
  6387. }
  6388. else if(children[i2].className == "newbonklobby_playerentry_avatar"){
  6389. avatarelement = children[i2];
  6390. }
  6391. }
  6392. var isadmin = [false,0];
  6393. for(var i3 = 0;i3<admins.length;i3++){
  6394. if(admins[i3][0] == namelist[i].textContent){
  6395. isadmin = [true,i3];
  6396. break;
  6397. }
  6398. }
  6399. if(level){
  6400. if(isadmin[0]){
  6401. namelist[i].style["color"] = "rgb("+admins[isadmin[1]][1].slice(0,-1).toString()+")";
  6402. var rotatevalue = 0;
  6403. if(admins[isadmin[1]][1][3]<90){
  6404. rotatevalue = admins[isadmin[1]][1][3]/2;
  6405. }
  6406. else if(admins[isadmin[1]][1][3]<270){
  6407. rotatevalue =(180-admins[isadmin[1]][1][3])/2;
  6408. }
  6409. else if(admins[isadmin[1]][1][3]<360){
  6410. rotatevalue = (-360+admins[isadmin[1]][1][3])/2;
  6411. }
  6412. namelist[i].parentElement.style["filter"] = "hue-rotate("+rotatevalue.toString()+"deg)";
  6413. namelist[i].parentElement.style["font-size"] = "17px";
  6414. 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()+")";
  6415. if(levelelement){
  6416. levelelement.style["color"] = "rgb("+admins[isadmin[1]][1].slice(0,-1).toString()+")";
  6417. }
  6418. if(pingelement){
  6419. pingelement.style["color"] = "rgb("+admins[isadmin[1]][1].slice(0,-1).toString()+")";
  6420. }
  6421. if(avatarelement){
  6422. avatarelement.style["filter"] = "hue-rotate("+rotatevalue.toString()+"deg)";
  6423. }
  6424. }
  6425. }
  6426. var stylekeys = Object.keys(allstyles);
  6427. for(var i3 = 0;i3<stylekeys.length;i3++){
  6428. if(stylekeys[i3] == namelist[i].textContent){
  6429. 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])){
  6430. var rgbvalue = [allstyles[stylekeys[i3]][0],allstyles[stylekeys[i3]][1],allstyles[stylekeys[i3]][2]];
  6431. namelist[i].style["color"] = "rgb("+rgbvalue.toString()+")";
  6432. if(!isadmin[0]){
  6433. var n = 255;
  6434. namelist[i].parentElement.style["background"] = "rgb("+[(203+rgbvalue[0])%n,(212+rgbvalue[1])%n,(215+rgbvalue[2])%n].toString()+")";
  6435. }
  6436. if(levelelement){
  6437. levelelement.style["color"] = "rgb("+rgbvalue.toString()+")";
  6438. }
  6439. if(pingelement){
  6440. pingelement.style["color"] = "rgb("+rgbvalue.toString()+")";
  6441. }
  6442. }
  6443. }
  6444. }
  6445. }
  6446. for(var i3 = 0;i3<admins.length;i3++){
  6447. if(admins[i3][1][0]==0 && admins[i3][1][1]==0 && admins[i3][1][2]==0){
  6448. admins[i3][1][2] = 180;
  6449. admins[i3][1][1] = 0;
  6450. admins[i3][1][0] = 0;
  6451. }
  6452. var rate = 5;
  6453. var lowest = 0;
  6454. var number = 360;
  6455. admins[i3][1][3] = (admins[i3][1][3]%number+4+number)%number;
  6456. if(admins[i3][1][0]>lowest && admins[i3][1][1] == lowest){
  6457. admins[i3][1][0]-=rate;
  6458. admins[i3][1][2]+=rate;
  6459. }
  6460. if(admins[i3][1][2]>lowest && admins[i3][1][0] == lowest){
  6461. admins[i3][1][2]-=rate;
  6462. admins[i3][1][1]+=rate;
  6463. }
  6464. if(admins[i3][1][1]>lowest && admins[i3][1][2] == lowest){
  6465. admins[i3][1][0]+=rate;
  6466. admins[i3][1][1]-=rate;
  6467. }
  6468. for(var i4 = 0;i4<3;i4++){
  6469. if(admins[i3][1][i4]<lowest){
  6470. admins[i3][1][i4]=lowest;
  6471. }
  6472. else if(admins[i3][1][i4]>255){
  6473. admins[i3][1][i4]=255;
  6474. }
  6475. }
  6476. }
  6477. if(randomchat){
  6478. if(randomchat_timestamp+randomchat_randomtimestamp<now){
  6479. randomchat_timestamp = now;
  6480. randomchat_randomtimestamp = 2000+Math.random()*2000;
  6481. var randnumber = Math.floor(Math.random()*randomchatpriority[0])-randomchatlastmessage[1];
  6482. for(var i = 0;i<randomchatpriority[1].length;i++){
  6483. if(randomchatpriority[1][i][0]!=randomchatlastmessage[0] && randomchatpriority[1][i][1]!=randomchatlastmessage[1]){
  6484. randnumber-=randomchatpriority[1][i][1];
  6485. if(randnumber<=0){
  6486. chat(flag_manage(randomchatpriority[1][i][0]));
  6487. randomchatpriority[1][i][1]+=2;
  6488. randomchatpriority[0]+=2;
  6489. randomchatlastmessage = randomchatpriority[1][i];
  6490. break;
  6491. }
  6492. }
  6493. }
  6494. }
  6495. }
  6496. for(var i = 0;i<keys.length;i++){
  6497. 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){
  6498. SEND('42[9,{"banshortid":'+keys[i].toString()+',"kickonly":'+(autokickban == 1).toString()+'}]');
  6499. autokickbantimestamp = now;
  6500. }
  6501. if(playerids[keys[i]].playerData){
  6502. if(playerids[keys[i]].playerData2){
  6503. if(playerids[keys[i]].playerData.transform){
  6504. playerids[keys[i]].playerData2.alive = true;
  6505. if(playerids[keys[i]].playerData2.timeStamp == 0){
  6506. playerids[keys[i]].playerData2.px = playerids[keys[i]].playerData.transform.position.x;
  6507. playerids[keys[i]].playerData2.py = playerids[keys[i]].playerData.transform.position.y;
  6508. playerids[keys[i]].playerData2.timeStamp = now;
  6509. }
  6510. else{
  6511. playerids[keys[i]].playerData2.xvel = (playerids[keys[i]].playerData2.px - playerids[keys[i]].playerData.transform.position.x)/(playerids[keys[i]].playerData2.timeStamp-now);
  6512. playerids[keys[i]].playerData2.yvel = (playerids[keys[i]].playerData2.py - playerids[keys[i]].playerData.transform.position.y)/(playerids[keys[i]].playerData2.timeStamp-now);
  6513. playerids[keys[i]].playerData2.px = playerids[keys[i]].playerData.transform.position.x;
  6514. playerids[keys[i]].playerData2.py = playerids[keys[i]].playerData.transform.position.y;
  6515. playerids[keys[i]].playerData2.timeStamp = now;
  6516. }
  6517. if(playerids[keys[i]].playerData2.timeStamp2 == 0){
  6518. playerids[keys[i]].playerData2.pvx = playerids[keys[i]].playerData2.xvel;
  6519. playerids[keys[i]].playerData2.pvy = playerids[keys[i]].playerData2.yvel;
  6520. playerids[keys[i]].playerData2.timeStamp2 = now;
  6521. }
  6522. else{
  6523. playerids[keys[i]].playerData2.xacc = (playerids[keys[i]].playerData2.pvx - playerids[keys[i]].playerData2.xvel)/((playerids[keys[i]].playerData2.timeStamp2-now));
  6524. playerids[keys[i]].playerData2.yacc = (playerids[keys[i]].playerData2.pvy - playerids[keys[i]].playerData2.yvel)/((playerids[keys[i]].playerData2.timeStamp2-now));
  6525. playerids[keys[i]].playerData2.pvx = playerids[keys[i]].playerData2.xvel;
  6526. playerids[keys[i]].playerData2.pvy = playerids[keys[i]].playerData2.yvel;
  6527. playerids[keys[i]].playerData2.timeStamp2 = now;
  6528. }
  6529. }
  6530. else{
  6531. if(playerids[keys[i]].playerData2.alive){
  6532.  
  6533. }
  6534. playerids[keys[i]].playerData2.alive = false;
  6535. }
  6536. }
  6537. else{
  6538. 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};
  6539. }
  6540. }
  6541. }
  6542. for(var i = 0;i<keys.length;i++){
  6543. if(!playerids[keys[i]].playerData2){
  6544. 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};
  6545. }
  6546. }
  6547. if(Gdocument.getElementById("redefineControls_table").children[0].children.length<=1 && keys.length>0){
  6548. Gdocument.getElementById("pretty_top_settings").click();
  6549. Gdocument.getElementById("settings_close").click();
  6550. }
  6551. if(pollactive[0] && pollactive[2]<now && ishost){
  6552. playerids[myid].ratelimit.poll = Date.now();
  6553. SEND("42"+JSON.stringify([4,{"type":"poll end","from":username}]));
  6554. var count = [0,0,0,0];
  6555. var keys = Object.keys(playerids);
  6556. for(var i = 0;i<keys.length;i++){
  6557. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive[3].length-1){
  6558. count[playerids[keys[i]].vote.poll]++;
  6559. }
  6560. playerids[keys[i]].vote.poll = -1;
  6561. }
  6562. displayInChat("The poll ended due to time.","#DA0808","#1EBCC1");
  6563. for(var i = 0;i<count.length;i++){
  6564. if(count[i]>1){
  6565. displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  6566. }
  6567. if(count[i]==1){
  6568. displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  6569. }
  6570. }
  6571. displayInChat("The poll was:","#DA0808","#1EBCC1");
  6572. for(var i = 0;i<pollactive[3].length;i++){
  6573. displayInChat(letters[i]+") "+pollactive[3][i],"#DA0808","#1EBCC1");
  6574. }
  6575. pollactive = [false,0,0,[]];
  6576. }
  6577. if(!ishost && sandboxcopyme!=-1){
  6578. sandboxcopyme = -1;
  6579. }
  6580. if(afkkill>0 && ishost){
  6581. var keys = Object.keys(playerids);
  6582. currentFrame = Math.floor((now - gameStartTimeStamp)/1000*30);
  6583. for(var i = 0; i<keys.length;i++){
  6584. if(typeof(playerids[keys[i]].lastmove)=="undefined"){
  6585. playerids[keys[i]].lastmove = now;
  6586. }
  6587. else{
  6588. if(playerids[keys[i]].playerData2?.alive && now-playerids[keys[i]].lastmove>=afkkill*1000 && now-gameStartTimeStamp>=afkkill*1000 && !killedids.includes(keys[i])){
  6589. killedids.push(keys[i]);
  6590. SEND('42[25,{"a":{"playersLeft":['+keys[i]+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  6591. RECIEVE('42[31,{"a":{"playersLeft":['+keys[i]+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  6592. break;
  6593. }
  6594. }
  6595. }
  6596. }
  6597. if(ishost && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS"){
  6598. clearmaprequests.style["display"] = "block";
  6599. refreshmaprequests.style["display"] = "block";
  6600. }
  6601. else{
  6602. clearmaprequests.style["display"] = "none";
  6603. refreshmaprequests.style["display"] = "none";
  6604. }
  6605. if(Gdocument.getElementById("gamerenderer").style["visibility"]=="hidden"){
  6606. Gdocument.getElementById("ingamewinner_scores").style["visibility"] = "unset";
  6607. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  6608. }
  6609. if(Gdocument.getElementById("maploadwindowmapscontainer").children.length>0 && maponclick == 0){
  6610. maponclick = Gdocument.getElementById("maploadwindowmapscontainer").children[0].onclick;
  6611. }
  6612. 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"] == "")){
  6613. var chatbox = Gdocument.getElementById("newbonklobby_chat_content");
  6614. while (chatbox.firstChild) {
  6615. chatbox.removeChild(chatbox.firstChild);
  6616. }
  6617. chatbox = Gdocument.getElementById("ingamechatcontent");
  6618. while (chatbox.firstChild) {
  6619. chatbox.removeChild(chatbox.firstChild);
  6620. }
  6621. rcaps_flag = false;
  6622. space_flag = false;
  6623. number_flag = false;
  6624. reverse_flag = false;
  6625. autocorrect = false;
  6626. translating2 = [false,""];
  6627. translating = [false,""];
  6628. echo_list = [];
  6629. scroll = false;
  6630. FollowCam = false;
  6631. autocam = false;
  6632. aimbot = false;
  6633. recievedinitdata = false;
  6634. zoom = 1;
  6635. zoom2 = 1;
  6636. newzoom = 1;
  6637. newzoom2 = 1;
  6638. FFA = true;
  6639. mode = "b";
  6640. ghostroomwss = -1;
  6641. heavybot = false;
  6642. stopquickplay = 1;
  6643. roundsperqp = 1;
  6644. roundsperqp2 = 0;
  6645. staystill = false;
  6646. staystillpos = [0,0];
  6647. recording = false;
  6648. recordingid = -1;
  6649. reverseqp = false;
  6650. jointeam = -1;
  6651. currentroomaddress = -1;
  6652. checkboxhidden = false;
  6653. freejoin = false;
  6654. shuffle = false;
  6655. defaultmode = "";
  6656. recmodebool = false;
  6657. recteams = false;
  6658. autorecord = false;
  6659. pollactive = [false,0,0,[]];
  6660. pollactive2 = [false,0,[]];
  6661. afkkill = -1;
  6662. nextafter = 0;
  6663. jointext = "";
  6664. ishost = false;
  6665. parentDraw = 0;
  6666. sandboxplayerids = {};
  6667. sandboxcopyme = -1;
  6668. wintext = "";
  6669. sandboxon = false;
  6670. sandboxid = 200;
  6671. disabledkeys = [];
  6672. myid = -1;
  6673. randomchat = false;
  6674. savedroombutton.className = "brownButton brownButton_classic buttonShadow brownButtonDisabled";
  6675. randomchatpriority = [0,[]];
  6676. randomchatlastmessage = ["",0];
  6677. autokickbantimestamp = 0;
  6678. autokickban = 0;
  6679. inroom = false;
  6680. causelag = false;
  6681. causelag2 = 0;
  6682. jukeboxplayerURL = "";
  6683. jukeboxplayer.src = "";
  6684. jukeboxplayervolume = 20;
  6685. allstyles = {};
  6686. if(!bonkwss){
  6687. playerids = {};
  6688. }
  6689.  
  6690. qppaused = false;
  6691. nextafterbuffer = -1;
  6692. hostid = -1;
  6693. if(chatlog[chatlog.length-1]!="ROOM END"){
  6694. chatlog.push("ROOM END");
  6695. }
  6696. }
  6697. else{
  6698. if(chatlog[chatlog.length-1]=="ROOM END"){
  6699. chatlog.push("ROOM START");
  6700. }
  6701. }
  6702.  
  6703. if(Gdocument.getElementById("newbonklobby").style["display"]=="block"){
  6704. Gdocument.getElementById("ingamechatinputtext").style["visibility"]="hidden";
  6705. }
  6706. else{
  6707. Gdocument.getElementById("ingamechatinputtext").style["visibility"]="visible";
  6708.  
  6709. }
  6710. if(Gdocument.getElementsByClassName('newbonklobby_settings_button brownButton brownButton_classic buttonShadow brownButtonDisabled').length == 0){
  6711. ishost = true;
  6712. }
  6713. else{
  6714. ishost = actuallyhost;
  6715. }
  6716.  
  6717. if(Gdocument.getElementById("pretty_top_name")!=null){
  6718. username = Gdocument.getElementById("pretty_top_name").textContent;
  6719. if(myid!=-1){
  6720. username = playerids[myid].userName;
  6721. }
  6722. }
  6723. try{
  6724. Last_message = lastmessage()
  6725. } catch{
  6726. Last_message = "";
  6727. }
  6728. if (Laster_message != Last_message){
  6729. Laster_message = Last_message;
  6730. if(changed_chat==false){
  6731. new_message = true;
  6732. }
  6733. else{
  6734. changed_chat = false;
  6735. }
  6736. }
  6737. if(new_message){
  6738. chatlog.push(Last_message);
  6739. var lm = "";
  6740. try{
  6741. lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  6742. if(typeof(lm[0].parentElement.style["parsed"]) == 'undefined'){
  6743. if (lm[0].className == "newbonklobby_chat_msg_colorbox"){
  6744. lm[2].innerHTML = urlify(lm[2].innerHTML);
  6745. Laster_message = lastmessage();
  6746. lm[0].parentElement.style["parsed"] = true;
  6747. }
  6748. if (lm[0].className == "newbonklobby_chat_status"){
  6749. lm[0].innerHTML = urlify(lm[0].innerHTML);
  6750. Laster_message = lastmessage();
  6751. lm[0].parentElement.style["parsed"] = true;
  6752. }
  6753. }
  6754. }
  6755. catch{
  6756. lm = "";
  6757. }
  6758.  
  6759. if(Last_message.indexOf("@"+username)!=-1 && npermissions == 1){
  6760. if(Notification.requestPermission()){
  6761. var n = new Notification(Last_message);
  6762. }
  6763. }
  6764.  
  6765. try{
  6766. lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  6767. if(typeof(lm[0].parentElement.style["parsed"])=='undefined'){
  6768. if(lm[0].className == "ingamechatname"){
  6769. lm[1].innerHTML = urlify(lm[1].innerHTML);
  6770. Laster_message = lastmessage();
  6771. lm[0].parentElement.style["parsed"] = true;
  6772. }
  6773. if(lm[0].className == ""){
  6774. lm[0].innerHTML = urlify(lm[0].innerHTML);
  6775. Laster_message = lastmessage();
  6776. lm[0].parentElement.style["parsed"] = true;
  6777. }
  6778. }
  6779. }
  6780. catch{
  6781. lm = "";
  6782. }
  6783. if(text2speech){
  6784. if(!sayer.speaking){
  6785. if(Last_message.includes(": ")){
  6786. speech.text = Last_message.substring(0,Last_message.indexOf(":")).toLowerCase();
  6787. speech.rate = 2.25;
  6788. sayer.speak(speech);
  6789. speech.text = Last_message.substring(Last_message.indexOf(": ")+3).toLowerCase();
  6790. speech.rate = 1.25;
  6791. sayer.speak(speech);
  6792. }
  6793. else{
  6794. speech.text = Last_message.toLowerCase();
  6795. sayer.speak(speech);
  6796. }
  6797. }
  6798. }
  6799. }
  6800. if (ishost==true && new_message){
  6801. for(i=0;i<banned.length;i++){
  6802. if(Last_message.startsWith("* "+banned[i]+" has joined the game")){
  6803. chat2("/kick '"+banned[i]+"'");
  6804. }
  6805. }
  6806. }
  6807. if(Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden" && ishost){
  6808. roundsperqp2 = 0;
  6809. }
  6810. if(Gdocument.getElementById("ingamewinner").style["visibility"]=="inherit" && ishost){
  6811. if(Gdocument.getElementById("ingamewinner").style["parsed"] != true){
  6812. if(stopquickplay!=1){
  6813. roundsperqp2++;
  6814. }
  6815. if(autorecord){
  6816. Gdocument.getElementById("pretty_top_replay").click();
  6817. }
  6818. }
  6819. if(Gdocument.getElementById("ingamewinner").style["parsed"] != true && wintext!="" && Gdocument.getElementById("ingamewinner_bottom").textContent!="DRAW"){
  6820. chat(flag_manage(wintext.replaceAll("username",Gdocument.getElementById("ingamewinner_top").textContent)));
  6821. }
  6822. Gdocument.getElementById("ingamewinner").style["parsed"] = true;
  6823. }
  6824. else{
  6825. Gdocument.getElementById("ingamewinner").style["parsed"] = false;
  6826. }
  6827. if(ishost && stopquickplay == 0){
  6828. if(checkboxhidden){
  6829. checkboxhidden = false;
  6830. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  6831. for(var i = 0; i<classes.length;i++){
  6832. classes[i].style["display"] = "block";
  6833. classes[i].className = "quickplaycheckbox quickplaychecked";
  6834. }
  6835. Gdocument.getElementById('clearallcheckboxes').style["display"] = "block";
  6836.  
  6837. }
  6838. if(nextafter>0 && gameStartTimeStamp+nextafter*1000<=now && Gdocument.getElementById("gamerenderer").style["visibility"] != "hidden" && dontswitch == false && Gdocument.getElementById("ingamewinner").style["visibility"]!="inherit" && !qppaused){
  6839. roundsperqp2 = 0;
  6840. if(shuffle){
  6841. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  6842. var available = [];
  6843. var availableindexes = [];
  6844. var notempty = false;
  6845. for(var i = 0; i<e.length;i++){
  6846. var a = false;
  6847. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  6848. available.push(a);
  6849. if(a){
  6850. availableindexes.push(i);
  6851. notempty = true;
  6852. }
  6853. }
  6854. if(notempty){
  6855. if(availableindexes.length!=1){
  6856. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  6857. }
  6858. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  6859. }
  6860. }
  6861. else{
  6862. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  6863. var available = [];
  6864. var availableindexes = [];
  6865. var notempty = false;
  6866. for(var i = 0; i<e.length;i++){
  6867. var a = false;
  6868. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  6869. available.push(a);
  6870. if(a){
  6871. availableindexes.push(i);
  6872. notempty = true;
  6873. }
  6874. }
  6875. if(notempty){
  6876. var above = [];
  6877. for(var i = 0;i<availableindexes.length;i++){
  6878. if(availableindexes[i]>quicki && !reverseqp){
  6879. above.push(availableindexes[i]);
  6880. }
  6881. else if(availableindexes[i]<quicki && reverseqp){
  6882. above.push(availableindexes[i]);
  6883. }
  6884. }
  6885. if(above.length>0){
  6886. quicki = above[0];
  6887. if(reverseqp){
  6888. above[above.length-1];
  6889. }
  6890. }
  6891. else{
  6892. quicki = availableindexes[0];
  6893. if(reverseqp){
  6894. quicki = availableindexes[availableindexes.length-1];
  6895. }
  6896. }
  6897. }
  6898. }
  6899. startedinqp = true;
  6900. dontswitch = true;
  6901. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  6902. }
  6903. if(Gdocument.getElementById("ingamewinner").style["visibility"]=="inherit" && dontswitch == false && !document.hidden && !qppaused){
  6904. if(roundsperqp2>=roundsperqp){
  6905. if(shuffle){
  6906. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  6907. var available = [];
  6908. var availableindexes = [];
  6909. var notempty = false;
  6910. for(var i = 0; i<e.length;i++){
  6911. var a = false;
  6912. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  6913. available.push(a);
  6914. if(a){
  6915. availableindexes.push(i);
  6916. notempty = true;
  6917. }
  6918. }
  6919. if(notempty){
  6920.  
  6921. if(availableindexes.length!=1){
  6922. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  6923. }
  6924. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  6925. }
  6926. }
  6927. else{
  6928. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  6929. var available = [];
  6930. var availableindexes = [];
  6931. var notempty = false;
  6932. for(var i = 0; i<e.length;i++){
  6933. var a = false;
  6934. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  6935. available.push(a);
  6936. if(a){
  6937. availableindexes.push(i);
  6938. notempty = true;
  6939. }
  6940. }
  6941. if(notempty){
  6942. var above = [];
  6943. for(var i = 0;i<availableindexes.length;i++){
  6944. if(availableindexes[i]>quicki && !reverseqp){
  6945. above.push(availableindexes[i]);
  6946. }
  6947. else if(availableindexes[i]<quicki && reverseqp){
  6948. above.push(availableindexes[i])
  6949. }
  6950. }
  6951. if(above.length>0){
  6952. quicki = above[0];
  6953. if(reverseqp){
  6954. quicki = above[above.length-1];
  6955. }
  6956. }
  6957. else{
  6958. quicki = availableindexes[0];
  6959. if(reverseqp){
  6960. quicki = availableindexes[availableindexes.length-1];
  6961. }
  6962.  
  6963. }
  6964. }
  6965. }
  6966. }
  6967. transitioning = true;
  6968. startedinqp = true;
  6969. map(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  6970. dontswitch = true;
  6971. setTimeout(function(){Gdocument.getElementById("ingamewinner").style["visibility"]="hidden"; dontswitch = false;},timedelay);
  6972. }
  6973. }
  6974. else{
  6975. if(!checkboxhidden){
  6976. checkboxhidden = true;
  6977. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  6978. for(var i = 0; i<classes.length;i++){
  6979. classes[i].style["display"] = "none";
  6980. classes[i].className = "quickplaycheckbox quickplayunchecked";
  6981. }
  6982. Gdocument.getElementById('clearallcheckboxes').style["display"] = "none";
  6983. }
  6984. }
  6985. new_message = false;
  6986. };
  6987. });

QingJ © 2025

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