Bonk Commands

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

当前为 2023-06-26 提交的版本,查看 最新版本

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

QingJ © 2025

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