Bonk Commands

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

当前为 2023-02-05 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Bonk Commands
  3. // @namespace https://greasyfork.org/en/scripts/451341-bonk-commands
  4. // @version 12.2
  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://greasyfork.org/en/scripts/451341-bonk-commands";
  29.  
  30. if(typeof(scope.injectedBonkCommandsScript)=='undefined'){
  31. scope.injectedBonkCommandsScript = true;
  32. }
  33. else{
  34. for (var i = 0; i < 100000; i++){
  35. clearInterval(i);
  36. }
  37. }
  38. scope.GENERATE_COPRIME_NUMBER = function(mini = 0,maxi = 0,coprimewith = 0,choices = []){
  39. if(choices.length == 0){
  40. for(var i = mini;i<maxi+1;i++){
  41. choices.push(i);
  42. }
  43. }
  44. firstTry = choices[Math.floor(Math.random()*choices.length)];
  45. for(var i = 2; i<firstTry+1;i++){
  46. if(firstTry%i == 0 && coprimewith%i == 0){
  47. choices.splice(choices.indexOf(firstTry),1);
  48. if(choices.length == 0){
  49. return 0;
  50. }
  51. return GENERATE_COPRIME_NUMBER(mini,maxi,coprimewith,choices);
  52. }
  53. }
  54. return firstTry;
  55. };
  56. scope.GENERATE_PRIME_NUMBER = function(mini = 0,maxi = 0,choices = []){
  57. if(choices.length == 0){
  58. for(var i = mini;i<maxi+1;i++){
  59. choices.push(i);
  60. }
  61. }
  62. firstTry = choices[Math.floor(Math.random()*choices.length)];
  63. for(var i = 2; i<Math.floor(Math.sqrt(firstTry)+1);i++){
  64. if(i!=firstTry){
  65. if(firstTry%i == 0){
  66. choices.splice(choices.indexOf(firstTry),1);
  67. if(choices.length == 0){
  68. return 0;
  69. }
  70. return GENERATE_PRIME_NUMBER(mini,maxi,choices);
  71. }
  72. }
  73. }
  74. return firstTry;
  75. };
  76. scope.SHUFFLE_LIST = function(x){
  77. var nl = x.slice();
  78. for(var i = nl.length - 1;i>0;i--){
  79. var r = Math.floor(Math.random()*(i+1));
  80. var t = nl[i];
  81. nl[i] = nl[r];
  82. nl[r] = t;
  83. }
  84. return nl;
  85. };
  86. scope.GENERATE_KEYS = function(){
  87. interval = [];
  88. for(var i = 100;i<301;i++){
  89. interval.push(i);
  90. }
  91. random_prime = [GENERATE_PRIME_NUMBER(0,0,choices = interval),0];
  92. interval.splice(interval.indexOf(random_prime[0]),1);
  93. random_prime[1] = GENERATE_PRIME_NUMBER(0,0,choices = interval);
  94.  
  95. n = random_prime[0]*random_prime[1];
  96. n2 = (random_prime[0]-1)*(random_prime[1]-1);
  97.  
  98. e = GENERATE_COPRIME_NUMBER(2,n2-1,n2);
  99. d = 0;
  100. redo = true;
  101. for(var i = 0;i<1000000;i++){
  102. if((e*i-1)%n2 == 0 && i!=e){
  103. d = i;
  104. redo = false;
  105. break;
  106. }
  107. }
  108. if(redo){
  109. return GENERATE_KEYS();
  110. }
  111. else{
  112. return [[n,e],[n,d]];
  113. }
  114.  
  115. };
  116. scope.CRYPT_NUMBER = function(key, data){
  117.  
  118. result = 1;
  119.  
  120. for(var i = 0;i<key[1];i++){
  121. result*=data;
  122. result = result%key[0];
  123. }
  124. return result%key[0];
  125.  
  126. };
  127.  
  128. scope.CRYPT_MESSAGE = function(key,data){
  129. var resulttext = [];
  130. for(var i = 0;i<data.length;i++){
  131. resulttext.push(CRYPT_NUMBER(key,data[i]));
  132. }
  133. return resulttext;
  134.  
  135. };
  136. if(typeof(scope.textdecoder)=='undefined'){scope.textdecoder = new Gwindow.TextDecoder;}
  137. if(typeof(scope.textencoder)=='undefined'){scope.textencoder = new Gwindow.TextEncoder;}
  138.  
  139. class bytebuffer2 {
  140. constructor() {
  141. var g1d = [arguments];
  142. this.index = 0;
  143. this.buffer = new ArrayBuffer(100*1024);
  144. this.view = new DataView(this.buffer);
  145. this.implicitClassAliasArray = [];
  146. this.implicitStringArray = [];
  147. this.bodgeCaptureZoneDataIdentifierArray = [];
  148. }
  149. readByte() {
  150. var N0H = [arguments];
  151. N0H[4] = this.view.getUint8(this.index);
  152. this.index += 1;
  153. return N0H[4];
  154. }
  155. writeByte(z0w) {
  156. var v8$ = [arguments];
  157. this.view.setUint8(this.index, v8$[0][0]);
  158. this.index += 1;
  159. }
  160. readInt() {
  161. var A71 = [arguments];
  162. A71[6] = this.view.getInt32(this.index);
  163. this.index += 4;
  164. return A71[6];
  165. }
  166. writeInt(W6i) {
  167. var p5u = [arguments];
  168. this.view.setInt32(this.index, p5u[0][0]);
  169. this.index += 4;
  170. }
  171. readShort() {
  172. var R1R = [arguments];
  173. R1R[9] = this.view.getInt16(this.index);
  174. this.index += 2;
  175. return R1R[9];
  176. }
  177. writeShort(H8B) {
  178. var d_3 = [arguments];
  179. this.view.setInt16(this.index, d_3[0][0]);
  180. this.index += 2;
  181. }
  182. readUint() {
  183. var W2$ = [arguments];
  184. W2$[8] = this.view.getUint32(this.index);
  185. this.index += 4;
  186. return W2$[8];
  187. }
  188. writeUint(B2X) {
  189. var f8B = [arguments];
  190. this.view.setUint32(this.index, f8B[0][0]);
  191. this.index += 4;
  192. }
  193. readBoolean() {
  194. var h6P = [arguments];
  195. h6P[6] = this.readByte();
  196. return h6P[6] == 1;
  197. }
  198. writeBoolean(Y3I) {
  199. var l79 = [arguments];
  200. if (l79[0][0]) {
  201. this.writeByte(1);
  202. } else {
  203. this.writeByte(0);
  204. }
  205. }
  206. readDouble() {
  207. var V60 = [arguments];
  208. V60[4] = this.view.getFloat64(this.index);
  209. this.index += 8;
  210. return V60[4];
  211. }
  212. writeDouble(z4Z) {
  213. var O41 = [arguments];
  214. this.view.setFloat64(this.index, O41[0][0]);
  215. this.index += 8;
  216. }
  217. readFloat() {
  218. var I0l = [arguments];
  219. I0l[5] = this.view.getFloat32(this.index);
  220. this.index += 4;
  221. return I0l[5];
  222. }
  223. writeFloat(y4B) {
  224. var B0v = [arguments];
  225. this.view.setFloat32(this.index, B0v[0][0]);
  226. this.index += 4;
  227. }
  228. readUTF() {
  229. var d6I = [arguments];
  230. d6I[8] = this.readByte();
  231. d6I[7] = this.readByte();
  232. d6I[9] = d6I[8] * 256 + d6I[7];
  233. d6I[1] = new Uint8Array(d6I[9]);
  234. for (d6I[6] = 0; d6I[6] < d6I[9]; d6I[6]++) {
  235. d6I[1][d6I[6]] = this.readByte();
  236. }
  237. return textdecoder.decode(d6I[1]);
  238. }
  239. writeUTF(L3Z) {
  240. var Z75 = [arguments];
  241. Z75[4] = textencoder.encode(Z75[0][0]);
  242. Z75[3] = Z75[4].length;
  243. Z75[5] = Math.floor(Z75[3]/256);
  244. Z75[8] = Z75[3] % 256;
  245. this.writeByte(Z75[5]);
  246. this.writeByte(Z75[8]);
  247. Z75[7] = this;
  248. Z75[4].forEach(I_O);
  249. function I_O(s0Q, H4K, j$o) {
  250. var N0o = [arguments];
  251. Z75[7].writeByte(N0o[0][0]);
  252. }
  253. }
  254. toBase64() {
  255. var P4$ = [arguments];
  256. P4$[4] = "";
  257. P4$[9] = new Uint8Array(this.buffer);
  258. P4$[8] = this.index;
  259. for (P4$[7] = 0; P4$[7] < P4$[8]; P4$[7]++) {
  260. P4$[4] += String.fromCharCode(P4$[9][P4$[7]]);
  261. }
  262. return Gwindow.btoa(P4$[4]);
  263. }
  264. fromBase64(W69, A8Q) {
  265. var o0n = [arguments];
  266. o0n[8] = Gwindow.pako;
  267. o0n[6] = Gwindow.atob(o0n[0][0]);
  268. o0n[9] = o0n[6].length;
  269. o0n[4] = new Uint8Array(o0n[9]);
  270. for (o0n[1] = 0; o0n[1] < o0n[9]; o0n[1]++) {
  271. o0n[4][o0n[1]] = o0n[6].charCodeAt(o0n[1]);
  272. }
  273. if (o0n[0][1] === true) {
  274. o0n[5] = o0n[8].inflate(o0n[4]);
  275. o0n[4] = o0n[5];
  276. }
  277. this.buffer = o0n[4].buffer.slice(
  278. o0n[4].byteOffset,
  279. o0n[4].byteLength + o0n[4].byteOffset
  280. );
  281. this.view = new DataView(this.buffer);
  282. this.index = 0;
  283. }
  284. };
  285.  
  286. if(typeof(scope.originalSend)=='undefined'){scope.originalSend = Gwindow.WebSocket.prototype.send;}
  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 = false;}
  290. if(typeof(scope.originalDrawCircle)=='undefined'){scope.originalDrawCircle = Gwindow.PIXI.Graphics.prototype.drawCircle;}
  291.  
  292. if(typeof(scope.bonkwss)=='undefined'){scope.bonkwss = 0;}
  293. if(typeof(scope.chatlog)=='undefined'){scope.chatlog = ["ROOM START"];}
  294. if(typeof(scope.wsssendrecievelog)=='undefined'){scope.wsssendrecievelog = [];}
  295. if(typeof(scope.wsssendlog)=='undefined'){scope.wsssendlog = [];}
  296. if(typeof(scope.wssrecievelog)=='undefined'){scope.wssrecievelog = [];}
  297. if(typeof(scope.wsslogpaused)=='undefined'){scope.wsslogpaused = false;}
  298. if(typeof(scope.debuggeropen)=='undefined'){scope.debuggeropen = false;}
  299. if(typeof(scope.debuggercount)=='undefined'){scope.debuggercount = true;}
  300. if(typeof(scope.packetcount)=='undefined'){scope.packetcount = 0;}
  301. if(typeof(scope.requestedmaps)=='undefined'){scope.requestedmaps = [];}
  302. if(typeof(scope.maponclick)=='undefined'){scope.maponclick = 0;}
  303. if(typeof(scope.LZString)=='undefined'){scope.LZString = Gwindow.LZString;}
  304. if(typeof(scope.PSON)=='undefined'){scope.PSON = Gwindow.dcodeIO.PSON;}
  305. if(typeof(scope.bytebuffer)=='undefined'){scope.bytebuffer = Gwindow.dcodeIO.ByteBuffer;}
  306. if(typeof(scope.speech)=='undefined'){scope.speech = new SpeechSynthesisUtterance();speech.pitch = 0.75;}
  307. if(typeof(scope.sayer)=='undefined'){scope.sayer = speechSynthesis;sayer.volume = 0.5;sayer.rate = 1.25;}
  308.  
  309. 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]);}
  310. if(typeof(scope.sandboxon)=='undefined'){scope.sandboxon = false;}
  311. if(typeof(scope.sandboxid)=='undefined'){scope.sandboxid = 1;}
  312. if(typeof(scope.playerids)=='undefined'){scope.playerids = {};}
  313. if(typeof(scope.delplayerids)=='undefined'){scope.delplayerids = {};}
  314. if(typeof(scope.myid)=='undefined'){scope.myid = -1;}
  315. if(typeof(scope.hostid)=='undefined'){scope.hostid = -1;}
  316. if(typeof(scope.sandboxplayerids)=='undefined'){scope.sandboxplayerids = {};}
  317. if(typeof(scope.originalMapLoad)=='undefined'){scope.originalMapLoad = Gdocument.getElementById("maploadwindowmapscontainer").appendChild;}
  318. if(typeof(scope.originalLobbyChat)=='undefined'){scope.originalLobbyChat = Gdocument.getElementById("newbonklobby_chat_content").appendChild;}
  319. if(typeof(scope.originalIngameChat)=='undefined'){scope.originalIngameChat = Gdocument.getElementById("ingamechatcontent").appendChild;}
  320. 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];}
  321. if(Gdocument.getElementById("maploadtypedropdowntitlerequested") == null){
  322. scope.clearmaprequests = Gdocument.createElement("div");
  323. clearmaprequests.id = "clearmaprequests";
  324. clearmaprequests.classList.value = "brownButton brownButton_classic buttonShadow";
  325. clearmaprequests.textContent = "Clear";
  326. clearmaprequests.style["position"] = "absolute";
  327. clearmaprequests.style["display"] = "none";
  328. if(typeof(ishost)!='undefined'){
  329. if(ishost && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS"){
  330. clearmaprequests.style["display"] = "block";
  331. }
  332. }
  333. clearmaprequests.style["right"] = "306px";
  334. clearmaprequests.style["top"] = "57px";
  335. clearmaprequests.style["height"] = "23px";
  336. clearmaprequests.style["width"] = "47px";
  337. clearmaprequests.style["line-height"] = "23px";
  338. clearmaprequests.style["font-size"] = "14px";
  339. clearmaprequests.addEventListener("click",function(){
  340. requestedmaps = [];
  341. Gdocument.getElementById("maploadwindowstatustext").style["visibility"] = "inherit";
  342. Gdocument.getElementById("maploadwindowstatustext").textContent = "No Maps";
  343. while(Gdocument.getElementById("maploadwindowmapscontainer").children.length>0){
  344. Gdocument.getElementById("maploadwindowmapscontainer").removeChild(Gdocument.getElementById("maploadwindowmapscontainer").firstChild);
  345. }
  346. });
  347. Gdocument.getElementById("maploadwindow").insertBefore(clearmaprequests,Gdocument.getElementById("maploadwindowsearchinput"));
  348. scope.refreshmaprequests = Gdocument.createElement("div");
  349. refreshmaprequests.id = "refreshmaprequests";
  350. refreshmaprequests.classList.value = "brownButton brownButton_classic buttonShadow";
  351. refreshmaprequests.textContent = "Refresh";
  352. refreshmaprequests.style["position"] = "absolute";
  353. refreshmaprequests.style["display"] = "none";
  354. if(typeof(ishost)!='undefined'){
  355. if(ishost && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS"){
  356. refreshmaprequests.style["display"] = "block";
  357. }
  358. }
  359. refreshmaprequests.style["right"] = "357px";
  360. refreshmaprequests.style["top"] = "57px";
  361. refreshmaprequests.style["height"] = "23px";
  362. refreshmaprequests.style["width"] = "47px";
  363. refreshmaprequests.style["line-height"] = "23px";
  364. refreshmaprequests.style["font-size"] = "14px";
  365. refreshmaprequests.addEventListener("click",function(){
  366. Gdocument.getElementById("maploadtypedropdowntitle").textContent = dropdownrequested.textContent;
  367. Gdocument.getElementById("maploadwindowsearchinput").value = "";
  368. dropdownrequested.style["display"] = "none";
  369. clearmaprequests.style["display"] = "block";
  370. refreshmaprequests.style["display"] = "block";
  371. Gdocument.getElementById("maploadwindowhotnessslider").style["visibility"] = "hidden";
  372. Gdocument.getElementById("maploadwindowsearchoptions").style["visibility"] = "hidden";
  373. searchrequested = true;
  374. Gdocument.getElementById("maploadwindowsearchbutton").click();
  375.  
  376. Gdocument.getElementById("maploadtypedropdowntitle").textContent = "MAP REQUESTS";
  377. });
  378. Gdocument.getElementById("maploadwindow").insertBefore(refreshmaprequests,Gdocument.getElementById("maploadwindowsearchinput"));
  379.  
  380. scope.dropdownrequested = Gdocument.createElement("div");
  381. dropdownrequested.classList = "dropdown-option dropdown_classic";
  382. dropdownrequested.style["display"] = "none";
  383. dropdownrequested.id = "maploadtypedropdowntitlerequested";
  384.  
  385. if(Gdocument.getElementById("maploadtypedropdownoption10").style["display"] == "block"){
  386. dropdownrequested.style["display"] = "block";
  387. }
  388. dropdownrequested.textContent = "MAP REQUESTS";
  389. dropdownrequested.onclick = function(){
  390. Gdocument.getElementById("maploadtypedropdowntitle").textContent = dropdownrequested.textContent;
  391. Gdocument.getElementById("maploadwindowsearchinput").value = "";
  392. dropdownrequested.style["display"] = "none";
  393. clearmaprequests.style["display"] = "block";
  394. refreshmaprequests.style["display"] = "block";
  395. Gdocument.getElementById("maploadwindowhotnessslider").style["visibility"] = "hidden";
  396. Gdocument.getElementById("maploadwindowsearchoptions").style["visibility"] = "hidden";
  397. searchrequested = true;
  398. Gdocument.getElementById("maploadwindowsearchbutton").click();
  399.  
  400. Gdocument.getElementById("maploadtypedropdowntitle").textContent = "MAP REQUESTS";
  401. };
  402. (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});
  403. Gdocument.getElementById("maploadtypedropdown").insertBefore(dropdownrequested,Gdocument.getElementById("maploadtypedropdownoption1"));
  404. Gdocument.getElementById("maploadwindowmapscontainer").__defineGetter__("clientHeight",function(){if(Gdocument.getElementById("maploadtypedropdowntitle").textContent != "MAP REQUESTS"){return Gdocument.getElementById("maploadwindowmapscontainer").getClientRects()[0].height;}else{return 0;}});
  405.  
  406. };
  407.  
  408. function sandboxonclick(){
  409. Gdocument.getElementById("roomlistcreatewindowmaxplayers").value = 1;
  410. Gdocument.getElementById("roomlistcreatewindowunlistedcheckbox").checked = true;
  411. Gdocument.getElementById("roomlistcreatecreatebutton").click();
  412. sandboxon = true;
  413. }
  414. function checkboxclearbuttononclick(){
  415. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  416. var e = true;
  417. for(var i = 0; i<classes.length;i++){
  418. if(classes[i].checked == true){
  419. e = false
  420. }
  421. classes[i].checked = false;
  422. }
  423. if(e){
  424. for(var i = 0; i<classes.length;i++){
  425. classes[i].checked = true;
  426. }
  427. }
  428. }
  429. Gdocument.getElementById("ingamechatcontent").__defineGetter__("childElementCount",function(){return this.children.length/50;});
  430. if(Gdocument.getElementById("classic_mid_sandbox")==null){
  431. Gdocument.getElementById("roomlistrefreshbutton").click();
  432. scope.sandboxbutton = Gdocument.createElement("div");
  433. sandboxbutton.id = "classic_mid_sandbox";
  434. sandboxbutton.classList.value = "brownButton brownButton_classic classic_mid_buttons";
  435. sandboxbutton.textContent = "Sandbox";
  436. sandboxbutton.addEventListener("click",sandboxonclick);
  437. Gdocument.getElementById("classic_mid").insertBefore(sandboxbutton,Gdocument.getElementById("classic_mid_news"));
  438.  
  439. }
  440. if(Gdocument.getElementById("clearallcheckboxes")==null){
  441. scope.checkboxclearbutton = Gdocument.createElement("div");
  442. checkboxclearbutton.id = "clearallcheckboxes";
  443. checkboxclearbutton.classList.value = "brownButton brownButton_classic buttonShadow";
  444. checkboxclearbutton.textContent = "On/Off";
  445. checkboxclearbutton.style["position"] = "absolute";
  446. checkboxclearbutton.style["display"] = "none";
  447. if(typeof(ishost)!='undefined'){
  448. if(ishost && stopquickplay == 0){
  449. checkboxclearbutton.style["display"] = "block";
  450. }
  451. }
  452. checkboxclearbutton.style["right"] = "255px";
  453. checkboxclearbutton.style["top"] = "57px";
  454. checkboxclearbutton.style["height"] = "23px";
  455. checkboxclearbutton.style["width"] = "47px";
  456. checkboxclearbutton.style["line-height"] = "23px";
  457. checkboxclearbutton.style["font-size"] = "13px";
  458. checkboxclearbutton.addEventListener("click",checkboxclearbuttononclick);
  459. Gdocument.getElementById("maploadwindow").insertBefore(checkboxclearbutton,Gdocument.getElementById("maploadwindowsearchinput"));
  460.  
  461. }
  462. scope.holdloadbuttonTimeout = [];
  463. scope.holdloadbutton = function(){
  464. var scrollcount = 0;
  465. var mapwindow = Gdocument.getElementById("maploadwindowmapscontainer");
  466. mapwindow.scroll(0,mapwindow.scrollHeight);
  467. };
  468.  
  469. if(Gdocument.getElementById("mapwindowloadall")==null){
  470. scope.loadall = Gdocument.createElement("div");
  471. loadall.id = "mapwindowloadall";
  472. loadall.classList.value = "brownButton brownButton_classic buttonShadow";
  473. loadall.textContent = "Load";
  474. loadall.style["position"] = "absolute";
  475. loadall.style["display"] = "block";
  476. loadall.style["left"] = "204px";
  477. loadall.style["top"] = "57px";
  478. loadall.style["height"] = "23px";
  479. loadall.style["width"] = "34px";
  480. loadall.style["line-height"] = "23px";
  481. loadall.style["font-size"] = "12px";
  482. var repeat = function(){holdloadbutton();holdloadbuttonTimeout.push(setTimeout(repeat,25));};
  483. loadall.onmousedown = function(){repeat();};
  484. loadall.onmouseup = function(){for(var i = 0; i<holdloadbuttonTimeout.length; i++){clearTimeout(holdloadbuttonTimeout[i]);}};
  485. loadall.onmouseout = function(){for(var i = 0; i<holdloadbuttonTimeout.length; i++){clearTimeout(holdloadbuttonTimeout[i]);}};
  486.  
  487. Gdocument.getElementById("maploadwindow").insertBefore(loadall,Gdocument.getElementById("maploadwindowsearchinput"));
  488.  
  489. }
  490. if(Gdocument.getElementById("BonkCommandsDebuggerContainer")==null){
  491. Gdocument.getElementById("leaveconfirmwindow").style["z-index"]=3;
  492. scope.debuggermenu = Gdocument.createElement("div");
  493. debuggermenu.id = "BonkCommandsDebuggerContainer";
  494. debuggermenu.style["position"] = "absolute";
  495. debuggermenu.style["display"] = "none";
  496. if(typeof(debuggeropen)!='undefined'){
  497. if(debuggeropen){
  498. debuggermenu.style["display"] = "block";
  499. }
  500. }
  501. debuggermenu.style["width"] = Gdocument.getElementById("bonkiocontainer").style["width"];
  502. debuggermenu.style["height"] = Gdocument.getElementById("bonkiocontainer").style["height"];
  503.  
  504. debuggermenu.style["background"] = "rgb(26, 39, 51)";
  505.  
  506. scope.width = parseInt(Gdocument.getElementById("bonkiocontainer").style["width"])-20;
  507. scope.height = parseInt(Gdocument.getElementById("bonkiocontainer").style["height"])-210;
  508.  
  509. scope.logmenu = Gdocument.createElement("div");
  510. logmenu.id = "BonkCommandsWebSocketLog";
  511. logmenu.style["position"] = "absolute";
  512. logmenu.style["width"] = width.toString()+"px";
  513. logmenu.style["height"] = height.toString()+"px";
  514. logmenu.style["top"] = "80px";
  515. logmenu.style["left"] = "10px";
  516. logmenu.style["background"] = "rgb(207, 216, 220)";
  517. scope.logmenutopleft = Gdocument.createElement("div");
  518. logmenutopleft.id = "BonkCommandsWebSocketLog";
  519. logmenutopleft.style["position"] = "absolute";
  520. logmenutopleft.textContent = "Sending";
  521. logmenutopleft.classList = "newbonklobby_boxtop newbonklobby_boxtop_classic";
  522. logmenutopleft.style["width"] = (width/2).toString()+"px";
  523. logmenutopleft.style["height"] = "30px";
  524. logmenutopleft.style["top"] = "-30px";
  525. logmenutopleft.style["background"] = "rgb(0, 150, 136)";
  526. logmenu.appendChild(logmenutopleft);
  527. scope.logmenutopright = Gdocument.createElement("div");
  528. logmenutopright.id = "BonkCommandsWebSocketLog";
  529. logmenutopright.style["position"] = "absolute";
  530. logmenutopright.textContent = "Recieving";
  531. logmenutopright.classList = "newbonklobby_boxtop newbonklobby_boxtop_classic";
  532. logmenutopright.style["width"] = (width/2).toString()+"px";
  533. logmenutopright.style["height"] = "30px";
  534. logmenutopright.style["left"] = (width/2).toString()+"px";
  535. logmenutopright.style["top"] = "-30px";
  536. logmenutopright.style["background"] = "rgb(0, 150, 136)";
  537. logmenu.appendChild(logmenutopright);
  538. scope.logmenutable = Gdocument.createElement("table");
  539. logmenutable.id = "BonkCommandsWebSocketTable";
  540. logmenutable.style["position"] = "absolute";
  541. logmenutable.style["border-spacing"] = "0px";
  542. logmenutable.style["font-size"] = "12px";
  543. logmenutable.style["display"] = "table-cell";
  544. logmenutable.style["width"] = "50%";
  545. logmenutable.style["height"] = "100%";
  546. logmenutable.style["table-layout"] = "fixed";
  547. logmenutable.style["overflow-y"] = "scroll";
  548.  
  549. scope.logmenutable2 = Gdocument.createElement("table");
  550. logmenutable2.id = "BonkCommandsWebSocketTable2";
  551. logmenutable2.style["position"] = "absolute";
  552. logmenutable2.style["width"] = "50%";
  553. logmenutable2.style["left"] = "50%";
  554. logmenutable2.style["font-size"] = "12px";
  555. logmenutable2.style["display"] = "table-cell";
  556. logmenutable2.style["height"] = "100%";
  557. logmenutable2.style["table-layout"] = "fixed";
  558. logmenutable2.style["overflow-y"] = "scroll";
  559. logmenutable2.style["border-spacing"] = "0px";
  560. scope.leftsync = false;
  561. scope.rightsync = false;
  562. logmenutable2.onscroll = function(){
  563. if(!leftsync){
  564. rightsync = true;
  565. logmenutable.scrollTop = this.scrollTop;
  566. }
  567. else{
  568. leftsync = false;
  569. }
  570. };
  571. logmenutable.onscroll = function(){
  572. if(!rightsync){
  573. leftsync = true;
  574. logmenutable2.scrollTop = this.scrollTop;
  575. }
  576. else{
  577. rightsync = false
  578. }
  579. };
  580. logmenu.appendChild(logmenutable);
  581. logmenu.appendChild(logmenutable2);
  582. debuggermenu.appendChild(logmenu);
  583. scope.debuggermenuclose = Gdocument.createElement("div");
  584. debuggermenuclose.id = "debuggerclose";
  585. debuggermenuclose.classList = "windowCloseButton brownButton brownButton_classic buttonShadow";
  586. debuggermenuclose.style["position"] = "absolute";
  587. debuggermenuclose.style["top"] = "40px";
  588. debuggermenuclose.style["right"] = "5px";
  589. debuggermenuclose.onclick = function(){debuggeropen = false;debuggermenu.style["display"] = "none";Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  590. Gdocument.getElementById("ingamechatinputtext").style["display"] = "";};
  591. debuggermenu.appendChild(debuggermenuclose);
  592. scope.debuggerform = Gdocument.createElement("form");
  593. debuggerform.autocomplete = "off";
  594. scope.debuggerinput = Gdocument.createElement("input");
  595. debuggerinput.style["position"] = "absolute";
  596. debuggerinput.style["width"] = width.toString()+"px";
  597. debuggerinput.style["left"] = "10px";
  598. debuggerinput.style["top"] = (height+90).toString()+"px";
  599. debuggerinput.style["font-size"] = "12px";
  600. debuggerinput.style["height"] = "20px";
  601. debuggerform.appendChild(debuggerinput);
  602. scope.debuggersendrecieve = Gdocument.createElement("div");
  603. debuggersendrecieve.style["position"] = "absolute";
  604. debuggersendrecieve.style["width"] = "140px";
  605. debuggersendrecieve.style["left"] = "10px";
  606. debuggersendrecieve.style["top"] = (height+120).toString()+"px";
  607. debuggersendrecieve.style["font-size"] = "15px";
  608. debuggersendrecieve.style["height"] = "20px";
  609. debuggersendrecieve.classList = "brownButton brownButton_classic buttonShadow";
  610. debuggersendrecieve.textContent = "Send";
  611. debuggersendrecieve.value = 0;
  612. debuggersendrecieve.onclick = function(){if(this.value == 0){this.textContent = "Recieve";this.value = 1;}else{this.textContent = "Send";this.value = 0;}};
  613.  
  614. debuggermenu.appendChild(debuggersendrecieve);
  615. scope.debuggerpausebutton = Gdocument.createElement("div");
  616. debuggerpausebutton.style["position"] = "absolute";
  617. debuggerpausebutton.style["width"] = "140px";
  618. debuggerpausebutton.style["left"] = "10px";
  619. debuggerpausebutton.style["top"] = (height+150).toString()+"px";
  620. debuggerpausebutton.style["font-size"] = "15px";
  621. debuggerpausebutton.style["height"] = "20px";
  622. debuggerpausebutton.classList = "brownButton brownButton_classic buttonShadow";
  623. debuggerpausebutton.textContent = "Pause";
  624. debuggerpausebutton.value = 0;
  625. debuggerpausebutton.onclick = function(){if(this.value == 0){this.textContent = "Play";this.value = 1;wsslogpaused = true}else{this.textContent = "Pause";this.value = 0;wsslogpaused = false;}};
  626.  
  627. debuggermenu.appendChild(debuggerpausebutton);
  628. scope.debuggereval = Gdocument.createElement("input");
  629. debuggereval.style["position"] = "absolute";
  630. debuggereval.style["width"] = (width-150).toString()+"px";
  631. debuggereval.style["right"] = "10px";
  632. debuggereval.style["top"] = (height+120).toString()+"px";
  633. debuggereval.style["font-size"] = "12px";
  634. debuggereval.style["height"] = "20px";
  635. debuggereval.addEventListener("keypress",function(e){if(e.repeat){return;}if(e.code == "Enter"){if(debuggersendrecieve.value == 0){SEND(this.value);}else{RECIEVE(this.value);}}});
  636. debuggerform.appendChild(debuggereval);
  637. debuggermenu.appendChild(debuggerform);
  638. Gdocument.getElementById("newbonkgamecontainer").appendChild(debuggermenu);
  639.  
  640. }
  641. scope.ISdecode = function(rawdata) {
  642. rawdata_caseflipped = "";
  643. for (i = 0; i < rawdata.length; i++) {
  644. if (i <= 100 && rawdata.charAt(i) === rawdata.charAt(i).toLowerCase()) {
  645. rawdata_caseflipped += rawdata.charAt(i).toUpperCase();
  646. } else if (i <= 100 && rawdata.charAt(i) === rawdata.charAt(i).toUpperCase()) {
  647. rawdata_caseflipped += rawdata.charAt(i).toLowerCase();
  648. } else {
  649. rawdata_caseflipped += rawdata.charAt(i);
  650. }
  651. }
  652.  
  653. data_deLZd = LZString.decompressFromEncodedURIComponent(rawdata_caseflipped);
  654. databuffer = bytebuffer.fromBase64(data_deLZd);
  655. data = ISpsonpair.decode(databuffer.buffer);
  656. return data;
  657. };
  658. scope.ISencode = function(obj) {
  659. data = ISpsonpair.encode(obj);
  660. b64 = data.toBase64();
  661. lzd = LZString.compressToEncodedURIComponent(b64);
  662.  
  663. caseflipped = "";
  664. for (i = 0; i < lzd.length; i++) {
  665. if (i <= 100 && lzd.charAt(i) === lzd.charAt(i).toLowerCase()) {
  666. caseflipped += lzd.charAt(i).toUpperCase();
  667. } else if (i <= 100 && lzd.charAt(i) === lzd.charAt(i).toUpperCase()) {
  668. caseflipped += lzd.charAt(i).toLowerCase();
  669. } else {
  670. caseflipped += lzd.charAt(i);
  671. }
  672. }
  673.  
  674.  
  675. return caseflipped;
  676. };
  677. scope.decodeIS = function(x){
  678. return ISdecode(x);
  679. };
  680. scope.encodeIS = function(x){
  681. return ISencode(x);
  682. };
  683.  
  684.  
  685. encodeToDatabase = function(mapObject) {
  686. var H_B = [arguments];
  687. H_B[2] = new bytebuffer2;
  688. H_B[5] = mapObject.physics;
  689. mapObject.v = 13;
  690. H_B[2].writeShort(mapObject.v);
  691. H_B[2].writeBoolean(mapObject.s.re);
  692. H_B[2].writeBoolean(mapObject.s.nc);
  693. H_B[2].writeShort(mapObject.s.pq);
  694. H_B[2].writeFloat(mapObject.s.gd);
  695. H_B[2].writeBoolean(mapObject.s.fl);
  696. H_B[2].writeUTF(mapObject.m.rxn);
  697. H_B[2].writeUTF(mapObject.m.rxa);
  698. H_B[2].writeUint(mapObject.m.rxid);
  699. H_B[2].writeShort(mapObject.m.rxdb);
  700. H_B[2].writeUTF(mapObject.m.n);
  701. H_B[2].writeUTF(mapObject.m.a);
  702. H_B[2].writeUint(mapObject.m.vu);
  703. H_B[2].writeUint(mapObject.m.vd);
  704. H_B[2].writeShort(mapObject.m.cr.length);
  705. for (
  706. H_B[62] = 0;
  707. H_B[62] < mapObject.m.cr.length;
  708. H_B[62]++
  709. ) {
  710. H_B[2].writeUTF(mapObject.m.cr[H_B[62]]);
  711. }
  712. H_B[2].writeUTF(mapObject.m.mo);
  713. H_B[2].writeInt(mapObject.m.dbid);
  714. H_B[2].writeBoolean(mapObject.m.pub);
  715. H_B[2].writeInt(mapObject.m.dbv);
  716. H_B[2].writeShort(H_B[5].ppm);
  717. H_B[2].writeShort(H_B[5].bro.length);
  718. for (H_B[31] = 0; H_B[31] < H_B[5].bro.length; H_B[31]++) {
  719. H_B[2].writeShort(H_B[5].bro[H_B[31]]);
  720. }
  721. H_B[2].writeShort(H_B[5].shapes.length);
  722. for (H_B[61] = 0; H_B[61] < H_B[5].shapes.length; H_B[61]++) {
  723. H_B[3] = H_B[5].shapes[H_B[61]];
  724. if (H_B[3].type == "bx") {
  725. H_B[2].writeShort(1);
  726. H_B[2].writeDouble(H_B[3].w);
  727. H_B[2].writeDouble(H_B[3].h);
  728. H_B[2].writeDouble(H_B[3].c[0]);
  729. H_B[2].writeDouble(H_B[3].c[1]);
  730. H_B[2].writeDouble(H_B[3].a);
  731. H_B[2].writeBoolean(H_B[3].sk);
  732. }
  733. if (H_B[3].type == "ci") {
  734. H_B[2].writeShort(2);
  735. H_B[2].writeDouble(H_B[3].r);
  736. H_B[2].writeDouble(H_B[3].c[0]);
  737. H_B[2].writeDouble(H_B[3].c[1]);
  738. H_B[2].writeBoolean(H_B[3].sk);
  739. }
  740. if (H_B[3].type == "po") {
  741. H_B[2].writeShort(3);
  742. H_B[2].writeDouble(H_B[3].s);
  743. H_B[2].writeDouble(H_B[3].a);
  744. H_B[2].writeDouble(H_B[3].c[0]);
  745. H_B[2].writeDouble(H_B[3].c[1]);
  746. H_B[2].writeShort(H_B[3].v.length);
  747. for (H_B[45] = 0; H_B[45] < H_B[3].v.length; H_B[45]++) {
  748. H_B[2].writeDouble(H_B[3].v[H_B[45]][0]);
  749. H_B[2].writeDouble(H_B[3].v[H_B[45]][1]);
  750. }
  751. }
  752. }
  753. H_B[2].writeShort(H_B[5].fixtures.length);
  754. for (H_B[88] = 0; H_B[88] < H_B[5].fixtures.length; H_B[88]++) {
  755. H_B[4] = H_B[5].fixtures[H_B[88]];
  756. H_B[2].writeShort(H_B[4].sh);
  757. H_B[2].writeUTF(H_B[4].n);
  758. if (H_B[4].fr === null) {
  759. H_B[2].writeDouble(Number.MAX_VALUE);
  760. } else {
  761. H_B[2].writeDouble(H_B[4].fr);
  762. }
  763. if (H_B[4].fp === null) {
  764. H_B[2].writeShort(0);
  765. }
  766. if (H_B[4].fp === false) {
  767. H_B[2].writeShort(1);
  768. }
  769. if (H_B[4].fp === true) {
  770. H_B[2].writeShort(2);
  771. }
  772. if (H_B[4].re === null) {
  773. H_B[2].writeDouble(Number.MAX_VALUE);
  774. } else {
  775. H_B[2].writeDouble(H_B[4].re);
  776. }
  777. if (H_B[4].de === null) {
  778. H_B[2].writeDouble(Number.MAX_VALUE);
  779. } else {
  780. H_B[2].writeDouble(H_B[4].de);
  781. }
  782. H_B[2].writeUint(H_B[4].f);
  783. H_B[2].writeBoolean(H_B[4].d);
  784. H_B[2].writeBoolean(H_B[4].np);
  785. H_B[2].writeBoolean(H_B[4].ng);
  786. H_B[2].writeBoolean(H_B[4].ig);
  787. }
  788. H_B[2].writeShort(H_B[5].bodies.length);
  789. for (H_B[41] = 0; H_B[41] < H_B[5].bodies.length; H_B[41]++) {
  790. H_B[9] = H_B[5].bodies[H_B[41]];
  791. H_B[2].writeUTF(H_B[9].type);
  792. H_B[2].writeUTF(H_B[9].n);
  793. H_B[2].writeDouble(H_B[9].p[0]);
  794. H_B[2].writeDouble(H_B[9].p[1]);
  795. H_B[2].writeDouble(H_B[9].a);
  796. H_B[2].writeDouble(H_B[9].fric);
  797. H_B[2].writeBoolean(H_B[9].fricp);
  798. H_B[2].writeDouble(H_B[9].re);
  799. H_B[2].writeDouble(H_B[9].de);
  800. H_B[2].writeDouble(H_B[9].lv[0]);
  801. H_B[2].writeDouble(H_B[9].lv[1]);
  802. H_B[2].writeDouble(H_B[9].av);
  803. H_B[2].writeDouble(H_B[9].ld);
  804. H_B[2].writeDouble(H_B[9].ad);
  805. H_B[2].writeBoolean(H_B[9].fr);
  806. H_B[2].writeBoolean(H_B[9].bu);
  807. H_B[2].writeDouble(H_B[9].cf.x);
  808. H_B[2].writeDouble(H_B[9].cf.y);
  809. H_B[2].writeDouble(H_B[9].cf.ct);
  810. H_B[2].writeBoolean(H_B[9].cf.w);
  811. H_B[2].writeShort(H_B[9].f_c);
  812. H_B[2].writeBoolean(H_B[9].f_1);
  813. H_B[2].writeBoolean(H_B[9].f_2);
  814. H_B[2].writeBoolean(H_B[9].f_3);
  815. H_B[2].writeBoolean(H_B[9].f_4);
  816. H_B[2].writeBoolean(H_B[9].f_p);
  817. H_B[2].writeShort(H_B[9].fx.length);
  818. for (H_B[78] = 0; H_B[78] < H_B[9].fx.length; H_B[78]++) {
  819. H_B[2].writeShort(H_B[9].fx[H_B[78]]);
  820. }
  821. }
  822. H_B[2].writeShort(mapObject.spawns.length);
  823. for (
  824. H_B[74] = 0;
  825. H_B[74] < mapObject.spawns.length;
  826. H_B[74]++
  827. ) {
  828. H_B[6] = mapObject.spawns[H_B[74]];
  829. H_B[2].writeDouble(H_B[6].x);
  830. H_B[2].writeDouble(H_B[6].y);
  831. H_B[2].writeDouble(H_B[6].xv);
  832. H_B[2].writeDouble(H_B[6].yv);
  833. H_B[2].writeShort(H_B[6].priority);
  834. H_B[2].writeBoolean(H_B[6].r);
  835. H_B[2].writeBoolean(H_B[6].f);
  836. H_B[2].writeBoolean(H_B[6].b);
  837. H_B[2].writeBoolean(H_B[6].gr);
  838. H_B[2].writeBoolean(H_B[6].ye);
  839. H_B[2].writeUTF(H_B[6].n);
  840. }
  841. H_B[2].writeShort(mapObject.capZones.length);
  842. for (
  843. H_B[48] = 0;
  844. H_B[48] < mapObject.capZones.length;
  845. H_B[48]++
  846. ) {
  847. H_B[1] = mapObject.capZones[H_B[48]];
  848. H_B[2].writeUTF(H_B[1].n);
  849. H_B[2].writeDouble(H_B[1].l);
  850. H_B[2].writeShort(H_B[1].i);
  851. H_B[2].writeShort(H_B[1].ty);
  852. }
  853. H_B[2].writeShort(H_B[5].joints.length);
  854. for (H_B[69] = 0; H_B[69] < H_B[5].joints.length; H_B[69]++) {
  855. H_B[8] = H_B[5].joints[H_B[69]];
  856. if (H_B[8].type == "rv") {
  857. H_B[2].writeShort(1);
  858. H_B[2].writeDouble(H_B[8].d.la);
  859. H_B[2].writeDouble(H_B[8].d.ua);
  860. H_B[2].writeDouble(H_B[8].d.mmt);
  861. H_B[2].writeDouble(H_B[8].d.ms);
  862. H_B[2].writeBoolean(H_B[8].d.el);
  863. H_B[2].writeBoolean(H_B[8].d.em);
  864. H_B[2].writeDouble(H_B[8].aa[0]);
  865. H_B[2].writeDouble(H_B[8].aa[1]);
  866. }
  867. if (H_B[8].type == "d") {
  868. H_B[2].writeShort(2);
  869. H_B[2].writeDouble(H_B[8].d.fh);
  870. H_B[2].writeDouble(H_B[8].d.dr);
  871. H_B[2].writeDouble(H_B[8].aa[0]);
  872. H_B[2].writeDouble(H_B[8].aa[1]);
  873. H_B[2].writeDouble(H_B[8].ab[0]);
  874. H_B[2].writeDouble(H_B[8].ab[1]);
  875. }
  876. if (H_B[8].type == "lpj") {
  877. H_B[2].writeShort(3);
  878. H_B[2].writeDouble(H_B[8].pax);
  879. H_B[2].writeDouble(H_B[8].pay);
  880. H_B[2].writeDouble(H_B[8].pa);
  881. H_B[2].writeDouble(H_B[8].pf);
  882. H_B[2].writeDouble(H_B[8].pl);
  883. H_B[2].writeDouble(H_B[8].pu);
  884. H_B[2].writeDouble(H_B[8].plen);
  885. H_B[2].writeDouble(H_B[8].pms);
  886. }
  887. if (H_B[8].type == "lsj") {
  888. H_B[2].writeShort(4);
  889. H_B[2].writeDouble(H_B[8].sax);
  890. H_B[2].writeDouble(H_B[8].say);
  891. H_B[2].writeDouble(H_B[8].sf);
  892. H_B[2].writeDouble(H_B[8].slen);
  893. }
  894. H_B[2].writeShort(H_B[8].ba);
  895. H_B[2].writeShort(H_B[8].bb);
  896. H_B[2].writeBoolean(H_B[8].d.cc);
  897. H_B[2].writeDouble(H_B[8].d.bf);
  898. H_B[2].writeBoolean(H_B[8].d.dl);
  899. }
  900. H_B[15] = H_B[2].toBase64();
  901. H_B[30] = LZString.compressToEncodedURIComponent(H_B[15]);
  902. return H_B[30];
  903. };
  904.  
  905.  
  906.  
  907.  
  908.  
  909. scope.decodeFromDatabase = function(map) {
  910. var a8k = [arguments];
  911. b64mapdata = LZString.decompressFromEncodedURIComponent(map);
  912. var binaryReader = new bytebuffer2;
  913. binaryReader.fromBase64(b64mapdata, false);
  914. 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": "" } };
  915. map.v = binaryReader.readShort();
  916. if (map.v > 13) {
  917. throw new Error("New map format, this script needs to be updated.");
  918. }
  919. map.s.re = binaryReader.readBoolean();
  920. map.s.nc = binaryReader.readBoolean();
  921. if (map.v >= 3) {
  922. map.s.pq = binaryReader.readShort();
  923. }
  924. if (map.v >= 4 && map.v <= 12) {
  925. map.s.gd = binaryReader.readShort();
  926. } else if (map.v >= 13) {
  927. map.s.gd = binaryReader.readFloat();
  928. }
  929. if (map.v >= 9) {
  930. map.s.fl = binaryReader.readBoolean();
  931. }
  932. map.m.rxn = binaryReader.readUTF();
  933. map.m.rxa = binaryReader.readUTF();
  934. map.m.rxid = binaryReader.readUint();
  935. map.m.rxdb = binaryReader.readShort();
  936. map.m.n = binaryReader.readUTF();
  937. map.m.a = binaryReader.readUTF();
  938. if (map.v >= 10) {
  939. map.m.vu = binaryReader.readUint();
  940. map.m.vd = binaryReader.readUint();
  941. }
  942. if (map.v >= 4) {
  943. cr_count = binaryReader.readShort();
  944. for (cr_iterator = 0; cr_iterator < cr_count; cr_iterator++) {
  945. map.m.cr.push(binaryReader.readUTF());
  946. }
  947. }
  948. if (map.v >= 5) {
  949. map.m.mo = binaryReader.readUTF();
  950. map.m.dbid = binaryReader.readInt();
  951. }
  952. if (map.v >= 7) {
  953. map.m.pub = binaryReader.readBoolean();
  954. }
  955. if (map.v >= 8) {
  956. map.m.dbv = binaryReader.readInt();
  957. }
  958. map.physics.ppm = binaryReader.readShort();
  959. bro_count = binaryReader.readShort();
  960. for (bro_iterator = 0; bro_iterator < bro_count; bro_iterator++) {
  961. map.physics.bro[bro_iterator] = binaryReader.readShort();
  962. }
  963. shape_count = binaryReader.readShort();
  964. for (shape_iterator = 0; shape_iterator < shape_count; shape_iterator++) {
  965. shape_type = binaryReader.readShort();
  966. if (shape_type == 1) {
  967. map.physics.shapes[shape_iterator] = {"type":"bx","w":10,"h":40,"c":[0,0],"a":0,"sk":false};
  968. map.physics.shapes[shape_iterator].w = binaryReader.readDouble();
  969. map.physics.shapes[shape_iterator].h = binaryReader.readDouble();
  970. map.physics.shapes[shape_iterator].c = [binaryReader.readDouble(), binaryReader.readDouble()];
  971. map.physics.shapes[shape_iterator].a = binaryReader.readDouble();
  972. map.physics.shapes[shape_iterator].sk = binaryReader.readBoolean();
  973. }
  974. if (shape_type == 2) {
  975. map.physics.shapes[shape_iterator] = {"type":"ci","r":25,"c":[0,0],"sk":false};
  976. map.physics.shapes[shape_iterator].r = binaryReader.readDouble();
  977. map.physics.shapes[shape_iterator].c = [binaryReader.readDouble(), binaryReader.readDouble()];
  978. map.physics.shapes[shape_iterator].sk = binaryReader.readBoolean();
  979. }
  980. if (shape_type == 3) {
  981. map.physics.shapes[shape_iterator] = {"type":"po","v":[],"s":1,"a":0,"c":[0,0]};
  982. map.physics.shapes[shape_iterator].s = binaryReader.readDouble();
  983. map.physics.shapes[shape_iterator].a = binaryReader.readDouble();
  984. map.physics.shapes[shape_iterator].c = [binaryReader.readDouble(), binaryReader.readDouble()];
  985. point_count = binaryReader.readShort();
  986. map.physics.shapes[shape_iterator].v = [];
  987. for (point_iterator = 0; point_iterator < point_count; point_iterator++) {
  988. map.physics.shapes[shape_iterator].v.push([binaryReader.readDouble(), binaryReader.readDouble()]);
  989. }
  990. }
  991. }
  992. a8k[31] = binaryReader.readShort();
  993. for (a8k[89] = 0; a8k[89] < a8k[31]; a8k[89]++) {
  994. map.physics.fixtures[a8k[89]] = {"n":"Def Fix","fr":0.3,"fp":null,"re":0.8,"de":0.3,"f":5209260,"d":false,"np":false,"ng":false};
  995. map.physics.fixtures[a8k[89]].sh = binaryReader.readShort();
  996. map.physics.fixtures[a8k[89]].n = binaryReader.readUTF();
  997. map.physics.fixtures[a8k[89]].fr = binaryReader.readDouble();
  998. if (map.physics.fixtures[a8k[89]].fr == Number.MAX_VALUE) {
  999. map.physics.fixtures[a8k[89]].fr = null;
  1000. }
  1001. a8k[22] = binaryReader.readShort();
  1002. if (a8k[22] == 0) {
  1003. map.physics.fixtures[a8k[89]].fp = null;
  1004. }
  1005. if (a8k[22] == 1) {
  1006. map.physics.fixtures[a8k[89]].fp = false;
  1007. }
  1008. if (a8k[22] == 2) {
  1009. map.physics.fixtures[a8k[89]].fp = true;
  1010. }
  1011. map.physics.fixtures[a8k[89]].re = binaryReader.readDouble();
  1012. if (map.physics.fixtures[a8k[89]].re == Number.MAX_VALUE) {
  1013. map.physics.fixtures[a8k[89]].re = null;
  1014. }
  1015. map.physics.fixtures[a8k[89]].de = binaryReader.readDouble();
  1016. if (map.physics.fixtures[a8k[89]].de == Number.MAX_VALUE) {
  1017. map.physics.fixtures[a8k[89]].de = null;
  1018. }
  1019. map.physics.fixtures[a8k[89]].f = binaryReader.readUint();
  1020. map.physics.fixtures[a8k[89]].d = binaryReader.readBoolean();
  1021. map.physics.fixtures[a8k[89]].np = binaryReader.readBoolean();
  1022. if (map.v >= 11) {
  1023. map.physics.fixtures[a8k[89]].ng = binaryReader.readBoolean();
  1024. }
  1025. if (map.v >= 12) {
  1026. map.physics.fixtures[a8k[89]].ig = binaryReader.readBoolean();
  1027. }
  1028. }
  1029. a8k[41] = binaryReader.readShort();
  1030. for (a8k[20] = 0; a8k[20] < a8k[41]; a8k[20]++) {
  1031. map.physics.bodies[a8k[20]] = {"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};
  1032. map.physics.bodies[a8k[20]].type = binaryReader.readUTF();
  1033. map.physics.bodies[a8k[20]].n = binaryReader.readUTF();
  1034. map.physics.bodies[a8k[20]].p = [binaryReader.readDouble(), binaryReader.readDouble()];
  1035. map.physics.bodies[a8k[20]].a = binaryReader.readDouble();
  1036. map.physics.bodies[a8k[20]].fric = binaryReader.readDouble();
  1037. map.physics.bodies[a8k[20]].fricp = binaryReader.readBoolean();
  1038. map.physics.bodies[a8k[20]].re = binaryReader.readDouble();
  1039. map.physics.bodies[a8k[20]].de = binaryReader.readDouble();
  1040. map.physics.bodies[a8k[20]].lv = [binaryReader.readDouble(), binaryReader.readDouble()];
  1041. map.physics.bodies[a8k[20]].av = binaryReader.readDouble();
  1042. map.physics.bodies[a8k[20]].ld = binaryReader.readDouble();
  1043. map.physics.bodies[a8k[20]].ad = binaryReader.readDouble();
  1044. map.physics.bodies[a8k[20]].fr = binaryReader.readBoolean();
  1045. map.physics.bodies[a8k[20]].bu = binaryReader.readBoolean();
  1046. map.physics.bodies[a8k[20]].cf.x = binaryReader.readDouble();
  1047. map.physics.bodies[a8k[20]].cf.y = binaryReader.readDouble();
  1048. map.physics.bodies[a8k[20]].cf.ct = binaryReader.readDouble();
  1049. map.physics.bodies[a8k[20]].cf.w = binaryReader.readBoolean();
  1050. map.physics.bodies[a8k[20]].f_c = binaryReader.readShort();
  1051. map.physics.bodies[a8k[20]].f_1 = binaryReader.readBoolean();
  1052. map.physics.bodies[a8k[20]].f_2 = binaryReader.readBoolean();
  1053. map.physics.bodies[a8k[20]].f_3 = binaryReader.readBoolean();
  1054. map.physics.bodies[a8k[20]].f_4 = binaryReader.readBoolean();
  1055. if (map.v >= 2) {
  1056. map.physics.bodies[a8k[20]].f_p = binaryReader.readBoolean();
  1057. }
  1058. a8k[50] = binaryReader.readShort();
  1059. for (a8k[66] = 0; a8k[66] < a8k[50]; a8k[66]++) {
  1060. map.physics.bodies[a8k[20]].fx.push(binaryReader.readShort());
  1061. }
  1062. }
  1063. a8k[48] = binaryReader.readShort();
  1064. for (a8k[36] = 0; a8k[36] < a8k[48]; a8k[36]++) {
  1065. map.spawns[a8k[36]] = {"x":400,"y":300,"xv":0,"yv":0,"priority":5,"r":true,"f":true,"b":true,"gr":false,"ye":false,"n":"Spawn"};
  1066. a8k[80] = map.spawns[a8k[36]];
  1067. a8k[80].x = binaryReader.readDouble();
  1068. a8k[80].y = binaryReader.readDouble();
  1069. a8k[80].xv = binaryReader.readDouble();
  1070. a8k[80].yv = binaryReader.readDouble();
  1071. a8k[80].priority = binaryReader.readShort();
  1072. a8k[80].r = binaryReader.readBoolean();
  1073. a8k[80].f = binaryReader.readBoolean();
  1074. a8k[80].b = binaryReader.readBoolean();
  1075. a8k[80].gr = binaryReader.readBoolean();
  1076. a8k[80].ye = binaryReader.readBoolean();
  1077. a8k[80].n = binaryReader.readUTF();
  1078. }
  1079. a8k[40] = binaryReader.readShort();
  1080. for (a8k[18] = 0; a8k[18] < a8k[40]; a8k[18]++) {
  1081. map.capZones[a8k[18]] = {"n":"Cap Zone","ty":1,"l":10,"i":-1};
  1082. map.capZones[a8k[18]].n = binaryReader.readUTF();
  1083. map.capZones[a8k[18]].l = binaryReader.readDouble();
  1084. map.capZones[a8k[18]].i = binaryReader.readShort();
  1085. if (map.v >= 6) {
  1086. map.capZones[a8k[18]].ty = binaryReader.readShort();
  1087. }
  1088. }
  1089. a8k[39] = binaryReader.readShort();
  1090. for (a8k[94] = 0; a8k[94] < a8k[39]; a8k[94]++) {
  1091. a8k[75] = binaryReader.readShort();
  1092. if (a8k[75] == 1) {
  1093. map.physics.joints[a8k[94]] = {"type":"rv","d":{"la":0,"ua":0,"mmt":0,"ms":0,"el":false,"em":false,"cc":false,"bf":0,"dl":true},"aa":[0,0]};
  1094. a8k[53] = map.physics.joints[a8k[94]];
  1095. a8k[53].d.la = binaryReader.readDouble();
  1096. a8k[53].d.ua = binaryReader.readDouble();
  1097. a8k[53].d.mmt = binaryReader.readDouble();
  1098. a8k[53].d.ms = binaryReader.readDouble();
  1099. a8k[53].d.el = binaryReader.readBoolean();
  1100. a8k[53].d.em = binaryReader.readBoolean();
  1101. a8k[53].aa = [binaryReader.readDouble(), binaryReader.readDouble()];
  1102. }
  1103. if (a8k[75] == 2) {
  1104. map.physics.joints[a8k[94]] = {"type":"d","d":{"fh":0,"dr":0,"cc":false,"bf":0,"dl":true},"aa":[0,0],"ab":[0,0]};
  1105. a8k[27] = map.physics.joints[a8k[94]];
  1106. a8k[27].d.fh = binaryReader.readDouble();
  1107. a8k[27].d.dr = binaryReader.readDouble();
  1108. a8k[27].aa = [binaryReader.readDouble(), binaryReader.readDouble()];
  1109. a8k[27].ab = [binaryReader.readDouble(), binaryReader.readDouble()];
  1110. }
  1111. if (a8k[75] == 3) {
  1112. map.physics.joints[a8k[94]] = {"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};
  1113. a8k[23] = map.physics.joints[a8k[94]];
  1114. a8k[23].pax = binaryReader.readDouble();
  1115. a8k[23].pay = binaryReader.readDouble();
  1116. a8k[23].pa = binaryReader.readDouble();
  1117. a8k[23].pf = binaryReader.readDouble();
  1118. a8k[23].pl = binaryReader.readDouble();
  1119. a8k[23].pu = binaryReader.readDouble();
  1120. a8k[23].plen = binaryReader.readDouble();
  1121. a8k[23].pms = binaryReader.readDouble();
  1122. }
  1123. if (a8k[75] == 4) {
  1124. map.physics.joints[a8k[94]] = {"type":"lsj","d":{"cc":false,"bf":0,"dl":true},"sax":0,"say":0,"sf":0,"slen":0};
  1125. a8k[47] = map.physics.joints[a8k[94]];
  1126. a8k[47].sax = binaryReader.readDouble();
  1127. a8k[47].say = binaryReader.readDouble();
  1128. a8k[47].sf = binaryReader.readDouble();
  1129. a8k[47].slen = binaryReader.readDouble();
  1130. }
  1131. map.physics.joints[a8k[94]].ba = binaryReader.readShort();
  1132. map.physics.joints[a8k[94]].bb = binaryReader.readShort();
  1133. map.physics.joints[a8k[94]].d.cc = binaryReader.readBoolean();
  1134. map.physics.joints[a8k[94]].d.bf = binaryReader.readDouble();
  1135. map.physics.joints[a8k[94]].d.dl = binaryReader.readBoolean();
  1136.  
  1137. }
  1138. return map;
  1139. };
  1140.  
  1141.  
  1142. scope.updateWssLog = function(){
  1143. if(!wsslogpaused){
  1144. if(logmenutable.children.length < wsssendrecievelog.length){
  1145. var bottomscroll = logmenutable.clientHeight + logmenutable.scrollTop >= logmenutable.scrollHeight-1;
  1146. while (logmenutable.children.length>1000) {
  1147. logmenutable.removeChild(logmenutable.firstChild);
  1148. logmenutable2.removeChild(logmenutable2.firstChild);
  1149. }
  1150. var loopthro = wsssendrecievelog.slice(packetcount);
  1151. for(var i = 0; i < loopthro.length;i++){
  1152. packetcount++;
  1153. var row = document.createElement("tr");
  1154. var row2 = document.createElement("tr");
  1155.  
  1156. var cell1 = document.createElement("td");
  1157. cell1.style["overflow-x"] = "scroll";
  1158. cell1.style["padding"] = "0px";
  1159. cell1.style["width"] = "100000px";
  1160.  
  1161. var cell2 = document.createElement("td");
  1162. cell2.style["overflow-x"] = "scroll";
  1163. cell2.style["padding"] = "0px";
  1164. cell2.style["width"] = "100000px";
  1165. if(debuggercount){
  1166. cell1.style["background"] = "rgb(178, 185, 189)";
  1167. debuggercount = false;
  1168. }
  1169. else{
  1170. cell2.style["background"] = "rgb(178, 185, 189)";
  1171. debuggercount = true;
  1172. }
  1173. cell1.textContent = loopthro[i][1];
  1174. cell2.textContent = loopthro[i][1];
  1175. if(loopthro[i][0] == 0){
  1176. cell2.style["color"] = "transparent";
  1177. cell1.onclick = function(){debuggerinput.value = this.textContent};
  1178. }
  1179. else{
  1180. cell1.style["color"] = "transparent";
  1181. cell2.onclick = function(){debuggerinput.value = this.textContent};
  1182. }
  1183. row.appendChild(cell1);
  1184. row2.appendChild(cell2);
  1185. logmenutable.appendChild(row);
  1186. logmenutable2.appendChild(row2);
  1187. }
  1188. while (logmenutable.children.length>1000) {
  1189. logmenutable.removeChild(logmenutable.firstChild);
  1190. logmenutable2.removeChild(logmenutable2.firstChild);
  1191. }
  1192. if(bottomscroll){
  1193. logmenutable.scrollTop = logmenutable.scrollHeight;
  1194. logmenutable2.scrollTop = logmenutable.scrollHeight;
  1195. }
  1196. }
  1197. }
  1198. };
  1199. Gdocument.getElementById("maploadwindowmapscontainer").appendChild = function(args){
  1200.  
  1201. var checkbox = Gdocument.createElement("input");
  1202. checkbox.type = "checkbox";
  1203. checkbox.style["position"]="absolute";
  1204. checkbox.style["margin-top"] = "135px";
  1205. checkbox.style["margin-left"] = "140px";
  1206. checkbox.style["scale"] = "2";
  1207. checkbox.style["display"] = "none";
  1208. checkbox.className = "quickplaycheckbox quickplayunchecked";
  1209. if(ishost && stopquickplay==0){
  1210. checkbox.style["display"] = "block";
  1211. checkbox.className = "quickplaycheckbox quickplaychecked";
  1212. }
  1213. checkbox.checked = true;
  1214. checkbox.onclick = function(e){e.stopPropagation();};
  1215. args.appendChild(checkbox);
  1216. originalMapLoad.call(this,args);
  1217. };
  1218. Gdocument.getElementById("newbonklobby_chat_content").appendChild = function(args){
  1219. if(beenKickedTimeStamp+100>Date.now() && args.children.length>0){
  1220. if(args.children[0].textContent.endsWith(" has left the game ") && args.children[0].textContent.startsWith("* ")){
  1221. var kickedorbanned = "banned";
  1222. if(onlykicked){
  1223. kickedorbanned = "kicked";
  1224. }
  1225. args.children[0].textContent = args.children[0].textContent.substring(0,args.children[0].textContent.length-19)+" has been "+kickedorbanned+" from the game ";
  1226. }
  1227. }
  1228. originalLobbyChat.call(this,args);
  1229. };
  1230. Gdocument.getElementById("ingamechatcontent").appendChild = function(args){
  1231. if(beenKickedTimeStamp+100>Date.now() && args.children.length>0){
  1232. if(args.children[0].textContent.endsWith(" has left the game.") && args.children[0].textContent.startsWith("* ")){
  1233. var kickedorbanned = "banned";
  1234. if(onlykicked){
  1235. kickedorbanned = "kicked";
  1236. }
  1237. args.children[0].textContent = args.children[0].textContent.substring(0,args.children[0].textContent.length-19)+" has been "+kickedorbanned+" from the game.";
  1238. }
  1239. }
  1240. if(recordedTimeStamp+100>Date.now() && args.children.length>0){
  1241. if(args.children[0].textContent.includes("seconds") && args.children[0].textContent.startsWith("* ")){
  1242. args.children[0].textContent = args.children[0].textContent + " - " + playerids[recordedId].userName;
  1243. }
  1244. }
  1245. originalIngameChat.call(this,args);
  1246. };
  1247. Gwindow.XMLHttpRequest.prototype.open = function(_, url) {
  1248. if (url.includes("scripts/map_get") || url.includes("scripts/map_b1_get") || url.includes("scripts/hotmaps/")) {
  1249. this.isSearchMap = true;
  1250. }
  1251. originalXMLOpen.call(this, ...arguments);
  1252. };
  1253. Gwindow.XMLHttpRequest.prototype.send = function(data) {
  1254. if (this.isSearchMap) {
  1255. this.onreadystatechange = function () {
  1256. if (this.readyState == 4 && searchrequested && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS") {
  1257. searchrequested = false;
  1258. var jsonargs = {r:"success",maps:[],more:true};
  1259. for(var i = 0; i<requestedmaps.length; i++){
  1260. var dec = requestedmaps[i][0];
  1261. var undec = requestedmaps[i][1];
  1262. var map = {};
  1263. map.id = dec["m"]["dbid"];
  1264. map.name = dec["m"]["n"];
  1265. map.authorname = dec["m"]["a"];
  1266. map.leveldata = undec;
  1267. map.publisheddate = dec["m"]["date"];
  1268. map.remixauthor = dec["m"]["rxa"];
  1269. map.remixdb = dec["m"]["rxdb"];
  1270. map.remixid = dec["m"]["rxid"];
  1271. map.remixname = dec["m"]["rxn"];
  1272. map.vd = dec["m"]["vd"];
  1273. map.vu = dec["m"]["vu"];
  1274. jsonargs.maps.push(map);
  1275. }
  1276. jsonargs2 = JSON.stringify(jsonargs);
  1277. function stringifyjsonargs(){
  1278. return jsonargs2;
  1279. }
  1280. this.__defineGetter__("responseText", stringifyjsonargs);
  1281. this.__defineGetter__("response", stringifyjsonargs);
  1282. }
  1283. }
  1284. }
  1285. originalXMLSend.call(this, ...arguments);
  1286. };
  1287. scope.STB = function(x){
  1288. if(x == "0"){
  1289. return 0;
  1290. }
  1291. else{
  1292. return 1;
  1293. }
  1294. };
  1295. scope.BTS = function(x){
  1296. if(x == 0){
  1297. return "0";
  1298. }
  1299. else{
  1300. return "1";
  1301. }
  1302. };
  1303. scope.GET_KEYS = function(x){
  1304. var x2 = ((x+64)>>>0).toString(2).substring(1).split("");
  1305. 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])}
  1306. };
  1307. scope.MAKE_KEYS = function(x){
  1308. return x.special*32+x.heavy*16+x.down*8+x.up*4+x.right*2+x.left
  1309. };
  1310.  
  1311. Gwindow.PIXI.Graphics.prototype.drawCircle = function(...args){
  1312. if(this.parent){
  1313. var This = this;
  1314. setTimeout(function(){
  1315. if(This.parent){
  1316. var childs = This.parent.children;
  1317. var user = 0;
  1318. for(var i = 0;i<childs.length;i++){
  1319. if(childs[i]._text){
  1320. user = childs[i]._text;
  1321. }
  1322. }
  1323. var keys = Object.keys(playerids);
  1324. for(var i = 0;i<keys.length;i++){
  1325. if(playerids[keys[i]].userName == user){
  1326. playerids[keys[i]].playerData = This.parent;
  1327. playerids[keys[i]].playerData2 = {"alive":true};
  1328. }
  1329. }
  1330. }
  1331. },0);
  1332. };
  1333. return originalDrawCircle.call(this,...args);
  1334. };
  1335. scope.SENDFUNCTION = function(args){return args;};
  1336. scope.RECIEVEFUNCTION = function(args){return args;};
  1337. Gwindow.WebSocket.prototype.send = function(args) {
  1338. if(this.url.includes(".bonk.io/socket.io/?EIO=3&transport=websocket&sid=")){
  1339. bonkwss = this;
  1340. if(typeof(args) == "string"){
  1341. args = SENDFUNCTION(args);
  1342. wsssendlog.push(args);
  1343. wsssendrecievelog.push([0,args]);
  1344. if(args.startsWith('42[26,')){
  1345. if(sandboxon){
  1346. var jsonargs = JSON.parse(args.substring(2))[1];
  1347. if(typeof(sandboxplayerids[jsonargs["targetID"]])!='undefined'){
  1348. RECIEVE('42[18,'+jsonargs["targetID"]+','+jsonargs["targetTeam"]+']');
  1349.  
  1350. }
  1351. }
  1352. }
  1353. if(args.startsWith('42[1,')){
  1354. return;
  1355. }
  1356.  
  1357. if(args.startsWith('42[4,')){
  1358. var jsonargs = JSON.parse(args.substring(2));
  1359. if(sandboxcopyme && typeof(jsonargs[1]["i"])!="undefined"){
  1360. var jsonkeys = Object.keys(sandboxplayerids);
  1361. for(var i = 0; i<jsonkeys.length;i++){
  1362. RECIEVE('42[7,'+jsonkeys[i].toString()+','+JSON.stringify(jsonargs[1])+']');
  1363. }
  1364. }
  1365. playerids[myid].lastmove = Date.now();
  1366. if(ishost && typeof(jsonargs[1]["i"])!="undefined"){
  1367. for(var i = 0;i<disabledkeys.length;i++){
  1368. if(GET_KEYS(jsonargs[1]["i"])[disabledkeys[i]]){
  1369. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden" && !killedids.includes(myid)){
  1370. killedids.push(myid);
  1371. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  1372. SEND('42[25,{"a":{"playersLeft":['+myid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  1373. RECIEVE('42[31,{"a":{"playersLeft":['+myid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  1374. break;
  1375. }
  1376. }
  1377. }
  1378. }
  1379. args = "42"+JSON.stringify(jsonargs);
  1380. }
  1381. if(args.startsWith('42[12,')){
  1382. var jsonargs = JSON.parse(args.substring(2))[1];
  1383. 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"],ratelimit:{"pm":0,"mode":0,"team":0}};
  1384. if(myid==-1){
  1385. myid = 0;
  1386. }
  1387. hostid = 0;
  1388. }
  1389. if(args.startsWith('42[23,') && recteams){
  1390. var jsonargs = JSON.parse(args.substring(2));
  1391. var map = decodeFromDatabase(jsonargs[1]["m"]);
  1392. var spawns = map["spawns"];
  1393. var teamsneeded = true;
  1394. var excludedindexes = [];
  1395. var ffaspawns = false;
  1396. var ffaforsure = false;
  1397. for(var i = 0; i<spawns.length;i++){
  1398. var currentSpawn = spawns[i];
  1399. if(Math.sqrt(currentSpawn.x**2 + currentSpawn.y**2)>=850 || currentSpawn.y>250){
  1400. excludedindexes.push(i);
  1401. }
  1402. else if(!(currentSpawn.f || currentSpawn.r || currentSpawn.b || currentSpawn.gr || currentSpawn.ye)){
  1403. excludedindexes.push(i);
  1404. }
  1405. else if(currentSpawn.f){
  1406. ffaspawns = true;
  1407. if(!(currentSpawn.r || currentSpawn.b || currentSpawn.gr || currentSpawn.ye)){
  1408. excludedindexes.push(i);
  1409. ffaforsure = true
  1410. }
  1411. }
  1412. }
  1413. if(!ffaspawns && !ffaforsure){
  1414. teamsneeded = true;
  1415. }
  1416. else{
  1417. teamsneeded = false;
  1418. }
  1419. if(teamsneeded){
  1420. var newspawns = [];
  1421. for(var i = 0; i<spawns.length;i++){
  1422. if(!excludedindexes.includes(i)){
  1423. 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"]});
  1424. }
  1425. }
  1426. if(newspawns.length>0){
  1427. var teamletters = ["r","g","b","y"];
  1428. var ratios = {"r":0,"g":0,"b":0,"y":0};
  1429. for(var i = 0; i < newspawns.length;i++){
  1430. for(var i2 = 0; i2<teamletters.length;i2++){
  1431. var ct = teamletters[i2];
  1432. if(newspawns[i]["priority"]!=0){
  1433. ratios[ct]+=(newspawns[i][ct])/newspawns[i]["total"]*newspawns[i]["priority"];
  1434. }
  1435. }
  1436. }
  1437. var highest = ["",0];
  1438. for(var i = 0; i<teamletters.length;i++){
  1439. var ct = teamletters[i];
  1440. if(ratios[ct]>0 && highest[1]<ratios[ct]){
  1441. highest = [ct,ratios[ct]];
  1442. }
  1443. }
  1444. if(highest[0]!=""){
  1445. for(var i = 0; i<teamletters.length;i++){
  1446. var ct = teamletters[i];
  1447. ratios[ct] = ratios[ct]/highest[1];
  1448. }
  1449. }
  1450. var playerids3 = Object.keys(playerids);
  1451. var playerids2 = [];
  1452. for(var i = 0; i<playerids3.length;i++){
  1453. if(playerids[playerids3[i]].team>0){
  1454. playerids2.push(playerids3[i]);
  1455. }
  1456. }
  1457. var pi2l = playerids2.length;
  1458. var ratios2 = {"r":0,"r1":0,"g":0,"g1":0,"b":0,"b1":0,"y":0,"y1":0};
  1459. var items = Object.entries(ratios);
  1460. items.sort(function(a,b){return a[1]-b[1];});
  1461. var items = items.map(function(e){return e[0];});
  1462. var highest2 = ["",0];
  1463. while(pi2l>0){
  1464. var done = false;
  1465. for(var i2 = 0; i2<items.length;i2++){
  1466. var ci = items[i2];
  1467. var ci2 = items[i2]+"1";
  1468. for(var i = 0; i<teamletters.length;i++){
  1469. var ct = teamletters[i];
  1470. if(ratios2[ct]>0 && highest2[1]<ratios2[ct]){
  1471. highest2 = [ct,ratios2[ct]];
  1472. }
  1473. }
  1474. if(highest2[0]!=""){
  1475. for(var i = 0; i<teamletters.length;i++){
  1476. var ct = teamletters[i];
  1477. ratios2[ct+"1"] = ratios2[ct]/highest2[1];
  1478. }
  1479. }
  1480. if(ratios[ci]>0 && ratios[ci]>=ratios2[ci2] && pi2l>0){
  1481. ratios2[ci]+=1;
  1482. pi2l--;
  1483. done = true;
  1484. }
  1485. }
  1486. if(pi2l>0 && !done){
  1487. ratios2[highest2[0]]+=1;
  1488. pi2l--;
  1489. }
  1490. }
  1491. SEND('42[32,{"t":true}]');
  1492. RECIEVE('42[39,true]');
  1493. for(var i = 0; i<ratios2["r"];i++){
  1494. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  1495. SEND('42[26,{"targetID":'+pid+',"targetTeam":2}]');
  1496. RECIEVE('42[18,'+pid+',2]');
  1497. }
  1498. for(var i = 0; i<ratios2["g"];i++){
  1499. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  1500. SEND('42[26,{"targetID":'+pid+',"targetTeam":4}]');
  1501. RECIEVE('42[18,'+pid+',4]');
  1502. }
  1503. for(var i = 0; i<ratios2["b"];i++){
  1504. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  1505. SEND('42[26,{"targetID":'+pid+',"targetTeam":3}]');
  1506. RECIEVE('42[18,'+pid+',3]');
  1507. }
  1508. for(var i = 0; i<ratios2["y"];i++){
  1509. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  1510. SEND('42[26,{"targetID":'+pid+',"targetTeam":5}]');
  1511. RECIEVE('42[18,'+pid+',5]');
  1512. }
  1513. }
  1514. }
  1515. else{
  1516. SEND('42[32,{"t":false}]');
  1517. RECIEVE('42[39,false]');
  1518. }
  1519. }
  1520.  
  1521. if(args.startsWith('42[47,') && stopquickplay == 0 && ishost && document.hidden){
  1522. roundsperqp2++;
  1523. if(roundsperqp2>=roundsperqp){
  1524. if(shuffle){
  1525. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  1526. var available = [];
  1527. var availableindexes = [];
  1528. var notempty = false;
  1529. for(var i = 0; i<e2.length;i++){
  1530. var a = false;
  1531. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  1532. available.push(a);
  1533. if(a){
  1534. availableindexes.push(i);
  1535. notempty = true;
  1536. }
  1537. }
  1538. if(notempty){
  1539.  
  1540. if(availableindexes.length!=1){
  1541. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  1542. }
  1543. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  1544. }
  1545. }
  1546. else{
  1547. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  1548. var available = [];
  1549. var availableindexes = [];
  1550. var notempty = false;
  1551. for(var i = 0; i<e2.length;i++){
  1552. var a = false;
  1553. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  1554. available.push(a);
  1555. if(a){
  1556. availableindexes.push(i);
  1557. notempty = true;
  1558. }
  1559. }
  1560. if(notempty){
  1561. var above = [];
  1562. for(var i = 0;i<availableindexes.length;i++){
  1563. if(availableindexes[i]>quicki){
  1564. above.push(availableindexes[i]);
  1565. }
  1566. }
  1567. if(above.length>0){
  1568. quicki = above[0];
  1569. }
  1570. else{
  1571. quicki = availableindexes[0];
  1572. }
  1573. }
  1574. }
  1575. }
  1576. canceled = false;
  1577. startedinqp = true;
  1578. window.map(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length),0);
  1579. }
  1580.  
  1581. if(args.startsWith('42[5,')){
  1582. var jsonargs = JSON.parse(args.substring(2));
  1583. if(stopquickplay!=1 && startedinqp){
  1584. startedinqp = false;
  1585. jsonargs[1]["gs"]["wl"] = 999;
  1586. if(!instaqp){
  1587. var jsonargs2 = decodeIS(jsonargs[1]["is"]);
  1588. jsonargs2["ftu"] = 60;
  1589. if(jsonargs2["mm"]["rxa"] != ""){
  1590. jsonargs2["mm"]["a"] = jsonargs2["mm"]["rxa"];
  1591. jsonargs2["mm"]["n"] = jsonargs2["mm"]["rxn"];
  1592. }
  1593. jsonargs2 = encodeIS(jsonargs2);
  1594. jsonargs[1]["is"] = jsonargs2;
  1595. var jsonargs3 = decodeFromDatabase(jsonargs[1]["gs"]["map"]);
  1596. if(jsonargs3["m"]["rxa"] != ""){
  1597. jsonargs3["m"]["a"] = jsonargs3["m"]["rxa"];
  1598. jsonargs3["m"]["n"] = jsonargs3["m"]["rxn"];
  1599. }
  1600.  
  1601. jsonargs3 = encodeToDatabase(jsonargs3);
  1602. jsonargs[1]["gs"]["map"] = jsonargs3;
  1603. }
  1604. }
  1605.  
  1606. args = "42"+JSON.stringify(jsonargs);
  1607. }
  1608. }
  1609.  
  1610. }
  1611. else{
  1612. this.onmessage = function(args){return;};
  1613. return;
  1614.  
  1615. }
  1616. if(this.url.includes(".bonk.io/socket.io/?EIO=3&transport=websocket&sid=") && !this.injected){
  1617. this.injected = true;
  1618.  
  1619. var originalRecieve = this.onmessage;
  1620. this.onmessage = function(args){
  1621. wssrecievelog.push(args.data);
  1622. wsssendrecievelog.push([1,args.data]);
  1623. if(typeof(args.data)=="string"){
  1624. args.data = RECIEVEFUNCTION(args.data);
  1625. if(args.data.startsWith('42[1,')){
  1626. var jsonargs = JSON.parse(args.data.substring(2));
  1627. originalSend.call(this,'42[1,{"id":'+jsonargs[2]+'}]');
  1628. }
  1629. if(args.data.startsWith('42[24,')){
  1630. beenKickedTimeStamp = Date.now();
  1631. onlykicked = JSON.parse(args.data.substring(2))[2];
  1632. }
  1633. if(args.data.startsWith('42[6,')){
  1634. var jsonargs = JSON.parse(args.data.substring(2));
  1635. if(typeof(playerids[jsonargs[1]])!='undefined'){
  1636. delplayerids[jsonargs[1]] = playerids[jsonargs[1]];
  1637. delete playerids[jsonargs[1]];
  1638. }
  1639. hostid = jsonargs[2];
  1640. }
  1641. if(args.data.startsWith('42[41,')){
  1642. var jsonargs = JSON.parse(args.data.substring(2));
  1643. hostid = jsonargs[1]["newHost"];
  1644. }
  1645. if(args.data.startsWith('42[20,')){
  1646. var jsonargs = JSON.parse(args.data.substring(2));
  1647. if(echo_list.includes(playerids[jsonargs[1]].userName)){
  1648. chat(flag_manage(echotext.replaceAll("username",playerids[jsonargs[1]].userName).replaceAll("message",jsonargs[2])));
  1649. }
  1650. }
  1651. if(args.data.startsWith('42[32')){
  1652. SEND('42[4,{"type":"inactive kick counter"}]');
  1653. }
  1654. if(args.data.startsWith('42[18')){
  1655. var jsonargs = JSON.parse(args.data.substring(2));
  1656. playerids[jsonargs[1]].team = jsonargs[2];
  1657. }
  1658. if(args.data.startsWith('42[40,')){
  1659. recordedTimeStamp = Date.now();
  1660. recordedId = JSON.parse(args.data.substring(2))[1];
  1661. }
  1662. if(args.data.startsWith('42[3,')){
  1663. var jsonargs = JSON.parse(args.data.substring(2));
  1664. for(var i = 0; i<jsonargs[3].length;i++){
  1665. if(jsonargs[3][i]!=null){
  1666. playerids[i.toString()] = jsonargs[3][i];
  1667. playerids[i.toString()].ratelimit = {"pm":0,"mode":0,"team":0};
  1668. }
  1669. }
  1670. if(myid==-1){
  1671. myid = jsonargs[1];
  1672. }
  1673. hostid = jsonargs[2];
  1674. }
  1675. if(args.data.startsWith('42[15,')){
  1676. var jsonargs = JSON.parse(args.data.substring(2));
  1677. gameStartTimeStamp = jsonargs[1];
  1678. killedids = [];
  1679. }
  1680. if(args.data.startsWith('42[33,')){
  1681. var jsonargs = JSON.parse(args.data.substring(2));
  1682. var decodedmap = decodeFromDatabase(jsonargs[1]);
  1683. if(decodedmap!=0){
  1684. requestedmaps.push([decodedmap,jsonargs[1]]);
  1685. }
  1686. }
  1687. if(args.data.startsWith('42[7,')){
  1688. var jsonargs2 = JSON.parse(args.data.substring(2));
  1689. var idofpacket = jsonargs2[1];
  1690. jsonargs = jsonargs2[2];
  1691. if(typeof(jsonargs["i"]) == "undefined"){
  1692. if(jsonargs["type"]=="private chat" && jsonargs["to"] == username){
  1693. from = jsonargs["from"];
  1694. if(Object.keys(playerids).includes(idofpacket.toString())){
  1695. from = playerids[idofpacket].userName;
  1696. }
  1697. if(!ignorepmlist.includes(from)){
  1698. if(typeof(jsonargs["message"])=="object" && typeof(jsonargs["password"]) == "object"){
  1699. if(public_key[0]==jsonargs["public key"][0] && public_key[1]==jsonargs["public key"][1]){
  1700. var now = Date.now();
  1701. if(jsonargs["password"].length<=25 && playerids[idofpacket].ratelimit.pm+250<now){
  1702. playerids[idofpacket].ratelimit.pm = now;
  1703. var password = CRYPT_MESSAGE(private_key,jsonargs["password"]);
  1704. var decodedtext = jsonargs["message"].slice(0,400);
  1705. var encodedtext = "";
  1706. for(var i=0;i<decodedtext.length;i++){
  1707. if(password[i%password.length]<1000){
  1708. encodedtext+=String.fromCharCode(password[i%password.length]^decodedtext[i]);
  1709. }
  1710. }
  1711. 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);';
  1712. displayInChat('> '+'<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+from+'</a>'+': ',"#DA0808","#1EBCC1",{sanitize:false},encodedtext);
  1713.  
  1714. Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true;
  1715. Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true;
  1716. Laster_message = lastmessage();
  1717. }
  1718. }
  1719. else{
  1720. SEND("42"+JSON.stringify([4,{"type":"public key correction","from":username,"to":private_chat_public_key[0],"public key":public_key}]));
  1721. }
  1722. }
  1723. }
  1724. }
  1725. if(jsonargs["type"]=="request public key" && jsonargs["to"] == username){
  1726. SEND("42"+JSON.stringify([4,{"type":"public key","from":username,"public key":public_key}]));
  1727. }
  1728. if(jsonargs["type"]=="private chat users" && pmuserstimestamp+1500>Date.now()){
  1729. if(typeof(jsonargs["from"])!='undefined'){
  1730. from = jsonargs["from"];
  1731. if(Object.keys(playerids).includes(idofpacket.toString())){
  1732. from = playerids[idofpacket].userName;
  1733. }
  1734. if(!pmusers.includes(from) && username == jsonargs["to"]){
  1735. pmusers.push(from);
  1736. }
  1737. }
  1738. }
  1739. if(jsonargs["type"]=="request private chat users"){
  1740. if(typeof(jsonargs["from"])!='undefined'){
  1741. from = jsonargs["from"];
  1742. if(Object.keys(playerids).includes(idofpacket.toString())){
  1743. from = playerids[idofpacket].userName;
  1744. }
  1745. SEND("42"+JSON.stringify([4,{"type":"private chat users","from":username,"to":from}]));
  1746. }
  1747. }
  1748. if(jsonargs["type"]=="public key" && request_public_key_time_stamp+1500>Date.now()){
  1749. from = jsonargs["from"];
  1750. if(Object.keys(playerids).includes(idofpacket.toString())){
  1751. from = playerids[idofpacket].userName;
  1752. }
  1753. if(from == private_chat){
  1754. private_chat_public_key = [private_chat,jsonargs["public key"]];
  1755. displayInChat("Private chatting with "+private_chat+".","#DA0808","#1EBCC1");
  1756. }
  1757.  
  1758. }
  1759. if(jsonargs["type"]=="request mode" && playerids[idofpacket].ratelimit.mode+1000<Date.now()){
  1760. playerids[idofpacket].ratelimit.mode = Date.now();
  1761. from = jsonargs["from"];
  1762. if(Object.keys(playerids).includes(idofpacket.toString())){
  1763. from = playerids[idofpacket].userName;
  1764. }
  1765. var req_mode = jsonargs["mode"];
  1766. var req_mode2 = "";
  1767. if(req_mode){
  1768. if(req_mode == "b"){
  1769. req_mode2 = "Classic";
  1770. }
  1771. else if(req_mode == "sp"){
  1772. req_mode2 = "Grapple";
  1773. }
  1774. else if(req_mode == "ar"){
  1775. req_mode2 = "Arrows";
  1776. }
  1777. else if(req_mode == "ard"){
  1778. req_mode2 = "Death Arrows";
  1779. }
  1780. }
  1781. if(req_mode2){
  1782. 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+'")}';
  1783. displayInChat('> '+playerids[idofpacket].userName+' requests [<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+req_mode2+'</a>]',"#DA0808","#1EBCC1",{sanitize:false}," mode.");
  1784. }
  1785.  
  1786. }
  1787. if(jsonargs["type"]=="public key correction" && private_chat_public_key[0] == private_chat){
  1788. from = jsonargs["from"];
  1789. if(Object.keys(playerids).includes(idofpacket.toString())){
  1790. from = playerids[idofpacket].userName;
  1791. }
  1792. if(from == private_chat){
  1793. private_chat_public_key = [private_chat,jsonargs["public key"]];
  1794. var text = pmlastmessage;
  1795. var password = [];
  1796. for(var i = 0;i<10;i++){
  1797. password.push(Math.floor(Math.random()*100+50));
  1798. }
  1799. var text2 = [];
  1800. for(var i = 0;i<text.length ;i++){
  1801. text2.push(password[i%password.length]^text.slice(0,400).charCodeAt(i));
  1802. }
  1803. 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)}]));
  1804. }
  1805. }
  1806.  
  1807. }
  1808. else{
  1809. var now = Date.now();
  1810. if(playerids[idofpacket.toString()]){
  1811. playerids[idofpacket.toString()].lastmove = now;
  1812. }
  1813. if(ishost){
  1814. for(var i = 0;i<disabledkeys.length;i++){
  1815. var get_keys_var = GET_KEYS(jsonargs["i"]);
  1816. if(get_keys_var[disabledkeys[i]]){
  1817. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden" && !killedids.includes(idofpacket)){
  1818. killedids.push(idofpacket);
  1819. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  1820. SEND('42[25,{"a":{"playersLeft":['+idofpacket.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  1821. RECIEVE('42[31,{"a":{"playersLeft":['+idofpacket.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  1822. break;
  1823. }
  1824. }
  1825. }
  1826. }
  1827. }
  1828. }
  1829.  
  1830. if(args.data.startsWith('42[4,')){
  1831. var jsonargs = JSON.parse(args.data.substring(2));
  1832. if(ishost){
  1833. if(jointext!=""){
  1834. chat(flag_manage(jointext.replaceAll("username",jsonargs[3])));
  1835. }
  1836. if(freejoin){
  1837. var count = 0;
  1838. var keys = Object.keys(playerids);
  1839. for(var i = 0; i<keys.length;i++){
  1840. if(playerids[keys[i]].team!=0){
  1841. count++;
  1842. }
  1843. }
  1844. if(count <= 1 && jsonargs[6]!=0){
  1845. setTimeout(function(){
  1846. Gdocument.getElementById("newbonklobby_editorbutton").click();
  1847. Gdocument.getElementById("mapeditor_close").click();
  1848. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  1849. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  1850. if(transitioning == true){
  1851. canceled = true;
  1852. }
  1853. },0);
  1854. }
  1855. }
  1856. }
  1857. playerids[jsonargs[1]] = {"peerID":jsonargs[2],"userName":jsonargs[3],"guest":jsonargs[4],"level":jsonargs[5],"team":jsonargs[6],"avatar":jsonargs[7],"ratelimit":{"pm":0,"mode":0,"team":0}};
  1858.  
  1859. }
  1860. if(args.data.startsWith('42[5,')){
  1861. var jsonargs = JSON.parse(args.data.substring(2));
  1862. if(typeof(playerids[jsonargs[1]])!='undefined'){
  1863. delplayerids[jsonargs[1]] = playerids[jsonargs[1]];
  1864. delete playerids[jsonargs[1]];
  1865. }
  1866. }
  1867. }
  1868. return originalRecieve.call(this,args);
  1869. };
  1870.  
  1871. var originalClose = this.onclose;
  1872. this.onclose = function () {
  1873. window.bonkwss = 0;
  1874. return originalClose.call(this);
  1875. }
  1876.  
  1877. }
  1878. return originalSend.call(this,args);
  1879. };
  1880.  
  1881. scope.SEND = function(args){
  1882. if(bonkwss!=0){
  1883. bonkwss.send(args);
  1884. }
  1885. };
  1886. scope.RECIEVE = function(args){
  1887. if(bonkwss!=0){
  1888. bonkwss.onmessage({data:args});
  1889. }
  1890. };
  1891.  
  1892.  
  1893.  
  1894. scope.dontswitch = false;
  1895. scope.username = 0;
  1896. scope.timedelay = 1400;
  1897. scope.ishost = false;
  1898. scope.checkboxhidden = true;
  1899. scope.quicki=0;
  1900. scope.defaultmode = "d";
  1901. scope.recmodebool = false;
  1902. scope.shuffle = false;
  1903. scope.startedinqp = false;
  1904. scope.instaqp = false;
  1905. scope.freejoin = false;
  1906. scope.recordedTimeStamp = 0;
  1907. scope.recordedId = 0;
  1908. scope.smartteams = false;
  1909. scope.beenKickedTimeStamp = 0;
  1910. scope.stopquickplay = 1;
  1911. scope.currentFrame = 0;
  1912. scope.text2speech = false;
  1913. scope.gameStartTimeStamp = 0;
  1914. scope.canceled = false;
  1915. scope.wintext = "";
  1916. scope.banned = [];
  1917. scope.transitioning = false;
  1918. scope.echo_list = [];
  1919. scope.echoAppend = "";
  1920. scope.message = "";
  1921. scope.mode = "";
  1922. scope.private_chat = "";
  1923. scope.private_chat_public_key = ["",[0,0]];
  1924. scope.disabledkeys = [];
  1925. scope.actuallyhost = false;
  1926. scope.pmusers = [];
  1927. scope.pmlastmessage = "";
  1928. scope.pmuserstimestamp = 0;
  1929. scope.ignorepmlist = [];
  1930. scope.scroll = false;
  1931. scope.elem = Gdocument.getElementById("maploadwindowmapscontainer");
  1932. scope.npermissions = 1;
  1933. scope.space_flag = false;
  1934. scope.rcaps_flag = false;
  1935. scope.number_flag = false;
  1936. scope.reverse_flag = false;
  1937. scope.request_public_key_time_stamp = 0;
  1938. scope.sandboxcopyme = false;
  1939. scope.recteams = false;
  1940. scope.chatheight = 128;
  1941. scope.onlykicked = false;
  1942. scope.killedids = [];
  1943. scope.jointext = "";
  1944. scope.afkkill = -1;
  1945. scope.tournament_mode = "";
  1946. scope.tournament_scores = [];
  1947. scope.tournament_in_and_out = {"in":[],"out":[]};
  1948. scope.echotext = "message";
  1949. scope.nextafter = 0;
  1950. scope.roundsperqp = 1;
  1951. scope.roundsperqp2 = 0;
  1952. scope.autorecord = false;
  1953. scope.help = ["All the commands are:","/help","/?","/advhelp [command]","/space","/rcaps","/number","/speech","/echo [username]","/clearecho","/remove [username]","/echotext [text]","/chatw [username]","/msg [text]","/ignorepm [username]","/pmusers","/lobby","/team [letter]","/mode [mode]","/scroll","/hidechat","/showchat","/notify","/stopnotify","Host commands are:","/startqp","/stopqp","/next","/nextafter [seconds]","/previous","/shuffle","/instaqp","/freejoin","/recmode","/recteam","/defaultmode [mode]","/start","/balanceA [number]","/moveA [letter]","/rounds [number]","/roundsperqp [number]","/disablekeys [keys]","/jointext [text]","/wintext [text]","/autorecord","/afkkill [number]","/ban [username]","/kill [username]","Sandbox commands are:","/addplayer [number]","/delplayer [number]","/copyme","Debugging commands are:","/eval [code]","/debugger","Hotkeys are:","Alt L","Alt C","Alt I","Alt <","Alt >","Host hotkeys are:","Alt S","Alt T","Alt E","Alt K","Alt M","Alt Q","Alt A","Alt D","Alt F","Alt R"];
  1954.  
  1955. scope.adv_help = {"help":"Shows all command names.",
  1956. "?":"Shows all command names.",
  1957. "advhelp":"Shows a command in detail.",
  1958. "space":"Toggles space. When space is on, whatever you type will be spaced apart.",
  1959. "rcaps":"Toggles rcaps. When rcaps is on, each letter will randomly get capitalized.",
  1960. "number":"Toggles number. When number is on, 'a' becomes 4, 'e' becomes 3, 's' becomes 5, 'o' becomes 0, 'l' and 'i' become 1.",
  1961. "speech":"Turns on text to speech for the chat.",
  1962. "echo":"Echoes a username. It copies the username's chat messages.",
  1963. "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.",
  1964. "remove":"Removes username from echo list. You will not echo that username anymore.",
  1965. "clearecho":"Clears echo list. You will not echo anyone anymore.",
  1966. "chatw":"It private chats with username. Type /msg to message that username.",
  1967. "msg":"Messages with what username you are chatting with. Type /chatw to chat with a username.",
  1968. "ignorepm":"Ignores the username's private chat messages. To unignore, type /ignorepm [username].",
  1969. "pmusers":"Dispays who you can private chat with.",
  1970. "eval":"Evaluates code. Only use this if you are experienced in javascript.",
  1971. "debugger":"Opens debugger.",
  1972. "lobby":"Makes lobby visible when you are ingame. Type /lobby again to close lobby.",
  1973. "team":"Joins a specific team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  1974. "scroll":"Toggles a scrollbar in ingame chat.",
  1975. "hidechat":"Hides ingame chat. Type /showchat to show it again.",
  1976. "showchat":"Shows ingame chat. /hidechat hides the chat.",
  1977. "notify":"You will be notified if a person types @username",
  1978. "stopnotify":"You will not be notified if a person types @username",
  1979. "startqp":"Starts cycling maps in your map menu.",
  1980. "stopqp":"Stops cycling maps in your map menu.",
  1981. "next":"Skips the map. Usable only with /startqp.",
  1982. "nextafter":"Skips the map if no one is able to win/draw within a certain amount of time.",
  1983. "previous":"Goes to previous map. Usable only with /startqp.",
  1984. "shuffle":"Makes quickplay play random maps instead of in order.",
  1985. "freejoin":"Toggles freejoin. If freejoin is on, starts the game instantly if there are 1 or less players currently playing.",
  1986. "recmode":"In quickplay, it switches mode to recommended mode, according to editor.",
  1987. "recteam":"In quickplay, it sorts people into teams when teams are necessary.",
  1988. "defaultmode":"Switches mode to defaultmode if there is no recmode.",
  1989. "start":"Starts game instantly.",
  1990. "instaqp":"Rounds will instantly start without a countdown.",
  1991. "balanceA":"Balances everyone with balance number.",
  1992. "moveA":"Sets everyones team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  1993. "rounds":"Sets rounds to win.",
  1994. "roundsperqp":"After that many rounds, the map will change. Normally, the map will change after 1 round.",
  1995. "autorecord":"After a round ends, automatically records the last 15 seconds.",
  1996. "mode":"If host, switches mode. Otherwise, it requests the host to switch mode, as long as the host has this mod.",
  1997. "disablekeys":"If anyone presses a disabled key, they get killed. Key options: left right up down heavy special.",
  1998. "jointext":"Chats the jointext whenever someone joins. \"username\" will get replaced by the joining person's username.",
  1999. "wintext":"Chats the wintext whenever someone wins. \"username\" will get replaced by the winning person's username.",
  2000. "afkkill":"If a person stays afk for that many seconds, they get automatically killed.",
  2001. "ban":"Bans username from lobby. If they rejoin, it automatically bans.",
  2002. "kill":"Kills the person ingame.",
  2003. "addplayer":"In sandbox, it adds players.",
  2004. "delplayer":"In sandbox, it deletes players.",
  2005. "copyme":"In sandbox, it makes each player copy your movements.",
  2006. "Alt L":"Makes lobby visible when you are ingame. Press Alt L again to close lobby.",
  2007. "Alt C":"Hides ingame chat. Press Alt C again to show ingame chat.",
  2008. "Alt S":"Starts game instantly.",
  2009. "Alt T":"Toggles teams.",
  2010. "Alt E":"Toggles editor.",
  2011. "Alt K":"Exits ingame and returns to lobby.",
  2012. "Alt M":"Switches modes.",
  2013. "Alt Q":"Toggles quickplay.",
  2014. "Alt A":"Skips the map if quickplay is on.",
  2015. "Alt D":"Goes to previous map if quickplay is on.",
  2016. "Alt F":"Toggles freejoin. If freejoin is on, starts the game instantly if there are 1 or less players currently playing.",
  2017. "Alt R":"In quickplay, it switches mode to recommended mode, according to editor.",
  2018. "Alt I":"Opens debugger.",
  2019. "Alt <":"Lowers ingame chat height.",
  2020. "Alt >":"Highers ingame chat height."
  2021. };
  2022. scope.displayadvhelp = function(command){
  2023. displayInChat(adv_help[command],"#009398","#DA0808",{sanitize:true},"",true);
  2024. };
  2025. scope.changemode = function(mode){
  2026. SEND('42[20,{"ga":"b","mo":"'+mode+'"}]');
  2027. RECIEVE('42[26,"b","'+mode+'"]');
  2028. };
  2029. Gdocument.getElementById("ingamechatcontent").style["pointer-events"]="all";
  2030. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  2031. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  2032. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  2033.  
  2034. document.getElementById('adboxverticalCurse').style["display"] = "none";
  2035. document.getElementById('adboxverticalleftCurse').style["display"] = "none";
  2036. elem.onclick=function(e){
  2037. if(stopquickplay==0 && ishost == true && e.isTrusted == true){
  2038. quicki = (Array.from(e.target.parentElement.parentNode.children).indexOf(e.target.parentNode)-1)%(Gdocument.getElementById("maploadwindowmapscontainer").children.length);
  2039. }
  2040. };
  2041. scope.urlify = function(text) {
  2042. return text.replace(/(?:https?:\/\/)?(?:[A-Za-z0-9-ßàÁâãóôþüúðæåïçèõöÿýòäœêëìíøùîûñé]+)(?:\.[A-Za-z0-9-ßàÁâãóôþüúðæåïçèõöÿýòäœêëìíøùîûñé]+)+(?:\/(?:[A-Za-z0-9-._~:/?#\[\]@!$&'()*+,;=]|%[0-9a-fA-F]{2})*)?(?:\?(?:[^=]+=[^&](?:&[^=]+=[^&])*)?)?/g, function(url) {
  2043. if(url.startsWith('https://') || url.startsWith('http://')){return '<a href="' + url + '" target="_blank" style = "color:orange">' + url + '</a>';}
  2044. else{return '<a href="https://' + url + '" target="_blank" style = "color:orange">' + url + '</a>';}
  2045. })
  2046. };
  2047.  
  2048. scope.fire = function(type,options,d = Gdocument){
  2049. var event= document.createEvent("HTMLEvents");
  2050. event.initEvent(type,true,false);
  2051. for(var p in options){
  2052. event[p]=options[p];
  2053. }
  2054. d.dispatchEvent(event);
  2055. };
  2056.  
  2057. scope.chat = function(message){
  2058. mess = Gdocument.getElementById("newbonklobby_chat_input").value;
  2059. mess2 = Gdocument.getElementById("ingamechatinputtext").value;
  2060. Gdocument.getElementById("newbonklobby_chat_input").value = message;
  2061. Gdocument.getElementById("ingamechatinputtext").value = message;
  2062. fire("keydown",{keyCode:13});
  2063. fire("keydown",{keyCode:13});
  2064. Gdocument.getElementById("newbonklobby_chat_input").value = mess;
  2065. Gdocument.getElementById("ingamechatinputtext").value = mess2;
  2066. };
  2067. scope.displayInChat = function(message, LobbyColor, InGameColor, options, message2, BringDown,urlifyon = urlify) {
  2068. options = options ?? {};
  2069. BringDown = BringDown ?? false;
  2070. message2 = message2 ?? "";
  2071. urlifyon = urlifyon ?? function(e){return e};
  2072. LobbyColor = LobbyColor ?? "#8800FF";
  2073. InGameColor = InGameColor ?? "#AA88FF";
  2074. let A = Gdocument.createElement("div");
  2075. let B = Gdocument.createElement("span");
  2076. B.className = "newbonklobby_chat_status";
  2077. B.style.color = LobbyColor;
  2078. A.appendChild(B);
  2079. B.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  2080. B.innerHTML+=urlify(message2.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;'));
  2081. let C = Gdocument.createElement("div");
  2082. let D = Gdocument.createElement("span");
  2083. D.style.color = InGameColor;
  2084. C.appendChild(D);
  2085. D.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  2086. D.innerHTML+=urlify(message2.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;'));
  2087. let a = BringDown;
  2088. if(Gdocument.getElementById("newbonklobby_chat_content").clientHeight + Gdocument.getElementById("newbonklobby_chat_content").scrollTop >= Gdocument.getElementById("newbonklobby_chat_content").scrollHeight-1) {
  2089. a = true;
  2090. }
  2091. A.style["parsed"] = true;
  2092. C.style["parsed"] = true;
  2093. Gdocument.getElementById("newbonklobby_chat_content").appendChild(A);
  2094. Gdocument.getElementById("ingamechatcontent").appendChild(C);
  2095. if (a) { Gdocument.getElementById("newbonklobby_chat_content").scrollTop = Number.MAX_SAFE_INTEGER;};
  2096. Gdocument.getElementById("ingamechatcontent").scrollTop = Number.MAX_SAFE_INTEGER;
  2097. chat("");
  2098. };
  2099.  
  2100. scope.lobby = function(){
  2101. if (Gdocument.getElementById("newbonklobby").style["display"]=="none"){
  2102.  
  2103. Gdocument.getElementById("newbonklobby_editorbutton").click();
  2104. Gdocument.getElementById("mapeditor_close").click();
  2105. if(Gdocument.getElementById("newbonklobby_playerbox_elementcontainer").children.length+Gdocument.getElementById("newbonklobby_specbox_elementcontainer").children.length-3>0){
  2106. Gdocument.getElementById("newbonklobby").style["z-index"]=1;
  2107. Gdocument.getElementById("maploadwindowcontainer").style["z-index"]=1;
  2108. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=1;
  2109. Gdocument.getElementById("pretty_top").style["z-index"]=3;
  2110. Gdocument.getElementById("settingsContainer").style["z-index"]=3;
  2111. Gdocument.getElementById("leaveconfirmwindow").style["z-index"]=3;
  2112. Gdocument.getElementById("hostleaveconfirmwindow").style["z-index"]=3;
  2113. debuggermenu.style["z-index"] = 2;
  2114. }
  2115. else{
  2116. Gdocument.getElementById("newbonklobby").style["opacity"]=0;
  2117. Gdocument.getElementById("newbonklobby").style["display"]="none";
  2118. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
  2119.  
  2120. }
  2121.  
  2122. }
  2123. else if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  2124. Gdocument.getElementById("newbonklobby").style["opacity"]=0;
  2125. Gdocument.getElementById("newbonklobby").style["display"]="none";
  2126. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
  2127.  
  2128. }
  2129. };
  2130.  
  2131. scope.lastmessage = function(){
  2132. if(Gdocument.getElementById("newbonklobby_chat_content").children.length!=0){
  2133. var lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  2134. var lm2 = "";
  2135. for(var i = 0; i<lm.length;i++){
  2136. lm2+=" "+lm[i].textContent.trim();
  2137. }
  2138. lm2 = lm2.trim();
  2139. if(lm2.startsWith("*")){
  2140. return lm2;
  2141. }
  2142. }
  2143. if(Gdocument.getElementById("ingamechatcontent").children.length!=0){
  2144. var lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  2145. var lm2 = "";
  2146. for(var i = 0; i<lm.length;i++){
  2147. lm2+=" "+lm[i].textContent.trim();
  2148. }
  2149. return lm2.trim();
  2150. }
  2151. return "";
  2152.  
  2153. };
  2154. scope.map = function(e,t=timedelay){
  2155. if(e<0){
  2156. displayInChat("There is no previous map.","#DA0808","#1EBCC1");
  2157. quicki = 0;
  2158. return;
  2159. }
  2160. if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
  2161. displayInChat("Click the maps button.","#DA0808","#1EBCC1");
  2162. return;
  2163. }
  2164.  
  2165. setTimeout(function(){if(!canceled){
  2166. startedinqp = true;
  2167. if(roundsperqp2>=roundsperqp){
  2168. roundsperqp2 = 0;
  2169. }
  2170. gameStartTimeStamp = Date.now();
  2171. Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
  2172. Gdocument.getElementById("newbonklobby_editorbutton").click();
  2173. if(recmodebool && ishost){
  2174. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  2175. if(mode == "" && defaultmode!="d"){
  2176. mode = defaultmode;
  2177. }
  2178. if(mode != ""){
  2179. RECIEVE('42[26,"b","'+mode+'"]');
  2180. }
  2181. }
  2182. var displayblock = Gdocument.getElementById("newbonklobby").style["display"] == "block";
  2183. Gdocument.getElementById("mapeditorcontainer").style["display"] = "none";
  2184. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  2185. if(displayblock){
  2186. Gdocument.getElementById("newbonklobby").style["display"] = "block";
  2187. }
  2188. Gdocument.getElementById("mapeditor_midbox_testbutton").click();}
  2189. canceled = false;
  2190. transitioning = false;
  2191. },t);
  2192.  
  2193. };
  2194.  
  2195. scope.gotonextmap = function(e){
  2196. if(e<0){
  2197. displayInChat("There is no previous map.","#DA0808","#1EBCC1");
  2198. quicki = 0;
  2199. return;
  2200. }
  2201. if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
  2202. displayInChat("Click the maps button.","#DA0808","#1EBCC1");
  2203. return;
  2204. }
  2205. Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
  2206. Gdocument.getElementById("newbonklobby_editorbutton").click();
  2207. if(recmodebool && ishost){
  2208. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  2209. if(mode == "" && defaultmode!="d"){
  2210. mode = defaultmode;
  2211. }
  2212. if(mode != ""){
  2213. RECIEVE('42[26,"b","'+mode+'"]');
  2214. }
  2215. }
  2216. startedinqp = true;
  2217. if(roundsperqp2>=roundsperqp){
  2218. roundsperqp2 = 0;
  2219. }
  2220. gameStartTimeStamp = Date.now();
  2221. var displayblock = Gdocument.getElementById("newbonklobby").style["display"] == "block";
  2222. Gdocument.getElementById("mapeditorcontainer").style["display"] = "none";
  2223. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  2224. if(displayblock){
  2225. Gdocument.getElementById("newbonklobby").style["display"] = "block";
  2226. }
  2227. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  2228. Gdocument.getElementById("newbonklobby").style["visibility"] = "visible";
  2229. };
  2230. scope.commandhandle = function(chat_val){
  2231. if (chat_val.substring(1,6)=="echo " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  2232. if (chat_val.substring(6).replace(/^\s+|\s+$/g, '')==username){
  2233. displayInChat("You cannot echo yourself.","#DA0808","#1EBCC1");
  2234. return "";
  2235. }
  2236. else if (echo_list.indexOf(chat_val.substring(6).replace(/^\s+|\s+$/g, ''))===-1) {
  2237.  
  2238. echo_list.push(chat_val.substring(6).replace(/^\s+|\s+$/g, ''));
  2239. displayInChat(chat_val.substring(6).replace(/^\s+|\s+$/g, '') + " is being echoed.","#DA0808","#1EBCC1");
  2240. return "";
  2241. }
  2242. else{
  2243. displayInChat(chat_val.substring(6).replace(/^\s+|\s+$/g, '') + " is already being echoed.","#DA0808","#1EBCC1");
  2244. return "";
  2245. }
  2246. }
  2247. else if (chat_val.substring(1,8)=="remove " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  2248. if (echo_list.indexOf(chat_val.substring(7).replace(/^\s+|\s+$/g, ''))!==-1){
  2249. echo_list.splice(echo_list.indexOf(chat_val.substring(7).replace(/^\s+|\s+$/g, '')),1);
  2250. displayInChat(chat_val.substring(7).replace(/^\s+|\s+$/g, '')+" is not being echoed.","#DA0808","#1EBCC1");
  2251. return "";
  2252. }
  2253. else{
  2254. displayInChat("You cannot remove someone that you didn't echo.","#DA0808","#1EBCC1");
  2255. return "";
  2256. }
  2257.  
  2258. }
  2259. else if (chat_val.substring(1,10)=="echotext " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  2260. echotext = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  2261. displayInChat("Set echotext as: "+echotext,"#DA0808","#1EBCC1");
  2262. displayInChat("Type \"/echotext\" to reset echotext.","#DA0808","#1EBCC1");
  2263. return "";
  2264.  
  2265. }
  2266. else if (chat_val.substring(1,9)=="echotext"){
  2267. echotext = "message";
  2268. displayInChat("Reset echotext.","#DA0808","#1EBCC1");
  2269. return "";
  2270.  
  2271. }
  2272. else if (chat_val.substring(1,10)=="clearecho"){
  2273. echo_list = [];
  2274. displayInChat("Cleared the echo list.","#DA0808","#1EBCC1");
  2275. return "";
  2276. }
  2277. else if (chat_val.substring(1,6)=="space"){
  2278. if(space_flag == true){
  2279. displayInChat("Space is now off.","#DA0808","#1EBCC1");
  2280. space_flag = false;
  2281. }
  2282. else{
  2283. displayInChat("Space is now on.","#DA0808","#1EBCC1");
  2284. space_flag = true;
  2285. }
  2286. return "";
  2287. }
  2288. else if (chat_val.substring(1,6)=="rcaps"){
  2289. if(rcaps_flag == true){
  2290. displayInChat("Rcaps is now off.","#DA0808","#1EBCC1");
  2291. rcaps_flag = false;
  2292. }
  2293. else{
  2294. displayInChat("Rcaps is now on.","#DA0808","#1EBCC1");
  2295. rcaps_flag = true;
  2296. }
  2297.  
  2298. return "";
  2299. }
  2300. else if (chat_val.substring(1,7)=="number"){
  2301. if(number_flag == true){
  2302. displayInChat("Number is now off.","#DA0808","#1EBCC1");
  2303. number_flag = false;
  2304. }
  2305. else{
  2306. displayInChat("Number is now on.","#DA0808","#1EBCC1");
  2307. number_flag = true;
  2308. }
  2309.  
  2310. return "";
  2311. }
  2312. else if (chat_val.substring(1,8)=="reverse"){
  2313. if(reverse_flag == true){
  2314. displayInChat("Reverse is now off.","#DA0808","#1EBCC1");
  2315. reverse_flag = false;
  2316. }
  2317. else{
  2318. displayInChat("Reverse is now on.","#DA0808","#1EBCC1");
  2319. reverse_flag = true;
  2320. }
  2321.  
  2322. return "";
  2323. }
  2324. else if (chat_val.substring(1,7)=="speech"){
  2325. if(text2speech == true){
  2326. displayInChat("Text to speech is now off.","#DA0808","#1EBCC1");
  2327. text2speech = false;
  2328. }
  2329. else{
  2330. displayInChat("Text to speech is now on.","#DA0808","#1EBCC1");
  2331. text2speech = true;
  2332. }
  2333.  
  2334. return "";
  2335. }
  2336. else if (chat_val.substring(1,6)=="eval " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  2337. var ev = "";
  2338. try{
  2339. ev = eval(chat_val.substring(6).replace(/^\s+|\s+$/g, ''));
  2340. }
  2341. catch(e){
  2342. displayInChat(e.message,"#DA0808","#1EBCC1");
  2343. }
  2344. try{
  2345. displayInChat(ev.toString(),"#DA0808","#1EBCC1");
  2346. }
  2347. catch{
  2348. }
  2349.  
  2350. return "";
  2351.  
  2352. }
  2353.  
  2354. else if (chat_val.substring(1,9)=="hidechat"){
  2355. Gdocument.getElementById("ingamechatcontent").style["max-height"]="0px";
  2356. return "";
  2357. }
  2358. else if (chat_val.substring(1,9)=="showchat"){
  2359. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  2360. return "";
  2361. }
  2362.  
  2363. else if (chat_val.substring(1,7)=="scroll"){
  2364. if(scroll==false){
  2365. scroll = true;
  2366. Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="scroll";
  2367. Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
  2368. }
  2369. else if(scroll==true){
  2370. scroll = false;
  2371. Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="hidden";
  2372. Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
  2373. }
  2374.  
  2375. return "";
  2376. }
  2377.  
  2378. else if (chat_val.substring(1,7)=="chatw "){
  2379. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '');
  2380.  
  2381. if(username == text){
  2382. displayInChat("You cannot private chat with yourself.","#DA0808","#1EBCC1");
  2383. return "";
  2384. }
  2385. private_chat = text;
  2386.  
  2387. SEND("42"+JSON.stringify([4,{"type":"request public key","from":username,"to":private_chat}]));
  2388. request_public_key_time_stamp = Date.now();
  2389. 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);
  2390. return "";
  2391. }
  2392.  
  2393. else if (chat_val.substring(1,5)=="msg " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  2394. if(private_chat_public_key[1][0] != 0 && private_chat_public_key[1][1] != 0 && private_chat_public_key[0] == private_chat){
  2395. var text = chat_val.substring(5).replace(/^\s+|\s+$/g, '');
  2396. var password = [];
  2397. for(var i = 0;i<10;i++){
  2398. password.push(Math.floor(Math.random()*100+50));
  2399. }
  2400. var text2 = [];
  2401. for(var i = 0;i<text.slice(0,400).length ;i++){
  2402. text2.push(password[i%password.length]^text.slice(0,400).charCodeAt(i));
  2403. }
  2404. pmlastmessage = text.slice(0,400);
  2405. 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)}]));
  2406. displayInChat("> "+username+": ","#DA0808","#1EBCC1",{sanitize:false},text,false);
  2407. Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true;
  2408. Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true;
  2409. Laster_message = lastmessage();
  2410.  
  2411. }
  2412. return "";
  2413. }
  2414. else if (chat_val.substring(1,10)=="ignorepm " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  2415. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  2416. if(ignorepmlist.includes(text)){
  2417. var index = ignorepmlist.indexOf(text);
  2418. ignorepmlist.splice(index,1);
  2419. displayInChat("You are not ignoring private messages from "+text+".","#DA0808","#1EBCC1");
  2420.  
  2421. }
  2422. else{
  2423. ignorepmlist.push(text);
  2424. displayInChat("You are now ignoring private messages from "+text+".","#DA0808","#1EBCC1");
  2425. }
  2426. return "";
  2427. }
  2428. else if (chat_val.substring(1,8)=="pmusers"){
  2429. pmusers = [];
  2430. SEND("42"+JSON.stringify([4,{"type":"request private chat users","from":username}]));
  2431. pmuserstimestamp = Date.now();
  2432. setTimeout(function(){if(pmusers.length == 0){displayInChat("You cannot private chat with anyone.","#DA0808","#1EBCC1");
  2433. }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);
  2434. return "";
  2435. }
  2436. else if (chat_val.substring(1,6)=="lobby"){
  2437. lobby();
  2438. return "";
  2439. }
  2440. else if (chat_val.substring(1,9)=="debugger"){
  2441. if(Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"] == "none"){
  2442. debuggeropen = true;
  2443. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="block";
  2444. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="none";
  2445. Gdocument.getElementById("ingamechatinputtext").style["display"] = "none";
  2446. }
  2447. else{
  2448. debuggeropen = false;
  2449. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="none";
  2450. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  2451. Gdocument.getElementById("ingamechatinputtext").style["display"] = "";
  2452. }
  2453. return "";
  2454. }
  2455. else if (chat_val.substring(1,6)=="team " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  2456. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  2457. if(text == "r"){Gdocument.getElementById("newbonklobby_redbutton").click();}
  2458. else if(text == "g"){Gdocument.getElementById("newbonklobby_greenbutton").click();}
  2459. else if(text == "y"){Gdocument.getElementById("newbonklobby_yellowbutton").click();}
  2460. else if(text == "b"){Gdocument.getElementById("newbonklobby_bluebutton").click();}
  2461. else if(text == "s"){Gdocument.getElementById("newbonklobby_specbutton").click();}
  2462. else if(text == "f"){Gdocument.getElementById("newbonklobby_ffabutton").click();}
  2463. return "";
  2464. }
  2465. else if (chat_val.substring(1,7)=="notify"){
  2466.  
  2467. npermissions = 1;
  2468. return "";
  2469. }
  2470. else if (chat_val.substring(1,11)=="stopnotify"){
  2471.  
  2472. npermissions = 0;
  2473. return "";
  2474. }
  2475. else if (chat_val.substring(1,5)=="help" || chat_val.substring(1,2)=="?"){
  2476. for(var i = 0;i<help.length;i++){
  2477. if(help[i].startsWith("/")){
  2478. var splitted = help[i].substring(1).split(" ");
  2479. var command = splitted[0];
  2480. var rest = "";
  2481. if(splitted.length>1){
  2482. rest = " "+splitted.slice(1).join(" ");
  2483. }
  2484. displayInChat("/"+'<a onclick = \'Gwindow.displayadvhelp("'+command+'");\' style = "color:green;" href = "javascript:void(0);">'+command+'</a>'+rest,"#DA0808","#1EBCC1",{sanitize:false},"",false);
  2485. }
  2486. else if(help[i].startsWith("Alt ")){
  2487. displayInChat('<a onclick = \'Gwindow.displayadvhelp("'+help[i]+'");\' style = "color:green;" href = "javascript:void(0);">'+help[i]+'</a>',"#DA0808","#1EBCC1",{sanitize:false},"",false);
  2488. }
  2489. else{
  2490. displayInChat(help[i],"#DA0808","#1EBCC1");
  2491. }
  2492.  
  2493. }
  2494. return "";
  2495. }
  2496. else if (chat_val.substring(1,9)=="advhelp " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  2497. var text = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  2498. if(typeof(adv_help[text])!='undefined'){
  2499. displayInChat(adv_help[text],"#DA0808","#1EBCC1");
  2500. }
  2501. return "";
  2502. }
  2503. else if (chat_val.substring(1,6)=="mode " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  2504. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  2505. var mode = "";
  2506. var text2 = text;
  2507. if(text == "arrows"){
  2508. text2 = "Arrows";
  2509. mode = "ar";
  2510. }
  2511. else if(text == "death arrows"){
  2512. mode = "ard";
  2513. text2 = "Death Arrows";
  2514. }
  2515. else if(text == "grapple"){
  2516. mode = "sp";
  2517. text2 = "Grapple";
  2518. }
  2519. else if(text == "classic"){
  2520. mode = "b";
  2521. text2 = "Classic";
  2522. }
  2523. else{
  2524. displayInChat("Mode options:","#DA0808","#1EBCC1");
  2525. displayInChat("classic","#DA0808","#1EBCC1");
  2526. displayInChat("arrows","#DA0808","#1EBCC1");
  2527. displayInChat("death arrows","#DA0808","#1EBCC1");
  2528. displayInChat("grapple","#DA0808","#1EBCC1");
  2529. }
  2530. if(mode != ""){
  2531. if(ishost){
  2532. SEND('42[20,{"ga":"b","mo":"'+mode+'"}]');
  2533. RECIEVE('42[26,"b","'+mode+'"]');
  2534. displayInChat("Changed mode to "+text+".","#DA0808","#1EBCC1");
  2535. }
  2536. else{
  2537. if(playerids[myid].ratelimit.mode+1000<Date.now()){
  2538. playerids[myid].ratelimit.mode=Date.now();
  2539. SEND("42"+JSON.stringify([4,{"type":"request mode","from":username,"mode":mode}]));
  2540. var code = 'if(!Gwindow.ishost){Gwindow.displayInChat("You must be host to change the mode.","#DA0808","#1EBCC1",{sanitize:false},"",true)}else{Gwindow.changemode("'+mode+'")}';
  2541. displayInChat('> '+username+' requests [<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+text2+'</a>]',"#DA0808","#1EBCC1",{sanitize:false}," mode.");
  2542.  
  2543. }
  2544. else{
  2545. displayInChat("You are requesting modes too quickly.","#DA0808","#1EBCC1");
  2546. }
  2547. }
  2548. }
  2549. return "";
  2550.  
  2551. }
  2552. else if(ishost){
  2553. if (chat_val.substring(1,11)=="nextafter " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  2554. text = parseFloat(chat_val.substring(11).replace(/^\s+|\s+$/g, ''));
  2555. if(isNaN(text)){
  2556. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  2557. return "";
  2558. }
  2559. else if(text<=0){
  2560. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  2561. return "";
  2562. }
  2563. nextafter = text;
  2564. displayInChat("Set next after to: " + text.toString()+" seconds.","#DA0808","#1EBCC1");
  2565. displayInChat("Type /nextafter to reset next after.","#DA0808","#1EBCC1");
  2566. return "";
  2567.  
  2568. }
  2569. else if (chat_val.substring(1,10)=="nextafter"){
  2570. nextafter = 0;
  2571. displayInChat("Reset next after.","#DA0808","#1EBCC1");
  2572. return "";
  2573.  
  2574. }
  2575. else if (chat_val.substring(1,5)=="next" && stopquickplay == 0){
  2576. roundsperqp2 = 0;
  2577. if(shuffle){
  2578. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  2579. var available = [];
  2580. var availableindexes = [];
  2581. var notempty = false;
  2582. for(var i = 0; i<e.length;i++){
  2583. var a = false;
  2584. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  2585. available.push(a);
  2586. if(a){
  2587. availableindexes.push(i);
  2588. notempty = true;
  2589. }
  2590. }
  2591. if(notempty){
  2592.  
  2593. if(availableindexes.length!=1){
  2594. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  2595. }
  2596. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  2597. }
  2598. }
  2599. else{
  2600. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  2601. var available = [];
  2602. var availableindexes = [];
  2603. var notempty = false;
  2604. for(var i = 0; i<e.length;i++){
  2605. var a = false;
  2606. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  2607. available.push(a);
  2608. if(a){
  2609. availableindexes.push(i);
  2610. notempty = true;
  2611. }
  2612. }
  2613. if(notempty){
  2614. var above = [];
  2615. for(var i = 0;i<availableindexes.length;i++){
  2616. if(availableindexes[i]>quicki){
  2617. above.push(availableindexes[i]);
  2618. }
  2619. }
  2620. if(above.length>0){
  2621. quicki = above[0];
  2622. }
  2623. else{
  2624. quicki = availableindexes[0];
  2625. }
  2626. }
  2627. }
  2628. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  2629. displayInChat("Switched to next map.","#DA0808","#1EBCC1");
  2630. return "";
  2631.  
  2632. }
  2633. else if (chat_val.substring(1,9)=="freejoin"){
  2634. if(freejoin == false){
  2635. freejoin = true;
  2636. displayInChat("Freejoin is now on.","#DA0808","#1EBCC1");
  2637.  
  2638. }
  2639. else{
  2640. freejoin = false;
  2641. displayInChat("Freejoin is now off.","#DA0808","#1EBCC1");
  2642. }
  2643.  
  2644. return "";
  2645.  
  2646. }
  2647. else if (chat_val.substring(1,8)=="instaqp"){
  2648. if(instaqp == false){
  2649. instaqp = true;
  2650. displayInChat("Instaqp is now on.","#DA0808","#1EBCC1");
  2651.  
  2652. }
  2653. else{
  2654. instaqp = false;
  2655. displayInChat("Instaqp is now off.","#DA0808","#1EBCC1");
  2656. }
  2657.  
  2658. return "";
  2659.  
  2660. }
  2661.  
  2662. else if (chat_val.substring(1,9)=="previous" && stopquickplay == 0){
  2663. roundsperqp2 = 0;
  2664. if(shuffle){
  2665. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  2666. var available = [];
  2667. var availableindexes = [];
  2668. var notempty = false;
  2669. for(var i = 0; i<e.length;i++){
  2670. var a = false;
  2671. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  2672. available.push(a);
  2673. if(a){
  2674. availableindexes.push(i);
  2675. notempty = true;
  2676. }
  2677. }
  2678. if(notempty){
  2679.  
  2680. if(availableindexes.length!=1){
  2681. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  2682. }
  2683. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  2684. }
  2685. }
  2686. else{
  2687. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  2688. var available = [];
  2689. var availableindexes = [];
  2690. var notempty = false;
  2691. for(var i = 0; i<e.length;i++){
  2692. var a = false;
  2693. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  2694. available.push(a);
  2695. if(a){
  2696. availableindexes.push(i);
  2697. notempty = true;
  2698. }
  2699. }
  2700. if(notempty){
  2701. var above = [];
  2702. for(var i = 0;i<availableindexes.length;i++){
  2703. if(availableindexes[i]<quicki){
  2704. above.push(availableindexes[i]);
  2705. }
  2706. }
  2707. if(above.length>0){
  2708. quicki = above[above.length-1];
  2709. }
  2710. else{
  2711. quicki = availableindexes[availableindexes.length-1];
  2712. }
  2713. }
  2714. }
  2715. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  2716.  
  2717. displayInChat("Switched to previous map.","#DA0808","#1EBCC1");
  2718. return "";
  2719. }
  2720. else if (chat_val.substring(1,6)=="start" && chat_val.length == 6){
  2721. Gdocument.getElementById("newbonklobby_editorbutton").click();
  2722. if(recmodebool && ishost){
  2723. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  2724. if(mode == "" && defaultmode!="d"){
  2725. mode = defaultmode;
  2726. }
  2727. if(mode != ""){
  2728. RECIEVE('42[26,"b","'+mode+'"]');
  2729. }
  2730. }
  2731. Gdocument.getElementById("mapeditor_close").click();
  2732. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  2733. roundsperqp2 = 0;
  2734. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  2735.  
  2736. return "";
  2737. }
  2738.  
  2739. else if (chat_val.substring(1,8)=="startqp" && stopquickplay == 1){
  2740. stopquickplay = 0;
  2741. quicki = 0;
  2742. displayInChat("Enabled quickplay.","#DA0808","#1EBCC1");
  2743. return "";
  2744. }
  2745. else if (chat_val.substring(1,7)=="stopqp" && stopquickplay == 0){
  2746. stopquickplay = 1;
  2747. quicki = 0;
  2748. displayInChat("Disabled quickplay.","#DA0808","#1EBCC1");
  2749. return "";
  2750. }
  2751.  
  2752. else if (chat_val.substring(1,5)=="ban " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  2753. banned.push(chat_val.substring(5).replace(/^\s+|\s+$/g, ''));
  2754. displayInChat("Banned "+chat_val.substring(5).replace(/^\s+|\s+$/g, '')+".","#DA0808","#1EBCC1");
  2755. return "/kick '" + chat_val.substring(5).replace(/^\s+|\s+$/g, '') + "'";
  2756. }
  2757. else if (chat_val.substring(1,6)=="kill " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  2758. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  2759. var keys = Object.keys(playerids);
  2760. var killid = undefined;
  2761. for(var i = 0; i<keys.length; i++){
  2762. if(playerids[keys[i]].userName == text){
  2763. killid = keys[i];
  2764. }
  2765. }
  2766. if(typeof(killid)!="undefined" && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden" && !killedids.includes(killid)){
  2767. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  2768. killedids.push(killid);
  2769. SEND('42[25,{"a":{"playersLeft":['+killid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  2770. RECIEVE('42[31,{"a":{"playersLeft":['+killid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  2771. }
  2772. return "";
  2773. }
  2774. else if (chat_val.substring(1,10)=="balanceA " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  2775. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  2776. if(!isNaN(parseInt(text))){
  2777. if(parseInt(text)>=-100 && parseInt(text)<=100){
  2778. var keys = Object.keys(playerids);
  2779. for(var i = 0; i<keys.length;i++){
  2780. SEND('42[29,{"sid":'+keys[i]+',"bal":'+text+'}]');
  2781. RECIEVE('42[36,'+keys[i]+','+text+']');
  2782. }
  2783. }
  2784. }
  2785. return "";
  2786.  
  2787. }
  2788. else if (chat_val.substring(1,7)=="moveA " && chat_val.replace(/^\s+|\s+$/g, '').length>=8){
  2789. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '');
  2790. var keys = Object.keys(playerids);
  2791. if(text == "f"){
  2792. for(var i = 0; i<keys.length;i++){
  2793. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":1}]')
  2794. }
  2795. }
  2796. else if(text == "b"){
  2797. for(var i = 0; i<keys.length;i++){
  2798. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":3}]')
  2799. }
  2800. }
  2801. else if(text == "g"){
  2802. for(var i = 0; i<keys.length;i++){
  2803. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":4}]')
  2804. }
  2805. }
  2806. else if(text == "r"){
  2807. for(var i = 0; i<keys.length;i++){
  2808. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":2}]')
  2809. }
  2810. }
  2811. else if(text == "y"){
  2812. for(var i = 0; i<keys.length;i++){
  2813. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":5}]')
  2814. }
  2815. }
  2816. else if(text == "s"){
  2817. for(var i = 0; i<keys.length;i++){
  2818. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":0}]')
  2819. }
  2820. }
  2821. return "";
  2822. }
  2823. if (chat_val.substring(1,13)=="roundsperqp " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  2824. text = parseInt(chat_val.substring(13).replace(/^\s+|\s+$/g, ''));
  2825. if(isNaN(text)){
  2826. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  2827. return "";
  2828. }
  2829. else if(text<=0){
  2830. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  2831. return "";
  2832. }
  2833. roundsperqp = text;
  2834. roundsperqp2 = 0;
  2835. displayInChat("Set rounds per quickplay to: " + text.toString(),"#DA0808","#1EBCC1");
  2836. displayInChat("Type /roundsperqp to reset rounds per quickplay.","#DA0808","#1EBCC1");
  2837. return "";
  2838.  
  2839. }
  2840. else if (chat_val.substring(1,12)=="roundsperqp"){
  2841. roundsperqp = 1;
  2842. roundsperqp2 = 0;
  2843. displayInChat("Reset rounds per quickplay.","#DA0808","#1EBCC1");
  2844. return "";
  2845.  
  2846. }
  2847. else if (chat_val.substring(1,8)=="rounds " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  2848. var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '');
  2849. if(!isNaN(parseInt(text))){
  2850. text = parseInt(text).toString();
  2851. SEND('42[21,{"w":'+text+'}]');
  2852. RECIEVE('42[27,'+text+']');
  2853. }
  2854. return "";
  2855.  
  2856. }
  2857. else if (chat_val.substring(1,13)=="disablekeys " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  2858. var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '');
  2859. var keys = text.split(" ");
  2860. var disabledkeys2 = [];
  2861. var possiblekeys = ["left","right","up","down","heavy","special"];
  2862. for(var i = 0; i<keys.length; i++){
  2863. if(keys[i]!="" && !disabledkeys2.includes(keys[i])){
  2864. if(possiblekeys.includes(keys[i])){
  2865. disabledkeys2.push(keys[i]);
  2866. }
  2867. else{
  2868. displayInChat("Key options: " + possiblekeys.join(" ") + ".","#DA0808","#1EBCC1");
  2869. return "";
  2870. }
  2871. }
  2872. }
  2873. disabledkeys = disabledkeys2;
  2874. displayInChat("Set disabled keys to: " + disabledkeys.join(" ") + ".","#DA0808","#1EBCC1");
  2875. displayInChat("Type /disablekeys to reset disabled keys.","#DA0808","#1EBCC1");
  2876. return "";
  2877.  
  2878. }
  2879. else if (chat_val.substring(1,12)=="disablekeys"){
  2880. displayInChat("Reset disabled keys.","#DA0808","#1EBCC1");
  2881. disabledkeys = [];
  2882. return "";
  2883.  
  2884. }
  2885. else if (chat_val.substring(1,10)=="jointext " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  2886. jointext = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  2887. displayInChat("Set jointext to: " + jointext,"#DA0808","#1EBCC1");
  2888. displayInChat("Type /jointext to reset jointext.","#DA0808","#1EBCC1");
  2889. return "";
  2890.  
  2891. }
  2892. else if (chat_val.substring(1,9)=="jointext"){
  2893. jointext = "";
  2894. displayInChat("Reset jointext.","#DA0808","#1EBCC1");
  2895. return "";
  2896.  
  2897. }
  2898. else if (chat_val.substring(1,9)=="wintext " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  2899. wintext = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  2900. displayInChat("Set wintext to: " + wintext,"#DA0808","#1EBCC1");
  2901. displayInChat("Type /wintext to reset wintext.","#DA0808","#1EBCC1");
  2902. return "";
  2903.  
  2904. }
  2905. else if (chat_val.substring(1,8)=="wintext"){
  2906. wintext = "";
  2907. displayInChat("Reset wintext.","#DA0808","#1EBCC1");
  2908. return "";
  2909.  
  2910. }
  2911. else if (chat_val.substring(1,11)=="autorecord"){
  2912. if(autorecord){
  2913. autorecord = false;
  2914. displayInChat("Autorecord is now off.","#DA0808","#1EBCC1");
  2915. }
  2916. else{
  2917. autorecord = true;
  2918. displayInChat("Autorecord is now on.","#DA0808","#1EBCC1");
  2919. }
  2920. return "";
  2921.  
  2922. }
  2923. else if (chat_val.substring(1,9)=="afkkill " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  2924. var text = parseFloat(chat_val.substring(9).replace(/^\s+|\s+$/g, ''));
  2925. if(!isNaN(text)){
  2926. if(text>0){
  2927. displayInChat("Set afk kill to: " + text.toString()+" seconds.","#DA0808","#1EBCC1");
  2928. displayInChat("Type /afkkill to reset afk kill.","#DA0808","#1EBCC1");
  2929. var keys = Object.keys(playerids);
  2930. var now = Date.now();
  2931. for(var i = 0;i<keys.length;i++){
  2932. playerids[keys[i]].lastmove = now;
  2933. }
  2934. afkkill = text;
  2935. }
  2936. else{
  2937. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  2938. }
  2939. }
  2940. else{
  2941. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  2942. }
  2943. return "";
  2944.  
  2945. }
  2946. else if (chat_val.substring(1,9)=="afkkill"){
  2947. afkkill = -1;
  2948. displayInChat("Reset afk kill.","#DA0808","#1EBCC1");
  2949. return "";
  2950.  
  2951. }
  2952. else if (chat_val.substring(1,13)=="defaultmode " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  2953. var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '');
  2954. if(text == "default"){
  2955. defaultmode = "";
  2956. displayInChat("Changed default mode to default.","#DA0808","#1EBCC1");
  2957. }
  2958. else if(text == "arrows"){
  2959. defaultmode = "ar";
  2960. displayInChat("Changed default mode to arrows.","#DA0808","#1EBCC1");
  2961. }
  2962. else if(text == "death arrows"){
  2963. defaultmode = "ard";
  2964. displayInChat("Changed default mode to death arrows.","#DA0808","#1EBCC1");
  2965. }
  2966. else if(text == "grapple"){
  2967. defaultmode = "sp";
  2968. displayInChat("Changed default mode to grapple.","#DA0808","#1EBCC1");
  2969. }
  2970. else if(text == "classic"){
  2971. defaultmode = "b";
  2972. displayInChat("Changed default mode to classic.","#DA0808","#1EBCC1");
  2973.  
  2974. }
  2975. else{
  2976. displayInChat("Default mode options:","#DA0808","#1EBCC1");
  2977. displayInChat("default","#DA0808","#1EBCC1");
  2978. displayInChat("classic","#DA0808","#1EBCC1");
  2979. displayInChat("arrows","#DA0808","#1EBCC1");
  2980. displayInChat("death arrows","#DA0808","#1EBCC1");
  2981. displayInChat("grapple","#DA0808","#1EBCC1");
  2982. }
  2983. return "";
  2984.  
  2985. }
  2986. else if (chat_val.substring(1,8)=="recmode"){
  2987. if(recmodebool == true){
  2988. recmodebool = false;
  2989. displayInChat("Recmode is now off.","#DA0808","#1EBCC1");
  2990.  
  2991. }
  2992. else{
  2993. recmodebool = true;
  2994. displayInChat("Recmode is now on.","#DA0808","#1EBCC1");
  2995.  
  2996. }
  2997.  
  2998. return "";
  2999.  
  3000. }
  3001. else if (chat_val.substring(1,8)=="recteam"){
  3002. if(recteams == true){
  3003. recteams = false;
  3004. displayInChat("Recteam is now off.","#DA0808","#1EBCC1");
  3005.  
  3006. }
  3007. else{
  3008. recteams = true;
  3009. displayInChat("Recteam is now on.","#DA0808","#1EBCC1");
  3010.  
  3011. }
  3012. return "";
  3013. }
  3014. else if (chat_val.substring(1,8)=="shuffle"){
  3015. if(shuffle == true){
  3016. shuffle = false;
  3017. displayInChat("Shuffle is now off.","#DA0808","#1EBCC1");
  3018.  
  3019. }
  3020. else{
  3021. shuffle = true;
  3022. displayInChat("Shuffle is now on.","#DA0808","#1EBCC1");
  3023.  
  3024. }
  3025.  
  3026. return "";
  3027.  
  3028. }
  3029. else if(sandboxon){
  3030. if (chat_val.substring(1,11)=="addplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  3031. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  3032. if(!isNaN(parseInt(text))){
  3033. var text2 = parseInt(text);
  3034. if(text2>0){
  3035. for(var i = 0;i<text2;i++){
  3036. RECIEVE('42[4,'+sandboxid+',"0123456789abcdef","'+sandboxid.toString()+'",true,0,1,{"layers":[],"bc":'+Math.floor(Math.random() * 16777215).toString()+'}]');
  3037. sandboxplayerids[sandboxid] = sandboxid.toString();
  3038. sandboxid+=1;
  3039. }
  3040.  
  3041. }
  3042. }
  3043. return "";
  3044.  
  3045. }
  3046. else if (chat_val.substring(1,11)=="delplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  3047. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  3048. if(!isNaN(parseInt(text))){
  3049. var text2 = parseInt(text);
  3050. if(text2>0){
  3051. if(Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden"){
  3052. var jsonkeys = Object.keys(sandboxplayerids).reverse();
  3053. for(var i = 0;i<text2 && i<jsonkeys.length;i++){
  3054. RECIEVE('42[5,'+jsonkeys[i]+',0]');
  3055. delete sandboxplayerids[jsonkeys[i]];
  3056. }
  3057. }
  3058. else{
  3059. displayInChat("Cannot delete players while ingame.","#DA0808","#1EBCC1");
  3060. }
  3061.  
  3062. }
  3063. }
  3064. return "";
  3065. }
  3066. else if (chat_val.substring(1,7)=="copyme"){
  3067. if(sandboxcopyme == true){
  3068. displayInChat("Copyme is now off.","#DA0808","#1EBCC1");
  3069. sandboxcopyme = false;
  3070. }
  3071. else{
  3072. displayInChat("Copyme is now on.","#DA0808","#1EBCC1");
  3073. sandboxcopyme = true;
  3074. }
  3075.  
  3076. return "";
  3077. }
  3078. }
  3079. }
  3080. return chat_val;
  3081. };
  3082.  
  3083. scope.flag_manage = function(t){
  3084. var text = t;
  3085. if(reverse_flag == true){
  3086. text = text.split("").reverse().join("")
  3087. }
  3088. if(rcaps_flag == true){
  3089. text = text.split('');
  3090. for(var i = 0; i<text.length;i++){
  3091. if(Math.floor(Math.random()*2)){
  3092. text[i] = text[i].toUpperCase();
  3093. }
  3094. else{
  3095. text[i] = text[i].toLowerCase();
  3096. }
  3097. }
  3098. text = text.join('');
  3099. }
  3100. if(space_flag == true){
  3101. text = text.split('').join(' ')
  3102. }
  3103. if(number_flag == true){
  3104. text = text.replace(/[t|T][Oo]+/g,"2");
  3105. text = text.replace(/[f|F][o|O][r|R]/g,"4");
  3106. text = text.replace(/[a|A][t|T][e|E]/g,"8");
  3107. text = text.replace(/[e|E]/g,"3");
  3108. text = text.replace(/[a|A]/g,"4");
  3109. text = text.replace(/[o|O]/g,"0");
  3110. text = text.replace(/[s|S]/g,"5");
  3111. text = text.replace(/[i|I|l|L]/g,"1");
  3112. }
  3113. return text;
  3114. };
  3115. Gdocument.getElementById("newbonklobby_chat_input").onkeydown = function(e){
  3116. if(e.keyCode==13){
  3117.  
  3118. var chat_val = Gdocument.getElementById("newbonklobby_chat_input").value;
  3119.  
  3120. if (chat_val!="" && chat_val[0]=="/"){
  3121.  
  3122. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  3123. chat(commandhandle(chat_val));
  3124. }
  3125. else{
  3126. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  3127. chat(flag_manage(chat_val));
  3128. }
  3129.  
  3130. }
  3131. };
  3132. Gdocument.getElementById("ingamechatinputtext").onkeydown = function(e){
  3133. if(e.keyCode==13){
  3134.  
  3135. var chat_val = Gdocument.getElementById("ingamechatinputtext").value;
  3136.  
  3137. if (chat_val!="" && chat_val[0]=="/"){
  3138.  
  3139. Gdocument.getElementById("ingamechatinputtext").value = "";
  3140. chat(commandhandle(chat_val));
  3141. }
  3142. else{
  3143. Gdocument.getElementById("ingamechatinputtext").value = "";
  3144. chat(flag_manage(chat_val));
  3145. }
  3146. }
  3147. };
  3148. scope.Last_message = "";
  3149. scope.Laster_message = "";
  3150. scope.new_message = false;
  3151. scope.changed_chat = false;
  3152. scope.interval = setInterval(timeout123,60);
  3153.  
  3154. scope.hotkeys = function(e){
  3155. var keycode = e.code;
  3156. if(e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  3157. if(keycode == "Period"){
  3158. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]!="0px"){
  3159. chatheight+=5;
  3160. if(chatheight>600){chatheight = 600;}
  3161. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  3162. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  3163. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  3164. }
  3165. e.preventDefault();
  3166. }
  3167. if(keycode == "Comma"){
  3168. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]!="0px"){
  3169. chatheight-=5;
  3170. if(chatheight<100){chatheight = 100;}
  3171. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  3172. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  3173. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  3174. }
  3175. e.preventDefault();
  3176. }
  3177. }
  3178. if(e.repeat){return;}
  3179. if(e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  3180. if(ishost){
  3181. if(keycode == "KeyE"){
  3182. if(Gdocument.getElementById("newbonklobby").style["display"] == "block"){
  3183. Gdocument.getElementById("newbonklobby_editorbutton").click();
  3184. }
  3185. else if(Gdocument.getElementById("mapeditorcontainer").style["display"] == "block"){
  3186. Gdocument.getElementById("mapeditor_close").click();
  3187. }
  3188. e.preventDefault();
  3189.  
  3190. }
  3191. else if(keycode == "KeyT"){
  3192. Gdocument.getElementById("newbonklobby_teamsbutton").click();
  3193. e.preventDefault();
  3194. }
  3195. else if(keycode == "KeyM"){
  3196. Gdocument.getElementById("newbonklobby_modebutton").click();
  3197. e.preventDefault();
  3198. }
  3199. else if(keycode == "KeyK"){
  3200. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  3201. Gdocument.getElementById("pretty_top_exit").click();
  3202. }
  3203. e.preventDefault();
  3204. }
  3205. else if(keycode == "KeyS"){
  3206. Gdocument.getElementById("newbonklobby_editorbutton").click();
  3207. if(recmodebool && ishost){
  3208. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  3209. if(mode == "" && defaultmode!="d"){
  3210. mode = defaultmode;
  3211. }
  3212. if(mode != ""){
  3213. RECIEVE('42[26,"b","'+mode+'"]');
  3214. }
  3215. }
  3216. Gdocument.getElementById("mapeditor_close").click();
  3217. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  3218. roundsperqp2 = 0;
  3219. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  3220. e.preventDefault();
  3221. }
  3222. else if(keycode == "KeyD"){
  3223. roundsperqp2 = 0;
  3224. if(stopquickplay == 0){
  3225. if(shuffle){
  3226. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  3227. var available = [];
  3228. var availableindexes = [];
  3229. var notempty = false;
  3230. for(var i = 0; i<e2.length;i++){
  3231. var a = false;
  3232. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  3233. available.push(a);
  3234. if(a){
  3235. availableindexes.push(i);
  3236. notempty = true;
  3237. }
  3238. }
  3239. if(notempty){
  3240.  
  3241. if(availableindexes.length!=1){
  3242. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  3243. }
  3244. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  3245. }
  3246. }
  3247. else{
  3248. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  3249. var available = [];
  3250. var availableindexes = [];
  3251. var notempty = false;
  3252. for(var i = 0; i<e2.length;i++){
  3253. var a = false;
  3254. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  3255. available.push(a);
  3256. if(a){
  3257. availableindexes.push(i);
  3258. notempty = true;
  3259. }
  3260. }
  3261. if(notempty){
  3262. var above = [];
  3263. for(var i = 0;i<availableindexes.length;i++){
  3264. if(availableindexes[i]>quicki){
  3265. above.push(availableindexes[i]);
  3266. }
  3267. }
  3268. if(above.length>0){
  3269. quicki = above[0];
  3270. }
  3271. else{
  3272. quicki = availableindexes[0];
  3273. }
  3274. }
  3275. }
  3276. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  3277. }
  3278. e.preventDefault();
  3279. }
  3280. else if(keycode == "KeyA"){
  3281. if(stopquickplay == 0){
  3282. roundsperqp2 = 0;
  3283. if(shuffle){
  3284. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  3285. var available = [];
  3286. var availableindexes = [];
  3287. var notempty = false;
  3288. for(var i = 0; i<e2.length;i++){
  3289. var a = false;
  3290. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  3291. available.push(a);
  3292. if(a){
  3293. availableindexes.push(i);
  3294. notempty = true;
  3295. }
  3296. }
  3297. if(notempty){
  3298.  
  3299. if(availableindexes.length!=1){
  3300. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  3301. }
  3302. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  3303. }
  3304. }
  3305. else{
  3306. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  3307. var available = [];
  3308. var availableindexes = [];
  3309. var notempty = false;
  3310. for(var i = 0; i<e2.length;i++){
  3311. var a = false;
  3312. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  3313. available.push(a);
  3314. if(a){
  3315. availableindexes.push(i);
  3316. notempty = true;
  3317. }
  3318. }
  3319. if(notempty){
  3320. var above = [];
  3321. for(var i = 0;i<availableindexes.length;i++){
  3322. if(availableindexes[i]<quicki){
  3323. above.push(availableindexes[i]);
  3324. }
  3325. }
  3326. if(above.length>0){
  3327. quicki = above[above.length-1];
  3328. }
  3329. else{
  3330. quicki = availableindexes[availableindexes.length-1];
  3331. }
  3332. }
  3333. }
  3334. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  3335. }
  3336. e.preventDefault();
  3337. }
  3338. else if(keycode == "KeyQ"){
  3339. if(stopquickplay == 1){
  3340. stopquickplay = 0;
  3341. quicki = 0;
  3342. displayInChat("Enabled quickplay.","#DA0808","#1EBCC1");
  3343. }
  3344. else{
  3345. stopquickplay = 1;
  3346. quicki = 0;
  3347. displayInChat("Disabled quickplay.","#DA0808","#1EBCC1");
  3348. }
  3349. e.preventDefault();
  3350. }
  3351. else if(keycode == "KeyR"){
  3352. if(recmodebool == true){
  3353. recmodebool = false;
  3354. displayInChat("Recmode is now off.","#DA0808","#1EBCC1");
  3355.  
  3356. }
  3357. else{
  3358. recmodebool = true;
  3359. displayInChat("Recmode is now on.","#DA0808","#1EBCC1");
  3360.  
  3361. }
  3362. }
  3363. else if(keycode == "KeyF"){
  3364. if(freejoin == false){
  3365. freejoin = true;
  3366. displayInChat("Freejoin is now on.","#DA0808","#1EBCC1");
  3367.  
  3368. }
  3369. else{
  3370. freejoin = false;
  3371. displayInChat("Freejoin is now off.","#DA0808","#1EBCC1");
  3372. }
  3373. e.preventDefault();
  3374. }
  3375. }
  3376. else{
  3377. if(keycode == "KeyE"){
  3378. e.preventDefault();
  3379. }
  3380. else if(keycode == "KeyT"){
  3381. e.preventDefault();
  3382. }
  3383. else if(keycode == "KeyM"){
  3384. e.preventDefault();
  3385. }
  3386. else if(keycode == "KeyK"){
  3387. e.preventDefault();
  3388. }
  3389. else if(keycode == "KeyS"){
  3390. e.preventDefault();
  3391. }
  3392. else if(keycode == "KeyD"){
  3393. e.preventDefault();
  3394. }
  3395. else if(keycode == "KeyA"){
  3396. e.preventDefault();
  3397. }
  3398. else if(keycode == "KeyQ"){
  3399. e.preventDefault();
  3400. }
  3401. else if(keycode == "KeyF"){
  3402. e.preventDefault();
  3403. }
  3404. else if(keycode == "KeyR"){
  3405. e.preventDefault();
  3406. }
  3407.  
  3408. }
  3409. if(keycode == "KeyL"){
  3410. lobby();
  3411. e.preventDefault();
  3412. }
  3413. if(keycode == "KeyC"){
  3414. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  3415. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]=="0px"){
  3416. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  3417. }
  3418. else{
  3419. Gdocument.getElementById("ingamechatcontent").style["max-height"]="0px";
  3420. }
  3421. }
  3422. e.preventDefault();
  3423. }
  3424. if(keycode == "KeyI"){
  3425. if(Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"] == "none"){
  3426. debuggeropen = true;
  3427. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="block";
  3428. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="none";
  3429. Gdocument.getElementById("ingamechatinputtext").style["display"] = "none";
  3430. }
  3431. else{
  3432. debuggeropen = false;
  3433. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="none";
  3434. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  3435. Gdocument.getElementById("ingamechatinputtext").style["display"] = "";
  3436. }
  3437. e.preventDefault();
  3438. }
  3439. }
  3440. if(!e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  3441. if(keycode == "Slash" && !(Gdocument.getElementById("gmeditor")?.style["transform"] == "scale(1)")){
  3442. 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"]==""){
  3443. Gdocument.getElementById("newbonklobby_chat_input").value = "/";
  3444. if(Gdocument.getElementById("newbonklobby_chat_input").style["pointer-events"] == "none"){
  3445. fire("keydown",{keyCode:13});
  3446. }
  3447. else{
  3448. Gdocument.getElementById("newbonklobby_chat_input").focus();
  3449. }
  3450. e.preventDefault();
  3451.  
  3452. }
  3453. else if(Gdocument.getElementById("ingamechatinputtext").style["visibility"]=="visible" && Gdocument.getElementById("ingamechatinputtext").style["display"]=="" && Gdocument.getElementById("mapeditorcontainer").style["display"]!="block" && Gdocument.getElementById("ingamechatinputtext").value == ""){
  3454. Gdocument.getElementById("ingamechatinputtext").value = "/";
  3455. if(!Gdocument.getElementById("ingamechatinputtext").classList.value.includes("ingamechatinputtextbg")){
  3456. fire("keydown",{keyCode:13});
  3457. }
  3458. else{
  3459. Gdocument.getElementById("ingamechatinputtext").focus();
  3460. }
  3461. e.preventDefault();
  3462.  
  3463. }
  3464. }
  3465. }
  3466. };
  3467.  
  3468. Gdocument.onkeydown = hotkeys;
  3469.  
  3470. Gwindow.addEventListener('resize',function(e){
  3471. debuggermenu.style["width"] = Gdocument.getElementById("bonkiocontainer").style["width"];
  3472. debuggermenu.style["height"] = Gdocument.getElementById("bonkiocontainer").style["height"];
  3473. scope.width = parseInt(Gdocument.getElementById("bonkiocontainer").style["width"])-20;
  3474. scope.height = parseInt(Gdocument.getElementById("bonkiocontainer").style["height"])-210;
  3475. logmenu.style["width"] = width.toString()+"px";
  3476. logmenu.style["height"] = height.toString()+"px";
  3477. logmenutopleft.style["width"] = (width/2).toString()+"px";
  3478. logmenutopright.style["width"] = (width/2).toString()+"px";
  3479. logmenutopright.style["left"] = (width/2).toString()+"px";
  3480. debuggerinput.style["width"] = width.toString()+"px";
  3481. debuggerinput.style["top"] = (height+90).toString()+"px";
  3482. debuggersendrecieve.style["top"] = (height+120).toString()+"px";
  3483. debuggerpausebutton.style["top"] = (height+150).toString()+"px";
  3484. debuggereval.style["width"] = (width-150).toString()+"px";
  3485. debuggereval.style["top"] = (height+120).toString()+"px";},true);
  3486.  
  3487.  
  3488. function timeout123() {
  3489. updateWssLog();
  3490. var now = Date.now();
  3491. var keys = Object.keys(playerids);
  3492. for(var i = 0;i<keys.length;i++){
  3493. if(playerids[keys[i]].playerData){
  3494. if(playerids[keys[i]].playerData2){
  3495. if(playerids[keys[i]].playerData.transform){
  3496. }
  3497. else{
  3498. if(playerids[keys[i]].playerData2.alive){
  3499. }
  3500. playerids[keys[i]].playerData2.alive = false;
  3501. }
  3502. }
  3503. else{
  3504. playerids[keys[i]].playerData2 = {"alive":true};
  3505. }
  3506. }
  3507. }
  3508. if(afkkill>0 && ishost){
  3509. var keys = Object.keys(playerids);
  3510. currentFrame = Math.floor((now - gameStartTimeStamp)/1000*30);
  3511. for(var i = 0; i<keys.length;i++){
  3512. if(typeof(playerids[keys[i]].lastmove)=="undefined"){
  3513. playerids[keys[i]].lastmove = now;
  3514. }
  3515. else{
  3516. if(playerids[keys[i]].playerData2?.alive && now-playerids[keys[i]].lastmove>=afkkill*1000 && now-gameStartTimeStamp>=afkkill*1000 && !killedids.includes(keys[i])){
  3517. killedids.push(keys[i]);
  3518. SEND('42[25,{"a":{"playersLeft":['+keys[i]+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  3519. RECIEVE('42[31,{"a":{"playersLeft":['+keys[i]+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  3520. break;
  3521. }
  3522. }
  3523. }
  3524. }
  3525. if(ishost && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS"){
  3526. clearmaprequests.style["display"] = "block";
  3527. refreshmaprequests.style["display"] = "block";
  3528. }
  3529. else{
  3530. clearmaprequests.style["display"] = "none";
  3531. refreshmaprequests.style["display"] = "none";
  3532. }
  3533. if(Gdocument.getElementById("gamerenderer").style["visibility"]=="hidden"){
  3534. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  3535. }
  3536. if(Gdocument.getElementById("maploadwindowmapscontainer").children.length>0 && maponclick == 0){
  3537. maponclick = Gdocument.getElementById("maploadwindowmapscontainer").children[0].onclick;
  3538. }
  3539. if(Gdocument.getElementById("sm_connectingContainer").style["visibility"] == "hidden"){
  3540. var chatbox = Gdocument.getElementById("newbonklobby_chat_content");
  3541. while (chatbox.firstChild) {
  3542. chatbox.removeChild(chatbox.firstChild);
  3543. }
  3544. rcaps_flag = false;
  3545. space_flag = false;
  3546. number_flag = false;
  3547. reverse_flag = false;
  3548. echo_list = [];
  3549. scroll = false;
  3550. stopquickplay = 1;
  3551. roundsperqp = 1;
  3552. roundsperqp2 = 0;
  3553. checkboxhidden = false;
  3554. freejoin = false;
  3555. shuffle = false;
  3556. defaultmode = "";
  3557. recmodebool = false;
  3558. recteams = false;
  3559. playerids = {};
  3560. autorecord = false;
  3561. afkkill = -1;
  3562. nextafter = 0;
  3563. jointext = "";
  3564. ishost = false;
  3565. sandboxplayerids = {};
  3566. sandboxcopyme = false;
  3567. wintext = "";
  3568. sandboxon = false;
  3569. sandboxid = 1;
  3570. disabledkeys = [];
  3571. myid = -1;
  3572. hostid = -1;
  3573. if(chatlog[chatlog.length-1]!="ROOM END"){
  3574. chatlog.push("ROOM END");
  3575. }
  3576. }
  3577. else{
  3578. if(chatlog[chatlog.length-1]=="ROOM END"){
  3579. chatlog.push("ROOM START");
  3580. }
  3581. }
  3582.  
  3583. if(Gdocument.getElementById("newbonklobby").style["display"]=="block"){
  3584. Gdocument.getElementById("ingamechatinputtext").style["visibility"]="hidden";
  3585. }
  3586. else{
  3587. Gdocument.getElementById("ingamechatinputtext").style["visibility"]="visible";
  3588.  
  3589. }
  3590. mode = Gdocument.getElementById("newbonklobby_modetext").textContent;
  3591. if(Gdocument.getElementsByClassName('newbonklobby_settings_button brownButton brownButton_classic buttonShadow brownButtonDisabled').length == 0 && Gdocument.getElementById("newbonklobby_playerbox_elementcontainer").children.length+Gdocument.getElementById("newbonklobby_specbox_elementcontainer").children.length-3
  3592. >0){
  3593. ishost = true;
  3594. }
  3595. else{
  3596. ishost = actuallyhost;
  3597. }
  3598.  
  3599. if(Gdocument.getElementById("pretty_top_name")!=null){
  3600. username = Gdocument.getElementById("pretty_top_name").textContent;
  3601. if(myid!=-1){
  3602. username = playerids[myid].userName;
  3603. }
  3604. }
  3605. try{
  3606. Last_message = lastmessage()
  3607. } catch{
  3608. Last_message = "";
  3609. }
  3610. if (Laster_message != Last_message){
  3611. Laster_message = Last_message;
  3612. if(changed_chat==false){
  3613. new_message = true;
  3614. }
  3615. else{
  3616. changed_chat = false;
  3617. }
  3618. }
  3619. if(new_message){
  3620. chatlog.push(Last_message);
  3621. var lm = "";
  3622. try{
  3623. lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  3624. if(typeof(lm[0].parentElement.style["parsed"]) == 'undefined'){
  3625. if (lm[0].className == "newbonklobby_chat_msg_colorbox"){
  3626. lm[2].innerHTML = urlify(lm[2].innerHTML);
  3627. Laster_message = lastmessage();
  3628. lm[0].parentElement.style["parsed"] = true;
  3629. }
  3630. if (lm[0].className == "newbonklobby_chat_status"){
  3631. lm[0].innerHTML = urlify(lm[0].innerHTML);
  3632. Laster_message = lastmessage();
  3633. lm[0].parentElement.style["parsed"] = true;
  3634. }
  3635. }
  3636. }
  3637. catch{
  3638. lm = "";
  3639. }
  3640.  
  3641. if(Last_message.indexOf("@"+username)!=-1 && npermissions == 1){
  3642. if(Notification.requestPermission()){
  3643. var n = new Notification(Last_message);
  3644. }
  3645. }
  3646.  
  3647. try{
  3648. lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  3649. if(typeof(lm[0].parentElement.style["parsed"])=='undefined'){
  3650. if(lm[0].className == "ingamechatname"){
  3651. lm[1].innerHTML = urlify(lm[1].innerHTML);
  3652. Laster_message = lastmessage();
  3653. lm[0].parentElement.style["parsed"] = true;
  3654. }
  3655. if(lm[0].className == ""){
  3656. lm[0].innerHTML = urlify(lm[0].innerHTML);
  3657. Laster_message = lastmessage();
  3658. lm[0].parentElement.style["parsed"] = true;
  3659. }
  3660. }
  3661. }
  3662. catch{
  3663. lm = "";
  3664. }
  3665. if(text2speech){
  3666. if(!sayer.speaking){
  3667. if(Last_message.includes(": ")){
  3668. speech.text = Last_message.substring(0,Last_message.indexOf(":")).toLowerCase();
  3669. speech.rate = 2.25;
  3670. sayer.speak(speech);
  3671. speech.text = Last_message.substring(Last_message.indexOf(": ")+3).toLowerCase();
  3672. speech.rate = 1.25;
  3673. sayer.speak(speech);
  3674. }
  3675. else{
  3676. speech.text = Last_message.toLowerCase();
  3677. sayer.speak(speech);
  3678. }
  3679. }
  3680. }
  3681. }
  3682. if (ishost==true && new_message){
  3683. for(i=0;i<banned.length;i++){
  3684. if(Last_message.startsWith("* "+banned[i]+" has joined the game")){
  3685. chat("/kick '"+banned[i]+"'");
  3686. }
  3687. }
  3688. }
  3689. if(Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden" && ishost){
  3690. roundsperqp2 = 0;
  3691. }
  3692. if(Gdocument.getElementById("ingamewinner").style["visibility"]=="inherit" && ishost){
  3693. if(Gdocument.getElementById("ingamewinner").style["parsed"] != true){
  3694. if(stopquickplay!=1){
  3695. roundsperqp2++;
  3696. }
  3697. if(autorecord){
  3698. Gdocument.getElementById("pretty_top_replay").click();
  3699. }
  3700. }
  3701. if(Gdocument.getElementById("ingamewinner").style["parsed"] != true && wintext!="" && Gdocument.getElementById("ingamewinner_bottom").textContent!="DRAW"){
  3702. chat(flag_manage(wintext.replaceAll("username",Gdocument.getElementById("ingamewinner_top").textContent)));
  3703. }
  3704. Gdocument.getElementById("ingamewinner").style["parsed"] = true;
  3705. }
  3706. else{
  3707. Gdocument.getElementById("ingamewinner").style["parsed"] = false;
  3708. }
  3709. if(ishost && stopquickplay == 0){
  3710. if(checkboxhidden){
  3711. checkboxhidden = false;
  3712. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  3713. for(var i = 0; i<classes.length;i++){
  3714. classes[i].style["display"] = "block";
  3715. classes[i].className = "quickplaycheckbox quickplaychecked";
  3716. }
  3717. Gdocument.getElementById('clearallcheckboxes').style["display"] = "block";
  3718.  
  3719. }
  3720. if(nextafter>0 && gameStartTimeStamp+nextafter*1000<=now && Gdocument.getElementById("gamerenderer").style["visibility"] != "hidden" && dontswitch == false && Gdocument.getElementById("ingamewinner").style["visibility"]!="inherit"){
  3721. roundsperqp2 = 0;
  3722. if(shuffle){
  3723. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  3724. var available = [];
  3725. var availableindexes = [];
  3726. var notempty = false;
  3727. for(var i = 0; i<e.length;i++){
  3728. var a = false;
  3729. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  3730. available.push(a);
  3731. if(a){
  3732. availableindexes.push(i);
  3733. notempty = true;
  3734. }
  3735. }
  3736. if(notempty){
  3737. if(availableindexes.length!=1){
  3738. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  3739. }
  3740. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  3741. }
  3742. }
  3743. else{
  3744. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  3745. var available = [];
  3746. var availableindexes = [];
  3747. var notempty = false;
  3748. for(var i = 0; i<e.length;i++){
  3749. var a = false;
  3750. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  3751. available.push(a);
  3752. if(a){
  3753. availableindexes.push(i);
  3754. notempty = true;
  3755. }
  3756. }
  3757. if(notempty){
  3758. var above = [];
  3759. for(var i = 0;i<availableindexes.length;i++){
  3760. if(availableindexes[i]>quicki){
  3761. above.push(availableindexes[i]);
  3762. }
  3763. }
  3764. if(above.length>0){
  3765. quicki = above[0];
  3766. }
  3767. else{
  3768. quicki = availableindexes[0];
  3769. }
  3770. }
  3771. }
  3772. startedinqp = true;
  3773. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  3774. }
  3775. if(Gdocument.getElementById("ingamewinner").style["visibility"]=="inherit" && dontswitch == false && !document.hidden){
  3776. if(roundsperqp2>=roundsperqp){
  3777. if(shuffle){
  3778. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  3779. var available = [];
  3780. var availableindexes = [];
  3781. var notempty = false;
  3782. for(var i = 0; i<e.length;i++){
  3783. var a = false;
  3784. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  3785. available.push(a);
  3786. if(a){
  3787. availableindexes.push(i);
  3788. notempty = true;
  3789. }
  3790. }
  3791. if(notempty){
  3792.  
  3793. if(availableindexes.length!=1){
  3794. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  3795. }
  3796. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  3797. }
  3798. }
  3799. else{
  3800. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  3801. var available = [];
  3802. var availableindexes = [];
  3803. var notempty = false;
  3804. for(var i = 0; i<e.length;i++){
  3805. var a = false;
  3806. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  3807. available.push(a);
  3808. if(a){
  3809. availableindexes.push(i);
  3810. notempty = true;
  3811. }
  3812. }
  3813. if(notempty){
  3814. var above = [];
  3815. for(var i = 0;i<availableindexes.length;i++){
  3816. if(availableindexes[i]>quicki){
  3817. above.push(availableindexes[i]);
  3818. }
  3819. }
  3820. if(above.length>0){
  3821. quicki = above[0];
  3822. }
  3823. else{
  3824. quicki = availableindexes[0];
  3825. }
  3826. }
  3827. }
  3828. }
  3829. transitioning = true;
  3830. startedinqp = true;
  3831. map(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  3832. dontswitch = true;
  3833. setTimeout(function(){Gdocument.getElementById("ingamewinner").style["visibility"]="hidden"; dontswitch = false;},timedelay);
  3834. }
  3835. }
  3836. else{
  3837. if(!checkboxhidden){
  3838. checkboxhidden = true;
  3839. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  3840. for(var i = 0; i<classes.length;i++){
  3841. classes[i].style["display"] = "none";
  3842. classes[i].className = "quickplaycheckbox quickplayunchecked";
  3843. }
  3844. Gdocument.getElementById('clearallcheckboxes').style["display"] = "none";
  3845. }
  3846. }
  3847. new_message = false;
  3848. };
  3849. });