Bonk Commands

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

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

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

QingJ © 2025

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