Bonk Commands

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

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

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

QingJ © 2025

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