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.7
  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. /*
  2407. var me = playerids[myid];
  2408. RECIEVE('42'+JSON.stringify([4,myid,me.peerID,me.userName,me.guest,me.level,me.team,me.avatar]));
  2409. */
  2410. }
  2411. if(args.data.startsWith('42[15,')){
  2412. var jsonargs = JSON.parse(args.data.substring(2));
  2413. dontswitch = false;
  2414. mode = jsonargs[3]["mo"];
  2415. gameStartTimeStamp = jsonargs[1];
  2416. killedids = [];
  2417. Gdocument.getElementById("newbonklobby").style["z-index"] = "unset";
  2418. Gdocument.getElementById("mapeditorcontainer").style["z-index"] = "unset";
  2419. }
  2420. if(args.data.startsWith('42[33,')){
  2421. var jsonargs = JSON.parse(args.data.substring(2));
  2422. var decodedmap = decodeFromDatabase(jsonargs[1]);
  2423. if(decodedmap!=0){
  2424. requestedmaps = [[decodedmap,jsonargs[1]]].concat(requestedmaps);
  2425. }
  2426. }
  2427. if(args.data.startsWith('42[7,')){
  2428. var jsonargs2 = JSON.parse(args.data.substring(2));
  2429. var idofpacket = jsonargs2[1];
  2430. jsonargs = jsonargs2[2];
  2431. if(typeof(jsonargs["i"]) == "undefined"){
  2432. if(jsonargs["type"]=="private chat" && jsonargs["to"] == username){
  2433. from = jsonargs["from"];
  2434. if(Object.keys(playerids).includes(idofpacket.toString())){
  2435. from = playerids[idofpacket].userName;
  2436. }
  2437. if(!ignorepmlist.includes(from)){
  2438. if(typeof(jsonargs["message"])=="object" && typeof(jsonargs["password"]) == "object"){
  2439. if(public_key[0]==jsonargs["public key"][0] && public_key[1]==jsonargs["public key"][1]){
  2440. var now = Date.now();
  2441. if(jsonargs["password"].length<=25 && playerids[idofpacket].ratelimit.pm+250<now){
  2442. playerids[idofpacket].ratelimit.pm = now;
  2443. var password = CRYPT_MESSAGE(private_key,jsonargs["password"]);
  2444. var decodedtext = jsonargs["message"].slice(0,400);
  2445. var encodedtext = "";
  2446. for(var i=0;i<decodedtext.length;i++){
  2447. if(password[i%password.length]<1000){
  2448. encodedtext+=String.fromCharCode(password[i%password.length]^decodedtext[i]);
  2449. }
  2450. }
  2451. 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);';
  2452. displayInChat('> '+'<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+from+'</a>'+': ',"#DA0808","#1EBCC1",{sanitize:false},encodedtext);
  2453.  
  2454. Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true;
  2455. Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true;
  2456. Laster_message = lastmessage();
  2457. }
  2458. }
  2459. else{
  2460. SEND("42"+JSON.stringify([4,{"type":"public key correction","from":username,"to":private_chat_public_key[0],"public key":public_key}]));
  2461. }
  2462. }
  2463. }
  2464. }
  2465. if(jsonargs["type"]=="request public key" && jsonargs["to"] == username){
  2466. SEND("42"+JSON.stringify([4,{"type":"public key","from":username,"public key":public_key}]));
  2467. }
  2468. if(jsonargs["type"]=="private chat users" && pmuserstimestamp+1500>Date.now()){
  2469. if(typeof(jsonargs["from"])!='undefined'){
  2470. from = jsonargs["from"];
  2471. if(Object.keys(playerids).includes(idofpacket.toString())){
  2472. from = playerids[idofpacket].userName;
  2473. }
  2474. if(!pmusers.includes(from) && username == jsonargs["to"]){
  2475. pmusers.push(from);
  2476. }
  2477. }
  2478. }
  2479. if(jsonargs["type"]=="request private chat users"){
  2480. if(typeof(jsonargs["from"])!='undefined'){
  2481. from = jsonargs["from"];
  2482. if(Object.keys(playerids).includes(idofpacket.toString())){
  2483. from = playerids[idofpacket].userName;
  2484. }
  2485. SEND("42"+JSON.stringify([4,{"type":"private chat users","from":username,"to":from}]));
  2486. }
  2487. }
  2488. if(jsonargs["type"]=="public key" && request_public_key_time_stamp+1500>Date.now()){
  2489. from = jsonargs["from"];
  2490. if(Object.keys(playerids).includes(idofpacket.toString())){
  2491. from = playerids[idofpacket].userName;
  2492. }
  2493. if(from == private_chat){
  2494. private_chat_public_key = [private_chat,jsonargs["public key"]];
  2495. displayInChat("Private chatting with "+private_chat+".","#DA0808","#1EBCC1");
  2496. }
  2497. }
  2498. if(jsonargs["type"]=="fakerecieve" && hostid == idofpacket && sandboxon && ((jsonargs["to"].includes(myid) && jsonargs["to"][0]!=-1) || (!jsonargs["to"].includes(myid) && jsonargs["to"][0]==-1))){
  2499. for(var i = 0;i<jsonargs["packet"].length;i++){
  2500. if(!jsonargs["packet"][i].startsWith("42[20,")){
  2501. RECIEVE(jsonargs["packet"][i]);
  2502. }
  2503. }
  2504. }
  2505. if(jsonargs["type"]=="customfakerecieve" && hostid == idofpacket && sandboxon && ((jsonargs["to"].includes(myid) && jsonargs["to"][0]!=-1) || (!jsonargs["to"].includes(myid) && jsonargs["to"][0]==-1))){
  2506. for(var i2 = 0;i2<jsonargs["packet"].length;i2++){
  2507. var keys = Object.keys(sandboxplayerids);
  2508. for(var i = 0;i<keys.length;i++){
  2509. if(jsonargs["packet"][i2].startsWith("42[7,")){
  2510. originalRecieve.call(this,{data:jsonargs["packet"][i2].replace("ID",keys[i].toString()).replace("CVALUE",playerids[keys[i]].movecount.toString())});
  2511. playerids[keys[i]].movecount+=1;
  2512. }
  2513. }
  2514. }
  2515. }
  2516. if(jsonargs["type"]=="commands"){
  2517. playerids[idofpacket].commands = true;
  2518. }
  2519. if(jsonargs["type"]=="sandboxid" && hostid == idofpacket && sandboxon && ((jsonargs["to"].includes(myid) && jsonargs["to"][0]!=-1) || (!jsonargs["to"].includes(myid) && jsonargs["to"][0]==-1))){
  2520. sandboxid = jsonargs["lastid"];
  2521. }
  2522. if(jsonargs["type"]=="sandboxon" && idofpacket == hostid){
  2523. if(!sandboxon){
  2524. displayInChat("This is a sandbox lobby.","#DA0808","#1EBCC1");
  2525. sandboxon = true;
  2526. }
  2527. }
  2528. if(jsonargs["type"]=="vote poll"){
  2529. from = jsonargs["from"];
  2530. if(Object.keys(playerids).includes(idofpacket.toString())){
  2531. from = playerids[idofpacket].userName;
  2532. }
  2533. if(typeof(jsonargs["vote"]) == 'number' && idofpacket!=hostid){
  2534. var now = Date.now();
  2535. if(ishost && pollactive[3].length>1 && pollactive[0]){
  2536. if(jsonargs["vote"]>=0 && jsonargs["vote"]<pollactive[3].length){
  2537. playerids[idofpacket].vote.poll = jsonargs["vote"];
  2538. }
  2539. }
  2540. else if(pollactive2[0] && pollactive2[2].length>1){
  2541. if(jsonargs["vote"]>=0 && jsonargs["vote"]<pollactive2[2].length){
  2542. playerids[idofpacket].vote.poll = jsonargs["vote"];
  2543. }
  2544. }
  2545. }
  2546.  
  2547. }
  2548. if(jsonargs["type"]=="poll end"){
  2549. from = jsonargs["from"];
  2550. if(Object.keys(playerids).includes(idofpacket.toString())){
  2551. from = playerids[idofpacket].userName;
  2552. }
  2553. var now = Date.now();
  2554. if(hostid == idofpacket && playerids[idofpacket].ratelimit.poll+5000<now){
  2555. playerids[idofpacket].ratelimit.poll = now;
  2556. var count = [0,0,0,0];
  2557. var keys = Object.keys(playerids);
  2558. for(var i = 0;i<keys.length;i++){
  2559. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive2[2].length-1){
  2560. count[playerids[keys[i]].vote.poll]++;
  2561. }
  2562. playerids[keys[i]].vote.poll = -1;
  2563. }
  2564. displayInChat("The poll ended.","#DA0808","#1EBCC1");
  2565. for(var i = 0;i<count.length;i++){
  2566. if(count[i]>1){
  2567. displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  2568. }
  2569. if(count[i]==1){
  2570. displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  2571. }
  2572. }
  2573. pollactive2 = [false,0,[]];
  2574. }
  2575.  
  2576. }
  2577. if(jsonargs["type"] == "video player" && idofpacket == hostid && ((jsonargs["to"].includes(myid) && jsonargs["to"][0]!=-1) || (!jsonargs["to"].includes(myid) && jsonargs["to"][0]==-1))){
  2578. changeJukeboxURL(jsonargs["url"],jsonargs["timestamp"]);
  2579. }
  2580. if(jsonargs["type"]=="poll" && idofpacket == hostid){
  2581. from = jsonargs["from"];
  2582. if(Object.keys(playerids).includes(idofpacket.toString())){
  2583. from = playerids[idofpacket].userName;
  2584. }
  2585. if(Array.isArray(jsonargs["poll"])){
  2586. var propperpoll = true;
  2587. var pollifproper = [];
  2588. if(jsonargs["poll"].length>5){
  2589. propperpoll = false;
  2590. }
  2591. else{
  2592. for(var i = 0;i<jsonargs["poll"].length;i++){
  2593. if(typeof(jsonargs["poll"][i]) == 'string'){
  2594. if(jsonargs["poll"][i].length>50){
  2595. propperpoll = false;
  2596. break;
  2597. }
  2598. else{
  2599. pollifproper.push(jsonargs["poll"][i]);
  2600. }
  2601. }
  2602. else{
  2603. propperpoll = false;
  2604. break;
  2605. }
  2606. }
  2607. }
  2608. if(propperpoll){
  2609. var now = Date.now();
  2610. var keys = Object.keys(playerids);
  2611. for(var i = 0;i<keys.length;i++){
  2612. playerids[keys[i]].vote.poll = -1;
  2613. }
  2614. pollactive2 = [true,now,pollifproper];
  2615. playerids[idofpacket].ratelimit.poll = now;
  2616. displayInChat(from+" started a poll:","#DA0808","#1EBCC1");
  2617. for(var i = 0;i<pollifproper.length;i++){
  2618. 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();';
  2619. displayInChat('<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+letters[i]+')</a>',"#DA0808","#1EBCC1",{sanitize:false}," "+pollifproper[i]);
  2620. }
  2621. }
  2622. }
  2623. }
  2624. if(jsonargs["type"]=="request mode" && playerids[idofpacket].ratelimit.mode+1000<Date.now()){
  2625. playerids[idofpacket].ratelimit.mode = Date.now();
  2626. from = jsonargs["from"];
  2627. if(Object.keys(playerids).includes(idofpacket.toString())){
  2628. from = playerids[idofpacket].userName;
  2629. }
  2630. var req_mode = jsonargs["mode"];
  2631. var req_mode2 = "";
  2632. if(req_mode){
  2633. if(req_mode == "b"){
  2634. req_mode2 = "Classic";
  2635. }
  2636. else if(req_mode == "sp"){
  2637. req_mode2 = "Grapple";
  2638. }
  2639. else if(req_mode == "ar"){
  2640. req_mode2 = "Arrows";
  2641. }
  2642. else if(req_mode == "ard"){
  2643. req_mode2 = "Death Arrows";
  2644. }
  2645. }
  2646. if(req_mode2){
  2647. 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+'")}';
  2648. displayInChat('> '+playerids[idofpacket].userName+' requests [<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+req_mode2+'</a>]',"#DA0808","#1EBCC1",{sanitize:false}," mode.");
  2649. }
  2650.  
  2651. }
  2652. if(jsonargs["type"]=="public key correction" && private_chat_public_key[0] == private_chat){
  2653. from = jsonargs["from"];
  2654. if(Object.keys(playerids).includes(idofpacket.toString())){
  2655. from = playerids[idofpacket].userName;
  2656. }
  2657. if(from == private_chat){
  2658. private_chat_public_key = [private_chat,jsonargs["public key"]];
  2659. var text = pmlastmessage;
  2660. var password = [];
  2661. for(var i = 0;i<10;i++){
  2662. password.push(Math.floor(Math.random()*100+50));
  2663. }
  2664. var text2 = [];
  2665. for(var i = 0;i<text.length ;i++){
  2666. text2.push(password[i%password.length]^text.slice(0,400).charCodeAt(i));
  2667. }
  2668. cc
  2669. }
  2670. }
  2671.  
  2672. }
  2673. else{
  2674. var now = Date.now();
  2675. if(playerids[idofpacket.toString()]){
  2676. playerids[idofpacket.toString()].lastmove = now;
  2677. }
  2678. if(idofpacket!=myid){
  2679. playerids[idofpacket.toString()].movecount+=1;
  2680. }
  2681. if(Math.abs(gameStartTimeStamp - (now-1000*jsonargs["f"]/30))>1000 && idofpacket!=myid){
  2682. gameStartTimeStamp = now-1000*jsonargs["f"]/30;
  2683. }
  2684. if(recording){
  2685. if(idofpacket.toString() == recordingid){
  2686. if(recordingdata.length == 0){
  2687. recordingdata.push([jsonargs["i"],jsonargs["f"]]);
  2688. }
  2689. recordingdata.push([jsonargs["i"],jsonargs["f"]-recordingdata[0][1]]);
  2690. }
  2691. }
  2692. if(ishost){
  2693. if(sandboxon && idofpacket == sandboxcopyme){
  2694. var jsonkeys = Object.keys(sandboxplayerids);
  2695. if(!jsonkeys.includes(sandboxcopyme.toString())){
  2696. var jsonargs2 = jsonargs;
  2697. for(var i = 0; i<jsonkeys.length;i++){
  2698. jsonargs2["c"] = playerids[jsonkeys[i]].movecount;
  2699. var packet = '42[7,'+jsonkeys[i].toString()+','+JSON.stringify(jsonargs2)+']';
  2700. RECIEVE(packet);
  2701. }
  2702. jsonargs2["c"] = "CVALUE";
  2703. jsonargs2 = JSON.stringify(jsonargs2).replace('"CVALUE"',"CVALUE");
  2704. SEND("42"+JSON.stringify([4,{"type":"customfakerecieve","from":username,"packet":['42[7,ID,'+jsonargs2+']'],to:[-1]}]));
  2705. }
  2706. }
  2707. for(var i = 0;i<disabledkeys.length;i++){
  2708. var get_keys_var = GET_KEYS(jsonargs["i"]);
  2709. if(get_keys_var[disabledkeys[i]]){
  2710. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden" && !killedids.includes(idofpacket)){
  2711. killedids.push(idofpacket);
  2712. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  2713. SEND('42[25,{"a":{"playersLeft":['+idofpacket.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  2714. RECIEVE('42[31,{"a":{"playersLeft":['+idofpacket.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  2715. break;
  2716. }
  2717. }
  2718. }
  2719. }
  2720. }
  2721. }
  2722.  
  2723. if(args.data.startsWith('42[4,')){
  2724. var jsonargs = JSON.parse(args.data.substring(2));
  2725. 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}};
  2726. if(jsonargs[2]!="sandbox"){
  2727. SEND('42[4,{"type":"commands"}]');
  2728. }
  2729. if(sandboxon){
  2730. var sandboxkeys = Object.keys(sandboxplayerids);
  2731. if(sandboxkeys.includes(jsonargs[1].toString())){
  2732. delete sandboxplayerids[jsonargs[1]];
  2733. }
  2734. if(jsonargs[2]=="sandbox"){
  2735. sandboxplayerids[jsonargs[1]] = jsonargs[3];
  2736. if(jsonargs[1]>sandboxid){
  2737. sandboxid = parseInt(jsonargs[1])+1;
  2738. }
  2739. }
  2740. else{
  2741. if(ishost){
  2742. SEND('42[4,{"type":"sandboxon"}]');
  2743. var sandboxkeys = Object.keys(sandboxplayerids);
  2744. var packets = [];
  2745. for(var i = 0;i<sandboxkeys.length;i++){
  2746. var p = playerids[sandboxkeys[i]];
  2747. var packet = '42'+JSON.stringify([4,sandboxkeys[i],p.peerID,p.userName,p.guest,p.level,p.team,p.avatar]);
  2748. packets.push(packet);
  2749. }
  2750. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":packets,to:[jsonargs[1]]}]));
  2751. SEND("42"+JSON.stringify([4,{"type":"sandboxid","from":username,"lastid":sandboxid,to:[jsonargs[1]]}]));
  2752. }
  2753. }
  2754. }
  2755. if(ishost){
  2756. if(jointext!="" && jsonargs[2]!="sandbox"){
  2757. chat(flag_manage(jointext.replaceAll("username",jsonargs[3])));
  2758. }
  2759. if(jointeam!=-1 && jsonargs[2]!="sandbox"){
  2760. SEND('42[26,{"targetID":'+jsonargs[1].toString()+',"targetTeam":'+jointeam.toString()+'}]');
  2761. setTimeout(function(){RECIEVE('42[18,'+jsonargs[1].toString()+','+jointeam.toString()+']');});
  2762. }
  2763. if(jukeboxplayer.src!="" && !jukeboxplayer.paused){
  2764. SEND("42"+JSON.stringify([4,{"type":"video player","from":username,"url":jukeboxplayerURL,"timestamp":Date.now()-jukeboxplayer.currentTime*1000,"to":[jsonargs[1]]}]));
  2765. }
  2766. if(freejoin){
  2767. var count = 0;
  2768. var keys = Object.keys(playerids);
  2769. for(var i = 0; i<keys.length;i++){
  2770. if(playerids[keys[i]].team!=0){
  2771. count++;
  2772. }
  2773. }
  2774. if(count <= 2 && jsonargs[6]!=0){
  2775. setTimeout(function(){
  2776. Gdocument.getElementById("newbonklobby_editorbutton").click();
  2777. Gdocument.getElementById("mapeditor_close").click();
  2778. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  2779. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  2780. if(transitioning == true){
  2781. canceled = true;
  2782. }
  2783. },150);
  2784. }
  2785. }
  2786. }
  2787.  
  2788. }
  2789. if(args.data.startsWith('42[5,')){
  2790. var jsonargs = JSON.parse(args.data.substring(2));
  2791. if(typeof(playerids[jsonargs[1]])!='undefined'){
  2792. delplayerids[jsonargs[1]] = playerids[jsonargs[1]];
  2793. delete playerids[jsonargs[1]];
  2794. }
  2795. if(sandboxon && typeof(sandboxplayerids[jsonargs[1]])!='undefined'){
  2796. delete sandboxplayerids[jsonargs[1]];
  2797. }
  2798. }
  2799. }}
  2800. return originalRecieve.call(this,args);
  2801. };
  2802.  
  2803. var originalClose = this.onclose;
  2804. this.onclose = function () {
  2805. if(bonkwssextra.includes(this)){
  2806. bonkwssextra.splice(bonkwssextra.indexOf(this),1)
  2807. }
  2808. else{
  2809. window.bonkwss = 0;
  2810. }
  2811. return originalClose.call(this);
  2812. }
  2813.  
  2814. }
  2815. return originalSend.call(this,args);
  2816. };
  2817.  
  2818. scope.SEND = function(args){
  2819. if(bonkwss!=0){
  2820. bonkwss.send(args);
  2821. }
  2822. };
  2823. scope.RECIEVE = function(args){
  2824. if(bonkwss!=0){
  2825. bonkwss.onmessage({data:args});
  2826. }
  2827. };
  2828.  
  2829.  
  2830.  
  2831. scope.dontswitch = false;
  2832. scope.username = 0;
  2833. scope.timedelay = 1400;
  2834. scope.ishost = false;
  2835. scope.checkboxhidden = true;
  2836. scope.quicki=0;
  2837. scope.defaultmode = "d";
  2838. scope.recmodebool = false;
  2839. scope.shuffle = false;
  2840. scope.startedinqp = false;
  2841. scope.instaqp = false;
  2842. scope.freejoin = false;
  2843. scope.recordedTimeStamp = 0;
  2844. scope.recordedId = 0;
  2845. scope.smartteams = false;
  2846. scope.beenKickedTimeStamp = 0;
  2847. scope.stopquickplay = 1;
  2848. scope.currentFrame = 0;
  2849. scope.text2speech = false;
  2850. scope.canceled = false;
  2851. scope.wintext = "";
  2852. scope.banned = [];
  2853. scope.transitioning = false;
  2854. scope.echo_list = [];
  2855. scope.echoAppend = "";
  2856. scope.message = "";
  2857. scope.private_chat = "";
  2858. scope.private_chat_public_key = ["",[0,0]];
  2859. scope.disabledkeys = [];
  2860. scope.actuallyhost = false;
  2861. scope.pmusers = [];
  2862. scope.pmlastmessage = "";
  2863. scope.pmuserstimestamp = 0;
  2864. scope.ignorepmlist = [];
  2865. scope.scroll = false;
  2866. scope.elem = Gdocument.getElementById("maploadwindowmapscontainer");
  2867. scope.npermissions = 1;
  2868. scope.space_flag = false;
  2869. scope.rcaps_flag = false;
  2870. scope.number_flag = false;
  2871. scope.reverse_flag = false;
  2872. scope.request_public_key_time_stamp = 0;
  2873. scope.sandboxcopyme = -1;
  2874. scope.recteams = false;
  2875. scope.chatheight = 128;
  2876. scope.onlykicked = false;
  2877. scope.killedids = [];
  2878. scope.jointext = "";
  2879. scope.randomchat = false;
  2880. scope.randomchatpriority = [0,[]];
  2881. scope.randomchatlastmessage = ["",0];
  2882. scope.afkkill = -1;
  2883. scope.tournament_mode = "";
  2884. scope.tournament_scores = [];
  2885. scope.tournament_in_and_out = {"in":[],"out":[]};
  2886. scope.echotext = "message";
  2887. scope.nextafter = 0;
  2888. scope.nextafterbuffer = -1;
  2889. scope.roundsperqp = 1;
  2890. scope.roundsperqp2 = 0;
  2891. scope.autorecord = false;
  2892. scope.poll = [];
  2893. scope.letters = ["A","B","C","D","E"];
  2894. scope.qppaused = false;
  2895. scope.FollowCam = false;
  2896. scope.autocam = false;
  2897. scope.gravity = 20;
  2898. scope.randomchat = false;
  2899. scope.randomchat_randomtimestamp = 0;
  2900. scope.randomchat_timestamp = 0;
  2901. scope.multiplier = 3.65;
  2902. scope.aimbot = false;
  2903. scope.recievedinitdata = false;
  2904. scope.heavybot = false;
  2905. scope.zoom = 1;
  2906. scope.prediction = 350;
  2907. scope.started = 0;
  2908. scope.holdheavy = 0;
  2909. scope.grappleheld = false;
  2910. scope.grappleheld2 = false;
  2911. scope.heavyheld = false;
  2912. scope.reverseqp = false;
  2913. scope.jointeam = -1;
  2914. scope.heavyheld2 = false;
  2915. scope.heavyid = 3;
  2916. scope.specialid = 0;
  2917. 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};
  2918. scope.leftRight = [37,39];
  2919. scope.upDown = [38,40];
  2920. scope.heavy = 88;
  2921. scope.special = 90;
  2922. scope.newzoom2 = 1;
  2923. scope.staystill = false;
  2924. scope.staystillpos = [0,0];
  2925. scope.zoom2 = 1;
  2926. scope.autokickban = 0;
  2927. scope.ghostroomwss = -1;
  2928. scope.autokickbantimestamp = 0;
  2929. scope.getroomslastcheck = 0;
  2930. scope.causelag = false;
  2931. scope.causelag2 = 0;
  2932. scope.overideDate = [false,0];
  2933. scope.scale = 1;
  2934. scope.pipedurl = "";
  2935. scope.pipedurllist = [
  2936. "https://pipedapi.kavin.rocks",
  2937. "https://pipedapi.syncpundit.io/streams/",
  2938. "https://api-piped.mha.fi/streams/",
  2939. "https://piped-api.garudalinux.org/streams/",
  2940. "https://pipedapi.rivo.lol/streams/",
  2941. "https://pipedapi.aeong.one/streams/",
  2942. "https://pipedapi.leptons.xyz/streams/",
  2943. "https://piped-api.lunar.icu/streams/",
  2944. "https://ytapi.dc09.ru/streams/",
  2945. "https://piped.tokhmi.xyz/streams/"];
  2946.  
  2947. async function checkInstances(){
  2948. var stop = false;
  2949. for (var i = 0;i<pipedurllist.length;i++){
  2950. if(stop){
  2951. break
  2952. }
  2953. fetch(pipedurllist[i]+"dQw4w9WgXcQ").then(
  2954. function(r){
  2955. return r.json();
  2956. }
  2957. ).then(function(r){
  2958. if (r.audioStreams && !stop){
  2959. stop = true;
  2960. pipedurl = pipedurllist[i];
  2961. }
  2962. }
  2963. ).catch(
  2964. function(){}
  2965. );
  2966. await new Promise((r) => setTimeout(r,500));
  2967. }
  2968. }
  2969. checkInstances();
  2970. scope.positive = function(angle){
  2971. if(angle<0){
  2972. angle += 2*Math.PI;
  2973. }
  2974. return angle%(Math.PI*2);
  2975. };
  2976. scope.angle_between = function(angle,angle2){
  2977. return Math.min(Math.abs(positive(angle)-positive(angle2)),Math.PI*2-Math.abs(positive(angle)-positive(angle2)));
  2978. };
  2979. scope.angle_between2 = function(angle,angle2){
  2980. if(angle_between(angle,angle2+Math.PI/2)<Math.PI/2){
  2981. return 1;
  2982. }
  2983. return -1;
  2984. };
  2985. scope.replay = function(){
  2986. var frame = getCurrentFrame();
  2987. /*var replaycounter = 0;
  2988. while(1){
  2989. if(replaycounter != recordingdata.length-1){
  2990. for(var i = 0;i<recordingdata[replaycounter+1][1]-recordingdata[replaycounter][1];i++){
  2991. RECIEVE('42[7,'+myid+',{"i":'+recordingdata[replaycounter][0]+',"f":'+(frame+i+recordingdata[replaycounter][1]).toString()+',"c":'+playerids[myid].movecount+'}]');
  2992. playerids[myid].movecount+=1;
  2993. }
  2994. replaycounter+=1;
  2995. }
  2996. else{
  2997. break;
  2998. }
  2999. }*/
  3000. for(var i = 0;i<recordingdata.length;i++){
  3001. SEND('42[4,{"i":'+recordingdata[i][0]+',"f":'+(frame+recordingdata[i][1]).toString()+',"c":'+playerids[myid].movecount+'}]');
  3002. }
  3003. };
  3004. scope.presskeys = function(x,y){
  3005. if(!x.left && y.left){
  3006. fire("keydown",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  3007. }
  3008. else if(x.left && !y.left){
  3009. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  3010. }
  3011. if(!x.right && y.right){
  3012. fire("keydown",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  3013. }
  3014. else if(x.right && !y.right){
  3015. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  3016. }
  3017. if(!x.up && y.up){
  3018. fire("keydown",{"keyCode":upDown[0]},Gdocument.getElementById("gamerenderer"));
  3019. }
  3020. else if(x.up && !y.up){
  3021. fire("keyup",{"keyCode":upDown[0]},Gdocument.getElementById("gamerenderer"));
  3022. }
  3023. if(!x.down && y.down){
  3024. fire("keydown",{"keyCode":upDown[1]},Gdocument.getElementById("gamerenderer"));
  3025. }
  3026. else if(x.down && !y.down){
  3027. fire("keyup",{"keyCode":upDown[1]},Gdocument.getElementById("gamerenderer"));
  3028. }
  3029. if(!x.heavy && y.heavy){
  3030. fire("keydown",{"keyCode":heavy},Gdocument.getElementById("gamerenderer"));
  3031. }
  3032. else if(x.heavy && !y.heavy){
  3033. fire("keyup",{"keyCode":heavy},Gdocument.getElementById("gamerenderer"));
  3034. }
  3035. if(!x.special && y.special){
  3036. fire("keydown",{"keyCode":special},Gdocument.getElementById("gamerenderer"));
  3037. }
  3038. else if(x.special && !y.special){
  3039. fire("keyup",{"keyCode":special},Gdocument.getElementById("gamerenderer"));
  3040. }
  3041. };
  3042. scope.getplayerkeys = function(){
  3043. var keykeys = Object.keys(keyCodes);
  3044. var keyslist = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[1].children).slice(1);
  3045. var keyslist2 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[2].children).slice(1);
  3046. var keyslist3 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[3].children).slice(1);
  3047. var keyslist4 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[4].children).slice(1);
  3048. var keyslist5 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[5].children).slice(1);
  3049. var keyslist6 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[6].children).slice(1);
  3050. for(var i = 0;i<keyslist.length;i++){
  3051. if(keykeys.includes(keyslist[i].textContent)){
  3052. leftRight[0] = keyCodes[keyslist[i].textContent];
  3053. break;
  3054. }
  3055. else{
  3056. leftRight[0] = keyslist[i].textContent.charCodeAt(0);
  3057. break
  3058. }
  3059. }
  3060. for(var i = 0;i<keyslist2.length;i++){
  3061. if(keykeys.includes(keyslist2[i].textContent)){
  3062. leftRight[1] = keyCodes[keyslist2[i].textContent];
  3063. break;
  3064. }
  3065. else{
  3066. leftRight[1] = keyslist2[i].textContent.charCodeAt(0);
  3067. break
  3068. }
  3069. }
  3070. for(var i = 0;i<keyslist3.length;i++){
  3071. if(keykeys.includes(keyslist3[i].textContent)){
  3072. upDown[0] = keyCodes[keyslist3[i].textContent];
  3073. break;
  3074. }
  3075. else{
  3076. upDown[0] = keyslist3[i].textContent.charCodeAt(0);
  3077. break
  3078. }
  3079. }
  3080. for(var i = 0;i<keyslist4.length;i++){
  3081. if(keykeys.includes(keyslist4[i].textContent)){
  3082. upDown[1] = keyCodes[keyslist4[i].textContent];
  3083. break;
  3084. }
  3085. else{
  3086. upDown[1] = keyslist4[i].textContent.charCodeAt(0);
  3087. break
  3088. }
  3089. }
  3090. for(var i = 0;i<keyslist5.length;i++){
  3091. if(keykeys.includes(keyslist5[i].textContent)){
  3092. heavy = keyCodes[keyslist5[i].textContent];
  3093. break;
  3094. }
  3095. else{
  3096. heavy = keyslist5[i].textContent.charCodeAt(0);
  3097. break
  3098. }
  3099. }
  3100. for(var i = 0;i<keyslist6.length;i++){
  3101. if(keykeys.includes(keyslist6[i].textContent)){
  3102. special = keyCodes[keyslist6[i].textContent];
  3103. break;
  3104. }
  3105. else{
  3106. special = keyslist6[i].textContent.charCodeAt(0);
  3107. break
  3108. }
  3109. }
  3110. };
  3111. scope.changeJukeboxURL = function(url,timestamp = 0){
  3112. if(url == ""){
  3113. jukeboxplayer.pause();
  3114. jukeboxplayer.src = '';
  3115. displayInChat("The jukebox has been paused.","#DA0808","#1EBCC1");
  3116. }
  3117. else if(url == jukeboxplayerURL && Date.now()-timestamp >= 2000){
  3118. jukeboxplayer.volume = jukeboxplayervolume/100;
  3119. displayInChat("The jukebox has been unpaused.","#DA0808","#1EBCC1",{sanitize:false});
  3120. jukeboxplayer.play();
  3121. jukeboxplayer.currentTime = (Date.now()-timestamp)/1000;
  3122. }
  3123. else{
  3124. let failed = {};
  3125. var id = url.match(/youtu\.?be.com\/watch\?.*v=[a-z|A-Z|0-9|_|-]{11}/)[0].split("?v=");
  3126. id = id[id.length-1];
  3127. fetch(pipedurl+id).then(function(response){
  3128. if(response.ok){
  3129. response.json().then(function(data){
  3130. var tries = 0;
  3131. new Promise(async function(resolve){
  3132. var loaded = false;
  3133. while(1){
  3134. var streams = data.audioStreams;
  3135. var audio = 0;
  3136. for(var i = 0;i<streams.length;i++){
  3137. if(streams[i].url && !failed[streams.url]){
  3138. audio = streams[i].url;
  3139. break;
  3140. }
  3141. }
  3142. if(!audio){
  3143. resolve();
  3144. displayInChat("The jukebox failed to load. Please try again.","#DA0808","#1EBCC1");
  3145. break;
  3146. }
  3147. var src = audio;
  3148. tries+=1;
  3149. jukeboxplayer.src = src;
  3150. jukeboxplayer.volume = jukeboxplayervolume/100;
  3151. jukeboxplayerURL = url;
  3152. jukeboxplayer.oncanplaythrough = function(){
  3153. displayInChat("The jukebox has been changed to: ","#DA0808","#1EBCC1",{sanitize:false},url);
  3154. displayInChat("Jukebox is now playing: "+data.title+" by "+data.uploader+".","#DA0808","#1EBCC1");
  3155. jukeboxplayer.play();
  3156. jukeboxplayer.currentTime = (Date.now()-timestamp)/1000;
  3157. jukeboxplayer.oncanplaythrough = null;
  3158. loaded = true;
  3159. };
  3160. var errored = false;
  3161. jukeboxplayer.onerror = function(){errored = true;};
  3162. await new Promise(function(r){
  3163. var interval = setInterval(function(){if(loaded||errored){r();clearInterval(interval)}},50);
  3164. });
  3165. if(loaded){
  3166. resolve();
  3167. break;
  3168. }
  3169. }
  3170. });
  3171. }).catch(function(){displayInChat("The jukebox failed to load. Please try again.","#DA0808","#1EBCC1");});
  3172. }
  3173. }).catch(function(){displayInChat("The jukebox failed to load. Please try again.","#DA0808","#1EBCC1");});
  3174. }
  3175. };
  3176. 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"];
  3177.  
  3178. scope.adv_help = {"help":"Shows all command names.",
  3179. "?":"Shows all command names.",
  3180. "advhelp":"Shows a command in detail.",
  3181. "space":"Toggles space. When space is on, whatever you type will be spaced apart.",
  3182. "rcaps":"Toggles rcaps. When rcaps is on, each letter will randomly get capitalized.",
  3183. "number":"Toggles number. When number is on, 'a' becomes 4, 'e' becomes 3, 's' becomes 5, 'o' becomes 0, 'l' and 'i' become 1.",
  3184. "speech":"Turns on text to speech for the chat.",
  3185. "savedroom":"Displays all the rooms you have saved, you can remove individual ones from the saved rooms by clicking \"Remove\".",
  3186. "clearsavedroom":"Clears all the saved rooms.",
  3187. "echo":"Echoes a username. It copies the username's chat messages.",
  3188. "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.",
  3189. "remove":"Removes username from echo list. You will not echo that username anymore.",
  3190. "clearecho":"Clears echo list. You will not echo anyone anymore.",
  3191. "chatw":"It private chats with username. Type /msg to message that username.",
  3192. "msg":"Messages with what username you are chatting with. Type /chatw to chat with a username.",
  3193. "ignorepm":"Ignores the username's private chat messages. To unignore, type '/ignorepm [username]'.",
  3194. "pmusers":"Dispays who you can private chat with.",
  3195. "pollstat":"Displays the current poll and its votes.",
  3196. "eval":"Evaluates code. Only use this if you are experienced in javascript.",
  3197. "debugger":"Opens debugger.",
  3198. "randomchat":"Spams random chat messages from the past.",
  3199. "lobby":"Makes lobby visible when you are ingame. Type '/lobby' again to close lobby.",
  3200. "score":"Displays the current score while ingame. Type '/score' again to hide the score.",
  3201. "team":"Joins a specific team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  3202. "scroll":"Toggles a scrollbar in ingame chat.",
  3203. "followcam":"Enables follow camera. Your character will be centered on the screen.",
  3204. "autocam":"Zooms in/out enough for you to see everyone on the screen.",
  3205. "zoom":"Zooms in, out, or resets zoom.",
  3206. "xray":"Removes all shapes that don't have a shadow. This means all non-physics shapes will be hidden.",
  3207. "aimbot":"Toggles aimbot. Aimbot will aim for you in arrows or death arrows mode.",
  3208. "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.",
  3209. "still":"Saves your position, and tries to reach it constantly. This is useful in parkour if you want to go afk.",
  3210. "lagbot":"Makes your movements very laggy. Type '/lagbot 0' to turn it off.",
  3211. "hidechat":"Hides ingame chat. Type '/showchat' to show it again.",
  3212. "showchat":"Shows ingame chat. '/hidechat' hides the chat.",
  3213. "notify":"You will be notified if a person types @username",
  3214. "stopnotify":"You will not be notified if a person types @username",
  3215. "support":"Displays all the people who have supported this mod.",
  3216. "startqp":"Starts cycling maps in your map menu.",
  3217. "stopqp":"Stops cycling maps in your map menu.",
  3218. "revqp":"Reverses the order of quickplay. '/next', '/previous' will be inverted.",
  3219. "pauseqp":"Only pauses or unpauses the quickplay cycle due to round end. '/next', '/previous' still work. Type 'pauseqp' to unpause quickplay.",
  3220. "next":"Skips the map. Usable only with '/startqp'.",
  3221. "nextafter":"Skips the map if no one is able to win/draw within a certain amount of time.",
  3222. "previous":"Goes to previous map. Usable only with '/startqp'.",
  3223. "shuffle":"Makes quickplay play random maps instead of in order.",
  3224. "freejoin":"Toggles freejoin. If freejoin is on, starts the game instantly if there are 1 or less players currently playing.",
  3225. "recmode":"In quickplay, it switches mode to recommended mode, according to editor.",
  3226. "recteam":"In quickplay, it sorts people into teams when teams are necessary.",
  3227. "defaultmode":"Switches mode to defaultmode if there is no recmode.",
  3228. "start":"Starts game instantly.",
  3229. "instaqp":"Rounds will instantly start without a countdown.",
  3230. "balanceA":"Balances everyone with balance number.",
  3231. "moveA":"Sets everyones team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  3232. "jointeam":"Sets the team of anyone who joins. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  3233. "moveT":"Sets everyone in one team to another team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  3234. "rounds":"Sets rounds to win.",
  3235. "replay":"Replays the movements that were recorded",
  3236. "record":"Records movements of the username",
  3237. "delrecording":"Deletes the recording with the name.",
  3238. "saverecording":"Saves the recording with the name.",
  3239. "loadrecording":"Loads the recording with the name. Type '/replay' to replay it.",
  3240. "stoprecord":"Stops recording the player. Type '/saverecording [text]' to save it.",
  3241. "jukebox":"Sets the jukebox to a link. That link will play for everyone who has this mod.",
  3242. "volume":"Sets the volume of the jukebox.",
  3243. "pausejukebox":"If the jukebox is playing, it pauses it.",
  3244. "resetjukebox":"Resets the jukebox, so it starts from the very beginning.",
  3245. "playjukebox":"If the jukebox is paused, it plays it.",
  3246. "roundsperqp":"After that many rounds, the map will change. Normally, the map will change after 1 round.",
  3247. "autorecord":"After a round ends, automatically records the last 15 seconds.",
  3248. "mode":"If host, switches mode. Otherwise, it requests the host to switch mode, as long as the host has this mod.",
  3249. "disablekeys":"If anyone presses a disabled key, they get killed. Key options: left right up down heavy special.",
  3250. "jointext":"Chats the jointext whenever someone joins. \"username\" will get replaced by the joining person's username.",
  3251. "wintext":"Chats the wintext whenever someone wins. \"username\" will get replaced by the winning person's username.",
  3252. "afkkill":"If a person stays afk for that many seconds, they get automatically killed.",
  3253. "ban":"Bans username from lobby. If they rejoin, it automatically bans.",
  3254. "kill":"Kills the person ingame.",
  3255. "resetpoll":"Clears the poll.",
  3256. "addoption":"Adds the option to the poll. You can only have 4 maximum options. Type '/deloption [letter]' to remove an option.",
  3257. "deloption":"Removes the option with that letter.",
  3258. "startpoll":"Starts a poll that lasts for at least 10 seconds. Type '/endpoll' to end it early.",
  3259. "endpoll":"Ends the poll early if the poll lasted for at least 10 seconds.",
  3260. "addplayer":"In sandbox, it adds bots.",
  3261. "addname":"Adds a bot with a specific name. If that name already exists, it will copy the skin of that player to the bot.",
  3262. "delplayer":"In sandbox, it deletes bots.",
  3263. "copy":"In sandbox, it makes all bots copy the username's movements.",
  3264. "sandbox":"Turns a normal lobby into a sandbox lobby. You cannot turn a sandbox lobby back into a normal lobby.",
  3265. "autokick":"Automatically kicks everyone who is not using this mod.",
  3266. "autoban":"Automatically bans everyone who is not using this mod.",
  3267. "Alt L":"Makes lobby visible when you are ingame. Press Alt L again to close lobby.",
  3268. "Alt C":"Hides ingame chat. Press Alt C again to show ingame chat.",
  3269. "Alt S":"Starts game instantly.",
  3270. "Alt T":"Toggles teams.",
  3271. "Alt N":"Enables follow camera. Your character will be centered on the screen.",
  3272. "Alt G":"Zooms in.",
  3273. "Alt H":"Resets zoom.",
  3274. "Alt J":"Zooms out.",
  3275. "Alt Y":"Enables xray. Removes all shapes that don't have a shadow. This means all non-physics shapes will be hidden.",
  3276. "Alt E":"Toggles editor.",
  3277. "Alt K":"Exits ingame and returns to lobby.",
  3278. "Alt M":"Switches modes.",
  3279. "Alt V":"Toggles autocam. Autocam zooms in/out enough for you to see everyone on the screen.",
  3280. "Alt Q":"Toggles quickplay.",
  3281. "Alt B":"Displays the current score while ingame. Press Alt B again to hide the score.",
  3282. "Alt A":"Skips the map if quickplay is on.",
  3283. "Alt D":"Goes to previous map if quickplay is on.",
  3284. "Alt F":"Toggles freejoin. If freejoin is on, starts the game instantly if there are 1 or less players currently playing.",
  3285. "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.",
  3286. "Alt U":"Toggles aimbot. Aimbot will aim for you in arrows or death arrows mode.",
  3287. "Alt P":"Only pauses or unpauses the quickplay cycle due to round end. '/next', '/previous' still work. Type 'pauseqp' to unpause quickplay.",
  3288. "Alt R":"In quickplay, it switches mode to recommended mode, according to editor.",
  3289. "Alt I":"Opens debugger.",
  3290. "Alt <":"Lowers ingame chat height.",
  3291. "Alt >":"Highers ingame chat height."
  3292. };
  3293. scope.displayadvhelp = function(command){
  3294. displayInChat(adv_help[command],"#009398","#DA0808",{sanitize:true},"",true);
  3295. };
  3296. scope.changemode = function(mode){
  3297. SEND('42[20,{"ga":"b","mo":"'+mode+'"}]');
  3298. RECIEVE('42[26,"b","'+mode+'"]');
  3299. };
  3300. Gdocument.getElementById("ingamechatcontent").style["pointer-events"]="all";
  3301. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  3302. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  3303. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  3304.  
  3305. document.getElementById('adboxverticalCurse').style["display"] = "none";
  3306. document.getElementById('adboxverticalleftCurse').style["display"] = "none";
  3307. elem.onclick=function(e){
  3308. if(stopquickplay==0 && ishost == true && e.isTrusted == true){
  3309. quicki = (Array.from(e.target.parentElement.parentNode.children).indexOf(e.target.parentNode)-1)%(Gdocument.getElementById("maploadwindowmapscontainer").children.length);
  3310. if(reverseqp){
  3311. quicki+=2;
  3312. quicki = quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length);
  3313. }
  3314. }
  3315. };
  3316. scope.getCurrentFrame = function(){
  3317. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  3318. return currentFrame;
  3319. };
  3320. scope.urlify = function(text) {
  3321. if(!Gdocument.getElementById('bl_Menu')){
  3322. return text.replace(/[(http(s)?):\/\/(www\.)?a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/ig, function(url) {
  3323. var extratext = "";
  3324. var matches = url.match(/youtu\.?be.com\/watch\?.*v=[a-z|A-Z|0-9|_|-]{11}/);
  3325. if(matches){
  3326. var button = Gdocument.createElement("a");
  3327. button.style["color"] = "green";
  3328. button.textContent = "Play";
  3329. button.href = "javascript:void(0)";
  3330. button.setAttribute("onclick",function(){
  3331. if(Gwindow.ishost){
  3332. Gwindow.SEND("42"+JSON.stringify([4,{"type":"video player","from":Gwindow.username,"url":"URL INSERT HERE","timestamp":Gwindow.Date.now()+2000,"to":[-1]}]));
  3333. Gwindow.displayInChat("Jukebox is loading... Please wait a few seconds.","#DA0808","#1EBCC1");
  3334. Gwindow.changeJukeboxURL("URL INSERT HERE",Gwindow.Date.now()+2000);
  3335. }
  3336. else{
  3337. Gwindow.displayInChat("You need to be host.","#DA0808","#1EBCC1");
  3338. }
  3339. });
  3340. button.attributes["onclick"].nodeValue = button.attributes["onclick"].nodeValue.slice(11,-1).replaceAll("URL INSERT HERE","https://www."+matches[0]);
  3341. var extratext = ' ['+button.outerHTML+']';
  3342. }
  3343. if(url.startsWith('https://') || url.startsWith('http://')){return '<a href="' + url + '" target="_blank" style = "color:orange">' + url + '</a>'+extratext;}
  3344. else{return '<a href="https://' + url + '" target="_blank" style = "color:orange">' + url + '</a>'+extratext;}
  3345. })}return text;
  3346. };
  3347. scope.fire = function(type,options,d = Gdocument){
  3348. var event= document.createEvent("HTMLEvents");
  3349. event.initEvent(type,true,false);
  3350. for(var p in options){
  3351. event[p]=options[p];
  3352. }
  3353. d.dispatchEvent(event);
  3354. };
  3355.  
  3356. scope.chat = function(message){
  3357. SEND('42[10,{"message":'+JSON.stringify(message)+'}]');
  3358. };
  3359. scope.chat2 = function(message,enteragain=false){
  3360. mess = Gdocument.getElementById("newbonklobby_chat_input").value;
  3361. mess2 = Gdocument.getElementById("ingamechatinputtext").value;
  3362. Gdocument.getElementById("newbonklobby_chat_input").value = message;
  3363. Gdocument.getElementById("ingamechatinputtext").value = message;
  3364. fire("keydown",{keyCode:13});
  3365. if(!enteragain){
  3366. fire("keydown",{keyCode:13});
  3367. }
  3368. Gdocument.getElementById("newbonklobby_chat_input").value = mess;
  3369. Gdocument.getElementById("ingamechatinputtext").value = mess2;
  3370. };
  3371. scope.displayInChat = function(message, LobbyColor, InGameColor, options, message2, BringDown) {
  3372. options = options ?? {};
  3373. BringDown = BringDown ?? false;
  3374. message2 = message2 ?? "";
  3375. LobbyColor = LobbyColor ?? "#8800FF";
  3376. InGameColor = InGameColor ?? "#AA88FF";
  3377. let A = Gdocument.createElement("div");
  3378. let B = Gdocument.createElement("span");
  3379. B.className = "newbonklobby_chat_status";
  3380. B.style.color = LobbyColor;
  3381. A.appendChild(B);
  3382. B.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  3383. B.innerHTML+=urlify(message2.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;'));
  3384. let C = Gdocument.createElement("div");
  3385. let D = Gdocument.createElement("span");
  3386. D.style.color = InGameColor;
  3387. C.appendChild(D);
  3388. D.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  3389. D.innerHTML+=urlify(message2.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;'));
  3390. let a = BringDown;
  3391. if(Gdocument.getElementById("newbonklobby_chat_content").clientHeight + Gdocument.getElementById("newbonklobby_chat_content").scrollTop >= Gdocument.getElementById("newbonklobby_chat_content").scrollHeight-1) {
  3392. a = true;
  3393. }
  3394. A.style["parsed"] = true;
  3395. C.style["parsed"] = true;
  3396. Gdocument.getElementById("newbonklobby_chat_content").appendChild(A);
  3397. Gdocument.getElementById("ingamechatcontent").appendChild(C);
  3398. if (a) { Gdocument.getElementById("newbonklobby_chat_content").scrollTop = Number.MAX_SAFE_INTEGER;};
  3399. Gdocument.getElementById("ingamechatcontent").scrollTop = Number.MAX_SAFE_INTEGER;
  3400. if(Gdocument.getElementById("newbonklobby_chat_input").style["pointer-events"]!="auto" && !Gdocument.getElementById("ingamechatinputtext").classList.value.includes("ingamechatinputtextbg")){
  3401. chat2("");
  3402. }
  3403. };
  3404.  
  3405. scope.lobby = function(){
  3406. if (Gdocument.getElementById("newbonklobby").style["display"]=="none"){
  3407.  
  3408. Gdocument.getElementById("newbonklobby_editorbutton").click();
  3409. Gdocument.getElementById("mapeditor_close").click();
  3410. if(Gdocument.getElementById("newbonklobby_playerbox_elementcontainer").children.length+Gdocument.getElementById("newbonklobby_specbox_elementcontainer").children.length-3>0){
  3411. Gdocument.getElementById("newbonklobby").style["z-index"]=1;
  3412. Gdocument.getElementById("maploadwindowcontainer").style["z-index"]=1;
  3413. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=1;
  3414. Gdocument.getElementById("pretty_top").style["z-index"]=3;
  3415. Gdocument.getElementById("settingsContainer").style["z-index"]=3;
  3416. Gdocument.getElementById("leaveconfirmwindow").style["z-index"]=3;
  3417. Gdocument.getElementById("hostleaveconfirmwindow").style["z-index"]=3;
  3418. debuggermenu.style["z-index"] = 2;
  3419. }
  3420. else{
  3421. Gdocument.getElementById("newbonklobby").style["opacity"]=0;
  3422. Gdocument.getElementById("newbonklobby").style["display"]="none";
  3423. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
  3424.  
  3425. }
  3426.  
  3427. }
  3428. else if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  3429. Gdocument.getElementById("newbonklobby").style["opacity"]=0;
  3430. Gdocument.getElementById("newbonklobby").style["display"]="none";
  3431. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
  3432.  
  3433. }
  3434. };
  3435.  
  3436. scope.lastmessage = function(){
  3437. if(Gdocument.getElementById("newbonklobby_chat_content").children.length!=0){
  3438. var lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  3439. var lm2 = "";
  3440. for(var i = 0; i<lm.length;i++){
  3441. lm2+=" "+lm[i].textContent.trim();
  3442. }
  3443. lm2 = lm2.trim();
  3444. if(lm2.startsWith("*")){
  3445. return lm2;
  3446. }
  3447. }
  3448. if(Gdocument.getElementById("ingamechatcontent").children.length!=0){
  3449. var lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  3450. var lm2 = "";
  3451. for(var i = 0; i<lm.length;i++){
  3452. lm2+=" "+lm[i].textContent.trim();
  3453. }
  3454. return lm2.trim();
  3455. }
  3456. return "";
  3457.  
  3458. };
  3459. scope.map = function(e,t=timedelay){
  3460. if(e<0){
  3461. displayInChat("There is no previous map.","#DA0808","#1EBCC1");
  3462. quicki = 0;
  3463. return;
  3464. }
  3465. if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
  3466. displayInChat("Click the maps button.","#DA0808","#1EBCC1");
  3467. return;
  3468. }
  3469.  
  3470. setTimeout(function(){if(!canceled){
  3471. startedinqp = true;
  3472. if(roundsperqp2>=roundsperqp){
  3473. roundsperqp2 = 0;
  3474. }
  3475. Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
  3476. Gdocument.getElementById("newbonklobby_editorbutton").click();
  3477. if(recmodebool && ishost){
  3478. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  3479. if(mode == "" && defaultmode!="d"){
  3480. mode = defaultmode;
  3481. }
  3482. if(mode != ""){
  3483. RECIEVE('42[26,"b","'+mode+'"]');
  3484. }
  3485. }
  3486. var displayblock = Gdocument.getElementById("newbonklobby").style["display"] == "block";
  3487. Gdocument.getElementById("mapeditorcontainer").style["display"] = "none";
  3488. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  3489. if(displayblock){
  3490. Gdocument.getElementById("newbonklobby").style["display"] = "block";
  3491. }
  3492. Gdocument.getElementById("mapeditor_midbox_testbutton").click();}
  3493. canceled = false;
  3494. transitioning = false;
  3495. },t);
  3496.  
  3497. };
  3498.  
  3499. scope.gotonextmap = function(e){
  3500. if(e<0){
  3501. displayInChat("There is no previous map.","#DA0808","#1EBCC1");
  3502. quicki = 0;
  3503. return;
  3504. }
  3505. if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
  3506. displayInChat("Click the maps button.","#DA0808","#1EBCC1");
  3507. return;
  3508. }
  3509. Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
  3510. Gdocument.getElementById("newbonklobby_editorbutton").click();
  3511. if(recmodebool && ishost){
  3512. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  3513. if(mode == "" && defaultmode!="d"){
  3514. mode = defaultmode;
  3515. }
  3516. if(mode != ""){
  3517. RECIEVE('42[26,"b","'+mode+'"]');
  3518. }
  3519. }
  3520. startedinqp = true;
  3521. if(roundsperqp2>=roundsperqp){
  3522. roundsperqp2 = 0;
  3523. }
  3524. var displayblock = Gdocument.getElementById("newbonklobby").style["display"] == "block";
  3525. Gdocument.getElementById("mapeditorcontainer").style["display"] = "none";
  3526. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  3527. if(displayblock){
  3528. Gdocument.getElementById("newbonklobby").style["display"] = "block";
  3529. }
  3530. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  3531. Gdocument.getElementById("newbonklobby").style["visibility"] = "visible";
  3532. };
  3533. scope.commandhandle = function(chat_val){
  3534. if (chat_val.substring(1,6)=="echo " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  3535. if (chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"")==username){
  3536. displayInChat("You cannot echo yourself.","#DA0808","#1EBCC1");
  3537. return "";
  3538. }
  3539. else if (echo_list.indexOf(chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',""))===-1) {
  3540.  
  3541. echo_list.push(chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',""));
  3542. displayInChat(chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"") + " is being echoed.","#DA0808","#1EBCC1");
  3543. return "";
  3544. }
  3545. else{
  3546. displayInChat(chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"") + " is already being echoed.","#DA0808","#1EBCC1");
  3547. return "";
  3548. }
  3549. }
  3550. else if (chat_val.substring(1,8)=="remove " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  3551. if (echo_list.indexOf(chat_val.substring(7).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',""))!==-1){
  3552. echo_list.splice(echo_list.indexOf(chat_val.substring(7).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"")),1);
  3553. displayInChat(chat_val.substring(7).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"")+" is not being echoed.","#DA0808","#1EBCC1");
  3554. return "";
  3555. }
  3556. else{
  3557. displayInChat("You cannot remove someone that you didn't echo.","#DA0808","#1EBCC1");
  3558. return "";
  3559. }
  3560.  
  3561. }
  3562. else if (chat_val.substring(1,10)=="echotext " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  3563. echotext = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  3564. displayInChat("Set echotext as: "+echotext,"#DA0808","#1EBCC1");
  3565. displayInChat("Type '/echotext' to reset echotext.","#DA0808","#1EBCC1");
  3566. return "";
  3567.  
  3568. }
  3569. else if (chat_val.substring(1,9)=="echotext"){
  3570. echotext = "message";
  3571. displayInChat("Reset echotext.","#DA0808","#1EBCC1");
  3572. return "";
  3573.  
  3574. }
  3575. else if (chat_val.substring(1,10)=="clearecho"){
  3576. echo_list = [];
  3577. displayInChat("Cleared the echo list.","#DA0808","#1EBCC1");
  3578. return "";
  3579. }
  3580. else if (chat_val.substring(1,11)=="randomchat"){
  3581. if(randomchat == true){
  3582. displayInChat("Random chat is now off.","#DA0808","#1EBCC1");
  3583. randomchat = false;
  3584. }
  3585. else{
  3586. displayInChat("Random chat is now on.","#DA0808","#1EBCC1");
  3587. randomchat = true;
  3588. }
  3589. return "";
  3590. }
  3591. else if (chat_val.substring(1,6)=="space"){
  3592. if(space_flag == true){
  3593. displayInChat("Space is now off.","#DA0808","#1EBCC1");
  3594. space_flag = false;
  3595. }
  3596. else{
  3597. displayInChat("Space is now on.","#DA0808","#1EBCC1");
  3598. space_flag = true;
  3599. }
  3600. return "";
  3601. }
  3602. else if (chat_val.substring(1,6)=="rcaps"){
  3603. if(rcaps_flag == true){
  3604. displayInChat("Rcaps is now off.","#DA0808","#1EBCC1");
  3605. rcaps_flag = false;
  3606. }
  3607. else{
  3608. displayInChat("Rcaps is now on.","#DA0808","#1EBCC1");
  3609. rcaps_flag = true;
  3610. }
  3611.  
  3612. return "";
  3613. }
  3614. else if (chat_val.substring(1,7)=="number"){
  3615. if(number_flag == true){
  3616. displayInChat("Number is now off.","#DA0808","#1EBCC1");
  3617. number_flag = false;
  3618. }
  3619. else{
  3620. displayInChat("Number is now on.","#DA0808","#1EBCC1");
  3621. number_flag = true;
  3622. }
  3623.  
  3624. return "";
  3625. }
  3626. else if (chat_val.substring(1,8)=="reverse"){
  3627. if(reverse_flag == true){
  3628. displayInChat("Reverse is now off.","#DA0808","#1EBCC1");
  3629. reverse_flag = false;
  3630. }
  3631. else{
  3632. displayInChat("Reverse is now on.","#DA0808","#1EBCC1");
  3633. reverse_flag = true;
  3634. }
  3635.  
  3636. return "";
  3637. }
  3638. else if (chat_val.substring(1,7)=="speech"){
  3639. if(text2speech == true){
  3640. displayInChat("Text to speech is now off.","#DA0808","#1EBCC1");
  3641. text2speech = false;
  3642. }
  3643. else{
  3644. displayInChat("Text to speech is now on.","#DA0808","#1EBCC1");
  3645. text2speech = true;
  3646. }
  3647.  
  3648. return "";
  3649. }
  3650. else if (chat_val.substring(1,6)=="eval " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  3651. var ev = "";
  3652. try{
  3653. ev = eval(chat_val.substring(6).replace(/^\s+|\s+$/g, ''));
  3654. }
  3655. catch(e){
  3656. displayInChat(e.message,"#DA0808","#1EBCC1");
  3657. }
  3658. try{
  3659. displayInChat(ev.toString(),"#DA0808","#1EBCC1");
  3660. }
  3661. catch{
  3662. }
  3663.  
  3664. return "";
  3665.  
  3666. }
  3667. else if (chat_val.substring(1,10)=="savedroom"){
  3668. if(savedrooms.length == 0){
  3669. displayInChat("You do not have any saved rooms.","#DA0808","#1EBCC1");
  3670. return "";
  3671. }
  3672. else{
  3673. var keys = Object.keys(savedroomsdata);
  3674. for(var i = 0;i<keys.length;i++){
  3675. var code = 'this.parentElement.remove();delete Gwindow.savedroomsdata["'+keys[i]+'"];Gwindow.savedrooms.splice(Gwindow.savedrooms.indexOf('+keys[i]+'),1);';
  3676. 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.");
  3677.  
  3678. Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true;
  3679. Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true;
  3680. Laster_message = lastmessage();
  3681. }
  3682. }
  3683. return "";
  3684. }
  3685. else if (chat_val.substring(1,15)=="clearsavedroom"){
  3686. if(savedrooms.length == 0){
  3687. displayInChat("You do not have any saved rooms.","#DA0808","#1EBCC1");
  3688. return "";
  3689. }
  3690. else{
  3691. var keys = Object.keys(savedroomsdata);
  3692. for(var i = 0;i<keys.length;i++){
  3693. savedrooms.splice(savedrooms.indexOf(parseInt(keys[i])),1);
  3694. delete savedroomsdata[keys[i]];
  3695. }
  3696. }
  3697. return "";
  3698. }
  3699. else if (chat_val.substring(1,10)=="followcam"){
  3700. if(FollowCam == true){
  3701. displayInChat("Follow Camera is now off.","#DA0808","#1EBCC1");
  3702. FollowCam = false;
  3703. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  3704. var addto = {"children":[]};
  3705. for(var i = 0;i<parentDraw.children.length;i++){
  3706. if(parentDraw.children[i].constructor.name == "e"){
  3707. addto = parentDraw.children[i];
  3708. break;
  3709. }
  3710. }
  3711. var canv = 0;
  3712. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  3713. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  3714. canv = Gdocument.getElementById("gamerenderer").children[i];
  3715. break;
  3716. }
  3717. }
  3718. var width = parseInt(canv.style["width"]);
  3719. var height = parseInt(canv.style["height"]);
  3720. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  3721. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  3722. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  3723. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  3724. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999){
  3725. pixiCircle.visible = false;
  3726. }
  3727. else{
  3728. pixiCircle.visible = true;
  3729. }
  3730. }
  3731. }
  3732. else{
  3733. displayInChat("Follow Camera is now on.","#DA0808","#1EBCC1");
  3734. FollowCam = true;
  3735. }
  3736.  
  3737. return "";
  3738. }
  3739. else if (chat_val.substring(1,8)=="autocam"){
  3740. if(autocam == true){
  3741. displayInChat("Auto Cam is now off.","#DA0808","#1EBCC1");
  3742. autocam = false
  3743. }
  3744. else{
  3745. displayInChat("Auto Cam is now on.","#DA0808","#1EBCC1");
  3746. autocam = true;
  3747. }
  3748.  
  3749. return "";
  3750. }
  3751. else if (chat_val.substring(1,7)=="aimbot"){
  3752. if(aimbot == true){
  3753. displayInChat("Aimbot is now off.","#DA0808","#1EBCC1");
  3754. aimbot = false;
  3755. }
  3756. else{
  3757. displayInChat("Aimbot is now on.","#DA0808","#1EBCC1");
  3758. aimbot = true;
  3759. getplayerkeys();
  3760. }
  3761.  
  3762. return "";
  3763. }
  3764. else if (chat_val.substring(1,8)=="volume " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  3765. var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '');
  3766. if(!isNaN(parseInt(text))){
  3767. int_text = parseInt(text);
  3768. if(int_text>=0 && int_text<=100){
  3769. jukeboxplayer.volume = int_text/100;
  3770. jukeboxplayervolume = int_text;
  3771. displayInChat("Jukebox volume set to: "+int_text.toString()+" percent.","#DA0808","#1EBCC1");
  3772. }
  3773. else{
  3774. displayInChat("Volume must be between 0 and 100 percent.","#DA0808","#1EBCC1");
  3775. }
  3776. }
  3777. return "";
  3778. }
  3779. else if (chat_val.substring(1,6)=="still"){
  3780. if(staystill == true){
  3781. displayInChat("Still is now off.","#DA0808","#1EBCC1");
  3782. staystill = false;
  3783. staystillpos = [0,0];
  3784. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  3785. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  3786. }
  3787. else{
  3788. if(playerids[myid].playerData?.transform){
  3789. displayInChat("Still is now on.","#DA0808","#1EBCC1");
  3790. staystill = true;
  3791. staystillpos = [playerids[myid].playerData.transform.position.x/scale,playerids[myid].playerData.transform.position.y/scale];
  3792. getplayerkeys();
  3793. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  3794. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  3795. }
  3796. else{
  3797. displayInChat("You have to be alive to use this command.","#DA0808","#1EBCC1");
  3798. }
  3799. }
  3800.  
  3801. return "";
  3802. }
  3803. else if (chat_val.substring(1,9)=="heavybot"){
  3804. if(heavybot == true){
  3805. displayInChat("Heavy bot is now off.","#DA0808","#1EBCC1");
  3806. heavybot = false;
  3807. }
  3808. else{
  3809. displayInChat("Heavy bot is now on.","#DA0808","#1EBCC1");
  3810. heavybot = true;
  3811. getplayerkeys();
  3812. }
  3813.  
  3814. return "";
  3815. }
  3816. else if (chat_val.substring(1,5)=="xray"){
  3817. Gdocument.getElementById("pretty_top_settings").click();
  3818. Gdocument.getElementById("settings_close").click();
  3819. if(Gdocument.getElementById("settings_graphicsquality").value==1){
  3820. displayInChat("You must have medium or high quality enabled to use this feature.","#DA0808","#1EBCC1");
  3821. return "";
  3822. }
  3823.  
  3824.  
  3825. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  3826. var addto = {"children":[]};
  3827. for(var i = 0;i<parentDraw.children.length;i++){
  3828. if(parentDraw.children[i].constructor.name == "e"){
  3829. addto = parentDraw.children[i];
  3830. break;
  3831. }
  3832. }
  3833. var addto2 = {"children":[]};
  3834. for(var i = 0;i<addto.children.length;i++){
  3835. if(addto.children[i].constructor.name == "e"){
  3836. addto2 = addto.children[i];
  3837. break;
  3838. }
  3839. }
  3840. var checkxray = addto2.children[0];
  3841. var addto3 = addto2.children[0].children;
  3842. if(addto3.length==1){
  3843. checkxray = checkxray.children[0];
  3844. addto3 = addto3[0].children;
  3845. }
  3846. var xrayon = false;
  3847. if(checkxray.xrayon){
  3848. checkxray.xrayon = false;
  3849. xrayon = false;
  3850. }
  3851. else{
  3852. checkxray.xrayon = true;
  3853. xrayon = true;
  3854. }
  3855. if(xrayon){
  3856. displayInChat("Xray is now on.","#DA0808","#1EBCC1");
  3857. for(var i = 0;i<addto3.length;i++){
  3858. if(addto3[i].children.length>0){
  3859. var ids = [];
  3860. var ids2 = [];
  3861. for(var i3 = 0;i3<addto3[i].children.length;i3++){
  3862. addto3[i].children[i3].visible = false;
  3863. if(addto3[i].children[i3].children.length>0){
  3864. for(var i4 = 0;i4<addto3[i].children[i3].children.length;i4++){
  3865. if(addto3[i].children[i3].children[i4].geometry?.id){
  3866. ids.push(addto3[i].children[i3].children[i4].geometry.id);
  3867. }
  3868. else if(addto3[i].children[i3].children[i4].texture?.baseTexture?.uid){
  3869. ids2.push(addto3[i].children[i3].children[i4].texture.baseTexture.uid);
  3870. }
  3871. }
  3872. }
  3873. }
  3874. for(var i3 = 0;i3<addto3[i].children.length;i3++){
  3875. if(addto3[i].children[i3].children.length==0){
  3876. if(addto3[i].children[i3].geometry?.id){
  3877. if(ids.includes(addto3[i].children[i3].geometry.id+1)){
  3878. addto3[i].children[i3].visible = true;
  3879. addto3[i].children[i3].alpha = 0.5;
  3880. }
  3881. }
  3882. else if(addto3[i].children[i3].texture?.baseTexture?.uid){
  3883. if(ids2.includes(addto3[i].children[i3].texture.baseTexture.uid+1)){
  3884. addto3[i].children[i3].visible = true;
  3885. addto3[i].children[i3].alpha = 0.5;
  3886. }
  3887. }
  3888. }
  3889. }
  3890. }
  3891. }
  3892.  
  3893. }
  3894. else{
  3895. displayInChat("Xray is now off.","#DA0808","#1EBCC1");
  3896. for(var i = 0;i<addto3.length;i++){
  3897. for(var i2 = 0;i2<addto3[i].children.length;i2++){
  3898. addto3[i].children[i2].visible = true;
  3899. addto3[i].children[i2].alpha = 1;
  3900. }
  3901. }
  3902. }
  3903. }
  3904.  
  3905. return "";
  3906. }
  3907. else if (chat_val.substring(1,6)=="zoom "){
  3908. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  3909. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  3910. var addto = 0;
  3911. for(var i = 0;i<parentDraw.children.length;i++){
  3912. if(parentDraw.children[i].constructor.name == "e"){
  3913. addto = parentDraw.children[i];
  3914. break;
  3915. }
  3916. }
  3917. var canv = 0;
  3918. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  3919. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  3920. canv = Gdocument.getElementById("gamerenderer").children[i];
  3921. break;
  3922. }
  3923. }
  3924. var width = parseInt(canv.style["width"]);
  3925. var height = parseInt(canv.style["height"]);
  3926. if(addto){
  3927. if(text == "in"){
  3928. zoom *= 1.1;
  3929. }
  3930. else if(text == "out"){
  3931. zoom /= 1.1;
  3932. }
  3933. else if(text == "reset"){
  3934. zoom = 1;
  3935. }
  3936. else{
  3937. displayInChat("Options for zooming:","#DA0808","#1EBCC1");
  3938. displayInChat("in","#DA0808","#1EBCC1");
  3939. displayInChat("out","#DA0808","#1EBCC1");
  3940. displayInChat("reset","#DA0808","#1EBCC1");
  3941. return "";
  3942. }
  3943. addto.scale.x=zoom;
  3944. addto.scale.y=zoom;
  3945. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  3946. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  3947. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  3948. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  3949. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999 && !FollowCam){
  3950. pixiCircle.visible = false;
  3951. }
  3952. else{
  3953. pixiCircle.visible = true;
  3954. }
  3955. }
  3956. }
  3957. return "";
  3958. }
  3959. else if (chat_val.substring(1,9)=="hidechat"){
  3960. Gdocument.getElementById("ingamechatcontent").style["max-height"]="0px";
  3961. return "";
  3962. }
  3963. else if (chat_val.substring(1,9)=="showchat"){
  3964. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  3965. return "";
  3966. }
  3967. else if (chat_val.substring(1,6)=="score"){
  3968. var element = Gdocument.getElementById("ingamewinner_scores");
  3969. element.style["visibility"] = "visible";
  3970. if(element.style["opacity"]<1){
  3971. element.style["opacity"] = 1;
  3972. }
  3973. else{
  3974. element.style["opacity"] = 0;
  3975. }
  3976. return "";
  3977. }
  3978.  
  3979. else if (chat_val.substring(1,7)=="scroll"){
  3980. if(scroll==false){
  3981. scroll = true;
  3982. Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="scroll";
  3983. Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
  3984. }
  3985. else if(scroll==true){
  3986. scroll = false;
  3987. Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="hidden";
  3988. Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
  3989. }
  3990.  
  3991. return "";
  3992. }
  3993.  
  3994. else if (chat_val.substring(1,7)=="chatw "){
  3995. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  3996.  
  3997. if(username == text){
  3998. displayInChat("You cannot private chat with yourself.","#DA0808","#1EBCC1");
  3999. return "";
  4000. }
  4001. private_chat = text;
  4002.  
  4003. SEND("42"+JSON.stringify([4,{"type":"request public key","from":username,"to":private_chat}]));
  4004. request_public_key_time_stamp = Date.now();
  4005. 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);
  4006. return "";
  4007. }
  4008. else if (chat_val.substring(1,8)=="lagbot " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  4009. var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '');
  4010. if(!isNaN(parseInt(text))){
  4011. int_text = parseInt(text);
  4012. if(int_text == 0){
  4013. causelag = false;
  4014. causelag2 = 0;
  4015. displayInChat("Lagbot is now off.","#DA0808","#1EBCC1");
  4016. displayInChat("To enable lagbot, type '/lagbot [number]' with a number between 1 and 10.","#DA0808","#1EBCC1");
  4017. }
  4018. else if(int_text>0 && int_text<=10){
  4019. causelag = true;
  4020. causelag2 = 45*int_text;
  4021. displayInChat("Lagbot is now on with a lag setting of "+int_text.toString()+" (~"+(45*int_text).toString()+"MS).","#DA0808","#1EBCC1");
  4022. displayInChat("Type '/lagbot 0' to turn off lagbot.","#DA0808","#1EBCC1");
  4023. }
  4024. else{
  4025. displayInChat("To enable lagbot, type '/lagbot [number]' with a number between 1 and 10.","#DA0808","#1EBCC1");
  4026. displayInChat("Type '/lagbot 0' to turn off lagbot.","#DA0808","#1EBCC1");
  4027. }
  4028. }
  4029. return "";
  4030. }
  4031. else if (chat_val.substring(1,8)=="record " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  4032. var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  4033. var keys = Object.keys(playerids);
  4034. var recordingid2 = -1;
  4035. for(var i = 0;i<keys.length;i++){
  4036. if(playerids[keys[i]].userName == text){
  4037. recordingid2 = keys[i];
  4038. }
  4039. }
  4040. if(recordingid2 == -1){
  4041. displayInChat("Player not found. Please type a valid username.","#DA0808","#1EBCC1");
  4042. return "";
  4043. }
  4044. else{
  4045. recording = true;
  4046. recordingid = recordingid2;
  4047. displayInChat(playerids[recordingid].userName+" is now being recorded.","#DA0808","#1EBCC1");
  4048. if(recordingdata.length>0){
  4049. displayInChat("Any unsaved recording data is now cleared.","#DA0808","#1EBCC1");
  4050. }
  4051. recordingdata = [];
  4052. }
  4053. return "";
  4054. }
  4055. else if (chat_val.substring(1,11)=="stoprecord"){
  4056. if(recording){
  4057. displayInChat(playerids[recordingid].userName+" is not being recorded anymore.","#DA0808","#1EBCC1");
  4058. displayInChat("Type '/saverecording [text]' to save this recording.","#DA0808","#1EBCC1");
  4059. recording = false;
  4060. recordingid = -1;
  4061. recordingdata[0][1] = 0;
  4062. }
  4063. else{
  4064. displayInChat("No one is being recorded.","#DA0808","#1EBCC1");
  4065. }
  4066. return "";
  4067. }
  4068. else if (chat_val.substring(1,15)=="saverecording " && chat_val.replace(/^\s+|\s+$/g, '').length>=16){
  4069. var text = chat_val.substring(15).replace(/^\s+|\s+$/g, '');
  4070. if(Object.keys(recorddata).includes(text)){
  4071. displayInChat("This recording already exists. Please use a different name or type '/delrecording "+text+"'.","#DA0808","#1EBCC1");
  4072. }
  4073. else if(recordingdata.length>0){
  4074. recorddata[text] = JSON.parse(JSON.stringify(recordingdata));
  4075. displayInChat("Recording saved as: "+text,"#DA0808","#1EBCC1");
  4076. }
  4077. else{
  4078. displayInChat("There is no recording data to save. Please record data using '/record [username]'","#DA0808","#1EBCC1");
  4079. }
  4080. return "";
  4081. }
  4082. else if (chat_val.substring(1,14)=="delrecording " && chat_val.replace(/^\s+|\s+$/g, '').length>=15){
  4083. var text = chat_val.substring(14).replace(/^\s+|\s+$/g, '');
  4084. if(Object.keys(recorddata).includes(text)){
  4085. displayInChat("Recording deleted.","#DA0808","#1EBCC1");
  4086. delete recorddata[text];
  4087. }
  4088. else{
  4089. displayInChat("This recording does not exist.","#DA0808","#1EBCC1");
  4090. }
  4091. return "";
  4092. }
  4093. else if (chat_val.substring(1,15)=="loadrecording " && chat_val.replace(/^\s+|\s+$/g, '').length>=16){
  4094. var text = chat_val.substring(15).replace(/^\s+|\s+$/g, '');
  4095. if(!Object.keys(recorddata).includes(text)){
  4096. displayInChat("This recording does not exist.","#DA0808","#1EBCC1");
  4097. }
  4098. else{
  4099. if(recordingdata.length>0){
  4100. displayInChat("Any unsaved recording data is now cleared.","#DA0808","#1EBCC1");
  4101. }
  4102. recordingdata = JSON.parse(JSON.stringify(recorddata[text]));
  4103. displayInChat("Recording data is now loaded.","#DA0808","#1EBCC1");
  4104. }
  4105. return "";
  4106. }
  4107. else if (chat_val.substring(1,7)=="replay"){
  4108. if(recording){
  4109. displayInChat(playerids[recordingid].userName+" is not being recorded anymore.","#DA0808","#1EBCC1");
  4110. displayInChat("Type '/saverecording [text]' to save this recording.","#DA0808","#1EBCC1");
  4111. recordingid = -1;
  4112. recording = false;
  4113. recordingdata[0][1] = 0;
  4114. }
  4115. replay();
  4116. return "";
  4117. }
  4118. else if (chat_val.substring(1,5)=="msg " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  4119. if(private_chat_public_key[1][0] != 0 && private_chat_public_key[1][1] != 0 && private_chat_public_key[0] == private_chat){
  4120. var text = chat_val.substring(5).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  4121. var password = [];
  4122. for(var i = 0;i<10;i++){
  4123. password.push(Math.floor(Math.random()*100+50));
  4124. }
  4125. var text2 = [];
  4126. for(var i = 0;i<text.slice(0,400).length ;i++){
  4127. text2.push(password[i%password.length]^text.slice(0,400).charCodeAt(i));
  4128. }
  4129. pmlastmessage = text.slice(0,400);
  4130. 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)}]));
  4131. displayInChat("> "+username+": ","#DA0808","#1EBCC1",{sanitize:false},text,false);
  4132. Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true;
  4133. Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true;
  4134. Laster_message = lastmessage();
  4135.  
  4136. }
  4137. return "";
  4138. }
  4139. else if (chat_val.substring(1,10)=="ignorepm " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  4140. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  4141. if(ignorepmlist.includes(text)){
  4142. var index = ignorepmlist.indexOf(text);
  4143. ignorepmlist.splice(index,1);
  4144. displayInChat("You are not ignoring private messages from "+text+".","#DA0808","#1EBCC1");
  4145.  
  4146. }
  4147. else{
  4148. ignorepmlist.push(text);
  4149. displayInChat("You are now ignoring private messages from "+text+".","#DA0808","#1EBCC1");
  4150. }
  4151. return "";
  4152. }
  4153. else if (chat_val.substring(1,8)=="pmusers"){
  4154. pmusers = [];
  4155. SEND("42"+JSON.stringify([4,{"type":"request private chat users","from":username}]));
  4156. pmuserstimestamp = Date.now();
  4157. setTimeout(function(){if(pmusers.length == 0){displayInChat("You cannot private chat with anyone.","#DA0808","#1EBCC1");
  4158. }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);
  4159. return "";
  4160. }
  4161. else if (chat_val.substring(1,6)=="lobby"){
  4162. lobby();
  4163. return "";
  4164. }
  4165. else if (chat_val.substring(1,9)=="debugger"){
  4166. if(Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"] == "none"){
  4167. debuggeropen = true;
  4168. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="block";
  4169. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="none";
  4170. Gdocument.getElementById("ingamechatinputtext").style["display"] = "none";
  4171. }
  4172. else{
  4173. debuggeropen = false;
  4174. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="none";
  4175. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  4176. Gdocument.getElementById("ingamechatinputtext").style["display"] = "";
  4177. }
  4178. return "";
  4179. }
  4180. else if (chat_val.substring(1,6)=="team " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  4181. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  4182. if(text == "r"){Gdocument.getElementById("newbonklobby_redbutton").click();}
  4183. else if(text == "g"){Gdocument.getElementById("newbonklobby_greenbutton").click();}
  4184. else if(text == "y"){Gdocument.getElementById("newbonklobby_yellowbutton").click();}
  4185. else if(text == "b"){Gdocument.getElementById("newbonklobby_bluebutton").click();}
  4186. else if(text == "s"){Gdocument.getElementById("newbonklobby_specbutton").click();}
  4187. else if(text == "f"){Gdocument.getElementById("newbonklobby_ffabutton").click();}
  4188. return "";
  4189. }
  4190. else if (chat_val.substring(1,7)=="notify"){
  4191. npermissions = 1;
  4192. return "";
  4193. }
  4194. else if (chat_val.substring(1,11)=="stopnotify"){
  4195. npermissions = 0;
  4196. return "";
  4197. }
  4198. else if (chat_val.substring(1,8)=="support"){
  4199. displayInChat("Thanks everyone for helping me make this mod - LEGENDBOSS123","#0000FF","#FFFFFF");
  4200. displayInChat("mastery3","#0000FF","#FFFFFF");
  4201. displayInChat("UnmatchedBracket aka Left Paren","#0000FF","#FFFFFF");
  4202. displayInChat("iNeonz","#0000FF","#FFFFFF");
  4203. return "";
  4204. }
  4205. else if (chat_val.substring(1,9)=="pollstat"){
  4206. if(pollactive[0] || pollactive2[0]){
  4207. var count = [0,0,0,0];
  4208. var keys = Object.keys(playerids);
  4209. for(var i = 0;i<keys.length;i++){
  4210. if(ishost){
  4211. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive[3].length-1){
  4212. count[playerids[keys[i]].vote.poll]++;
  4213. }
  4214. }
  4215. else{
  4216. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive2[2].length-1){
  4217. count[playerids[keys[i]].vote.poll]++;
  4218. }
  4219. }
  4220. }
  4221. for(var i = 0;i<count.length;i++){
  4222. if(count[i]>1){
  4223. displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  4224. }
  4225. if(count[i]==1){
  4226. displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  4227. }
  4228. }
  4229. if(ishost){
  4230. displayInChat("The poll will end in: "+((pollactive[2]-Date.now())/1000).toString()+" seconds.","#DA0808","#1EBCC1");
  4231. }
  4232. displayInChat("The poll is:","#DA0808","#1EBCC1");
  4233. if(ishost){
  4234. for(var i = 0;i<pollactive[3].length;i++){
  4235. displayInChat(letters[i]+") "+pollactive[3][i],"#DA0808","#1EBCC1");
  4236. }
  4237. }
  4238. else{
  4239. for(var i = 0;i<pollactive2[2].length;i++){
  4240. displayInChat(letters[i]+") "+pollactive2[2][i],"#DA0808","#1EBCC1");
  4241. }
  4242. }
  4243. }
  4244. else{
  4245. displayInChat("No poll has been started.","#DA0808","#1EBCC1");
  4246. if(ishost){
  4247. displayInChat("Type '/startpoll [seconds]' to start a poll.","#DA0808","#1EBCC1");
  4248. if(poll.length>0){
  4249. displayInChat("The poll is:","#DA0808","#1EBCC1");
  4250. for(var i = 0;i<poll.length;i++){
  4251. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  4252. }
  4253. }
  4254. }
  4255. }
  4256. return "";
  4257. }
  4258. else if (chat_val.substring(1,5)=="help" || chat_val.substring(1,2)=="?"){
  4259. for(var i = 0;i<help.length;i++){
  4260. if(help[i].startsWith("/")){
  4261. var splitted = help[i].substring(1).split(" ");
  4262. var command = splitted[0];
  4263. var rest = "";
  4264. if(splitted.length>1){
  4265. rest = " "+splitted.slice(1).join(" ");
  4266. }
  4267. displayInChat("/"+'<a onclick = \'Gwindow.displayadvhelp("'+command+'");\' style = "color:green;" href = "javascript:void(0);">'+command+'</a>'+rest,"#DA0808","#1EBCC1",{sanitize:false},"",false);
  4268. }
  4269. else if(help[i].startsWith("Alt ")){
  4270. displayInChat('<a onclick = \'Gwindow.displayadvhelp("'+help[i]+'");\' style = "color:green;" href = "javascript:void(0);">'+help[i]+'</a>',"#DA0808","#1EBCC1",{sanitize:false},"",false);
  4271. }
  4272. else{
  4273. displayInChat(help[i],"#DA0808","#1EBCC1");
  4274. }
  4275.  
  4276. }
  4277. return "";
  4278. }
  4279. else if (chat_val.substring(1,9)=="advhelp " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  4280. var text = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  4281. if(typeof(adv_help[text])!='undefined'){
  4282. displayInChat(adv_help[text],"#DA0808","#1EBCC1");
  4283. }
  4284. return "";
  4285. }
  4286. else if (chat_val.substring(1,6)=="mode " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  4287. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  4288. var mode = "";
  4289. var text2 = text;
  4290. if(text == "arrows"){
  4291. text2 = "Arrows";
  4292. mode = "ar";
  4293. }
  4294. else if(text == "death arrows"){
  4295. mode = "ard";
  4296. text2 = "Death Arrows";
  4297. }
  4298. else if(text == "grapple"){
  4299. mode = "sp";
  4300. text2 = "Grapple";
  4301. }
  4302. else if(text == "classic"){
  4303. mode = "b";
  4304. text2 = "Classic";
  4305. }
  4306. else{
  4307. displayInChat("Mode options:","#DA0808","#1EBCC1");
  4308. displayInChat("classic","#DA0808","#1EBCC1");
  4309. displayInChat("arrows","#DA0808","#1EBCC1");
  4310. displayInChat("death arrows","#DA0808","#1EBCC1");
  4311. displayInChat("grapple","#DA0808","#1EBCC1");
  4312. }
  4313. if(mode != ""){
  4314. if(ishost){
  4315. SEND('42[20,{"ga":"b","mo":"'+mode+'"}]');
  4316. RECIEVE('42[26,"b","'+mode+'"]');
  4317. displayInChat("Changed mode to "+text+".","#DA0808","#1EBCC1");
  4318. }
  4319. else{
  4320. if(playerids[myid].ratelimit.mode+1000<Date.now()){
  4321. playerids[myid].ratelimit.mode=Date.now();
  4322. SEND("42"+JSON.stringify([4,{"type":"request mode","from":username,"mode":mode}]));
  4323. var code = 'if(!Gwindow.ishost){Gwindow.displayInChat("You must be host to change the mode.","#DA0808","#1EBCC1",{sanitize:false},"",true)}else{Gwindow.changemode("'+mode+'")}';
  4324. displayInChat('> '+username+' requests [<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+text2+'</a>]',"#DA0808","#1EBCC1",{sanitize:false}," mode.");
  4325.  
  4326. }
  4327. else{
  4328. displayInChat("You are requesting modes too quickly.","#DA0808","#1EBCC1");
  4329. }
  4330. }
  4331. }
  4332. return "";
  4333.  
  4334. }
  4335. else if(ishost){
  4336. if (chat_val.substring(1,11)=="nextafter " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  4337. var text = parseFloat(chat_val.substring(11).replace(/^\s+|\s+$/g, ''));
  4338. if(isNaN(text)){
  4339. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  4340. return "";
  4341. }
  4342. else if(text<=0){
  4343. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  4344. return "";
  4345. }
  4346. nextafter = text;
  4347. displayInChat("Set next after to: " + text.toString()+" seconds.","#DA0808","#1EBCC1");
  4348. displayInChat("Type '/nextafter' to reset next after.","#DA0808","#1EBCC1");
  4349. return "";
  4350.  
  4351. }
  4352. else if (chat_val.substring(1,10)=="nextafter"){
  4353. nextafter = 0;
  4354. displayInChat("Reset next after.","#DA0808","#1EBCC1");
  4355. return "";
  4356.  
  4357. }
  4358. else if (chat_val.substring(1,5)=="next" && stopquickplay == 0){
  4359. roundsperqp2 = 0;
  4360. if(shuffle){
  4361. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4362. var available = [];
  4363. var availableindexes = [];
  4364. var notempty = false;
  4365. for(var i = 0; i<e.length;i++){
  4366. var a = false;
  4367. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4368. available.push(a);
  4369. if(a){
  4370. availableindexes.push(i);
  4371. notempty = true;
  4372. }
  4373. }
  4374. if(notempty){
  4375.  
  4376. if(availableindexes.length!=1){
  4377. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  4378. }
  4379. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  4380. }
  4381. }
  4382. else{
  4383. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4384. var available = [];
  4385. var availableindexes = [];
  4386. var notempty = false;
  4387. for(var i = 0; i<e.length;i++){
  4388. var a = false;
  4389. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4390. available.push(a);
  4391. if(a){
  4392. availableindexes.push(i);
  4393. notempty = true;
  4394. }
  4395. }
  4396. if(notempty){
  4397. var above = [];
  4398. for(var i = 0;i<availableindexes.length;i++){
  4399. if(availableindexes[i]>quicki && !reverseqp){
  4400. above.push(availableindexes[i]);
  4401. }
  4402. else if(availableindexes[i]<quicki && reverseqp){
  4403. above.push(availableindexes[i])
  4404. }
  4405. }
  4406. if(above.length>0){
  4407. quicki = above[0];
  4408. if(reverseqp){
  4409. quicki = above[above.length-1];
  4410. }
  4411. }
  4412. else{
  4413. quicki = availableindexes[0];
  4414. if(reverseqp){
  4415. quicki = availableindexes[availableindexes.length-1];
  4416. }
  4417. }
  4418. }
  4419. }
  4420. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  4421. displayInChat("Switched to next map.","#DA0808","#1EBCC1");
  4422. return "";
  4423.  
  4424. }
  4425. else if (chat_val.substring(1,9)=="freejoin"){
  4426. if(freejoin == false){
  4427. freejoin = true;
  4428. displayInChat("Freejoin is now on.","#DA0808","#1EBCC1");
  4429.  
  4430. }
  4431. else{
  4432. freejoin = false;
  4433. displayInChat("Freejoin is now off.","#DA0808","#1EBCC1");
  4434. }
  4435.  
  4436. return "";
  4437.  
  4438. }
  4439. else if (chat_val.substring(1,8)=="instaqp"){
  4440. if(instaqp == false){
  4441. instaqp = true;
  4442. displayInChat("Instaqp is now on.","#DA0808","#1EBCC1");
  4443.  
  4444. }
  4445. else{
  4446. instaqp = false;
  4447. displayInChat("Instaqp is now off.","#DA0808","#1EBCC1");
  4448. }
  4449.  
  4450. return "";
  4451.  
  4452. }
  4453.  
  4454. else if (chat_val.substring(1,9)=="previous" && stopquickplay == 0){
  4455. roundsperqp2 = 0;
  4456. if(shuffle){
  4457. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4458. var available = [];
  4459. var availableindexes = [];
  4460. var notempty = false;
  4461. for(var i = 0; i<e.length;i++){
  4462. var a = false;
  4463. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4464. available.push(a);
  4465. if(a){
  4466. availableindexes.push(i);
  4467. notempty = true;
  4468. }
  4469. }
  4470. if(notempty){
  4471.  
  4472. if(availableindexes.length!=1){
  4473. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  4474. }
  4475. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  4476. }
  4477. }
  4478. else{
  4479. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4480. var available = [];
  4481. var availableindexes = [];
  4482. var notempty = false;
  4483. for(var i = 0; i<e.length;i++){
  4484. var a = false;
  4485. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4486. available.push(a);
  4487. if(a){
  4488. availableindexes.push(i);
  4489. notempty = true;
  4490. }
  4491. }
  4492. if(notempty){
  4493. var above = [];
  4494. for(var i = 0;i<availableindexes.length;i++){
  4495. if(availableindexes[i]<quicki && !reverseqp){
  4496. above.push(availableindexes[i]);
  4497. }
  4498. else if(availableindexes[i]>quicki && reverseqp){
  4499. above.push(availableindexes[i])
  4500. }
  4501. }
  4502. if(above.length>0){
  4503. quicki = above[above.length-1];
  4504. if(reverseqp){
  4505. quicki = above[0];
  4506. }
  4507. }
  4508. else{
  4509. quicki = availableindexes[availableindexes.length-1];
  4510. if(reverseqp){
  4511. quicki = availableindexes[0];
  4512. }
  4513. }
  4514. }
  4515. }
  4516. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  4517.  
  4518. displayInChat("Switched to previous map.","#DA0808","#1EBCC1");
  4519. return "";
  4520. }
  4521. else if (chat_val.substring(1,6)=="start" && chat_val.length == 6){
  4522. if(Gdocument.getElementById("mapeditorcontainer").style["display"]!="block"){
  4523. Gdocument.getElementById("newbonklobby_editorbutton").click();
  4524. }
  4525. if(recmodebool && ishost){
  4526. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  4527. if(mode == "" && defaultmode!="d"){
  4528. mode = defaultmode;
  4529. }
  4530. if(mode != ""){
  4531. RECIEVE('42[26,"b","'+mode+'"]');
  4532. }
  4533. }
  4534. Gdocument.getElementById("mapeditor_close").click();
  4535. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  4536. roundsperqp2 = 0;
  4537. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  4538.  
  4539. return "";
  4540. }
  4541.  
  4542. else if (chat_val.substring(1,8)=="startqp" && stopquickplay == 1){
  4543. stopquickplay = 0;
  4544. quicki = 0;
  4545. qppaused = false;
  4546. displayInChat("Enabled quickplay.","#DA0808","#1EBCC1");
  4547. return "";
  4548. }
  4549. else if (chat_val.substring(1,7)=="stopqp" && stopquickplay == 0){
  4550. stopquickplay = 1;
  4551. quicki = 0;
  4552. qppaused = false;
  4553. displayInChat("Disabled quickplay.","#DA0808","#1EBCC1");
  4554. return "";
  4555. }
  4556. else if (chat_val.substring(1,8)=="pauseqp" && stopquickplay == 0){
  4557. if(qppaused == false){
  4558. qppaused = true;
  4559. displayInChat("Paused quickplay.","#DA0808","#1EBCC1");
  4560. }
  4561. else{
  4562. qppaused = false;
  4563. displayInChat("Unpaused quickplay.","#DA0808","#1EBCC1");
  4564. }
  4565. return "";
  4566. }
  4567. else if (chat_val.substring(1,6)=="revqp" && stopquickplay == 0){
  4568. if(reverseqp == false){
  4569. reverseqp = true;
  4570. displayInChat("Reverseqp is now on..","#DA0808","#1EBCC1");
  4571. }
  4572. else{
  4573. reverseqp = false;
  4574. displayInChat("Reverseqp is now off.","#DA0808","#1EBCC1");
  4575. }
  4576. return "";
  4577. }
  4578. else if (chat_val.substring(1,9)=="jukebox " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  4579. var text = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  4580. SEND("42"+JSON.stringify([4,{"type":"video player","from":username,"url":text,"timestamp":Date.now()+2000,"to":[-1]}]));
  4581. displayInChat("Jukebox is loading... Please wait a few seconds.","#DA0808","#1EBCC1");
  4582. changeJukeboxURL(text,Date.now()+2000);
  4583. return "";
  4584. }
  4585. else if (chat_val.substring(1,13)=="pausejukebox"){
  4586. if(jukeboxplayer.src!="" && !jukeboxplayer.paused){
  4587. displayInChat("Jukebox is now paused.","#DA0808","#1EBCC1");
  4588. jukeboxplayer.pause();
  4589. SEND("42"+JSON.stringify([4,{"type":"video player","from":username,"url":"","timestamp":Date.now(),"to":[-1]}]));
  4590. }
  4591. return "";
  4592. }
  4593. else if (chat_val.substring(1,13)=="resetjukebox"){
  4594. if(jukeboxplayer.src!=""){
  4595. jukeboxplayer.currentTime = 0;
  4596. displayInChat("Jukebox has reset.","#DA0808","#1EBCC1");
  4597. changeJukeboxURL(jukeboxplayerURL,Date.now()+2000);
  4598. SEND("42"+JSON.stringify([4,{"type":"video player","from":username,"url":jukeboxplayerURL,"timestamp":Date.now()+2000,"to":[-1]}]));
  4599. }
  4600. return "";
  4601. }
  4602. else if (chat_val.substring(1,12)=="playjukebox"){
  4603. if(jukeboxplayer.src!="" && jukeboxplayer.paused){
  4604. changeJukeboxURL(jukeboxplayerURL,Date.now()-jukeboxplayer.currentTime*1000);
  4605. SEND("42"+JSON.stringify([4,{"type":"video player","from":username,"url":jukeboxplayerURL,"timestamp":Date.now()-jukeboxplayer.currentTime*1000,"to":[-1]}]));
  4606. }
  4607. return "";
  4608. }
  4609. else if (chat_val.substring(1,5)=="ban " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  4610. banned.push(chat_val.substring(5).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',""));
  4611. displayInChat("Banned "+chat_val.substring(5).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"")+".","#DA0808","#1EBCC1");
  4612. return "/kick '" + chat_val.substring(5).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"") + "'";
  4613. }
  4614. else if (chat_val.substring(1,6)=="kill " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  4615. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  4616. var keys = Object.keys(playerids);
  4617. var killid = undefined;
  4618. for(var i = 0; i<keys.length; i++){
  4619. if(playerids[keys[i]].userName == text){
  4620. killid = keys[i];
  4621. }
  4622. }
  4623. if(typeof(killid)!="undefined" && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden" && !killedids.includes(killid)){
  4624. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  4625. killedids.push(killid);
  4626. SEND('42[25,{"a":{"playersLeft":['+killid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  4627. RECIEVE('42[31,{"a":{"playersLeft":['+killid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  4628. }
  4629. return "";
  4630. }
  4631. else if (chat_val.substring(1,10)=="balanceA " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  4632. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  4633. if(!isNaN(parseInt(text))){
  4634. if(parseInt(text)>=-100 && parseInt(text)<=100){
  4635. var keys = Object.keys(playerids);
  4636. for(var i = 0; i<keys.length;i++){
  4637. SEND('42[29,{"sid":'+keys[i]+',"bal":'+text+'}]');
  4638. RECIEVE('42[36,'+keys[i]+','+text+']');
  4639. }
  4640. }
  4641. }
  4642. return "";
  4643.  
  4644. }
  4645. else if (chat_val.substring(1,10)=="resetpoll"){
  4646. poll = [];
  4647. displayInChat("The poll has been reset.","#DA0808","#1EBCC1");
  4648. return "";
  4649. }
  4650. else if (chat_val.substring(1,11)=="addoption " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  4651. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  4652. if(text.length>50){
  4653. displayInChat("Your option is greater than 50 characters.","#DA0808","#1EBCC1");
  4654. return "";
  4655. }
  4656. if(poll.includes(text)){
  4657. displayInChat("This option already exists.","#DA0808","#1EBCC1");
  4658. }
  4659. else if(poll.length>=4){
  4660. displayInChat("Your poll already has the max 4 amounts of options.","#DA0808","#1EBCC1");
  4661. displayInChat("Type '/deloption [letter]' to remove a option.","#DA0808","#1EBCC1");
  4662. displayInChat("The poll is:","#DA0808","#1EBCC1");
  4663. for(var i = 0;i<poll.length;i++){
  4664. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  4665. }
  4666. }
  4667. else{
  4668. poll.push(text);
  4669. displayInChat("The poll is now:","#DA0808","#1EBCC1");
  4670. for(var i = 0;i<poll.length;i++){
  4671. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  4672. }
  4673. }
  4674. return "";
  4675. }
  4676. else if (chat_val.substring(1,11)=="deloption " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  4677. var text = letters.indexOf(chat_val.substring(11).replace(/^\s+|\s+$/g, ''));
  4678. if(text==-1 || text>=poll.length){
  4679. if(poll.length>0){
  4680. displayInChat("Available options are:","#DA0808","#1EBCC1");
  4681. for(var i = 0;i<poll.length;i++){
  4682. displayInChat(letters[i],"#DA0808","#1EBCC1");
  4683. }
  4684. }
  4685. else{
  4686. displayInChat("Your poll is empty.","#DA0808","#1EBCC1");
  4687. displayInChat("Type '/addoption [text]' to add an option.","#DA0808","#1EBCC1");
  4688. }
  4689. }
  4690. else{
  4691. poll.splice(text,1);
  4692. displayInChat("The poll is now:","#DA0808","#1EBCC1");
  4693. for(var i = 0;i<poll.length;i++){
  4694. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  4695. }
  4696. }
  4697. return "";
  4698. }
  4699. else if (chat_val.substring(1,11)=="startpoll " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  4700. var text = parseFloat(chat_val.substring(11).replace(/^\s+|\s+$/g, ''));
  4701. if(isNaN(text)){
  4702. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  4703. return "";
  4704. }
  4705. else if(text<=0){
  4706. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  4707. return "";
  4708. }
  4709. else if(text<10){
  4710. displayInChat("Your poll has to last for at least 10 seconds.","#DA0808","#1EBCC1");
  4711. return "";
  4712. }
  4713. if(pollactive[0]){
  4714. displayInChat("There is already an ongoing poll.","#DA0808","#1EBCC1");
  4715. displayInChat("Type '/endpoll' to end the poll.","#DA0808","#1EBCC1");
  4716. return "";
  4717. }
  4718. if(poll.length<2){
  4719. displayInChat("Your poll needs at least 2 options.","#DA0808","#1EBCC1");
  4720. displayInChat("Type '/addoption' to add to the poll.","#DA0808","#1EBCC1");
  4721. return "";
  4722. }
  4723. var now = Date.now();
  4724. pollactive = [true,now,now+text*1000,[...poll]];
  4725. playerids[myid].ratelimit.poll = now;
  4726. var chatpoll = [...poll];
  4727. chatpoll.push("Cancel vote.");
  4728. pollactive[3].push("Cancel vote.");
  4729. for(var i = 0;i<chatpoll.length;i++){
  4730. chatpoll[i] = letters[i]+") "+chatpoll[i];
  4731. }
  4732. chat(chatpoll.join("     "));
  4733. setTimeout(function(){
  4734. if(pollactive[0]){
  4735. SEND("42"+JSON.stringify([4,{"type":"poll","from":username,"poll":pollactive[3]}]));
  4736. var keys = Object.keys(playerids);
  4737. for(var i = 0;i<keys.length;i++){
  4738. playerids[keys[i]].vote.poll = -1;
  4739. }
  4740. displayInChat("The poll will end in: " + text.toString()+" seconds.","#DA0808","#1EBCC1");
  4741. displayInChat("Type '/endpoll' to end the poll early.","#DA0808","#1EBCC1");
  4742. }
  4743. },200);
  4744. return "";
  4745. }
  4746. else if (chat_val.substring(1,8)=="endpoll"){
  4747. if(pollactive[0]){
  4748. if(playerids[myid].ratelimit.poll+10000>Date.now()){
  4749. displayInChat("Your poll has to be at least 10 seconds.","#DA0808","#1EBCC1");
  4750. displayInChat("There are "+((playerids[myid].ratelimit.poll+10000-Date.now())/1000).toString()+" seconds left until you can end the poll early.","#DA0808","#1EBCC1");
  4751. return "";
  4752. }
  4753. playerids[myid].ratelimit.poll = Date.now();
  4754. SEND("42"+JSON.stringify([4,{"type":"poll end","from":username}]));
  4755. displayInChat("The poll ended.","#DA0808","#1EBCC1");
  4756. var count = [0,0,0,0];
  4757. var keys = Object.keys(playerids);
  4758. for(var i = 0;i<keys.length;i++){
  4759. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive[3].length-1){
  4760. count[playerids[keys[i]].vote.poll]++;
  4761. }
  4762. playerids[keys[i]].vote.poll = -1;
  4763. }
  4764. for(var i = 0;i<count.length;i++){
  4765. if(count[i]>1){
  4766. displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  4767. }
  4768. if(count[i]==1){
  4769. displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  4770. }
  4771. }
  4772. displayInChat("The poll was:","#DA0808","#1EBCC1");
  4773. for(var i = 0;i<pollactive[3].length;i++){
  4774. displayInChat(letters[i]+") "+pollactive[3][i],"#DA0808","#1EBCC1");
  4775. }
  4776. pollactive = [false,0,0,[]];
  4777. }
  4778. else{
  4779. displayInChat("No poll has been started","#DA0808","#1EBCC1");
  4780. displayInChat("Type '/startpoll [seconds]' to start a poll.","#DA0808","#1EBCC1");
  4781. }
  4782. return "";
  4783. }
  4784. else if (chat_val.substring(1,7)=="moveA " && chat_val.replace(/^\s+|\s+$/g, '').length>=8){
  4785. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '');
  4786. var keys = Object.keys(playerids);
  4787. var t = -1;
  4788. if(text == "f"){
  4789. t = 1;
  4790. }
  4791. else if(text == "b"){
  4792. t = 3;
  4793. }
  4794. else if(text == "g"){
  4795. t = 4;
  4796. }
  4797. else if(text == "r"){
  4798. t = 2;
  4799. }
  4800. else if(text == "y"){
  4801. t = 5;
  4802. }
  4803. else if(text == "s"){
  4804. t = 0;
  4805. }
  4806. if(t == -1){
  4807. displayInChat("The format for this command is:","#DA0808","#1EBCC1");
  4808. displayInChat("/moveA [letter]","#DA0808","#1EBCC1");
  4809. displayInChat("For example: '/moveA r' would move everyone to red team.","#DA0808","#1EBCC1");
  4810. return "";
  4811. }
  4812. for(var i = 0;i<keys.length;i++){
  4813. SEND('42[26,{"targetID":'+keys[i].toString()+',"targetTeam":'+t.toString()+'}]');
  4814. if(playerids[keys[i]].peerID!="sandbox"){
  4815. RECIEVE('42[18,'+keys[i].toString()+','+t.toString()+']');
  4816. }
  4817. }
  4818. return "";
  4819. }
  4820. else if (chat_val.substring(1,7)=="moveT " && chat_val.replace(/^\s+|\s+$/g, '').length>=8){
  4821. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '').split(" ").filter(function(i){if(i==""){return false}else{return true}});
  4822. if(text.length == 2){
  4823. var firstteam = -1;
  4824. var secondteam = -1;
  4825. for(var i = 0;i<2;i++){
  4826. var t = -1;
  4827. if(text[i] == "f"){
  4828. t = 1;
  4829. }
  4830. else if(text[i] == "b"){
  4831. t = 3;
  4832. }
  4833. else if(text[i] == "g"){
  4834. t = 4;
  4835. }
  4836. else if(text[i] == "r"){
  4837. t = 2;
  4838. }
  4839. else if(text[i] == "y"){
  4840. t = 5;
  4841. }
  4842. else if(text[i] == "s"){
  4843. t = 0;
  4844. }
  4845. if(t==-1){
  4846. displayInChat("The format for this command is:","#DA0808","#1EBCC1");
  4847. displayInChat("/moveT [letter] [letter]","#DA0808","#1EBCC1");
  4848. displayInChat("For example: '/moveT s r' would move everyone in spectate to red team.","#DA0808","#1EBCC1");
  4849. return "";
  4850. }
  4851. else{
  4852. if(i == 0){
  4853. firstteam = t;
  4854. }
  4855. else{
  4856. secondteam = t;
  4857. }
  4858. }
  4859. }
  4860. var keys = Object.keys(playerids);
  4861. for(var i = 0;i<keys.length;i++){
  4862. if(playerids[keys[i]].team == firstteam){
  4863. SEND('42[26,{"targetID":'+keys[i].toString()+',"targetTeam":'+secondteam.toString()+'}]');
  4864. if(playerids[keys[i]].peerID!="sandbox"){
  4865. RECIEVE('42[18,'+keys[i].toString()+','+secondteam.toString()+']');
  4866. }
  4867. }
  4868. }
  4869. }
  4870. else{
  4871. displayInChat("The format for this command is:","#DA0808","#1EBCC1");
  4872. displayInChat("/moveT [team] [team]","#DA0808","#1EBCC1");
  4873. displayInChat("For example: '/moveT s r' would move everyone in spectate to red team.","#DA0808","#1EBCC1");
  4874. return "";
  4875. }
  4876. return "";
  4877. }
  4878. if (chat_val.substring(1,13)=="roundsperqp " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  4879. var text = parseInt(chat_val.substring(13).replace(/^\s+|\s+$/g, ''));
  4880. if(isNaN(text)){
  4881. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  4882. return "";
  4883. }
  4884. else if(text<=0){
  4885. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  4886. return "";
  4887. }
  4888. roundsperqp = text;
  4889. roundsperqp2 = 0;
  4890. displayInChat("Set rounds per quickplay to: " + text.toString(),"#DA0808","#1EBCC1");
  4891. displayInChat("Type '/roundsperqp' to reset rounds per quickplay.","#DA0808","#1EBCC1");
  4892. return "";
  4893.  
  4894. }
  4895. else if (chat_val.substring(1,12)=="roundsperqp"){
  4896. roundsperqp = 1;
  4897. roundsperqp2 = 0;
  4898. displayInChat("Reset rounds per quickplay.","#DA0808","#1EBCC1");
  4899. return "";
  4900.  
  4901. }
  4902. else if (chat_val.substring(1,8)=="rounds " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  4903. var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '');
  4904. if(!isNaN(parseInt(text))){
  4905. text = parseInt(text).toString();
  4906. SEND('42[21,{"w":'+text+'}]');
  4907. RECIEVE('42[27,'+text+']');
  4908. }
  4909. return "";
  4910.  
  4911. }
  4912. else if (chat_val.substring(1,13)=="disablekeys " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  4913. var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '');
  4914. var keys = text.split(" ");
  4915. var disabledkeys2 = [];
  4916. var possiblekeys = ["left","right","up","down","heavy","special"];
  4917. for(var i = 0; i<keys.length; i++){
  4918. if(keys[i]!="" && !disabledkeys2.includes(keys[i])){
  4919. if(possiblekeys.includes(keys[i])){
  4920. disabledkeys2.push(keys[i]);
  4921. }
  4922. else{
  4923. displayInChat("Key options: " + possiblekeys.join(" ") + ".","#DA0808","#1EBCC1");
  4924. return "";
  4925. }
  4926. }
  4927. }
  4928. disabledkeys = disabledkeys2;
  4929. displayInChat("Set disabled keys to: " + disabledkeys.join(" ") + ".","#DA0808","#1EBCC1");
  4930. displayInChat("Type '/disablekeys' to reset disabled keys.","#DA0808","#1EBCC1");
  4931. return "";
  4932.  
  4933. }
  4934. else if (chat_val.substring(1,12)=="disablekeys"){
  4935. displayInChat("Reset disabled keys.","#DA0808","#1EBCC1");
  4936. disabledkeys = [];
  4937. return "";
  4938.  
  4939. }
  4940. else if (chat_val.substring(1,10)=="jointext " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  4941. jointext = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  4942. displayInChat("Set jointext to: " + jointext,"#DA0808","#1EBCC1");
  4943. displayInChat("Type '/jointext' to reset jointext.","#DA0808","#1EBCC1");
  4944. return "";
  4945.  
  4946. }
  4947. else if (chat_val.substring(1,9)=="jointext"){
  4948. jointext = "";
  4949. displayInChat("Reset jointext.","#DA0808","#1EBCC1");
  4950. return "";
  4951.  
  4952. }
  4953. else if (chat_val.substring(1,10)=="jointeam " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  4954. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  4955. var keys = Object.keys(playerids);
  4956. var t = -1;
  4957. if(text == "f"){
  4958. t = 1;
  4959. displayInChat("Set jointeam to FFA.","#DA0808","#1EBCC1");
  4960. }
  4961. else if(text == "b"){
  4962. t = 3;
  4963. displayInChat("Set jointeam to blue team.","#DA0808","#1EBCC1");
  4964. }
  4965. else if(text == "g"){
  4966. t = 4;
  4967. displayInChat("Set jointeam to green team.","#DA0808","#1EBCC1");
  4968. }
  4969. else if(text == "r"){
  4970. t = 2;
  4971. displayInChat("Set jointeam to red team.","#DA0808","#1EBCC1");
  4972. }
  4973. else if(text == "y"){
  4974. t = 5;
  4975. displayInChat("Set jointeam to yellow team.","#DA0808","#1EBCC1");
  4976. }
  4977. else if(text == "s"){
  4978. t = 0;
  4979. displayInChat("Set jointeam to spectate.","#DA0808","#1EBCC1");
  4980. }
  4981. if(t == -1){
  4982. displayInChat("The format for this command is:","#DA0808","#1EBCC1");
  4983. displayInChat("/jointeam [letter]","#DA0808","#1EBCC1");
  4984. displayInChat("For example: '/jointeam r' would move every joined person to red team.","#DA0808","#1EBCC1");
  4985. return "";
  4986. }
  4987. displayInChat("Type '/jointeam' to reset jointeam.","#DA0808","#1EBCC1");
  4988. jointeam = t;
  4989. return "";
  4990. }
  4991. else if (chat_val.substring(1,9)=="jointeam"){
  4992. jointeam = -1;
  4993. displayInChat("Reset jointeam.","#DA0808","#1EBCC1");
  4994. return "";
  4995.  
  4996. }
  4997. else if (chat_val.substring(1,9)=="wintext " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  4998. wintext = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  4999. displayInChat("Set wintext to: " + wintext,"#DA0808","#1EBCC1");
  5000. displayInChat("Type '/wintext' to reset wintext.","#DA0808","#1EBCC1");
  5001. return "";
  5002.  
  5003. }
  5004. else if (chat_val.substring(1,8)=="wintext"){
  5005. wintext = "";
  5006. displayInChat("Reset wintext.","#DA0808","#1EBCC1");
  5007. return "";
  5008.  
  5009. }
  5010. else if (chat_val.substring(1,11)=="autorecord"){
  5011. if(autorecord){
  5012. autorecord = false;
  5013. displayInChat("Autorecord is now off.","#DA0808","#1EBCC1");
  5014. }
  5015. else{
  5016. autorecord = true;
  5017. displayInChat("Autorecord is now on.","#DA0808","#1EBCC1");
  5018. }
  5019. return "";
  5020.  
  5021. }
  5022. else if (chat_val.substring(1,9)=="afkkill " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  5023. var text = parseFloat(chat_val.substring(9).replace(/^\s+|\s+$/g, ''));
  5024. if(!isNaN(text)){
  5025. if(text>0){
  5026. displayInChat("Set afk kill to: " + text.toString()+" seconds.","#DA0808","#1EBCC1");
  5027. displayInChat("Type '/afkkill' to reset afk kill.","#DA0808","#1EBCC1");
  5028. var keys = Object.keys(playerids);
  5029. var now = Date.now();
  5030. for(var i = 0;i<keys.length;i++){
  5031. playerids[keys[i]].lastmove = now;
  5032. }
  5033. afkkill = text;
  5034. }
  5035. else{
  5036. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  5037. }
  5038. }
  5039. else{
  5040. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  5041. }
  5042. return "";
  5043.  
  5044. }
  5045. else if (chat_val.substring(1,9)=="afkkill"){
  5046. afkkill = -1;
  5047. displayInChat("Reset afk kill.","#DA0808","#1EBCC1");
  5048. return "";
  5049.  
  5050. }
  5051. else if (chat_val.substring(1,13)=="defaultmode " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  5052. var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '');
  5053. if(text == "default"){
  5054. defaultmode = "";
  5055. displayInChat("Changed default mode to default.","#DA0808","#1EBCC1");
  5056. }
  5057. else if(text == "arrows"){
  5058. defaultmode = "ar";
  5059. displayInChat("Changed default mode to arrows.","#DA0808","#1EBCC1");
  5060. }
  5061. else if(text == "death arrows"){
  5062. defaultmode = "ard";
  5063. displayInChat("Changed default mode to death arrows.","#DA0808","#1EBCC1");
  5064. }
  5065. else if(text == "grapple"){
  5066. defaultmode = "sp";
  5067. displayInChat("Changed default mode to grapple.","#DA0808","#1EBCC1");
  5068. }
  5069. else if(text == "classic"){
  5070. defaultmode = "b";
  5071. displayInChat("Changed default mode to classic.","#DA0808","#1EBCC1");
  5072.  
  5073. }
  5074. else{
  5075. displayInChat("Default mode options:","#DA0808","#1EBCC1");
  5076. displayInChat("default","#DA0808","#1EBCC1");
  5077. displayInChat("classic","#DA0808","#1EBCC1");
  5078. displayInChat("arrows","#DA0808","#1EBCC1");
  5079. displayInChat("death arrows","#DA0808","#1EBCC1");
  5080. displayInChat("grapple","#DA0808","#1EBCC1");
  5081. }
  5082. return "";
  5083.  
  5084. }
  5085. else if (chat_val.substring(1,8)=="recmode"){
  5086. if(recmodebool == true){
  5087. recmodebool = false;
  5088. displayInChat("Recmode is now off.","#DA0808","#1EBCC1");
  5089.  
  5090. }
  5091. else{
  5092. recmodebool = true;
  5093. displayInChat("Recmode is now on.","#DA0808","#1EBCC1");
  5094.  
  5095. }
  5096.  
  5097. return "";
  5098.  
  5099. }
  5100. else if (chat_val.substring(1,8)=="recteam"){
  5101. if(recteams == true){
  5102. recteams = false;
  5103. displayInChat("Recteam is now off.","#DA0808","#1EBCC1");
  5104.  
  5105. }
  5106. else{
  5107. recteams = true;
  5108. displayInChat("Recteam is now on.","#DA0808","#1EBCC1");
  5109.  
  5110. }
  5111. return "";
  5112. }
  5113. else if (chat_val.substring(1,8)=="shuffle"){
  5114. if(shuffle == true){
  5115. shuffle = false;
  5116. displayInChat("Shuffle is now off.","#DA0808","#1EBCC1");
  5117.  
  5118. }
  5119. else{
  5120. shuffle = true;
  5121. displayInChat("Shuffle is now on.","#DA0808","#1EBCC1");
  5122.  
  5123. }
  5124.  
  5125. return "";
  5126.  
  5127. }
  5128. else if (chat_val.substring(1,9)=="autokick"){
  5129. if(autokickban == 0){
  5130. displayInChat("Autokick is now on.","#DA0808","#1EBCC1");
  5131. autokickban = 1;
  5132. }
  5133. else if(autokickban == 1){
  5134. autokickban = 0;
  5135. displayInChat("Autokick is now off.","#DA0808","#1EBCC1");
  5136. }
  5137. else{
  5138. autokickban = 1;
  5139. displayInChat("Autokick is now on, and Autoban is now off.","#DA0808","#1EBCC1");
  5140. }
  5141.  
  5142. return "";
  5143. }
  5144. else if (chat_val.substring(1,8)=="autoban"){
  5145. if(autokickban == 0){
  5146. displayInChat("Autoban is now on.","#DA0808","#1EBCC1");
  5147. autokickban = 2;
  5148. }
  5149. else if(autokickban == 2){
  5150. autokickban = 0;
  5151. displayInChat("Autoban is now off.","#DA0808","#1EBCC1");
  5152. }
  5153. else{
  5154. autokickban = 2;
  5155. displayInChat("Autoban is now on, and Autokick is now off.","#DA0808","#1EBCC1");
  5156. }
  5157.  
  5158. return "";
  5159. }
  5160. else if (chat_val.substring(1,8)=="sandbox"){
  5161. if(sandboxon == false){
  5162. displayInChat("This room is now a sandbox room.","#DA0808","#1EBCC1");
  5163. sandboxon = true;
  5164. SEND('42[4,{"type":"sandboxon"}]');
  5165. var sandboxkeys = Object.keys(sandboxplayerids);
  5166. var packets = [];
  5167. for(var i = 0;i<sandboxkeys.length;i++){
  5168. var p = playerids[sandboxkeys[i]];
  5169. var packet = '42'+JSON.stringify([4,sandboxkeys[i],p.peerID,p.userName,p.guest,p.level,p.team,p.avatar]);
  5170. packets.push(packet);
  5171. }
  5172. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":packets,to:[-1]}]));
  5173. SEND("42"+JSON.stringify([4,{"type":"sandboxid","from":username,"lastid":sandboxid,to:[-1]}]));
  5174. }
  5175. else{
  5176. displayInChat("You cannot turn a sandbox room back into a normal room.","#DA0808","#1EBCC1");
  5177. }
  5178.  
  5179. return "";
  5180. }
  5181. else if(sandboxon){
  5182. if (chat_val.substring(1,11)=="addplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  5183. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  5184. if(!isNaN(parseInt(text))){
  5185. var text2 = parseInt(text);
  5186. if(text2>0){
  5187. for(var i = 0;i<text2;i++){
  5188. while(playerids[sandboxid]){
  5189. sandboxid+=1;
  5190. }
  5191. var color = Math.floor(Math.random() * 16777215).toString();
  5192. var packet = '42'+JSON.stringify([4,sandboxid,"sandbox",sandboxid.toString(),true,0,0,{"layers":[],"bc":color}]);
  5193. RECIEVE(packet);
  5194. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  5195. sandboxplayerids[sandboxid] = sandboxid.toString();
  5196. sandboxid+=1;
  5197. }
  5198.  
  5199. }
  5200. }
  5201. return "";
  5202.  
  5203. }
  5204. if (chat_val.substring(1,9)=="addname " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  5205. var text = chat_val.substring(9).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  5206. while(playerids[sandboxid]){
  5207. sandboxid+=1;
  5208. }
  5209. var keys = Object.keys(playerids);
  5210. var addon = "";
  5211. var escape = false;
  5212. var keysi = -1;
  5213. while(!escape){
  5214. escape = true;
  5215. for(var i = 0;i<keys.length;i++){
  5216. if(playerids[keys[i]].userName == text+addon){
  5217. addon+="‎";
  5218. var escape = false;
  5219. }
  5220. if(playerids[keys[i]].userName == text){
  5221. keysi = keys[i];
  5222. }
  5223. }
  5224. }
  5225. if(keysi!=-1){
  5226. var packet = '42'+JSON.stringify([4,sandboxid,"sandbox",text+addon,playerids[keysi].guest,playerids[keysi].level,0,playerids[keysi].avatar]);
  5227. RECIEVE(packet);
  5228. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  5229. }
  5230. else{
  5231. var color = Math.floor(Math.random() * 16777215).toString();
  5232. var packet = '42'+JSON.stringify([4,sandboxid,"sandbox",text+addon,true,0,0,{"layers":[],"bc":color}]);
  5233. RECIEVE(packet);
  5234. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  5235. }
  5236. sandboxplayerids[sandboxid] = sandboxid.toString();
  5237. sandboxid+=1;
  5238. return "";
  5239.  
  5240. }
  5241. else if (chat_val.substring(1,11)=="delplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  5242. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  5243. if(!isNaN(parseInt(text))){
  5244. var text2 = parseInt(text);
  5245. if(text2>0){
  5246. if(Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden"){
  5247. var jsonkeys = Object.keys(sandboxplayerids).reverse();
  5248. var packets = [];
  5249. for(var i = 0;i<text2 && i<jsonkeys.length;i++){
  5250. var packet = '42[5,'+jsonkeys[i]+',0]';
  5251. RECIEVE(packet);
  5252. packets.push(packet);
  5253. delete sandboxplayerids[jsonkeys[i]];
  5254. }
  5255. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":packets,to:[-1]}]));
  5256. }
  5257. else{
  5258. displayInChat("Cannot delete players while ingame.","#DA0808","#1EBCC1");
  5259. }
  5260.  
  5261. }
  5262. }
  5263. return "";
  5264. }
  5265. else if (chat_val.substring(1,6)=="copy " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  5266. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  5267. var keys = Object.keys(playerids);
  5268. var keys2 = Object.keys(sandboxplayerids);
  5269. var copiedperson = -1;
  5270. for(var i = 0;i<keys.length;i++){
  5271. if(playerids[keys[i]].userName==text){
  5272. copiedperson = keys[i];
  5273. }
  5274. }
  5275. if(copiedperson==-1){
  5276. displayInChat(playerids[copiedperson].userName + " was not found in this room.","#DA0808","#1EBCC1");
  5277. return "";
  5278. }
  5279. if(keys2.includes(copiedperson.toString())){
  5280. displayInChat("Bots cannot copy a bot.","#DA0808","#1EBCC1");
  5281. return "";
  5282. }
  5283. displayInChat("All bots will now copy "+playerids[copiedperson].userName+".","#DA0808","#1EBCC1");
  5284. displayInChat("To reset copy, type '/copy'.","#DA0808","#1EBCC1");
  5285. sandboxcopyme = copiedperson;
  5286.  
  5287. return "";
  5288. }
  5289. else if (chat_val.substring(1,5)=="copy"){
  5290. sandboxcopyme = -1;
  5291. displayInChat("Copy is now off.","#DA0808","#1EBCC1");
  5292. return "";
  5293. }
  5294. }
  5295. }
  5296. return chat_val;
  5297. };
  5298.  
  5299. scope.flag_manage = function(t){
  5300. var text = t;
  5301. if(reverse_flag == true){
  5302. text = text.split("").reverse().join("")
  5303. }
  5304. if(rcaps_flag == true){
  5305. text = text.split('');
  5306. for(var i = 0; i<text.length;i++){
  5307. if(Math.floor(Math.random()*2)){
  5308. text[i] = text[i].toUpperCase();
  5309. }
  5310. else{
  5311. text[i] = text[i].toLowerCase();
  5312. }
  5313. }
  5314. text = text.join('');
  5315. }
  5316. if(space_flag == true){
  5317. text = text.split('').join(' ')
  5318. }
  5319. if(number_flag == true){
  5320. text = text.replace(/[t|T][Oo]+/g,"2");
  5321. text = text.replace(/[f|F][o|O][r|R]/g,"4");
  5322. text = text.replace(/[a|A][t|T][e|E]/g,"8");
  5323. text = text.replace(/[e|E]/g,"3");
  5324. text = text.replace(/[a|A]/g,"4");
  5325. text = text.replace(/[o|O]/g,"0");
  5326. text = text.replace(/[s|S]/g,"5");
  5327. text = text.replace(/[i|I|l|L]/g,"1");
  5328. }
  5329. return text;
  5330. };
  5331. Gdocument.getElementById("newbonklobby_chat_input").onkeydown = function(e){
  5332. if(e.keyCode==13){
  5333.  
  5334. var chat_val = Gdocument.getElementById("newbonklobby_chat_input").value;
  5335.  
  5336. if (chat_val!="" && chat_val[0]=="/"){
  5337.  
  5338. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  5339. chat2(commandhandle(chat_val));
  5340. }
  5341. else{
  5342. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  5343. chat2(flag_manage(chat_val));
  5344. }
  5345.  
  5346. }
  5347. };
  5348. Gdocument.getElementById("ingamechatinputtext").onkeydown = function(e){
  5349. if(e.keyCode==13){
  5350.  
  5351. var chat_val = Gdocument.getElementById("ingamechatinputtext").value;
  5352.  
  5353. if (chat_val!="" && chat_val[0]=="/"){
  5354.  
  5355. Gdocument.getElementById("ingamechatinputtext").value = "";
  5356. chat2(commandhandle(chat_val));
  5357. }
  5358. else{
  5359. Gdocument.getElementById("ingamechatinputtext").value = "";
  5360. chat2(flag_manage(chat_val));
  5361. }
  5362. }
  5363. };
  5364. scope.Last_message = "";
  5365. scope.Laster_message = "";
  5366. scope.new_message = false;
  5367. scope.changed_chat = false;
  5368. scope.injectedBonkCommandsScript = setInterval(timeout123,60);
  5369.  
  5370. scope.hotkeys = function(e){
  5371. var keycode = e.code;
  5372. if(e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  5373. if(keycode == "Period"){
  5374. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]!="0px"){
  5375. chatheight+=5;
  5376. if(chatheight>600){chatheight = 600;}
  5377. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  5378. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  5379. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  5380. }
  5381. e.preventDefault();
  5382. }
  5383. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  5384. if(keycode == "KeyG"){
  5385. var addto = 0;
  5386. for(var i = 0;i<parentDraw.children.length;i++){
  5387. if(parentDraw.children[i].constructor.name == "e"){
  5388. addto = parentDraw.children[i];
  5389. break;
  5390. }
  5391. }
  5392. var canv = 0;
  5393. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  5394. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  5395. canv = Gdocument.getElementById("gamerenderer").children[i];
  5396. break;
  5397. }
  5398. }
  5399. var width = parseInt(canv.style["width"]);
  5400. var height = parseInt(canv.style["height"]);
  5401. if(addto){
  5402. zoom *= 1.1;
  5403. }
  5404. addto.scale.x = zoom;
  5405. addto.scale.y = zoom;
  5406. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  5407. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  5408. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  5409. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  5410. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999 && !FollowCam){
  5411. pixiCircle.visible = false;
  5412. }
  5413. else{
  5414. pixiCircle.visible = true;
  5415. }
  5416. e.preventDefault();
  5417. }
  5418. if(keycode == "KeyH"){
  5419. var addto = 0;
  5420. for(var i = 0;i<parentDraw.children.length;i++){
  5421. if(parentDraw.children[i].constructor.name == "e"){
  5422. addto = parentDraw.children[i];
  5423. break;
  5424. }
  5425. }
  5426. var canv = 0;
  5427. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  5428. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  5429. canv = Gdocument.getElementById("gamerenderer").children[i];
  5430. break;
  5431. }
  5432. }
  5433. var width = parseInt(canv.style["width"]);
  5434. var height = parseInt(canv.style["height"]);
  5435. if(addto){
  5436. zoom = 1;
  5437. }
  5438. addto.scale.x = zoom;
  5439. addto.scale.y = zoom;
  5440. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  5441. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  5442. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  5443. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  5444. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999 && !FollowCam){
  5445. pixiCircle.visible = false;
  5446. }
  5447. else{
  5448. pixiCircle.visible = true;
  5449. }
  5450. e.preventDefault();
  5451. }
  5452. if(keycode == "KeyJ"){
  5453. var addto = 0;
  5454. for(var i = 0;i<parentDraw.children.length;i++){
  5455. if(parentDraw.children[i].constructor.name == "e"){
  5456. addto = parentDraw.children[i];
  5457. break;
  5458. }
  5459. }
  5460. var canv = 0;
  5461. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  5462. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  5463. canv = Gdocument.getElementById("gamerenderer").children[i];
  5464. break;
  5465. }
  5466. }
  5467. var width = parseInt(canv.style["width"]);
  5468. var height = parseInt(canv.style["height"]);
  5469. if(addto){
  5470. zoom /= 1.1;
  5471. }
  5472. addto.scale.x = zoom;
  5473. addto.scale.y = zoom;
  5474. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  5475. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  5476. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  5477. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  5478. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999 && !FollowCam){
  5479. pixiCircle.visible = false;
  5480. }
  5481. else{
  5482. pixiCircle.visible = true;
  5483. }
  5484. e.preventDefault();
  5485. }
  5486. }
  5487. if(keycode == "Comma"){
  5488. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]!="0px"){
  5489. chatheight-=5;
  5490. if(chatheight<100){chatheight = 100;}
  5491. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  5492. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  5493. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  5494. }
  5495. e.preventDefault();
  5496. }
  5497. }
  5498. if(e.repeat){return;}
  5499. if(e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  5500. if(ishost){
  5501. if(keycode == "KeyE"){
  5502. if(Gdocument.getElementById("newbonklobby").style["display"] == "block"){
  5503. Gdocument.getElementById("newbonklobby_editorbutton").click();
  5504. }
  5505. else if(Gdocument.getElementById("mapeditorcontainer").style["display"] == "block"){
  5506. Gdocument.getElementById("mapeditor_close").click();
  5507. }
  5508. e.preventDefault();
  5509.  
  5510. }
  5511. else if(keycode == "KeyT"){
  5512. Gdocument.getElementById("newbonklobby_teamsbutton").click();
  5513. e.preventDefault();
  5514. }
  5515. else if(keycode == "KeyM"){
  5516. Gdocument.getElementById("newbonklobby_modebutton").click();
  5517. e.preventDefault();
  5518. }
  5519. else if(keycode == "KeyK"){
  5520. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  5521. Gdocument.getElementById("pretty_top_exit").click();
  5522. }
  5523. e.preventDefault();
  5524. }
  5525. else if(keycode == "KeyS"){
  5526. if(Gdocument.getElementById("mapeditorcontainer").style["display"]!="block"){
  5527. Gdocument.getElementById("newbonklobby_editorbutton").click();
  5528. }
  5529. if(recmodebool && ishost){
  5530. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  5531. if(mode == "" && defaultmode!="d"){
  5532. mode = defaultmode;
  5533. }
  5534. if(mode != ""){
  5535. RECIEVE('42[26,"b","'+mode+'"]');
  5536. }
  5537. }
  5538. Gdocument.getElementById("mapeditor_close").click();
  5539. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  5540. roundsperqp2 = 0;
  5541. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  5542. e.preventDefault();
  5543. }
  5544. else if(keycode == "KeyD"){
  5545. roundsperqp2 = 0;
  5546. if(stopquickplay == 0){
  5547. if(shuffle){
  5548. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  5549. var available = [];
  5550. var availableindexes = [];
  5551. var notempty = false;
  5552. for(var i = 0; i<e2.length;i++){
  5553. var a = false;
  5554. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  5555. available.push(a);
  5556. if(a){
  5557. availableindexes.push(i);
  5558. notempty = true;
  5559. }
  5560. }
  5561. if(notempty){
  5562.  
  5563. if(availableindexes.length!=1){
  5564. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  5565. }
  5566. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  5567. }
  5568. }
  5569. else{
  5570. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  5571. var available = [];
  5572. var availableindexes = [];
  5573. var notempty = false;
  5574. for(var i = 0; i<e2.length;i++){
  5575. var a = false;
  5576. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  5577. available.push(a);
  5578. if(a){
  5579. availableindexes.push(i);
  5580. notempty = true;
  5581. }
  5582. }
  5583. if(notempty){
  5584. var above = [];
  5585. for(var i = 0;i<availableindexes.length;i++){
  5586. if(availableindexes[i]>quicki && !reverseqp){
  5587. above.push(availableindexes[i]);
  5588. }
  5589. else if(availableindexes[i]<quicki && reverseqp){
  5590. above.push(availableindexes[i])
  5591. }
  5592. }
  5593. if(above.length>0){
  5594. quicki = above[0];
  5595. if(reverseqp){
  5596. quicki = above[above.length-1];
  5597. }
  5598. }
  5599. else{
  5600. quicki = availableindexes[0];
  5601. if(reverseqp){
  5602. quicki = availableindexes[availableindexes.length-1];
  5603. }
  5604. }
  5605. }
  5606. }
  5607. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  5608. }
  5609. e.preventDefault();
  5610. }
  5611. else if(keycode == "KeyA"){
  5612. if(stopquickplay == 0){
  5613. roundsperqp2 = 0;
  5614. if(shuffle){
  5615. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  5616. var available = [];
  5617. var availableindexes = [];
  5618. var notempty = false;
  5619. for(var i = 0; i<e2.length;i++){
  5620. var a = false;
  5621. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  5622. available.push(a);
  5623. if(a){
  5624. availableindexes.push(i);
  5625. notempty = true;
  5626. }
  5627. }
  5628. if(notempty){
  5629.  
  5630. if(availableindexes.length!=1){
  5631. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  5632. }
  5633. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  5634. }
  5635. }
  5636. else{
  5637. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  5638. var available = [];
  5639. var availableindexes = [];
  5640. var notempty = false;
  5641. for(var i = 0; i<e2.length;i++){
  5642. var a = false;
  5643. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  5644. available.push(a);
  5645. if(a){
  5646. availableindexes.push(i);
  5647. notempty = true;
  5648. }
  5649. }
  5650. if(notempty){
  5651. var above = [];
  5652. for(var i = 0;i<availableindexes.length;i++){
  5653. if(availableindexes[i]<quicki && !reverseqp){
  5654. above.push(availableindexes[i]);
  5655. }
  5656. else if(availableindexes[i]>quicki && reverseqp){
  5657. above.push(availableindexes[i])
  5658. }
  5659. }
  5660. if(above.length>0){
  5661. quicki = above[above.length-1];
  5662. if(reverseqp){
  5663. quicki = above[0];
  5664. }
  5665. }
  5666. else{
  5667. quicki = availableindexes[availableindexes.length-1];
  5668. if(reverseqp){
  5669. quicki = availableindexes[0];
  5670. }
  5671. }
  5672. }
  5673. }
  5674. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  5675. }
  5676. e.preventDefault();
  5677. }
  5678. else if(keycode == "KeyQ"){
  5679. if(stopquickplay == 1){
  5680. stopquickplay = 0;
  5681. quicki = 0;
  5682. qppaused = false;
  5683. displayInChat("Enabled quickplay.","#DA0808","#1EBCC1");
  5684. }
  5685. else{
  5686. stopquickplay = 1;
  5687. quicki = 0;
  5688. qppaused = false;
  5689. displayInChat("Disabled quickplay.","#DA0808","#1EBCC1");
  5690. }
  5691. e.preventDefault();
  5692. }
  5693. else if(keycode == "KeyP" && stopquickplay==0){
  5694. if(qppaused == true){
  5695. qppaused = false;
  5696. displayInChat("Unpaused quickplay.","#DA0808","#1EBCC1");
  5697. }
  5698. else{
  5699. qppaused = true;
  5700. displayInChat("Paused quickplay.","#DA0808","#1EBCC1");
  5701. }
  5702. e.preventDefault();
  5703. }
  5704. else if(keycode == "KeyR"){
  5705. if(recmodebool == true){
  5706. recmodebool = false;
  5707. displayInChat("Recmode is now off.","#DA0808","#1EBCC1");
  5708.  
  5709. }
  5710. else{
  5711. recmodebool = true;
  5712. displayInChat("Recmode is now on.","#DA0808","#1EBCC1");
  5713.  
  5714. }
  5715. }
  5716. else if(keycode == "KeyF"){
  5717. if(freejoin == false){
  5718. freejoin = true;
  5719. displayInChat("Freejoin is now on.","#DA0808","#1EBCC1");
  5720.  
  5721. }
  5722. else{
  5723. freejoin = false;
  5724. displayInChat("Freejoin is now off.","#DA0808","#1EBCC1");
  5725. }
  5726. e.preventDefault();
  5727. }
  5728. }
  5729. else{
  5730. if(keycode == "KeyE"){
  5731. e.preventDefault();
  5732. }
  5733. else if(keycode == "KeyT"){
  5734. e.preventDefault();
  5735. }
  5736. else if(keycode == "KeyM"){
  5737. e.preventDefault();
  5738. }
  5739. else if(keycode == "KeyK"){
  5740. e.preventDefault();
  5741. }
  5742. else if(keycode == "KeyS"){
  5743. e.preventDefault();
  5744. }
  5745. else if(keycode == "KeyD"){
  5746. e.preventDefault();
  5747. }
  5748. else if(keycode == "KeyA"){
  5749. e.preventDefault();
  5750. }
  5751. else if(keycode == "KeyQ"){
  5752. e.preventDefault();
  5753. }
  5754. else if(keycode == "KeyP"){
  5755. e.preventDefault();
  5756. }
  5757. else if(keycode == "KeyF"){
  5758. e.preventDefault();
  5759. }
  5760. else if(keycode == "KeyR"){
  5761. e.preventDefault();
  5762. }
  5763.  
  5764. }
  5765. if(keycode == "KeyL"){
  5766. lobby();
  5767. e.preventDefault();
  5768. }
  5769. if(keycode == "KeyC"){
  5770. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  5771. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]=="0px"){
  5772. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  5773. }
  5774. else{
  5775. Gdocument.getElementById("ingamechatcontent").style["max-height"]="0px";
  5776. }
  5777. }
  5778. e.preventDefault();
  5779. }
  5780. if(keycode == "KeyI"){
  5781. if(Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"] == "none"){
  5782. debuggeropen = true;
  5783. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="block";
  5784. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="none";
  5785. Gdocument.getElementById("ingamechatinputtext").style["display"] = "none";
  5786. }
  5787. else{
  5788. debuggeropen = false;
  5789. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="none";
  5790. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  5791. Gdocument.getElementById("ingamechatinputtext").style["display"] = "";
  5792. }
  5793. e.preventDefault();
  5794. }
  5795. if(keycode == "KeyB"){
  5796. var element = Gdocument.getElementById("ingamewinner_scores");
  5797. element.style["visibility"] = "visible";
  5798. if(element.style["opacity"]<1){
  5799. element.style["opacity"] = 1;
  5800. }
  5801. else{
  5802. element.style["opacity"] = 0;
  5803. }
  5804. e.preventDefault();
  5805. }
  5806. if(keycode == "KeyY"){
  5807. Gdocument.getElementById("pretty_top_settings").click();
  5808. Gdocument.getElementById("settings_close").click();
  5809. if(Gdocument.getElementById("settings_graphicsquality").value==1){
  5810. displayInChat("You must have medium or high quality enabled to use this feature.","#DA0808","#1EBCC1");
  5811. return "";
  5812. }
  5813.  
  5814.  
  5815. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  5816. var addto = {"children":[]};
  5817. for(var i = 0;i<parentDraw.children.length;i++){
  5818. if(parentDraw.children[i].constructor.name == "e"){
  5819. addto = parentDraw.children[i];
  5820. break;
  5821. }
  5822. }
  5823. var addto2 = {"children":[]};
  5824. for(var i = 0;i<addto.children.length;i++){
  5825. if(addto.children[i].constructor.name == "e"){
  5826. addto2 = addto.children[i];
  5827. break;
  5828. }
  5829. }
  5830. var checkxray = addto2.children[0];
  5831. var addto3 = addto2.children[0].children;
  5832. if(addto3.length==1){
  5833. checkxray = checkxray.children[0];
  5834. addto3 = addto3[0].children;
  5835. }
  5836. var xrayon = false;
  5837. if(checkxray.xrayon){
  5838. checkxray.xrayon = false;
  5839. xrayon = false;
  5840. }
  5841. else{
  5842. checkxray.xrayon = true;
  5843. xrayon = true;
  5844. }
  5845. if(xrayon){
  5846. displayInChat("Xray is now on.","#DA0808","#1EBCC1");
  5847. for(var i = 0;i<addto3.length;i++){
  5848. if(addto3[i].children.length>0){
  5849. var ids = [];
  5850. var ids2 = [];
  5851. for(var i3 = 0;i3<addto3[i].children.length;i3++){
  5852. addto3[i].children[i3].visible = false;
  5853. if(addto3[i].children[i3].children.length>0){
  5854. for(var i4 = 0;i4<addto3[i].children[i3].children.length;i4++){
  5855. if(addto3[i].children[i3].children[i4].geometry?.id){
  5856. ids.push(addto3[i].children[i3].children[i4].geometry.id);
  5857. }
  5858. else if(addto3[i].children[i3].children[i4].texture?.baseTexture?.uid){
  5859. ids2.push(addto3[i].children[i3].children[i4].texture.baseTexture.uid);
  5860. }
  5861. }
  5862. }
  5863. }
  5864. for(var i3 = 0;i3<addto3[i].children.length;i3++){
  5865. if(addto3[i].children[i3].children.length==0){
  5866. if(addto3[i].children[i3].geometry?.id){
  5867. if(ids.includes(addto3[i].children[i3].geometry.id+1)){
  5868. addto3[i].children[i3].visible = true;
  5869. addto3[i].children[i3].alpha = 0.5;
  5870. }
  5871. }
  5872. else if(addto3[i].children[i3].texture?.baseTexture?.uid){
  5873. if(ids2.includes(addto3[i].children[i3].texture.baseTexture.uid+1)){
  5874. addto3[i].children[i3].visible = true;
  5875. addto3[i].children[i3].alpha = 0.5;
  5876. }
  5877. }
  5878. }
  5879. }
  5880. }
  5881. }
  5882.  
  5883. }
  5884. else{
  5885. displayInChat("Xray is now off.","#DA0808","#1EBCC1");
  5886. for(var i = 0;i<addto3.length;i++){
  5887. for(var i2 = 0;i2<addto3[i].children.length;i2++){
  5888. addto3[i].children[i2].visible = true;
  5889. addto3[i].children[i2].alpha = 1;
  5890. }
  5891. }
  5892. }
  5893. }
  5894. e.preventDefault();
  5895. }
  5896. if(keycode == "KeyN"){
  5897. if(FollowCam == true){
  5898. displayInChat("Follow Camera is now off.","#DA0808","#1EBCC1");
  5899. FollowCam = false;
  5900. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  5901. var addto = {"children":[]};
  5902. for(var i = 0;i<parentDraw.children.length;i++){
  5903. if(parentDraw.children[i].constructor.name == "e"){
  5904. addto = parentDraw.children[i];
  5905. break;
  5906. }
  5907. }
  5908. var canv = 0;
  5909. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  5910. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  5911. canv = Gdocument.getElementById("gamerenderer").children[i];
  5912. break;
  5913. }
  5914. }
  5915. var width = parseInt(canv.style["width"]);
  5916. var height = parseInt(canv.style["height"]);
  5917. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  5918. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  5919. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  5920. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  5921. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999){
  5922. pixiCircle.visible = false;
  5923. }
  5924. else{
  5925. pixiCircle.visible = true;
  5926. }
  5927. }
  5928. }
  5929. else{
  5930. displayInChat("Follow Camera is now on.","#DA0808","#1EBCC1");
  5931. FollowCam = true;
  5932. }
  5933. e.preventDefault();
  5934. }
  5935. if(keycode == "KeyV"){
  5936. if(autocam == true){
  5937. displayInChat("Auto Cam is now off.","#DA0808","#1EBCC1");
  5938. autocam = false
  5939. }
  5940. else{
  5941. displayInChat("Auto Cam is now on.","#DA0808","#1EBCC1");
  5942. autocam = true;
  5943. }
  5944. e.preventDefault();
  5945. }
  5946. if(keycode == "KeyO"){
  5947. if(heavybot == true){
  5948. displayInChat("Heavy bot is now off.","#DA0808","#1EBCC1");
  5949. heavybot = false;
  5950. }
  5951. else{
  5952. displayInChat("Heavy bot is now on.","#DA0808","#1EBCC1");
  5953. heavybot = true;
  5954. getplayerkeys();
  5955. }
  5956. e.preventDefault();
  5957. }
  5958. if(keycode == "KeyU"){
  5959. if(aimbot == true){
  5960. displayInChat("Aimbot is now off.","#DA0808","#1EBCC1");
  5961. aimbot = false;
  5962. }
  5963. else{
  5964. displayInChat("Aimbot is now on.","#DA0808","#1EBCC1");
  5965. aimbot = true;
  5966. getplayerkeys();
  5967. }
  5968. e.preventDefault();
  5969. }
  5970. }
  5971. if(!e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  5972. if(keycode == "Slash" && !(Gdocument.getElementById("gmeditor")?.style["transform"] == "scale(1)")){
  5973. 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"]==""){
  5974. Gdocument.getElementById("newbonklobby_chat_input").value = "/";
  5975. if(Gdocument.getElementById("newbonklobby_chat_input").style["pointer-events"] == "none"){
  5976. fire("keydown",{keyCode:13});
  5977. }
  5978. else{
  5979. Gdocument.getElementById("newbonklobby_chat_input").focus();
  5980. }
  5981. e.preventDefault();
  5982.  
  5983. }
  5984. else if(Gdocument.getElementById("ingamechatinputtext").style["visibility"]=="visible" && Gdocument.getElementById("ingamechatinputtext").style["display"]=="" && Gdocument.getElementById("mapeditorcontainer").style["display"]!="block" && Gdocument.getElementById("ingamechatinputtext").value == ""){
  5985. Gdocument.getElementById("ingamechatinputtext").value = "/";
  5986. if(!Gdocument.getElementById("ingamechatinputtext").classList.value.includes("ingamechatinputtextbg")){
  5987. fire("keydown",{keyCode:13});
  5988. }
  5989. else{
  5990. Gdocument.getElementById("ingamechatinputtext").focus();
  5991. }
  5992. e.preventDefault();
  5993.  
  5994. }
  5995. }
  5996. }
  5997. };
  5998.  
  5999. Gdocument.onkeydown = hotkeys;
  6000.  
  6001. Gwindow.addEventListener('resize',function(e){
  6002. debuggermenu.style["width"] = Gdocument.getElementById("bonkiocontainer").style["width"];
  6003. debuggermenu.style["height"] = Gdocument.getElementById("bonkiocontainer").style["height"];
  6004. scope.width = parseInt(Gdocument.getElementById("bonkiocontainer").style["width"])-20;
  6005. scope.height = parseInt(Gdocument.getElementById("bonkiocontainer").style["height"])-210;
  6006. logmenu.style["width"] = width.toString()+"px";
  6007. logmenu.style["height"] = height.toString()+"px";
  6008. logmenutopleft.style["width"] = (width/2).toString()+"px";
  6009. logmenutopright.style["width"] = (width/2).toString()+"px";
  6010. logmenutopright.style["left"] = (width/2).toString()+"px";
  6011. debuggerinput.style["width"] = width.toString()+"px";
  6012. debuggerinput.style["top"] = (height+90).toString()+"px";
  6013. debuggersendrecieve.style["top"] = (height+120).toString()+"px";
  6014. debuggerpausebutton.style["top"] = (height+150).toString()+"px";
  6015. debuggereval.style["width"] = (width-150).toString()+"px";
  6016. debuggereval.style["top"] = (height+120).toString()+"px";},true);
  6017.  
  6018.  
  6019. function timeout123() {
  6020. updateWssLog();
  6021. EVENTLOOPFUNCTION();
  6022. var now = Date.now();
  6023. var keys = Object.keys(playerids);
  6024. if(getroomslastcheck+3000<now){
  6025. getroomslastcheck = now;
  6026. if(inroom && savedrooms.length>0){
  6027. Gdocument.getElementById("roomlistrefreshbutton").click();
  6028. }
  6029. }
  6030. if(randomchat){
  6031. if(randomchat_timestamp+randomchat_randomtimestamp<now){
  6032. randomchat_timestamp = now;
  6033. randomchat_randomtimestamp = 2000+Math.random()*2000;
  6034. var randnumber = Math.floor(Math.random()*randomchatpriority[0])-randomchatlastmessage[1];
  6035. for(var i = 0;i<randomchatpriority[1].length;i++){
  6036. if(randomchatpriority[1][i][0]!=randomchatlastmessage[0] && randomchatpriority[1][i][1]!=randomchatlastmessage[1]){
  6037. randnumber-=randomchatpriority[1][i][1];
  6038. if(randnumber<=0){
  6039. chat(flag_manage(randomchatpriority[1][i][0]));
  6040. randomchatpriority[1][i][1]+=2;
  6041. randomchatpriority[0]+=2;
  6042. randomchatlastmessage = randomchatpriority[1][i];
  6043. break;
  6044. }
  6045. }
  6046. }
  6047. }
  6048. }
  6049. for(var i = 0;i<keys.length;i++){
  6050. 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){
  6051. SEND('42[9,{"banshortid":'+keys[i].toString()+',"kickonly":'+(autokickban == 1).toString()+'}]');
  6052. autokickbantimestamp = now;
  6053. }
  6054. if(playerids[keys[i]].playerData){
  6055. if(playerids[keys[i]].playerData2){
  6056. if(playerids[keys[i]].playerData.transform){
  6057. playerids[keys[i]].playerData2.alive = true;
  6058. if(playerids[keys[i]].playerData2.timeStamp == 0){
  6059. playerids[keys[i]].playerData2.px = playerids[keys[i]].playerData.transform.position.x;
  6060. playerids[keys[i]].playerData2.py = playerids[keys[i]].playerData.transform.position.y;
  6061. playerids[keys[i]].playerData2.timeStamp = now;
  6062. }
  6063. else{
  6064. playerids[keys[i]].playerData2.xvel = (playerids[keys[i]].playerData2.px - playerids[keys[i]].playerData.transform.position.x)/(playerids[keys[i]].playerData2.timeStamp-now);
  6065. playerids[keys[i]].playerData2.yvel = (playerids[keys[i]].playerData2.py - playerids[keys[i]].playerData.transform.position.y)/(playerids[keys[i]].playerData2.timeStamp-now);
  6066. playerids[keys[i]].playerData2.px = playerids[keys[i]].playerData.transform.position.x;
  6067. playerids[keys[i]].playerData2.py = playerids[keys[i]].playerData.transform.position.y;
  6068. playerids[keys[i]].playerData2.timeStamp = now;
  6069. }
  6070. if(playerids[keys[i]].playerData2.timeStamp2 == 0){
  6071. playerids[keys[i]].playerData2.pvx = playerids[keys[i]].playerData2.xvel;
  6072. playerids[keys[i]].playerData2.pvy = playerids[keys[i]].playerData2.yvel;
  6073. playerids[keys[i]].playerData2.timeStamp2 = now;
  6074. }
  6075. else{
  6076. playerids[keys[i]].playerData2.xacc = (playerids[keys[i]].playerData2.pvx - playerids[keys[i]].playerData2.xvel)/((playerids[keys[i]].playerData2.timeStamp2-now));
  6077. playerids[keys[i]].playerData2.yacc = (playerids[keys[i]].playerData2.pvy - playerids[keys[i]].playerData2.yvel)/((playerids[keys[i]].playerData2.timeStamp2-now));
  6078. playerids[keys[i]].playerData2.pvx = playerids[keys[i]].playerData2.xvel;
  6079. playerids[keys[i]].playerData2.pvy = playerids[keys[i]].playerData2.yvel;
  6080. playerids[keys[i]].playerData2.timeStamp2 = now;
  6081. }
  6082. }
  6083. else{
  6084. if(playerids[keys[i]].playerData2.alive){
  6085.  
  6086. }
  6087. playerids[keys[i]].playerData2.alive = false;
  6088. }
  6089. }
  6090. else{
  6091. 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};
  6092. }
  6093. }
  6094. }
  6095. for(var i = 0;i<keys.length;i++){
  6096. if(!playerids[keys[i]].playerData2){
  6097. 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};
  6098. }
  6099. }
  6100. if(Gdocument.getElementById("redefineControls_table").children[0].children.length<=1 && keys.length>0){
  6101. Gdocument.getElementById("pretty_top_settings").click();
  6102. Gdocument.getElementById("settings_close").click();
  6103. }
  6104. if(pollactive[0] && pollactive[2]<now && ishost){
  6105. playerids[myid].ratelimit.poll = Date.now();
  6106. SEND("42"+JSON.stringify([4,{"type":"poll end","from":username}]));
  6107. var count = [0,0,0,0];
  6108. var keys = Object.keys(playerids);
  6109. for(var i = 0;i<keys.length;i++){
  6110. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive[3].length-1){
  6111. count[playerids[keys[i]].vote.poll]++;
  6112. }
  6113. playerids[keys[i]].vote.poll = -1;
  6114. }
  6115. displayInChat("The poll ended due to time.","#DA0808","#1EBCC1");
  6116. for(var i = 0;i<count.length;i++){
  6117. if(count[i]>1){
  6118. displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  6119. }
  6120. if(count[i]==1){
  6121. displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  6122. }
  6123. }
  6124. displayInChat("The poll was:","#DA0808","#1EBCC1");
  6125. for(var i = 0;i<pollactive[3].length;i++){
  6126. displayInChat(letters[i]+") "+pollactive[3][i],"#DA0808","#1EBCC1");
  6127. }
  6128. pollactive = [false,0,0,[]];
  6129. }
  6130. if(!ishost && sandboxcopyme!=-1){
  6131. sandboxcopyme = -1;
  6132. }
  6133. if(afkkill>0 && ishost){
  6134. var keys = Object.keys(playerids);
  6135. currentFrame = Math.floor((now - gameStartTimeStamp)/1000*30);
  6136. for(var i = 0; i<keys.length;i++){
  6137. if(typeof(playerids[keys[i]].lastmove)=="undefined"){
  6138. playerids[keys[i]].lastmove = now;
  6139. }
  6140. else{
  6141. if(playerids[keys[i]].playerData2?.alive && now-playerids[keys[i]].lastmove>=afkkill*1000 && now-gameStartTimeStamp>=afkkill*1000 && !killedids.includes(keys[i])){
  6142. killedids.push(keys[i]);
  6143. SEND('42[25,{"a":{"playersLeft":['+keys[i]+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  6144. RECIEVE('42[31,{"a":{"playersLeft":['+keys[i]+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  6145. break;
  6146. }
  6147. }
  6148. }
  6149. }
  6150. if(ishost && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS"){
  6151. clearmaprequests.style["display"] = "block";
  6152. refreshmaprequests.style["display"] = "block";
  6153. }
  6154. else{
  6155. clearmaprequests.style["display"] = "none";
  6156. refreshmaprequests.style["display"] = "none";
  6157. }
  6158. if(Gdocument.getElementById("gamerenderer").style["visibility"]=="hidden"){
  6159. Gdocument.getElementById("ingamewinner_scores").style["visibility"] = "unset";
  6160. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  6161. }
  6162. if(Gdocument.getElementById("maploadwindowmapscontainer").children.length>0 && maponclick == 0){
  6163. maponclick = Gdocument.getElementById("maploadwindowmapscontainer").children[0].onclick;
  6164. }
  6165. 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"] == "")){
  6166. var chatbox = Gdocument.getElementById("newbonklobby_chat_content");
  6167. while (chatbox.firstChild) {
  6168. chatbox.removeChild(chatbox.firstChild);
  6169. }
  6170. chatbox = Gdocument.getElementById("ingamechatcontent");
  6171. while (chatbox.firstChild) {
  6172. chatbox.removeChild(chatbox.firstChild);
  6173. }
  6174. rcaps_flag = false;
  6175. space_flag = false;
  6176. number_flag = false;
  6177. reverse_flag = false;
  6178. echo_list = [];
  6179. scroll = false;
  6180. FollowCam = false;
  6181. autocam = false;
  6182. aimbot = false;
  6183. recievedinitdata = false;
  6184. zoom = 1;
  6185. zoom2 = 1;
  6186. newzoom = 1;
  6187. newzoom2 = 1;
  6188. FFA = true;
  6189. mode = "b";
  6190. ghostroomwss = -1;
  6191. heavybot = false;
  6192. stopquickplay = 1;
  6193. roundsperqp = 1;
  6194. roundsperqp2 = 0;
  6195. staystill = false;
  6196. staystillpos = [0,0];
  6197. recording = false;
  6198. recordingid = -1;
  6199. reverseqp = false;
  6200. jointeam = -1;
  6201. currentroomaddress = -1;
  6202. checkboxhidden = false;
  6203. freejoin = false;
  6204. shuffle = false;
  6205. defaultmode = "";
  6206. recmodebool = false;
  6207. recteams = false;
  6208. autorecord = false;
  6209. pollactive = [false,0,0,[]];
  6210. pollactive2 = [false,0,[]];
  6211. afkkill = -1;
  6212. nextafter = 0;
  6213. jointext = "";
  6214. ishost = false;
  6215. parentDraw = 0;
  6216. sandboxplayerids = {};
  6217. sandboxcopyme = -1;
  6218. wintext = "";
  6219. sandboxon = false;
  6220. sandboxid = 200;
  6221. disabledkeys = [];
  6222. myid = -1;
  6223. randomchat = false;
  6224. savedroombutton.className = "brownButton brownButton_classic buttonShadow brownButtonDisabled";
  6225. randomchatpriority = [0,[]];
  6226. randomchatlastmessage = ["",0];
  6227. autokickbantimestamp = 0;
  6228. autokickban = 0;
  6229. inroom = false;
  6230. causelag = false;
  6231. causelag2 = 0;
  6232. jukeboxplayerURL = "";
  6233. jukeboxplayer.src = "";
  6234. jukeboxplayervolume = 20;
  6235. if(!bonkwss){
  6236. playerids = {};
  6237. }
  6238.  
  6239. qppaused = false;
  6240. nextafterbuffer = -1;
  6241. hostid = -1;
  6242. if(chatlog[chatlog.length-1]!="ROOM END"){
  6243. chatlog.push("ROOM END");
  6244. }
  6245. }
  6246. else{
  6247. if(chatlog[chatlog.length-1]=="ROOM END"){
  6248. chatlog.push("ROOM START");
  6249. }
  6250. }
  6251.  
  6252. if(Gdocument.getElementById("newbonklobby").style["display"]=="block"){
  6253. Gdocument.getElementById("ingamechatinputtext").style["visibility"]="hidden";
  6254. }
  6255. else{
  6256. Gdocument.getElementById("ingamechatinputtext").style["visibility"]="visible";
  6257.  
  6258. }
  6259. if(Gdocument.getElementsByClassName('newbonklobby_settings_button brownButton brownButton_classic buttonShadow brownButtonDisabled').length == 0){
  6260. ishost = true;
  6261. }
  6262. else{
  6263. ishost = actuallyhost;
  6264. }
  6265.  
  6266. if(Gdocument.getElementById("pretty_top_name")!=null){
  6267. username = Gdocument.getElementById("pretty_top_name").textContent;
  6268. if(myid!=-1){
  6269. username = playerids[myid].userName;
  6270. }
  6271. }
  6272. try{
  6273. Last_message = lastmessage()
  6274. } catch{
  6275. Last_message = "";
  6276. }
  6277. if (Laster_message != Last_message){
  6278. Laster_message = Last_message;
  6279. if(changed_chat==false){
  6280. new_message = true;
  6281. }
  6282. else{
  6283. changed_chat = false;
  6284. }
  6285. }
  6286. if(new_message){
  6287. chatlog.push(Last_message);
  6288. var lm = "";
  6289. try{
  6290. lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  6291. if(typeof(lm[0].parentElement.style["parsed"]) == 'undefined'){
  6292. if (lm[0].className == "newbonklobby_chat_msg_colorbox"){
  6293. lm[2].innerHTML = urlify(lm[2].innerHTML);
  6294. Laster_message = lastmessage();
  6295. lm[0].parentElement.style["parsed"] = true;
  6296. }
  6297. if (lm[0].className == "newbonklobby_chat_status"){
  6298. lm[0].innerHTML = urlify(lm[0].innerHTML);
  6299. Laster_message = lastmessage();
  6300. lm[0].parentElement.style["parsed"] = true;
  6301. }
  6302. }
  6303. }
  6304. catch{
  6305. lm = "";
  6306. }
  6307.  
  6308. if(Last_message.indexOf("@"+username)!=-1 && npermissions == 1){
  6309. if(Notification.requestPermission()){
  6310. var n = new Notification(Last_message);
  6311. }
  6312. }
  6313.  
  6314. try{
  6315. lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  6316. if(typeof(lm[0].parentElement.style["parsed"])=='undefined'){
  6317. if(lm[0].className == "ingamechatname"){
  6318. lm[1].innerHTML = urlify(lm[1].innerHTML);
  6319. Laster_message = lastmessage();
  6320. lm[0].parentElement.style["parsed"] = true;
  6321. }
  6322. if(lm[0].className == ""){
  6323. lm[0].innerHTML = urlify(lm[0].innerHTML);
  6324. Laster_message = lastmessage();
  6325. lm[0].parentElement.style["parsed"] = true;
  6326. }
  6327. }
  6328. }
  6329. catch{
  6330. lm = "";
  6331. }
  6332. if(text2speech){
  6333. if(!sayer.speaking){
  6334. if(Last_message.includes(": ")){
  6335. speech.text = Last_message.substring(0,Last_message.indexOf(":")).toLowerCase();
  6336. speech.rate = 2.25;
  6337. sayer.speak(speech);
  6338. speech.text = Last_message.substring(Last_message.indexOf(": ")+3).toLowerCase();
  6339. speech.rate = 1.25;
  6340. sayer.speak(speech);
  6341. }
  6342. else{
  6343. speech.text = Last_message.toLowerCase();
  6344. sayer.speak(speech);
  6345. }
  6346. }
  6347. }
  6348. }
  6349. if (ishost==true && new_message){
  6350. for(i=0;i<banned.length;i++){
  6351. if(Last_message.startsWith("* "+banned[i]+" has joined the game")){
  6352. chat2("/kick '"+banned[i]+"'");
  6353. }
  6354. }
  6355. }
  6356. if(Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden" && ishost){
  6357. roundsperqp2 = 0;
  6358. }
  6359. if(Gdocument.getElementById("ingamewinner").style["visibility"]=="inherit" && ishost){
  6360. if(Gdocument.getElementById("ingamewinner").style["parsed"] != true){
  6361. if(stopquickplay!=1){
  6362. roundsperqp2++;
  6363. }
  6364. if(autorecord){
  6365. Gdocument.getElementById("pretty_top_replay").click();
  6366. }
  6367. }
  6368. if(Gdocument.getElementById("ingamewinner").style["parsed"] != true && wintext!="" && Gdocument.getElementById("ingamewinner_bottom").textContent!="DRAW"){
  6369. chat(flag_manage(wintext.replaceAll("username",Gdocument.getElementById("ingamewinner_top").textContent)));
  6370. }
  6371. Gdocument.getElementById("ingamewinner").style["parsed"] = true;
  6372. }
  6373. else{
  6374. Gdocument.getElementById("ingamewinner").style["parsed"] = false;
  6375. }
  6376. if(ishost && stopquickplay == 0){
  6377. if(checkboxhidden){
  6378. checkboxhidden = false;
  6379. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  6380. for(var i = 0; i<classes.length;i++){
  6381. classes[i].style["display"] = "block";
  6382. classes[i].className = "quickplaycheckbox quickplaychecked";
  6383. }
  6384. Gdocument.getElementById('clearallcheckboxes').style["display"] = "block";
  6385.  
  6386. }
  6387. if(nextafter>0 && gameStartTimeStamp+nextafter*1000<=now && Gdocument.getElementById("gamerenderer").style["visibility"] != "hidden" && dontswitch == false && Gdocument.getElementById("ingamewinner").style["visibility"]!="inherit" && !qppaused){
  6388. roundsperqp2 = 0;
  6389. if(shuffle){
  6390. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  6391. var available = [];
  6392. var availableindexes = [];
  6393. var notempty = false;
  6394. for(var i = 0; i<e.length;i++){
  6395. var a = false;
  6396. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  6397. available.push(a);
  6398. if(a){
  6399. availableindexes.push(i);
  6400. notempty = true;
  6401. }
  6402. }
  6403. if(notempty){
  6404. if(availableindexes.length!=1){
  6405. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  6406. }
  6407. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  6408. }
  6409. }
  6410. else{
  6411. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  6412. var available = [];
  6413. var availableindexes = [];
  6414. var notempty = false;
  6415. for(var i = 0; i<e.length;i++){
  6416. var a = false;
  6417. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  6418. available.push(a);
  6419. if(a){
  6420. availableindexes.push(i);
  6421. notempty = true;
  6422. }
  6423. }
  6424. if(notempty){
  6425. var above = [];
  6426. for(var i = 0;i<availableindexes.length;i++){
  6427. if(availableindexes[i]>quicki && !reverseqp){
  6428. above.push(availableindexes[i]);
  6429. }
  6430. else if(availableindexes[i]<quicki && reverseqp){
  6431. above.push(availableindexes[i]);
  6432. }
  6433. }
  6434. if(above.length>0){
  6435. quicki = above[0];
  6436. if(reverseqp){
  6437. above[above.length-1];
  6438. }
  6439. }
  6440. else{
  6441. quicki = availableindexes[0];
  6442. if(reverseqp){
  6443. quicki = availableindexes[availableindexes.length-1];
  6444. }
  6445. }
  6446. }
  6447. }
  6448. startedinqp = true;
  6449. dontswitch = true;
  6450. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  6451. }
  6452. if(Gdocument.getElementById("ingamewinner").style["visibility"]=="inherit" && dontswitch == false && !document.hidden && !qppaused){
  6453. if(roundsperqp2>=roundsperqp){
  6454. if(shuffle){
  6455. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  6456. var available = [];
  6457. var availableindexes = [];
  6458. var notempty = false;
  6459. for(var i = 0; i<e.length;i++){
  6460. var a = false;
  6461. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  6462. available.push(a);
  6463. if(a){
  6464. availableindexes.push(i);
  6465. notempty = true;
  6466. }
  6467. }
  6468. if(notempty){
  6469.  
  6470. if(availableindexes.length!=1){
  6471. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  6472. }
  6473. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  6474. }
  6475. }
  6476. else{
  6477. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  6478. var available = [];
  6479. var availableindexes = [];
  6480. var notempty = false;
  6481. for(var i = 0; i<e.length;i++){
  6482. var a = false;
  6483. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  6484. available.push(a);
  6485. if(a){
  6486. availableindexes.push(i);
  6487. notempty = true;
  6488. }
  6489. }
  6490. if(notempty){
  6491. var above = [];
  6492. for(var i = 0;i<availableindexes.length;i++){
  6493. if(availableindexes[i]>quicki && !reverseqp){
  6494. above.push(availableindexes[i]);
  6495. }
  6496. else if(availableindexes[i]<quicki && reverseqp){
  6497. above.push(availableindexes[i])
  6498. }
  6499. }
  6500. if(above.length>0){
  6501. quicki = above[0];
  6502. if(reverseqp){
  6503. quicki = above[above.length-1];
  6504. }
  6505. }
  6506. else{
  6507. quicki = availableindexes[0];
  6508. if(reverseqp){
  6509. quicki = availableindexes[availableindexes.length-1];
  6510. }
  6511.  
  6512. }
  6513. }
  6514. }
  6515. }
  6516. transitioning = true;
  6517. startedinqp = true;
  6518. map(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  6519. dontswitch = true;
  6520. setTimeout(function(){Gdocument.getElementById("ingamewinner").style["visibility"]="hidden"; dontswitch = false;},timedelay);
  6521. }
  6522. }
  6523. else{
  6524. if(!checkboxhidden){
  6525. checkboxhidden = true;
  6526. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  6527. for(var i = 0; i<classes.length;i++){
  6528. classes[i].style["display"] = "none";
  6529. classes[i].className = "quickplaycheckbox quickplayunchecked";
  6530. }
  6531. Gdocument.getElementById('clearallcheckboxes').style["display"] = "none";
  6532. }
  6533. }
  6534. new_message = false;
  6535. };
  6536. });

QingJ © 2025

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