Bonk Commands

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

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

  1. // ==UserScript==
  2. // @name Bonk Commands
  3. // @namespace https://greasyfork.org/en/scripts/451341-bonk-commands
  4. // @version 12.1
  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. myid = 0;
  1385. hostid = 0;
  1386. }
  1387. if(args.startsWith('42[23,') && recteams){
  1388. var jsonargs = JSON.parse(args.substring(2));
  1389. var map = decodeFromDatabase(jsonargs[1]["m"]);
  1390. var spawns = map["spawns"];
  1391. var teamsneeded = true;
  1392. var excludedindexes = [];
  1393. var ffaspawns = false;
  1394. var ffaforsure = false;
  1395. for(var i = 0; i<spawns.length;i++){
  1396. var currentSpawn = spawns[i];
  1397. if(Math.sqrt(currentSpawn.x**2 + currentSpawn.y**2)>=850 || currentSpawn.y>250){
  1398. excludedindexes.push(i);
  1399. }
  1400. else if(!(currentSpawn.f || currentSpawn.r || currentSpawn.b || currentSpawn.gr || currentSpawn.ye)){
  1401. excludedindexes.push(i);
  1402. }
  1403. else if(currentSpawn.f){
  1404. ffaspawns = true;
  1405. if(!(currentSpawn.r || currentSpawn.b || currentSpawn.gr || currentSpawn.ye)){
  1406. excludedindexes.push(i);
  1407. ffaforsure = true
  1408. }
  1409. }
  1410. }
  1411. if(!ffaspawns && !ffaforsure){
  1412. teamsneeded = true;
  1413. }
  1414. else{
  1415. teamsneeded = false;
  1416. }
  1417. if(teamsneeded){
  1418. var newspawns = [];
  1419. for(var i = 0; i<spawns.length;i++){
  1420. if(!excludedindexes.includes(i)){
  1421. 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"]});
  1422. }
  1423. }
  1424. if(newspawns.length>0){
  1425. var teamletters = ["r","g","b","y"];
  1426. var ratios = {"r":0,"g":0,"b":0,"y":0};
  1427. for(var i = 0; i < newspawns.length;i++){
  1428. for(var i2 = 0; i2<teamletters.length;i2++){
  1429. var ct = teamletters[i2];
  1430. if(newspawns[i]["priority"]!=0){
  1431. ratios[ct]+=(newspawns[i][ct])/newspawns[i]["total"]*newspawns[i]["priority"];
  1432. }
  1433. }
  1434. }
  1435. var highest = ["",0];
  1436. for(var i = 0; i<teamletters.length;i++){
  1437. var ct = teamletters[i];
  1438. if(ratios[ct]>0 && highest[1]<ratios[ct]){
  1439. highest = [ct,ratios[ct]];
  1440. }
  1441. }
  1442. if(highest[0]!=""){
  1443. for(var i = 0; i<teamletters.length;i++){
  1444. var ct = teamletters[i];
  1445. ratios[ct] = ratios[ct]/highest[1];
  1446. }
  1447. }
  1448. var playerids3 = Object.keys(playerids);
  1449. var playerids2 = [];
  1450. for(var i = 0; i<playerids3.length;i++){
  1451. if(playerids[playerids3[i]].team>0){
  1452. playerids2.push(playerids3[i]);
  1453. }
  1454. }
  1455. var pi2l = playerids2.length;
  1456. var ratios2 = {"r":0,"r1":0,"g":0,"g1":0,"b":0,"b1":0,"y":0,"y1":0};
  1457. var items = Object.entries(ratios);
  1458. items.sort(function(a,b){return a[1]-b[1];});
  1459. var items = items.map(function(e){return e[0];});
  1460. var highest2 = ["",0];
  1461. while(pi2l>0){
  1462. var done = false;
  1463. for(var i2 = 0; i2<items.length;i2++){
  1464. var ci = items[i2];
  1465. var ci2 = items[i2]+"1";
  1466. for(var i = 0; i<teamletters.length;i++){
  1467. var ct = teamletters[i];
  1468. if(ratios2[ct]>0 && highest2[1]<ratios2[ct]){
  1469. highest2 = [ct,ratios2[ct]];
  1470. }
  1471. }
  1472. if(highest2[0]!=""){
  1473. for(var i = 0; i<teamletters.length;i++){
  1474. var ct = teamletters[i];
  1475. ratios2[ct+"1"] = ratios2[ct]/highest2[1];
  1476. }
  1477. }
  1478. if(ratios[ci]>0 && ratios[ci]>=ratios2[ci2] && pi2l>0){
  1479. ratios2[ci]+=1;
  1480. pi2l--;
  1481. done = true;
  1482. }
  1483. }
  1484. if(pi2l>0 && !done){
  1485. ratios2[highest2[0]]+=1;
  1486. pi2l--;
  1487. }
  1488. }
  1489. SEND('42[32,{"t":true}]');
  1490. RECIEVE('42[39,true]');
  1491. for(var i = 0; i<ratios2["r"];i++){
  1492. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  1493. SEND('42[26,{"targetID":'+pid+',"targetTeam":2}]');
  1494. RECIEVE('42[18,'+pid+',2]');
  1495. }
  1496. for(var i = 0; i<ratios2["g"];i++){
  1497. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  1498. SEND('42[26,{"targetID":'+pid+',"targetTeam":4}]');
  1499. RECIEVE('42[18,'+pid+',4]');
  1500. }
  1501. for(var i = 0; i<ratios2["b"];i++){
  1502. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  1503. SEND('42[26,{"targetID":'+pid+',"targetTeam":3}]');
  1504. RECIEVE('42[18,'+pid+',3]');
  1505. }
  1506. for(var i = 0; i<ratios2["y"];i++){
  1507. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  1508. SEND('42[26,{"targetID":'+pid+',"targetTeam":5}]');
  1509. RECIEVE('42[18,'+pid+',5]');
  1510. }
  1511. }
  1512. }
  1513. else{
  1514. SEND('42[32,{"t":false}]');
  1515. RECIEVE('42[39,false]');
  1516. }
  1517. }
  1518.  
  1519. if(args.startsWith('42[47,') && stopquickplay == 0 && ishost && document.hidden){
  1520. if(roundsperqp2>=roundsperqp){
  1521. if(shuffle){
  1522. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  1523. var available = [];
  1524. var availableindexes = [];
  1525. var notempty = false;
  1526. for(var i = 0; i<e2.length;i++){
  1527. var a = false;
  1528. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  1529. available.push(a);
  1530. if(a){
  1531. availableindexes.push(i);
  1532. notempty = true;
  1533. }
  1534. }
  1535. if(notempty){
  1536.  
  1537. if(availableindexes.length!=1){
  1538. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  1539. }
  1540. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  1541. }
  1542. }
  1543. else{
  1544. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  1545. var available = [];
  1546. var availableindexes = [];
  1547. var notempty = false;
  1548. for(var i = 0; i<e2.length;i++){
  1549. var a = false;
  1550. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  1551. available.push(a);
  1552. if(a){
  1553. availableindexes.push(i);
  1554. notempty = true;
  1555. }
  1556. }
  1557. if(notempty){
  1558. var above = [];
  1559. for(var i = 0;i<availableindexes.length;i++){
  1560. if(availableindexes[i]>quicki){
  1561. above.push(availableindexes[i]);
  1562. }
  1563. }
  1564. if(above.length>0){
  1565. quicki = above[0];
  1566. }
  1567. else{
  1568. quicki = availableindexes[0];
  1569. }
  1570. }
  1571. }
  1572. }
  1573. canceled = false;
  1574. startedinqp = true;
  1575. window.map(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length),0);
  1576. }
  1577.  
  1578. if(args.startsWith('42[5,')){
  1579. var jsonargs = JSON.parse(args.substring(2));
  1580. if(stopquickplay!=1 && startedinqp){
  1581. startedinqp = false;
  1582. jsonargs[1]["gs"]["wl"] = 999;
  1583. if(!instaqp){
  1584. var jsonargs2 = decodeIS(jsonargs[1]["is"]);
  1585. jsonargs2["ftu"] = 60;
  1586. if(jsonargs2["mm"]["rxa"] != ""){
  1587. jsonargs2["mm"]["a"] = jsonargs2["mm"]["rxa"];
  1588. jsonargs2["mm"]["n"] = jsonargs2["mm"]["rxn"];
  1589. }
  1590. jsonargs2 = encodeIS(jsonargs2);
  1591. jsonargs[1]["is"] = jsonargs2;
  1592. var jsonargs3 = decodeFromDatabase(jsonargs[1]["gs"]["map"]);
  1593. if(jsonargs3["m"]["rxa"] != ""){
  1594. jsonargs3["m"]["a"] = jsonargs3["m"]["rxa"];
  1595. jsonargs3["m"]["n"] = jsonargs3["m"]["rxn"];
  1596. }
  1597.  
  1598. jsonargs3 = encodeToDatabase(jsonargs3);
  1599. jsonargs[1]["gs"]["map"] = jsonargs3;
  1600. }
  1601. }
  1602.  
  1603. args = "42"+JSON.stringify(jsonargs);
  1604. }
  1605. }
  1606.  
  1607. }
  1608. else{
  1609. this.onmessage = function(args){return;};
  1610. return;
  1611.  
  1612. }
  1613. if(this.url.includes(".bonk.io/socket.io/?EIO=3&transport=websocket&sid=") && !this.injected){
  1614. this.injected = true;
  1615.  
  1616. var originalRecieve = this.onmessage;
  1617. this.onmessage = function(args){
  1618. wssrecievelog.push(args.data);
  1619. wsssendrecievelog.push([1,args.data]);
  1620. if(typeof(args.data)=="string"){
  1621. args.data = RECIEVEFUNCTION(args.data);
  1622. if(args.data.startsWith('42[1,')){
  1623. var jsonargs = JSON.parse(args.data.substring(2));
  1624. originalSend.call(this,'42[1,{"id":'+jsonargs[2]+'}]');
  1625. }
  1626. if(args.data.startsWith('42[24,')){
  1627. beenKickedTimeStamp = Date.now();
  1628. onlykicked = JSON.parse(args.data.substring(2))[2];
  1629. }
  1630. if(args.data.startsWith('42[6,')){
  1631. var jsonargs = JSON.parse(args.data.substring(2));
  1632. if(typeof(playerids[jsonargs[1]])!='undefined'){
  1633. delplayerids[jsonargs[1]] = playerids[jsonargs[1]];
  1634. delete playerids[jsonargs[1]];
  1635. }
  1636. hostid = jsonargs[2];
  1637. }
  1638. if(args.data.startsWith('42[41,')){
  1639. var jsonargs = JSON.parse(args.data.substring(2));
  1640. hostid = jsonargs[1]["newHost"];
  1641. }
  1642. if(args.data.startsWith('42[20,')){
  1643. var jsonargs = JSON.parse(args.data.substring(2));
  1644. if(echo_list.includes(playerids[jsonargs[1]].userName)){
  1645. chat(flag_manage(echotext.replaceAll("username",playerids[jsonargs[1]].userName).replaceAll("message",jsonargs[2])));
  1646. }
  1647. }
  1648. if(args.data.startsWith('42[32')){
  1649. SEND('42[4,{"type":"inactive kick counter"}]');
  1650. }
  1651. if(args.data.startsWith('42[18')){
  1652. var jsonargs = JSON.parse(args.data.substring(2));
  1653. playerids[jsonargs[1]].team = jsonargs[2];
  1654. }
  1655. if(args.data.startsWith('42[40,')){
  1656. recordedTimeStamp = Date.now();
  1657. recordedId = JSON.parse(args.data.substring(2))[1];
  1658. }
  1659. if(args.data.startsWith('42[3,')){
  1660. var jsonargs = JSON.parse(args.data.substring(2));
  1661. for(var i = 0; i<jsonargs[3].length;i++){
  1662. if(jsonargs[3][i]!=null){
  1663. playerids[i.toString()] = jsonargs[3][i];
  1664. playerids[i.toString()].ratelimit = {"pm":0,"mode":0,"team":0};
  1665. }
  1666. }
  1667. myid = jsonargs[1];
  1668. hostid = jsonargs[2];
  1669. }
  1670. if(args.data.startsWith('42[15,')){
  1671. var jsonargs = JSON.parse(args.data.substring(2));
  1672. gameStartTimeStamp = jsonargs[1];
  1673. killedids = [];
  1674. }
  1675. if(args.data.startsWith('42[33,')){
  1676. var jsonargs = JSON.parse(args.data.substring(2));
  1677. var decodedmap = decodeFromDatabase(jsonargs[1]);
  1678. if(decodedmap!=0){
  1679. requestedmaps.push([decodedmap,jsonargs[1]]);
  1680. }
  1681. }
  1682. if(args.data.startsWith('42[7,')){
  1683. var jsonargs2 = JSON.parse(args.data.substring(2));
  1684. var idofpacket = jsonargs2[1];
  1685. jsonargs = jsonargs2[2];
  1686. if(typeof(jsonargs["i"]) == "undefined"){
  1687. if(jsonargs["type"]=="private chat" && jsonargs["to"] == username){
  1688. from = jsonargs["from"];
  1689. if(Object.keys(playerids).includes(idofpacket.toString())){
  1690. from = playerids[idofpacket].userName;
  1691. }
  1692. if(!ignorepmlist.includes(from)){
  1693. if(typeof(jsonargs["message"])=="object" && typeof(jsonargs["password"]) == "object"){
  1694. if(public_key[0]==jsonargs["public key"][0] && public_key[1]==jsonargs["public key"][1]){
  1695. var now = Date.now();
  1696. if(jsonargs["password"].length<=25 && playerids[idofpacket].ratelimit.pm+250<now){
  1697. playerids[idofpacket].ratelimit.pm = now;
  1698. var password = CRYPT_MESSAGE(private_key,jsonargs["password"]);
  1699. var decodedtext = jsonargs["message"].slice(0,400);
  1700. var encodedtext = "";
  1701. for(var i=0;i<decodedtext.length;i++){
  1702. if(password[i%password.length]<1000){
  1703. encodedtext+=String.fromCharCode(password[i%password.length]^decodedtext[i]);
  1704. }
  1705. }
  1706. 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);';
  1707. displayInChat('> '+'<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+from+'</a>'+': ',"#DA0808","#1EBCC1",{sanitize:false},encodedtext);
  1708.  
  1709. Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true;
  1710. Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true;
  1711. Laster_message = lastmessage();
  1712. }
  1713. }
  1714. else{
  1715. SEND("42"+JSON.stringify([4,{"type":"public key correction","from":username,"to":private_chat_public_key[0],"public key":public_key}]));
  1716. }
  1717. }
  1718. }
  1719. }
  1720. if(jsonargs["type"]=="request public key" && jsonargs["to"] == username){
  1721. SEND("42"+JSON.stringify([4,{"type":"public key","from":username,"public key":public_key}]));
  1722. }
  1723. if(jsonargs["type"]=="private chat users" && pmuserstimestamp+1500>Date.now()){
  1724. if(typeof(jsonargs["from"])!='undefined'){
  1725. from = jsonargs["from"];
  1726. if(Object.keys(playerids).includes(idofpacket.toString())){
  1727. from = playerids[idofpacket].userName;
  1728. }
  1729. if(!pmusers.includes(from) && username == jsonargs["to"]){
  1730. pmusers.push(from);
  1731. }
  1732. }
  1733. }
  1734. if(jsonargs["type"]=="request private chat users"){
  1735. if(typeof(jsonargs["from"])!='undefined'){
  1736. from = jsonargs["from"];
  1737. if(Object.keys(playerids).includes(idofpacket.toString())){
  1738. from = playerids[idofpacket].userName;
  1739. }
  1740. SEND("42"+JSON.stringify([4,{"type":"private chat users","from":username,"to":from}]));
  1741. }
  1742. }
  1743. if(jsonargs["type"]=="public key" && request_public_key_time_stamp+1500>Date.now()){
  1744. from = jsonargs["from"];
  1745. if(Object.keys(playerids).includes(idofpacket.toString())){
  1746. from = playerids[idofpacket].userName;
  1747. }
  1748. if(from == private_chat){
  1749. private_chat_public_key = [private_chat,jsonargs["public key"]];
  1750. displayInChat("Private chatting with "+private_chat+".","#DA0808","#1EBCC1");
  1751. }
  1752.  
  1753. }
  1754. if(jsonargs["type"]=="request mode" && playerids[idofpacket].ratelimit.mode+500<Date.now()){
  1755. playerids[idofpacket].ratelimit.mode = Date.now();
  1756. from = jsonargs["from"];
  1757. if(Object.keys(playerids).includes(idofpacket.toString())){
  1758. from = playerids[idofpacket].userName;
  1759. }
  1760. var req_mode = jsonargs["mode"];
  1761. var req_mode2 = "";
  1762. if(req_mode){
  1763. if(req_mode == "b"){
  1764. req_mode2 = "Classic";
  1765. }
  1766. else if(req_mode == "sp"){
  1767. req_mode2 = "Grapple";
  1768. }
  1769. else if(req_mode == "ar"){
  1770. req_mode2 = "Arrows";
  1771. }
  1772. else if(req_mode == "ard"){
  1773. req_mode2 = "Death Arrows";
  1774. }
  1775. }
  1776. if(req_mode2){
  1777. 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+'")}';
  1778. displayInChat('> '+playerids[idofpacket].userName+' requests [<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+req_mode2+'</a>]',"#DA0808","#1EBCC1",{sanitize:false}," mode.");
  1779. }
  1780.  
  1781. }
  1782. if(jsonargs["type"]=="public key correction" && private_chat_public_key[0] == private_chat){
  1783. from = jsonargs["from"];
  1784. if(Object.keys(playerids).includes(idofpacket.toString())){
  1785. from = playerids[idofpacket].userName;
  1786. }
  1787. if(from == private_chat){
  1788. private_chat_public_key = [private_chat,jsonargs["public key"]];
  1789. var text = pmlastmessage;
  1790. var password = [];
  1791. for(var i = 0;i<10;i++){
  1792. password.push(Math.floor(Math.random()*100+50));
  1793. }
  1794. var text2 = [];
  1795. for(var i = 0;i<text.length ;i++){
  1796. text2.push(password[i%password.length]^text.slice(0,400).charCodeAt(i));
  1797. }
  1798. 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)}]));
  1799. }
  1800. }
  1801.  
  1802. }
  1803. else{
  1804. var now = Date.now();
  1805. if(playerids[idofpacket.toString()]){
  1806. playerids[idofpacket.toString()].lastmove = now;
  1807. }
  1808. if(ishost){
  1809. for(var i = 0;i<disabledkeys.length;i++){
  1810. var get_keys_var = GET_KEYS(jsonargs["i"]);
  1811. if(get_keys_var[disabledkeys[i]]){
  1812. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden" && !killedids.includes(idofpacket)){
  1813. killedids.push(idofpacket);
  1814. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  1815. SEND('42[25,{"a":{"playersLeft":['+idofpacket.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  1816. RECIEVE('42[31,{"a":{"playersLeft":['+idofpacket.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  1817. break;
  1818. }
  1819. }
  1820. }
  1821. }
  1822. }
  1823. }
  1824.  
  1825. if(args.data.startsWith('42[4,')){
  1826. var jsonargs = JSON.parse(args.data.substring(2));
  1827. if(ishost){
  1828. if(jointext!=""){
  1829. chat(flag_manage(jointext.replaceAll("username",jsonargs[3])));
  1830. }
  1831. if(freejoin){
  1832. var count = 0;
  1833. var keys = Object.keys(playerids);
  1834. for(var i = 0; i<keys.length;i++){
  1835. if(playerids[keys[i]].team!=0){
  1836. count++;
  1837. }
  1838. }
  1839. if(count <= 1 && jsonargs[6]!=0){
  1840. setTimeout(function(){
  1841. Gdocument.getElementById("newbonklobby_editorbutton").click();
  1842. Gdocument.getElementById("mapeditor_close").click();
  1843. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  1844. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  1845. if(transitioning == true){
  1846. canceled = true;
  1847. }
  1848. },0);
  1849. }
  1850. }
  1851. }
  1852. 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}};
  1853.  
  1854. }
  1855. if(args.data.startsWith('42[5,')){
  1856. var jsonargs = JSON.parse(args.data.substring(2));
  1857. if(typeof(playerids[jsonargs[1]])!='undefined'){
  1858. delplayerids[jsonargs[1]] = playerids[jsonargs[1]];
  1859. delete playerids[jsonargs[1]];
  1860. }
  1861. }
  1862. }
  1863. return originalRecieve.call(this,args);
  1864. };
  1865.  
  1866. var originalClose = this.onclose;
  1867. this.onclose = function () {
  1868. window.bonkwss = 0;
  1869. return originalClose.call(this);
  1870. }
  1871.  
  1872. }
  1873. return originalSend.call(this,args);
  1874. };
  1875.  
  1876. scope.SEND = function(args){
  1877. if(bonkwss!=0){
  1878. bonkwss.send(args);
  1879. }
  1880. };
  1881. scope.RECIEVE = function(args){
  1882. if(bonkwss!=0){
  1883. bonkwss.onmessage({data:args});
  1884. }
  1885. };
  1886.  
  1887.  
  1888.  
  1889. scope.dontswitch = false;
  1890. scope.username = 0;
  1891. scope.timedelay = 1400;
  1892. scope.ishost = false;
  1893. scope.checkboxhidden = true;
  1894. scope.quicki=0;
  1895. scope.defaultmode = "d";
  1896. scope.recmodebool = false;
  1897. scope.shuffle = false;
  1898. scope.startedinqp = false;
  1899. scope.instaqp = false;
  1900. scope.freejoin = false;
  1901. scope.recordedTimeStamp = 0;
  1902. scope.recordedId = 0;
  1903. scope.smartteams = false;
  1904. scope.beenKickedTimeStamp = 0;
  1905. scope.stopquickplay = 1;
  1906. scope.currentFrame = 0;
  1907. scope.text2speech = false;
  1908. scope.gameStartTimeStamp = 0;
  1909. scope.canceled = false;
  1910. scope.wintext = "";
  1911. scope.banned = [];
  1912. scope.transitioning = false;
  1913. scope.echo_list = [];
  1914. scope.echoAppend = "";
  1915. scope.message = "";
  1916. scope.mode = "";
  1917. scope.private_chat = "";
  1918. scope.private_chat_public_key = ["",[0,0]];
  1919. scope.disabledkeys = [];
  1920. scope.actuallyhost = false;
  1921. scope.pmusers = [];
  1922. scope.pmlastmessage = "";
  1923. scope.pmuserstimestamp = 0;
  1924. scope.ignorepmlist = [];
  1925. scope.scroll = false;
  1926. scope.elem = Gdocument.getElementById("maploadwindowmapscontainer");
  1927. scope.npermissions = 1;
  1928. scope.space_flag = false;
  1929. scope.rcaps_flag = false;
  1930. scope.number_flag = false;
  1931. scope.reverse_flag = false;
  1932. scope.request_public_key_time_stamp = 0;
  1933. scope.sandboxcopyme = false;
  1934. scope.recteams = false;
  1935. scope.chatheight = 128;
  1936. scope.onlykicked = false;
  1937. scope.killedids = [];
  1938. scope.jointext = "";
  1939. scope.afkkill = -1;
  1940. scope.tournament_mode = "";
  1941. scope.tournament_scores = [];
  1942. scope.tournament_in_and_out = {"in":[],"out":[]};
  1943. scope.echotext = "message";
  1944. scope.nextafter = 0;
  1945. scope.roundsperqp = 1;
  1946. scope.roundsperqp2 = 0;
  1947. scope.autorecord = false;
  1948. 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"];
  1949.  
  1950. scope.adv_help = {"help":"Shows all command names.",
  1951. "?":"Shows all command names.",
  1952. "advhelp":"Shows a command in detail.",
  1953. "space":"Toggles space. When space is on, whatever you type will be spaced apart.",
  1954. "rcaps":"Toggles rcaps. When rcaps is on, each letter will randomly get capitalized.",
  1955. "number":"Toggles number. When number is on, 'a' becomes 4, 'e' becomes 3, 's' becomes 5, 'o' becomes 0, 'l' and 'i' become 1.",
  1956. "speech":"Turns on text to speech for the chat.",
  1957. "echo":"Echoes a username. It copies the username's chat messages.",
  1958. "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.",
  1959. "remove":"Removes username from echo list. You will not echo that username anymore.",
  1960. "clearecho":"Clears echo list. You will not echo anyone anymore.",
  1961. "chatw":"It private chats with username. Type /msg to message that username.",
  1962. "msg":"Messages with what username you are chatting with. Type /chatw to chat with a username.",
  1963. "ignorepm":"Ignores the username's private chat messages. To unignore, type /ignorepm [username].",
  1964. "pmusers":"Dispays who you can private chat with.",
  1965. "eval":"Evaluates code. Only use this if you are experienced in javascript.",
  1966. "debugger":"Opens debugger.",
  1967. "lobby":"Makes lobby visible when you are ingame. Type /lobby again to close lobby.",
  1968. "team":"Joins a specific team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  1969. "scroll":"Toggles a scrollbar in ingame chat.",
  1970. "hidechat":"Hides ingame chat. Type /showchat to show it again.",
  1971. "showchat":"Shows ingame chat. /hidechat hides the chat.",
  1972. "notify":"You will be notified if a person types @username",
  1973. "stopnotify":"You will not be notified if a person types @username",
  1974. "startqp":"Starts cycling maps in your map menu.",
  1975. "stopqp":"Stops cycling maps in your map menu.",
  1976. "next":"Skips the map. Usable only with /startqp.",
  1977. "nextafter":"Skips the map if no one is able to win/draw within a certain amount of time.",
  1978. "previous":"Goes to previous map. Usable only with /startqp.",
  1979. "shuffle":"Makes quickplay play random maps instead of in order.",
  1980. "freejoin":"Toggles freejoin. If freejoin is on, starts the game instantly if there are 1 or less players currently playing.",
  1981. "recmode":"In quickplay, it switches mode to recommended mode, according to editor.",
  1982. "recteam":"In quickplay, it sorts people into teams when teams are necessary.",
  1983. "defaultmode":"Switches mode to defaultmode if there is no recmode.",
  1984. "start":"Starts game instantly.",
  1985. "instaqp":"Rounds will instantly start without a countdown.",
  1986. "balanceA":"Balances everyone with balance number.",
  1987. "moveA":"Sets everyones team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  1988. "rounds":"Sets rounds to win.",
  1989. "roundsperqp":"After that many rounds, the map will change. Normally, the map will change after 1 round.",
  1990. "autorecord":"After a round ends, automatically records the last 15 seconds.",
  1991. "mode":"If host, switches mode. Otherwise, it requests the host to switch mode, as long as the host has this mod.",
  1992. "disablekeys":"If anyone presses a disabled key, they get killed. Key options: left right up down heavy special.",
  1993. "jointext":"Chats the jointext whenever someone joins. \"username\" will get replaced by the joining person's username.",
  1994. "wintext":"Chats the wintext whenever someone wins. \"username\" will get replaced by the winning person's username.",
  1995. "afkkill":"If a person stays afk for that many seconds, they get automatically killed.",
  1996. "ban":"Bans username from lobby. If they rejoin, it automatically bans.",
  1997. "kill":"Kills the person ingame.",
  1998. "addplayer":"In sandbox, it adds players.",
  1999. "delplayer":"In sandbox, it deletes players.",
  2000. "copyme":"In sandbox, it makes each player copy your movements.",
  2001. "Alt L":"Makes lobby visible when you are ingame. Press Alt L again to close lobby.",
  2002. "Alt C":"Hides ingame chat. Press Alt C again to show ingame chat.",
  2003. "Alt S":"Starts game instantly.",
  2004. "Alt T":"Toggles teams.",
  2005. "Alt E":"Toggles editor.",
  2006. "Alt K":"Exits ingame and returns to lobby.",
  2007. "Alt M":"Switches modes.",
  2008. "Alt Q":"Toggles quickplay.",
  2009. "Alt A":"Skips the map if quickplay is on.",
  2010. "Alt D":"Goes to previous map if quickplay is on.",
  2011. "Alt F":"Toggles freejoin. If freejoin is on, starts the game instantly if there are 1 or less players currently playing.",
  2012. "Alt R":"In quickplay, it switches mode to recommended mode, according to editor.",
  2013. "Alt I":"Opens debugger.",
  2014. "Alt <":"Lowers ingame chat height.",
  2015. "Alt >":"Highers ingame chat height."
  2016. };
  2017. scope.displayadvhelp = function(command){
  2018. displayInChat(adv_help[command],"#009398","#DA0808",{sanitize:true},"",true);
  2019. };
  2020. scope.changemode = function(mode){
  2021. SEND('42[20,{"ga":"b","mo":"'+mode+'"}]');
  2022. RECIEVE('42[26,"b","'+mode+'"]');
  2023. };
  2024. Gdocument.getElementById("ingamechatcontent").style["pointer-events"]="all";
  2025. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  2026. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  2027. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  2028.  
  2029. document.getElementById('adboxverticalCurse').style["display"] = "none";
  2030. document.getElementById('adboxverticalleftCurse').style["display"] = "none";
  2031. elem.onclick=function(e){
  2032. if(stopquickplay==0 && ishost == true && e.isTrusted == true){
  2033. quicki = (Array.from(e.target.parentElement.parentNode.children).indexOf(e.target.parentNode)-1)%(Gdocument.getElementById("maploadwindowmapscontainer").children.length);
  2034. }
  2035. };
  2036. scope.urlify = function(text) {
  2037. return text.replace(/(?:https?:\/\/)?(?:[A-Za-z0-9-ßàÁâãóôþüúðæåïçèõöÿýòäœêëìíøùîûñé]+)(?:\.[A-Za-z0-9-ßàÁâãóôþüúðæåïçèõöÿýòäœêëìíøùîûñé]+)+(?:\/(?:[A-Za-z0-9-._~:/?#\[\]@!$&'()*+,;=]|%[0-9a-fA-F]{2})*)?(?:\?(?:[^=]+=[^&](?:&[^=]+=[^&])*)?)?/g, function(url) {
  2038. if(url.startsWith('https://') || url.startsWith('http://')){return '<a href="' + url + '" target="_blank" style = "color:orange">' + url + '</a>';}
  2039. else{return '<a href="https://' + url + '" target="_blank" style = "color:orange">' + url + '</a>';}
  2040. })
  2041. };
  2042.  
  2043. scope.fire = function(type,options,d = Gdocument){
  2044. var event= document.createEvent("HTMLEvents");
  2045. event.initEvent(type,true,false);
  2046. for(var p in options){
  2047. event[p]=options[p];
  2048. }
  2049. d.dispatchEvent(event);
  2050. };
  2051.  
  2052. scope.chat = function(message){
  2053. mess = Gdocument.getElementById("newbonklobby_chat_input").value;
  2054. mess2 = Gdocument.getElementById("ingamechatinputtext").value;
  2055. Gdocument.getElementById("newbonklobby_chat_input").value = message;
  2056. Gdocument.getElementById("ingamechatinputtext").value = message;
  2057. fire("keydown",{keyCode:13});
  2058. fire("keydown",{keyCode:13});
  2059. Gdocument.getElementById("newbonklobby_chat_input").value = mess;
  2060. Gdocument.getElementById("ingamechatinputtext").value = mess2;
  2061. };
  2062. scope.displayInChat = function(message, LobbyColor, InGameColor, options, message2, BringDown,urlifyon = urlify) {
  2063. options = options ?? {};
  2064. BringDown = BringDown ?? false;
  2065. message2 = message2 ?? "";
  2066. urlifyon = urlifyon ?? function(e){return e};
  2067. LobbyColor = LobbyColor ?? "#8800FF";
  2068. InGameColor = InGameColor ?? "#AA88FF";
  2069. let A = Gdocument.createElement("div");
  2070. let B = Gdocument.createElement("span");
  2071. B.className = "newbonklobby_chat_status";
  2072. B.style.color = LobbyColor;
  2073. A.appendChild(B);
  2074. B.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  2075. B.innerHTML+=urlify(message2.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;'));
  2076. let C = Gdocument.createElement("div");
  2077. let D = Gdocument.createElement("span");
  2078. D.style.color = InGameColor;
  2079. C.appendChild(D);
  2080. D.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  2081. D.innerHTML+=urlify(message2.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;'));
  2082. let a = BringDown;
  2083. if(Gdocument.getElementById("newbonklobby_chat_content").clientHeight + Gdocument.getElementById("newbonklobby_chat_content").scrollTop >= Gdocument.getElementById("newbonklobby_chat_content").scrollHeight-1) {
  2084. a = true;
  2085. }
  2086. A.style["parsed"] = true;
  2087. C.style["parsed"] = true;
  2088. Gdocument.getElementById("newbonklobby_chat_content").appendChild(A);
  2089. Gdocument.getElementById("ingamechatcontent").appendChild(C);
  2090. if (a) { Gdocument.getElementById("newbonklobby_chat_content").scrollTop = Number.MAX_SAFE_INTEGER;};
  2091. Gdocument.getElementById("ingamechatcontent").scrollTop = Number.MAX_SAFE_INTEGER;
  2092. chat("");
  2093. };
  2094.  
  2095. scope.lobby = function(){
  2096. if (Gdocument.getElementById("newbonklobby").style["display"]=="none"){
  2097.  
  2098. Gdocument.getElementById("newbonklobby_editorbutton").click();
  2099. Gdocument.getElementById("mapeditor_close").click();
  2100. if(Gdocument.getElementById("newbonklobby_playerbox_elementcontainer").children.length+Gdocument.getElementById("newbonklobby_specbox_elementcontainer").children.length-3>0){
  2101. Gdocument.getElementById("newbonklobby").style["z-index"]=1;
  2102. Gdocument.getElementById("maploadwindowcontainer").style["z-index"]=1;
  2103. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=1;
  2104. Gdocument.getElementById("pretty_top").style["z-index"]=3;
  2105. Gdocument.getElementById("settingsContainer").style["z-index"]=3;
  2106. Gdocument.getElementById("leaveconfirmwindow").style["z-index"]=3;
  2107. Gdocument.getElementById("hostleaveconfirmwindow").style["z-index"]=3;
  2108. debuggermenu.style["z-index"] = 2;
  2109. }
  2110. else{
  2111. Gdocument.getElementById("newbonklobby").style["opacity"]=0;
  2112. Gdocument.getElementById("newbonklobby").style["display"]="none";
  2113. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
  2114.  
  2115. }
  2116.  
  2117. }
  2118. else if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  2119. Gdocument.getElementById("newbonklobby").style["opacity"]=0;
  2120. Gdocument.getElementById("newbonklobby").style["display"]="none";
  2121. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
  2122.  
  2123. }
  2124. };
  2125.  
  2126. scope.lastmessage = function(){
  2127. if(Gdocument.getElementById("newbonklobby_chat_content").children.length!=0){
  2128. var lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  2129. var lm2 = "";
  2130. for(var i = 0; i<lm.length;i++){
  2131. lm2+=" "+lm[i].textContent.trim();
  2132. }
  2133. lm2 = lm2.trim();
  2134. if(lm2.startsWith("*")){
  2135. return lm2;
  2136. }
  2137. }
  2138. if(Gdocument.getElementById("ingamechatcontent").children.length!=0){
  2139. var lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  2140. var lm2 = "";
  2141. for(var i = 0; i<lm.length;i++){
  2142. lm2+=" "+lm[i].textContent.trim();
  2143. }
  2144. return lm2.trim();
  2145. }
  2146. return "";
  2147.  
  2148. };
  2149. scope.map = function(e,t=timedelay){
  2150. if(e<0){
  2151. displayInChat("There is no previous map.","#DA0808","#1EBCC1");
  2152. quicki = 0;
  2153. return;
  2154. }
  2155. if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
  2156. displayInChat("Click the maps button.","#DA0808","#1EBCC1");
  2157. return;
  2158. }
  2159.  
  2160. setTimeout(function(){if(!canceled){
  2161. startedinqp = true;
  2162. if(roundsperqp2>=roundsperqp){
  2163. roundsperqp2 = 0;
  2164. }
  2165. gameStartTimeStamp = Date.now();
  2166. Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
  2167. Gdocument.getElementById("newbonklobby_editorbutton").click();
  2168. if(recmodebool && ishost){
  2169. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  2170. if(mode == "" && defaultmode!="d"){
  2171. mode = defaultmode;
  2172. }
  2173. if(mode != ""){
  2174. RECIEVE('42[26,"b","'+mode+'"]');
  2175. }
  2176. }
  2177. var displayblock = Gdocument.getElementById("newbonklobby").style["display"] == "block";
  2178. Gdocument.getElementById("mapeditorcontainer").style["display"] = "none";
  2179. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  2180. if(displayblock){
  2181. Gdocument.getElementById("newbonklobby").style["display"] = "block";
  2182. }
  2183. Gdocument.getElementById("mapeditor_midbox_testbutton").click();}
  2184. canceled = false;
  2185. transitioning = false;
  2186. },t);
  2187.  
  2188. };
  2189.  
  2190. scope.gotonextmap = function(e){
  2191. if(e<0){
  2192. displayInChat("There is no previous map.","#DA0808","#1EBCC1");
  2193. quicki = 0;
  2194. return;
  2195. }
  2196. if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
  2197. displayInChat("Click the maps button.","#DA0808","#1EBCC1");
  2198. return;
  2199. }
  2200. Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
  2201. Gdocument.getElementById("newbonklobby_editorbutton").click();
  2202. if(recmodebool && ishost){
  2203. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  2204. if(mode == "" && defaultmode!="d"){
  2205. mode = defaultmode;
  2206. }
  2207. if(mode != ""){
  2208. RECIEVE('42[26,"b","'+mode+'"]');
  2209. }
  2210. }
  2211. startedinqp = true;
  2212. if(roundsperqp2>=roundsperqp){
  2213. roundsperqp2 = 0;
  2214. }
  2215. gameStartTimeStamp = Date.now();
  2216. var displayblock = Gdocument.getElementById("newbonklobby").style["display"] == "block";
  2217. Gdocument.getElementById("mapeditorcontainer").style["display"] = "none";
  2218. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  2219. if(displayblock){
  2220. Gdocument.getElementById("newbonklobby").style["display"] = "block";
  2221. }
  2222. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  2223. Gdocument.getElementById("newbonklobby").style["visibility"] = "visible";
  2224. };
  2225. scope.commandhandle = function(chat_val){
  2226. if (chat_val.substring(1,6)=="echo " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  2227. if (chat_val.substring(6).replace(/^\s+|\s+$/g, '')==username){
  2228. displayInChat("You cannot echo yourself.","#DA0808","#1EBCC1");
  2229. return "";
  2230. }
  2231. else if (echo_list.indexOf(chat_val.substring(6).replace(/^\s+|\s+$/g, ''))===-1) {
  2232.  
  2233. echo_list.push(chat_val.substring(6).replace(/^\s+|\s+$/g, ''));
  2234. displayInChat(chat_val.substring(6).replace(/^\s+|\s+$/g, '') + " is being echoed.","#DA0808","#1EBCC1");
  2235. return "";
  2236. }
  2237. else{
  2238. displayInChat(chat_val.substring(6).replace(/^\s+|\s+$/g, '') + " is already being echoed.","#DA0808","#1EBCC1");
  2239. return "";
  2240. }
  2241. }
  2242. else if (chat_val.substring(1,8)=="remove " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  2243. if (echo_list.indexOf(chat_val.substring(7).replace(/^\s+|\s+$/g, ''))!==-1){
  2244. echo_list.splice(echo_list.indexOf(chat_val.substring(7).replace(/^\s+|\s+$/g, '')),1);
  2245. displayInChat(chat_val.substring(7).replace(/^\s+|\s+$/g, '')+" is not being echoed.","#DA0808","#1EBCC1");
  2246. return "";
  2247. }
  2248. else{
  2249. displayInChat("You cannot remove someone that you didn't echo.","#DA0808","#1EBCC1");
  2250. return "";
  2251. }
  2252.  
  2253. }
  2254. else if (chat_val.substring(1,10)=="echotext " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  2255. echotext = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  2256. displayInChat("Set echotext as: "+echotext,"#DA0808","#1EBCC1");
  2257. displayInChat("Type \"/echotext\" to reset echotext.","#DA0808","#1EBCC1");
  2258. return "";
  2259.  
  2260. }
  2261. else if (chat_val.substring(1,9)=="echotext"){
  2262. echotext = "message";
  2263. displayInChat("Reset echotext.","#DA0808","#1EBCC1");
  2264. return "";
  2265.  
  2266. }
  2267. else if (chat_val.substring(1,10)=="clearecho"){
  2268. echo_list = [];
  2269. displayInChat("Cleared the echo list.","#DA0808","#1EBCC1");
  2270. return "";
  2271. }
  2272. else if (chat_val.substring(1,6)=="space"){
  2273. if(space_flag == true){
  2274. displayInChat("Space is now off.","#DA0808","#1EBCC1");
  2275. space_flag = false;
  2276. }
  2277. else{
  2278. displayInChat("Space is now on.","#DA0808","#1EBCC1");
  2279. space_flag = true;
  2280. }
  2281. return "";
  2282. }
  2283. else if (chat_val.substring(1,6)=="rcaps"){
  2284. if(rcaps_flag == true){
  2285. displayInChat("Rcaps is now off.","#DA0808","#1EBCC1");
  2286. rcaps_flag = false;
  2287. }
  2288. else{
  2289. displayInChat("Rcaps is now on.","#DA0808","#1EBCC1");
  2290. rcaps_flag = true;
  2291. }
  2292.  
  2293. return "";
  2294. }
  2295. else if (chat_val.substring(1,7)=="number"){
  2296. if(number_flag == true){
  2297. displayInChat("Number is now off.","#DA0808","#1EBCC1");
  2298. number_flag = false;
  2299. }
  2300. else{
  2301. displayInChat("Number is now on.","#DA0808","#1EBCC1");
  2302. number_flag = true;
  2303. }
  2304.  
  2305. return "";
  2306. }
  2307. else if (chat_val.substring(1,8)=="reverse"){
  2308. if(reverse_flag == true){
  2309. displayInChat("Reverse is now off.","#DA0808","#1EBCC1");
  2310. reverse_flag = false;
  2311. }
  2312. else{
  2313. displayInChat("Reverse is now on.","#DA0808","#1EBCC1");
  2314. reverse_flag = true;
  2315. }
  2316.  
  2317. return "";
  2318. }
  2319. else if (chat_val.substring(1,7)=="speech"){
  2320. if(text2speech == true){
  2321. displayInChat("Text to speech is now off.","#DA0808","#1EBCC1");
  2322. text2speech = false;
  2323. }
  2324. else{
  2325. displayInChat("Text to speech is now on.","#DA0808","#1EBCC1");
  2326. text2speech = true;
  2327. }
  2328.  
  2329. return "";
  2330. }
  2331. else if (chat_val.substring(1,6)=="eval " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  2332. var ev = "";
  2333. try{
  2334. ev = eval(chat_val.substring(6).replace(/^\s+|\s+$/g, ''));
  2335. }
  2336. catch(e){
  2337. displayInChat(e.message,"#DA0808","#1EBCC1");
  2338. }
  2339. try{
  2340. displayInChat(ev.toString(),"#DA0808","#1EBCC1");
  2341. }
  2342. catch{
  2343. }
  2344.  
  2345. return "";
  2346.  
  2347. }
  2348.  
  2349. else if (chat_val.substring(1,9)=="hidechat"){
  2350. Gdocument.getElementById("ingamechatcontent").style["max-height"]="0px";
  2351. return "";
  2352. }
  2353. else if (chat_val.substring(1,9)=="showchat"){
  2354. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  2355. return "";
  2356. }
  2357.  
  2358. else if (chat_val.substring(1,7)=="scroll"){
  2359. if(scroll==false){
  2360. scroll = true;
  2361. Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="scroll";
  2362. Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
  2363. }
  2364. else if(scroll==true){
  2365. scroll = false;
  2366. Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="hidden";
  2367. Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
  2368. }
  2369.  
  2370. return "";
  2371. }
  2372.  
  2373. else if (chat_val.substring(1,7)=="chatw "){
  2374. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '');
  2375.  
  2376. if(username == text){
  2377. displayInChat("You cannot private chat with yourself.","#DA0808","#1EBCC1");
  2378. return "";
  2379. }
  2380. private_chat = text;
  2381.  
  2382. SEND("42"+JSON.stringify([4,{"type":"request public key","from":username,"to":private_chat}]));
  2383. request_public_key_time_stamp = Date.now();
  2384. 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);
  2385. return "";
  2386. }
  2387.  
  2388. else if (chat_val.substring(1,5)=="msg " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  2389. if(private_chat_public_key[1][0] != 0 && private_chat_public_key[1][1] != 0 && private_chat_public_key[0] == private_chat){
  2390. var text = chat_val.substring(5).replace(/^\s+|\s+$/g, '');
  2391. var password = [];
  2392. for(var i = 0;i<10;i++){
  2393. password.push(Math.floor(Math.random()*100+50));
  2394. }
  2395. var text2 = [];
  2396. for(var i = 0;i<text.slice(0,400).length ;i++){
  2397. text2.push(password[i%password.length]^text.slice(0,400).charCodeAt(i));
  2398. }
  2399. pmlastmessage = text.slice(0,400);
  2400. 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)}]));
  2401. displayInChat("> "+username+": ","#DA0808","#1EBCC1",{sanitize:false},text,false);
  2402. Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true;
  2403. Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true;
  2404. Laster_message = lastmessage();
  2405.  
  2406. }
  2407. return "";
  2408. }
  2409. else if (chat_val.substring(1,10)=="ignorepm " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  2410. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  2411. if(ignorepmlist.includes(text)){
  2412. var index = ignorepmlist.indexOf(text);
  2413. ignorepmlist.splice(index,1);
  2414. displayInChat("You are not ignoring private messages from "+text+".","#DA0808","#1EBCC1");
  2415.  
  2416. }
  2417. else{
  2418. ignorepmlist.push(text);
  2419. displayInChat("You are now ignoring private messages from "+text+".","#DA0808","#1EBCC1");
  2420. }
  2421. return "";
  2422. }
  2423. else if (chat_val.substring(1,8)=="pmusers"){
  2424. pmusers = [];
  2425. SEND("42"+JSON.stringify([4,{"type":"request private chat users","from":username}]));
  2426. pmuserstimestamp = Date.now();
  2427. setTimeout(function(){if(pmusers.length == 0){displayInChat("You cannot private chat with anyone.","#DA0808","#1EBCC1");
  2428. }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);
  2429. return "";
  2430. }
  2431. else if (chat_val.substring(1,6)=="lobby"){
  2432. lobby();
  2433. return "";
  2434. }
  2435. else if (chat_val.substring(1,9)=="debugger"){
  2436. if(Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"] == "none"){
  2437. debuggeropen = true;
  2438. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="block";
  2439. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="none";
  2440. Gdocument.getElementById("ingamechatinputtext").style["display"] = "none";
  2441. }
  2442. else{
  2443. debuggeropen = false;
  2444. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="none";
  2445. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  2446. Gdocument.getElementById("ingamechatinputtext").style["display"] = "";
  2447. }
  2448. return "";
  2449. }
  2450. else if (chat_val.substring(1,6)=="team " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  2451. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  2452. if(text == "r"){Gdocument.getElementById("newbonklobby_redbutton").click();}
  2453. else if(text == "g"){Gdocument.getElementById("newbonklobby_greenbutton").click();}
  2454. else if(text == "y"){Gdocument.getElementById("newbonklobby_yellowbutton").click();}
  2455. else if(text == "b"){Gdocument.getElementById("newbonklobby_bluebutton").click();}
  2456. else if(text == "s"){Gdocument.getElementById("newbonklobby_specbutton").click();}
  2457. else if(text == "f"){Gdocument.getElementById("newbonklobby_ffabutton").click();}
  2458. return "";
  2459. }
  2460. else if (chat_val.substring(1,7)=="notify"){
  2461.  
  2462. npermissions = 1;
  2463. return "";
  2464. }
  2465. else if (chat_val.substring(1,11)=="stopnotify"){
  2466.  
  2467. npermissions = 0;
  2468. return "";
  2469. }
  2470. else if (chat_val.substring(1,5)=="help" || chat_val.substring(1,2)=="?"){
  2471. for(var i = 0;i<help.length;i++){
  2472. if(help[i].startsWith("/")){
  2473. var splitted = help[i].substring(1).split(" ");
  2474. var command = splitted[0];
  2475. var rest = "";
  2476. if(splitted.length>1){
  2477. rest = " "+splitted.slice(1).join(" ");
  2478. }
  2479. displayInChat("/"+'<a onclick = \'Gwindow.displayadvhelp("'+command+'");\' style = "color:green;" href = "javascript:void(0);">'+command+'</a>'+rest,"#DA0808","#1EBCC1",{sanitize:false},"",false);
  2480. }
  2481. else if(help[i].startsWith("Alt ")){
  2482. displayInChat('<a onclick = \'Gwindow.displayadvhelp("'+help[i]+'");\' style = "color:green;" href = "javascript:void(0);">'+help[i]+'</a>',"#DA0808","#1EBCC1",{sanitize:false},"",false);
  2483. }
  2484. else{
  2485. displayInChat(help[i],"#DA0808","#1EBCC1");
  2486. }
  2487.  
  2488. }
  2489. return "";
  2490. }
  2491. else if (chat_val.substring(1,9)=="advhelp " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  2492. var text = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  2493. if(typeof(adv_help[text])!='undefined'){
  2494. displayInChat(adv_help[text],"#DA0808","#1EBCC1");
  2495. }
  2496. return "";
  2497. }
  2498. else if (chat_val.substring(1,6)=="mode " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  2499. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  2500. var mode = "";
  2501. var text2 = text;
  2502. if(text == "arrows"){
  2503. text2 = "Arrows";
  2504. mode = "ar";
  2505. }
  2506. else if(text == "death arrows"){
  2507. mode = "ard";
  2508. text2 = "Death Arrows";
  2509. }
  2510. else if(text == "grapple"){
  2511. mode = "sp";
  2512. text2 = "Grapple";
  2513. }
  2514. else if(text == "classic"){
  2515. mode = "b";
  2516. text2 = "Classic";
  2517. }
  2518. else{
  2519. displayInChat("Mode options:","#DA0808","#1EBCC1");
  2520. displayInChat("classic","#DA0808","#1EBCC1");
  2521. displayInChat("arrows","#DA0808","#1EBCC1");
  2522. displayInChat("death arrows","#DA0808","#1EBCC1");
  2523. displayInChat("grapple","#DA0808","#1EBCC1");
  2524. }
  2525. if(mode != ""){
  2526. if(ishost){
  2527. SEND('42[20,{"ga":"b","mo":"'+mode+'"}]');
  2528. RECIEVE('42[26,"b","'+mode+'"]');
  2529. displayInChat("Changed mode to "+text+".","#DA0808","#1EBCC1");
  2530. }
  2531. else{
  2532. if(playerids[myid].ratelimit.mode+500<Date.now()){
  2533. playerids[myid].ratelimit.mode=Date.now();
  2534. SEND("42"+JSON.stringify([4,{"type":"request mode","from":username,"mode":mode}]));
  2535. var code = 'if(!Gwindow.ishost){Gwindow.displayInChat("You must be host to change the mode.","#DA0808","#1EBCC1",{sanitize:false},"",true)}else{Gwindow.changemode("'+mode+'")}';
  2536. displayInChat('> '+username+' requests [<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+text2+'</a>]',"#DA0808","#1EBCC1",{sanitize:false}," mode.");
  2537.  
  2538. }
  2539. else{
  2540. displayInChat("You are requesting modes too quickly.","#DA0808","#1EBCC1");
  2541. }
  2542. }
  2543. }
  2544. return "";
  2545.  
  2546. }
  2547. else if(ishost){
  2548. if (chat_val.substring(1,11)=="nextafter " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  2549. text = parseFloat(chat_val.substring(11).replace(/^\s+|\s+$/g, ''));
  2550. if(isNaN(text)){
  2551. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  2552. return "";
  2553. }
  2554. else if(text<=0){
  2555. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  2556. return "";
  2557. }
  2558. nextafter = text;
  2559. displayInChat("Set next after to: " + text.toString()+" seconds.","#DA0808","#1EBCC1");
  2560. displayInChat("Type /nextafter to reset next after.","#DA0808","#1EBCC1");
  2561. return "";
  2562.  
  2563. }
  2564. else if (chat_val.substring(1,10)=="nextafter"){
  2565. nextafter = 0;
  2566. displayInChat("Reset next after.","#DA0808","#1EBCC1");
  2567. return "";
  2568.  
  2569. }
  2570. else if (chat_val.substring(1,5)=="next" && stopquickplay == 0){
  2571. roundsperqp2 = 0;
  2572. if(shuffle){
  2573. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  2574. var available = [];
  2575. var availableindexes = [];
  2576. var notempty = false;
  2577. for(var i = 0; i<e.length;i++){
  2578. var a = false;
  2579. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  2580. available.push(a);
  2581. if(a){
  2582. availableindexes.push(i);
  2583. notempty = true;
  2584. }
  2585. }
  2586. if(notempty){
  2587.  
  2588. if(availableindexes.length!=1){
  2589. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  2590. }
  2591. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  2592. }
  2593. }
  2594. else{
  2595. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  2596. var available = [];
  2597. var availableindexes = [];
  2598. var notempty = false;
  2599. for(var i = 0; i<e.length;i++){
  2600. var a = false;
  2601. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  2602. available.push(a);
  2603. if(a){
  2604. availableindexes.push(i);
  2605. notempty = true;
  2606. }
  2607. }
  2608. if(notempty){
  2609. var above = [];
  2610. for(var i = 0;i<availableindexes.length;i++){
  2611. if(availableindexes[i]>quicki){
  2612. above.push(availableindexes[i]);
  2613. }
  2614. }
  2615. if(above.length>0){
  2616. quicki = above[0];
  2617. }
  2618. else{
  2619. quicki = availableindexes[0];
  2620. }
  2621. }
  2622. }
  2623. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  2624. displayInChat("Switched to next map.","#DA0808","#1EBCC1");
  2625. return "";
  2626.  
  2627. }
  2628. else if (chat_val.substring(1,9)=="freejoin"){
  2629. if(freejoin == false){
  2630. freejoin = true;
  2631. displayInChat("Freejoin is now on.","#DA0808","#1EBCC1");
  2632.  
  2633. }
  2634. else{
  2635. freejoin = false;
  2636. displayInChat("Freejoin is now off.","#DA0808","#1EBCC1");
  2637. }
  2638.  
  2639. return "";
  2640.  
  2641. }
  2642. else if (chat_val.substring(1,8)=="instaqp"){
  2643. if(instaqp == false){
  2644. instaqp = true;
  2645. displayInChat("Instaqp is now on.","#DA0808","#1EBCC1");
  2646.  
  2647. }
  2648. else{
  2649. instaqp = false;
  2650. displayInChat("Instaqp is now off.","#DA0808","#1EBCC1");
  2651. }
  2652.  
  2653. return "";
  2654.  
  2655. }
  2656.  
  2657. else if (chat_val.substring(1,9)=="previous" && stopquickplay == 0){
  2658. roundsperqp2 = 0;
  2659. if(shuffle){
  2660. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  2661. var available = [];
  2662. var availableindexes = [];
  2663. var notempty = false;
  2664. for(var i = 0; i<e.length;i++){
  2665. var a = false;
  2666. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  2667. available.push(a);
  2668. if(a){
  2669. availableindexes.push(i);
  2670. notempty = true;
  2671. }
  2672. }
  2673. if(notempty){
  2674.  
  2675. if(availableindexes.length!=1){
  2676. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  2677. }
  2678. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  2679. }
  2680. }
  2681. else{
  2682. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  2683. var available = [];
  2684. var availableindexes = [];
  2685. var notempty = false;
  2686. for(var i = 0; i<e.length;i++){
  2687. var a = false;
  2688. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  2689. available.push(a);
  2690. if(a){
  2691. availableindexes.push(i);
  2692. notempty = true;
  2693. }
  2694. }
  2695. if(notempty){
  2696. var above = [];
  2697. for(var i = 0;i<availableindexes.length;i++){
  2698. if(availableindexes[i]<quicki){
  2699. above.push(availableindexes[i]);
  2700. }
  2701. }
  2702. if(above.length>0){
  2703. quicki = above[above.length-1];
  2704. }
  2705. else{
  2706. quicki = availableindexes[availableindexes.length-1];
  2707. }
  2708. }
  2709. }
  2710. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  2711.  
  2712. displayInChat("Switched to previous map.","#DA0808","#1EBCC1");
  2713. return "";
  2714. }
  2715. else if (chat_val.substring(1,6)=="start" && chat_val.length == 6){
  2716. Gdocument.getElementById("newbonklobby_editorbutton").click();
  2717. if(recmodebool && ishost){
  2718. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  2719. if(mode == "" && defaultmode!="d"){
  2720. mode = defaultmode;
  2721. }
  2722. if(mode != ""){
  2723. RECIEVE('42[26,"b","'+mode+'"]');
  2724. }
  2725. }
  2726. Gdocument.getElementById("mapeditor_close").click();
  2727. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  2728. roundsperqp2 = 0;
  2729. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  2730.  
  2731. return "";
  2732. }
  2733.  
  2734. else if (chat_val.substring(1,8)=="startqp" && stopquickplay == 1){
  2735. stopquickplay = 0;
  2736. quicki = 0;
  2737. displayInChat("Enabled quickplay.","#DA0808","#1EBCC1");
  2738. return "";
  2739. }
  2740. else if (chat_val.substring(1,7)=="stopqp" && stopquickplay == 0){
  2741. stopquickplay = 1;
  2742. quicki = 0;
  2743. displayInChat("Disabled quickplay.","#DA0808","#1EBCC1");
  2744. return "";
  2745. }
  2746.  
  2747. else if (chat_val.substring(1,5)=="ban " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  2748. banned.push(chat_val.substring(5).replace(/^\s+|\s+$/g, ''));
  2749. displayInChat("Banned "+chat_val.substring(5).replace(/^\s+|\s+$/g, '')+".","#DA0808","#1EBCC1");
  2750. return "/kick '" + chat_val.substring(5).replace(/^\s+|\s+$/g, '') + "'";
  2751. }
  2752. else if (chat_val.substring(1,6)=="kill " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  2753. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  2754. var keys = Object.keys(playerids);
  2755. var killid = undefined;
  2756. for(var i = 0; i<keys.length; i++){
  2757. if(playerids[keys[i]].userName == text){
  2758. killid = keys[i];
  2759. }
  2760. }
  2761. if(typeof(killid)!="undefined" && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden" && !killedids.includes(killid)){
  2762. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  2763. killedids.push(killid);
  2764. SEND('42[25,{"a":{"playersLeft":['+killid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  2765. RECIEVE('42[31,{"a":{"playersLeft":['+killid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  2766. }
  2767. return "";
  2768. }
  2769. else if (chat_val.substring(1,10)=="balanceA " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  2770. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  2771. if(!isNaN(parseInt(text))){
  2772. if(parseInt(text)>=-100 && parseInt(text)<=100){
  2773. var keys = Object.keys(playerids);
  2774. for(var i = 0; i<keys.length;i++){
  2775. SEND('42[29,{"sid":'+keys[i]+',"bal":'+text+'}]');
  2776. RECIEVE('42[36,'+keys[i]+','+text+']');
  2777. }
  2778. }
  2779. }
  2780. return "";
  2781.  
  2782. }
  2783. else if (chat_val.substring(1,7)=="moveA " && chat_val.replace(/^\s+|\s+$/g, '').length>=8){
  2784. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '');
  2785. var keys = Object.keys(playerids);
  2786. if(text == "f"){
  2787. for(var i = 0; i<keys.length;i++){
  2788. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":1}]')
  2789. }
  2790. }
  2791. else if(text == "b"){
  2792. for(var i = 0; i<keys.length;i++){
  2793. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":3}]')
  2794. }
  2795. }
  2796. else if(text == "g"){
  2797. for(var i = 0; i<keys.length;i++){
  2798. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":4}]')
  2799. }
  2800. }
  2801. else if(text == "r"){
  2802. for(var i = 0; i<keys.length;i++){
  2803. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":2}]')
  2804. }
  2805. }
  2806. else if(text == "y"){
  2807. for(var i = 0; i<keys.length;i++){
  2808. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":5}]')
  2809. }
  2810. }
  2811. else if(text == "s"){
  2812. for(var i = 0; i<keys.length;i++){
  2813. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":0}]')
  2814. }
  2815. }
  2816. return "";
  2817. }
  2818. if (chat_val.substring(1,13)=="roundsperqp " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  2819. text = parseInt(chat_val.substring(13).replace(/^\s+|\s+$/g, ''));
  2820. if(isNaN(text)){
  2821. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  2822. return "";
  2823. }
  2824. else if(text<=0){
  2825. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  2826. return "";
  2827. }
  2828. roundsperqp = text;
  2829. roundsperqp2 = 0;
  2830. displayInChat("Set rounds per quickplay to: " + text.toString(),"#DA0808","#1EBCC1");
  2831. displayInChat("Type /roundsperqp to reset rounds per quickplay.","#DA0808","#1EBCC1");
  2832. return "";
  2833.  
  2834. }
  2835. else if (chat_val.substring(1,12)=="roundsperqp"){
  2836. roundsperqp = 1;
  2837. roundsperqp2 = 0;
  2838. displayInChat("Reset rounds per quickplay.","#DA0808","#1EBCC1");
  2839. return "";
  2840.  
  2841. }
  2842. else if (chat_val.substring(1,8)=="rounds " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  2843. var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '');
  2844. if(!isNaN(parseInt(text))){
  2845. text = parseInt(text).toString();
  2846. SEND('42[21,{"w":'+text+'}]');
  2847. RECIEVE('42[27,'+text+']');
  2848. }
  2849. return "";
  2850.  
  2851. }
  2852. else if (chat_val.substring(1,13)=="disablekeys " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  2853. var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '');
  2854. var keys = text.split(" ");
  2855. var disabledkeys2 = [];
  2856. var possiblekeys = ["left","right","up","down","heavy","special"];
  2857. for(var i = 0; i<keys.length; i++){
  2858. if(keys[i]!="" && !disabledkeys2.includes(keys[i])){
  2859. if(possiblekeys.includes(keys[i])){
  2860. disabledkeys2.push(keys[i]);
  2861. }
  2862. else{
  2863. displayInChat("Key options: " + possiblekeys.join(" ") + ".","#DA0808","#1EBCC1");
  2864. return "";
  2865. }
  2866. }
  2867. }
  2868. disabledkeys = disabledkeys2;
  2869. displayInChat("Set disabled keys to: " + disabledkeys.join(" ") + ".","#DA0808","#1EBCC1");
  2870. displayInChat("Type /disablekeys to reset disabled keys.","#DA0808","#1EBCC1");
  2871. return "";
  2872.  
  2873. }
  2874. else if (chat_val.substring(1,12)=="disablekeys"){
  2875. displayInChat("Reset disabled keys.","#DA0808","#1EBCC1");
  2876. disabledkeys = [];
  2877. return "";
  2878.  
  2879. }
  2880. else if (chat_val.substring(1,10)=="jointext " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  2881. jointext = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  2882. displayInChat("Set jointext to: " + jointext,"#DA0808","#1EBCC1");
  2883. displayInChat("Type /jointext to reset jointext.","#DA0808","#1EBCC1");
  2884. return "";
  2885.  
  2886. }
  2887. else if (chat_val.substring(1,9)=="jointext"){
  2888. jointext = "";
  2889. displayInChat("Reset jointext.","#DA0808","#1EBCC1");
  2890. return "";
  2891.  
  2892. }
  2893. else if (chat_val.substring(1,9)=="wintext " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  2894. wintext = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  2895. displayInChat("Set wintext to: " + wintext,"#DA0808","#1EBCC1");
  2896. displayInChat("Type /wintext to reset wintext.","#DA0808","#1EBCC1");
  2897. return "";
  2898.  
  2899. }
  2900. else if (chat_val.substring(1,8)=="wintext"){
  2901. wintext = "";
  2902. displayInChat("Reset wintext.","#DA0808","#1EBCC1");
  2903. return "";
  2904.  
  2905. }
  2906. else if (chat_val.substring(1,11)=="autorecord"){
  2907. if(autorecord){
  2908. autorecord = false;
  2909. displayInChat("Autorecord is now off.","#DA0808","#1EBCC1");
  2910. }
  2911. else{
  2912. autorecord = true;
  2913. displayInChat("Autorecord is now on.","#DA0808","#1EBCC1");
  2914. }
  2915. return "";
  2916.  
  2917. }
  2918. else if (chat_val.substring(1,9)=="afkkill " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  2919. var text = parseFloat(chat_val.substring(9).replace(/^\s+|\s+$/g, ''));
  2920. if(!isNaN(text)){
  2921. if(text>0){
  2922. displayInChat("Set afk kill to: " + text.toString()+" seconds.","#DA0808","#1EBCC1");
  2923. displayInChat("Type /afkkill to reset afk kill.","#DA0808","#1EBCC1");
  2924. var keys = Object.keys(playerids);
  2925. var now = Date.now();
  2926. for(var i = 0;i<keys.length;i++){
  2927. playerids[keys[i]].lastmove = now;
  2928. }
  2929. afkkill = text;
  2930. }
  2931. else{
  2932. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  2933. }
  2934. }
  2935. else{
  2936. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  2937. }
  2938. return "";
  2939.  
  2940. }
  2941. else if (chat_val.substring(1,9)=="afkkill"){
  2942. afkkill = -1;
  2943. displayInChat("Reset afk kill.","#DA0808","#1EBCC1");
  2944. return "";
  2945.  
  2946. }
  2947. else if (chat_val.substring(1,13)=="defaultmode " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  2948. var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '');
  2949. if(text == "default"){
  2950. defaultmode = "";
  2951. displayInChat("Changed default mode to default.","#DA0808","#1EBCC1");
  2952. }
  2953. else if(text == "arrows"){
  2954. defaultmode = "ar";
  2955. displayInChat("Changed default mode to arrows.","#DA0808","#1EBCC1");
  2956. }
  2957. else if(text == "death arrows"){
  2958. defaultmode = "ard";
  2959. displayInChat("Changed default mode to death arrows.","#DA0808","#1EBCC1");
  2960. }
  2961. else if(text == "grapple"){
  2962. defaultmode = "sp";
  2963. displayInChat("Changed default mode to grapple.","#DA0808","#1EBCC1");
  2964. }
  2965. else if(text == "classic"){
  2966. defaultmode = "b";
  2967. displayInChat("Changed default mode to classic.","#DA0808","#1EBCC1");
  2968.  
  2969. }
  2970. else{
  2971. displayInChat("Default mode options:","#DA0808","#1EBCC1");
  2972. displayInChat("default","#DA0808","#1EBCC1");
  2973. displayInChat("classic","#DA0808","#1EBCC1");
  2974. displayInChat("arrows","#DA0808","#1EBCC1");
  2975. displayInChat("death arrows","#DA0808","#1EBCC1");
  2976. displayInChat("grapple","#DA0808","#1EBCC1");
  2977. }
  2978. return "";
  2979.  
  2980. }
  2981. else if (chat_val.substring(1,8)=="recmode"){
  2982. if(recmodebool == true){
  2983. recmodebool = false;
  2984. displayInChat("Recmode is now off.","#DA0808","#1EBCC1");
  2985.  
  2986. }
  2987. else{
  2988. recmodebool = true;
  2989. displayInChat("Recmode is now on.","#DA0808","#1EBCC1");
  2990.  
  2991. }
  2992.  
  2993. return "";
  2994.  
  2995. }
  2996. else if (chat_val.substring(1,8)=="recteam"){
  2997. if(recteams == true){
  2998. recteams = false;
  2999. displayInChat("Recteam is now off.","#DA0808","#1EBCC1");
  3000.  
  3001. }
  3002. else{
  3003. recteams = true;
  3004. displayInChat("Recteam is now on.","#DA0808","#1EBCC1");
  3005.  
  3006. }
  3007. return "";
  3008. }
  3009. else if (chat_val.substring(1,8)=="shuffle"){
  3010. if(shuffle == true){
  3011. shuffle = false;
  3012. displayInChat("Shuffle is now off.","#DA0808","#1EBCC1");
  3013.  
  3014. }
  3015. else{
  3016. shuffle = true;
  3017. displayInChat("Shuffle is now on.","#DA0808","#1EBCC1");
  3018.  
  3019. }
  3020.  
  3021. return "";
  3022.  
  3023. }
  3024. else if(sandboxon){
  3025. if (chat_val.substring(1,11)=="addplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  3026. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  3027. if(!isNaN(parseInt(text))){
  3028. var text2 = parseInt(text);
  3029. if(text2>0){
  3030. for(var i = 0;i<text2;i++){
  3031. RECIEVE('42[4,'+sandboxid+',"0123456789abcdef","'+sandboxid.toString()+'",true,0,1,{"layers":[],"bc":'+Math.floor(Math.random() * 16777215).toString()+'}]');
  3032. sandboxplayerids[sandboxid] = sandboxid.toString();
  3033. sandboxid+=1;
  3034. }
  3035.  
  3036. }
  3037. }
  3038. return "";
  3039.  
  3040. }
  3041. else if (chat_val.substring(1,11)=="delplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  3042. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  3043. if(!isNaN(parseInt(text))){
  3044. var text2 = parseInt(text);
  3045. if(text2>0){
  3046. if(Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden"){
  3047. var jsonkeys = Object.keys(sandboxplayerids).reverse();
  3048. for(var i = 0;i<text2 && i<jsonkeys.length;i++){
  3049. RECIEVE('42[5,'+jsonkeys[i]+',0]');
  3050. delete sandboxplayerids[jsonkeys[i]];
  3051. }
  3052. }
  3053. else{
  3054. displayInChat("Cannot delete players while ingame.","#DA0808","#1EBCC1");
  3055. }
  3056.  
  3057. }
  3058. }
  3059. return "";
  3060. }
  3061. else if (chat_val.substring(1,7)=="copyme"){
  3062. if(sandboxcopyme == true){
  3063. displayInChat("Copyme is now off.","#DA0808","#1EBCC1");
  3064. sandboxcopyme = false;
  3065. }
  3066. else{
  3067. displayInChat("Copyme is now on.","#DA0808","#1EBCC1");
  3068. sandboxcopyme = true;
  3069. }
  3070.  
  3071. return "";
  3072. }
  3073. }
  3074. }
  3075. return chat_val;
  3076. };
  3077.  
  3078. scope.flag_manage = function(t){
  3079. var text = t;
  3080. if(reverse_flag == true){
  3081. text = text.split("").reverse().join("")
  3082. }
  3083. if(rcaps_flag == true){
  3084. text = text.split('');
  3085. for(var i = 0; i<text.length;i++){
  3086. if(Math.floor(Math.random()*2)){
  3087. text[i] = text[i].toUpperCase();
  3088. }
  3089. else{
  3090. text[i] = text[i].toLowerCase();
  3091. }
  3092. }
  3093. text = text.join('');
  3094. }
  3095. if(space_flag == true){
  3096. text = text.split('').join(' ')
  3097. }
  3098. if(number_flag == true){
  3099. text = text.replace(/[t|T][Oo]+/g,"2");
  3100. text = text.replace(/[f|F][o|O][r|R]/g,"4");
  3101. text = text.replace(/[a|A][t|T][e|E]/g,"8");
  3102. text = text.replace(/[e|E]/g,"3");
  3103. text = text.replace(/[a|A]/g,"4");
  3104. text = text.replace(/[o|O]/g,"0");
  3105. text = text.replace(/[s|S]/g,"5");
  3106. text = text.replace(/[i|I|l|L]/g,"1");
  3107. }
  3108. return text;
  3109. };
  3110. Gdocument.getElementById("newbonklobby_chat_input").onkeydown = function(e){
  3111. if(e.keyCode==13){
  3112.  
  3113. var chat_val = Gdocument.getElementById("newbonklobby_chat_input").value;
  3114.  
  3115. if (chat_val!="" && chat_val[0]=="/"){
  3116.  
  3117. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  3118. chat(commandhandle(chat_val));
  3119. }
  3120. else{
  3121. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  3122. chat(flag_manage(chat_val));
  3123. }
  3124.  
  3125. }
  3126. };
  3127. Gdocument.getElementById("ingamechatinputtext").onkeydown = function(e){
  3128. if(e.keyCode==13){
  3129.  
  3130. var chat_val = Gdocument.getElementById("ingamechatinputtext").value;
  3131.  
  3132. if (chat_val!="" && chat_val[0]=="/"){
  3133.  
  3134. Gdocument.getElementById("ingamechatinputtext").value = "";
  3135. chat(commandhandle(chat_val));
  3136. }
  3137. else{
  3138. Gdocument.getElementById("ingamechatinputtext").value = "";
  3139. chat(flag_manage(chat_val));
  3140. }
  3141. }
  3142. };
  3143. scope.Last_message = "";
  3144. scope.Laster_message = "";
  3145. scope.new_message = false;
  3146. scope.changed_chat = false;
  3147. scope.interval = setInterval(timeout123,60);
  3148.  
  3149. scope.hotkeys = function(e){
  3150. var keycode = e.code;
  3151. if(e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  3152. if(keycode == "Period"){
  3153. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]!="0px"){
  3154. chatheight+=5;
  3155. if(chatheight>600){chatheight = 600;}
  3156. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  3157. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  3158. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  3159. }
  3160. e.preventDefault();
  3161. }
  3162. if(keycode == "Comma"){
  3163. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]!="0px"){
  3164. chatheight-=5;
  3165. if(chatheight<100){chatheight = 100;}
  3166. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  3167. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  3168. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  3169. }
  3170. e.preventDefault();
  3171. }
  3172. }
  3173. if(e.repeat){return;}
  3174. if(e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  3175. if(ishost){
  3176. if(keycode == "KeyE"){
  3177. if(Gdocument.getElementById("newbonklobby").style["display"] == "block"){
  3178. Gdocument.getElementById("newbonklobby_editorbutton").click();
  3179. }
  3180. else if(Gdocument.getElementById("mapeditorcontainer").style["display"] == "block"){
  3181. Gdocument.getElementById("mapeditor_close").click();
  3182. }
  3183. e.preventDefault();
  3184.  
  3185. }
  3186. else if(keycode == "KeyT"){
  3187. Gdocument.getElementById("newbonklobby_teamsbutton").click();
  3188. e.preventDefault();
  3189. }
  3190. else if(keycode == "KeyM"){
  3191. Gdocument.getElementById("newbonklobby_modebutton").click();
  3192. e.preventDefault();
  3193. }
  3194. else if(keycode == "KeyK"){
  3195. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  3196. Gdocument.getElementById("pretty_top_exit").click();
  3197. }
  3198. e.preventDefault();
  3199. }
  3200. else if(keycode == "KeyS"){
  3201. Gdocument.getElementById("newbonklobby_editorbutton").click();
  3202. if(recmodebool && ishost){
  3203. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  3204. if(mode == "" && defaultmode!="d"){
  3205. mode = defaultmode;
  3206. }
  3207. if(mode != ""){
  3208. RECIEVE('42[26,"b","'+mode+'"]');
  3209. }
  3210. }
  3211. Gdocument.getElementById("mapeditor_close").click();
  3212. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  3213. roundsperqp2 = 0;
  3214. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  3215. e.preventDefault();
  3216. }
  3217. else if(keycode == "KeyD"){
  3218. roundsperqp2 = 0;
  3219. if(stopquickplay == 0){
  3220. if(shuffle){
  3221. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  3222. var available = [];
  3223. var availableindexes = [];
  3224. var notempty = false;
  3225. for(var i = 0; i<e2.length;i++){
  3226. var a = false;
  3227. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  3228. available.push(a);
  3229. if(a){
  3230. availableindexes.push(i);
  3231. notempty = true;
  3232. }
  3233. }
  3234. if(notempty){
  3235.  
  3236. if(availableindexes.length!=1){
  3237. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  3238. }
  3239. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  3240. }
  3241. }
  3242. else{
  3243. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  3244. var available = [];
  3245. var availableindexes = [];
  3246. var notempty = false;
  3247. for(var i = 0; i<e2.length;i++){
  3248. var a = false;
  3249. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  3250. available.push(a);
  3251. if(a){
  3252. availableindexes.push(i);
  3253. notempty = true;
  3254. }
  3255. }
  3256. if(notempty){
  3257. var above = [];
  3258. for(var i = 0;i<availableindexes.length;i++){
  3259. if(availableindexes[i]>quicki){
  3260. above.push(availableindexes[i]);
  3261. }
  3262. }
  3263. if(above.length>0){
  3264. quicki = above[0];
  3265. }
  3266. else{
  3267. quicki = availableindexes[0];
  3268. }
  3269. }
  3270. }
  3271. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  3272. }
  3273. e.preventDefault();
  3274. }
  3275. else if(keycode == "KeyA"){
  3276. if(stopquickplay == 0){
  3277. roundsperqp2 = 0;
  3278. if(shuffle){
  3279. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  3280. var available = [];
  3281. var availableindexes = [];
  3282. var notempty = false;
  3283. for(var i = 0; i<e2.length;i++){
  3284. var a = false;
  3285. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  3286. available.push(a);
  3287. if(a){
  3288. availableindexes.push(i);
  3289. notempty = true;
  3290. }
  3291. }
  3292. if(notempty){
  3293.  
  3294. if(availableindexes.length!=1){
  3295. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  3296. }
  3297. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  3298. }
  3299. }
  3300. else{
  3301. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  3302. var available = [];
  3303. var availableindexes = [];
  3304. var notempty = false;
  3305. for(var i = 0; i<e2.length;i++){
  3306. var a = false;
  3307. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  3308. available.push(a);
  3309. if(a){
  3310. availableindexes.push(i);
  3311. notempty = true;
  3312. }
  3313. }
  3314. if(notempty){
  3315. var above = [];
  3316. for(var i = 0;i<availableindexes.length;i++){
  3317. if(availableindexes[i]<quicki){
  3318. above.push(availableindexes[i]);
  3319. }
  3320. }
  3321. if(above.length>0){
  3322. quicki = above[above.length-1];
  3323. }
  3324. else{
  3325. quicki = availableindexes[availableindexes.length-1];
  3326. }
  3327. }
  3328. }
  3329. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  3330. }
  3331. e.preventDefault();
  3332. }
  3333. else if(keycode == "KeyQ"){
  3334. if(stopquickplay == 1){
  3335. stopquickplay = 0;
  3336. quicki = 0;
  3337. displayInChat("Enabled quickplay.","#DA0808","#1EBCC1");
  3338. }
  3339. else{
  3340. stopquickplay = 1;
  3341. quicki = 0;
  3342. displayInChat("Disabled quickplay.","#DA0808","#1EBCC1");
  3343. }
  3344. e.preventDefault();
  3345. }
  3346. else if(keycode == "KeyR"){
  3347. if(recmodebool == true){
  3348. recmodebool = false;
  3349. displayInChat("Recmode is now off.","#DA0808","#1EBCC1");
  3350.  
  3351. }
  3352. else{
  3353. recmodebool = true;
  3354. displayInChat("Recmode is now on.","#DA0808","#1EBCC1");
  3355.  
  3356. }
  3357. }
  3358. else if(keycode == "KeyF"){
  3359. if(freejoin == false){
  3360. freejoin = true;
  3361. displayInChat("Freejoin is now on.","#DA0808","#1EBCC1");
  3362.  
  3363. }
  3364. else{
  3365. freejoin = false;
  3366. displayInChat("Freejoin is now off.","#DA0808","#1EBCC1");
  3367. }
  3368. e.preventDefault();
  3369. }
  3370. }
  3371. else{
  3372. if(keycode == "KeyE"){
  3373. e.preventDefault();
  3374. }
  3375. else if(keycode == "KeyT"){
  3376. e.preventDefault();
  3377. }
  3378. else if(keycode == "KeyM"){
  3379. e.preventDefault();
  3380. }
  3381. else if(keycode == "KeyK"){
  3382. e.preventDefault();
  3383. }
  3384. else if(keycode == "KeyS"){
  3385. e.preventDefault();
  3386. }
  3387. else if(keycode == "KeyD"){
  3388. e.preventDefault();
  3389. }
  3390. else if(keycode == "KeyA"){
  3391. e.preventDefault();
  3392. }
  3393. else if(keycode == "KeyQ"){
  3394. e.preventDefault();
  3395. }
  3396. else if(keycode == "KeyF"){
  3397. e.preventDefault();
  3398. }
  3399. else if(keycode == "KeyR"){
  3400. e.preventDefault();
  3401. }
  3402.  
  3403. }
  3404. if(keycode == "KeyL"){
  3405. lobby();
  3406. e.preventDefault();
  3407. }
  3408. if(keycode == "KeyC"){
  3409. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  3410. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]=="0px"){
  3411. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  3412. }
  3413. else{
  3414. Gdocument.getElementById("ingamechatcontent").style["max-height"]="0px";
  3415. }
  3416. }
  3417. e.preventDefault();
  3418. }
  3419. if(keycode == "KeyI"){
  3420. if(Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"] == "none"){
  3421. debuggeropen = true;
  3422. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="block";
  3423. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="none";
  3424. Gdocument.getElementById("ingamechatinputtext").style["display"] = "none";
  3425. }
  3426. else{
  3427. debuggeropen = false;
  3428. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="none";
  3429. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  3430. Gdocument.getElementById("ingamechatinputtext").style["display"] = "";
  3431. }
  3432. e.preventDefault();
  3433. }
  3434. }
  3435. if(!e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  3436. if(keycode == "Slash" && !(Gdocument.getElementById("gmeditor")?.style["transform"] == "scale(1)")){
  3437. 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"]==""){
  3438. Gdocument.getElementById("newbonklobby_chat_input").value = "/";
  3439. if(Gdocument.getElementById("newbonklobby_chat_input").style["pointer-events"] == "none"){
  3440. fire("keydown",{keyCode:13});
  3441. }
  3442. else{
  3443. Gdocument.getElementById("newbonklobby_chat_input").focus();
  3444. }
  3445. e.preventDefault();
  3446.  
  3447. }
  3448. else if(Gdocument.getElementById("ingamechatinputtext").style["visibility"]=="visible" && Gdocument.getElementById("ingamechatinputtext").style["display"]=="" && Gdocument.getElementById("mapeditorcontainer").style["display"]!="block" && Gdocument.getElementById("ingamechatinputtext").value == ""){
  3449. Gdocument.getElementById("ingamechatinputtext").value = "/";
  3450. if(!Gdocument.getElementById("ingamechatinputtext").classList.value.includes("ingamechatinputtextbg")){
  3451. fire("keydown",{keyCode:13});
  3452. }
  3453. else{
  3454. Gdocument.getElementById("ingamechatinputtext").focus();
  3455. }
  3456. e.preventDefault();
  3457.  
  3458. }
  3459. }
  3460. }
  3461. };
  3462.  
  3463. Gdocument.onkeydown = hotkeys;
  3464.  
  3465. Gwindow.addEventListener('resize',function(e){
  3466. debuggermenu.style["width"] = Gdocument.getElementById("bonkiocontainer").style["width"];
  3467. debuggermenu.style["height"] = Gdocument.getElementById("bonkiocontainer").style["height"];
  3468. scope.width = parseInt(Gdocument.getElementById("bonkiocontainer").style["width"])-20;
  3469. scope.height = parseInt(Gdocument.getElementById("bonkiocontainer").style["height"])-210;
  3470. logmenu.style["width"] = width.toString()+"px";
  3471. logmenu.style["height"] = height.toString()+"px";
  3472. logmenutopleft.style["width"] = (width/2).toString()+"px";
  3473. logmenutopright.style["width"] = (width/2).toString()+"px";
  3474. logmenutopright.style["left"] = (width/2).toString()+"px";
  3475. debuggerinput.style["width"] = width.toString()+"px";
  3476. debuggerinput.style["top"] = (height+90).toString()+"px";
  3477. debuggersendrecieve.style["top"] = (height+120).toString()+"px";
  3478. debuggerpausebutton.style["top"] = (height+150).toString()+"px";
  3479. debuggereval.style["width"] = (width-150).toString()+"px";
  3480. debuggereval.style["top"] = (height+120).toString()+"px";},true);
  3481.  
  3482.  
  3483. function timeout123() {
  3484. updateWssLog();
  3485. var now = Date.now();
  3486. var keys = Object.keys(playerids);
  3487. for(var i = 0;i<keys.length;i++){
  3488. if(playerids[keys[i]].playerData){
  3489. if(playerids[keys[i]].playerData2){
  3490. if(playerids[keys[i]].playerData.transform){
  3491. }
  3492. else{
  3493. if(playerids[keys[i]].playerData2.alive){
  3494. }
  3495. playerids[keys[i]].playerData2.alive = false;
  3496. }
  3497. }
  3498. else{
  3499. playerids[keys[i]].playerData2 = {"alive":true};
  3500. }
  3501. }
  3502. }
  3503. if(afkkill>0 && ishost){
  3504. var keys = Object.keys(playerids);
  3505. currentFrame = Math.floor((now - gameStartTimeStamp)/1000*30);
  3506. for(var i = 0; i<keys.length;i++){
  3507. if(typeof(playerids[keys[i]].lastmove)=="undefined"){
  3508. playerids[keys[i]].lastmove = now;
  3509. }
  3510. else{
  3511. if(playerids[keys[i]].playerData2?.alive && now-playerids[keys[i]].lastmove>=afkkill*1000 && now-gameStartTimeStamp>=afkkill*1000 && !killedids.includes(keys[i])){
  3512. killedids.push(keys[i]);
  3513. SEND('42[25,{"a":{"playersLeft":['+keys[i]+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  3514. RECIEVE('42[31,{"a":{"playersLeft":['+keys[i]+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  3515. break;
  3516. }
  3517. }
  3518. }
  3519. }
  3520. if(ishost && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS"){
  3521. clearmaprequests.style["display"] = "block";
  3522. refreshmaprequests.style["display"] = "block";
  3523. }
  3524. else{
  3525. clearmaprequests.style["display"] = "none";
  3526. refreshmaprequests.style["display"] = "none";
  3527. }
  3528. if(Gdocument.getElementById("gamerenderer").style["visibility"]=="hidden"){
  3529. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  3530. }
  3531. if(Gdocument.getElementById("maploadwindowmapscontainer").children.length>0 && maponclick == 0){
  3532. maponclick = Gdocument.getElementById("maploadwindowmapscontainer").children[0].onclick;
  3533. }
  3534. if(Gdocument.getElementById("sm_connectingContainer").style["visibility"] == "hidden"){
  3535. var chatbox = Gdocument.getElementById("newbonklobby_chat_content");
  3536. while (chatbox.firstChild) {
  3537. chatbox.removeChild(chatbox.firstChild);
  3538. }
  3539. rcaps_flag = false;
  3540. space_flag = false;
  3541. number_flag = false;
  3542. reverse_flag = false;
  3543. echo_list = [];
  3544. scroll = false;
  3545. stopquickplay = 1;
  3546. roundsperqp = 1;
  3547. roundsperqp2 = 0;
  3548. checkboxhidden = false;
  3549. freejoin = false;
  3550. shuffle = false;
  3551. defaultmode = "";
  3552. recmodebool = false;
  3553. recteams = false;
  3554. playerids = {};
  3555. autorecord = false;
  3556. afkkill = -1;
  3557. nextafter = 0;
  3558. jointext = "";
  3559. ishost = false;
  3560. sandboxplayerids = {};
  3561. sandboxcopyme = false;
  3562. wintext = "";
  3563. sandboxon = false;
  3564. sandboxid = 1;
  3565. disabledkeys = [];
  3566. myid = -1;
  3567. hostid = -1;
  3568. if(chatlog[chatlog.length-1]!="ROOM END"){
  3569. chatlog.push("ROOM END");
  3570. }
  3571. }
  3572. else{
  3573. if(chatlog[chatlog.length-1]=="ROOM END"){
  3574. chatlog.push("ROOM START");
  3575. }
  3576. }
  3577.  
  3578. if(Gdocument.getElementById("newbonklobby").style["display"]=="block"){
  3579. Gdocument.getElementById("ingamechatinputtext").style["visibility"]="hidden";
  3580. }
  3581. else{
  3582. Gdocument.getElementById("ingamechatinputtext").style["visibility"]="visible";
  3583.  
  3584. }
  3585. mode = Gdocument.getElementById("newbonklobby_modetext").textContent;
  3586. 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
  3587. >0){
  3588. ishost = true;
  3589. }
  3590. else{
  3591. ishost = actuallyhost;
  3592. }
  3593.  
  3594. if(Gdocument.getElementById("pretty_top_name")!=null){
  3595. username = Gdocument.getElementById("pretty_top_name").textContent;
  3596. if(myid!=-1){
  3597. username = playerids[myid].userName;
  3598. }
  3599. }
  3600. try{
  3601. Last_message = lastmessage()
  3602. } catch{
  3603. Last_message = "";
  3604. }
  3605. if (Laster_message != Last_message){
  3606. Laster_message = Last_message;
  3607. if(changed_chat==false){
  3608. new_message = true;
  3609. }
  3610. else{
  3611. changed_chat = false;
  3612. }
  3613. }
  3614. if(new_message){
  3615. chatlog.push(Last_message);
  3616. var lm = "";
  3617. try{
  3618. lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  3619. if(typeof(lm[0].parentElement.style["parsed"]) == 'undefined'){
  3620. if (lm[0].className == "newbonklobby_chat_msg_colorbox"){
  3621. lm[2].innerHTML = urlify(lm[2].innerHTML);
  3622. Laster_message = lastmessage();
  3623. lm[0].parentElement.style["parsed"] = true;
  3624. }
  3625. if (lm[0].className == "newbonklobby_chat_status"){
  3626. lm[0].innerHTML = urlify(lm[0].innerHTML);
  3627. Laster_message = lastmessage();
  3628. lm[0].parentElement.style["parsed"] = true;
  3629. }
  3630. }
  3631. }
  3632. catch{
  3633. lm = "";
  3634. }
  3635.  
  3636. if(Last_message.indexOf("@"+username)!=-1 && npermissions == 1){
  3637. if(Notification.requestPermission()){
  3638. var n = new Notification(Last_message);
  3639. }
  3640. }
  3641.  
  3642. try{
  3643. lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  3644. if(typeof(lm[0].parentElement.style["parsed"])=='undefined'){
  3645. if(lm[0].className == "ingamechatname"){
  3646. lm[1].innerHTML = urlify(lm[1].innerHTML);
  3647. Laster_message = lastmessage();
  3648. lm[0].parentElement.style["parsed"] = true;
  3649. }
  3650. if(lm[0].className == ""){
  3651. lm[0].innerHTML = urlify(lm[0].innerHTML);
  3652. Laster_message = lastmessage();
  3653. lm[0].parentElement.style["parsed"] = true;
  3654. }
  3655. }
  3656. }
  3657. catch{
  3658. lm = "";
  3659. }
  3660. if(text2speech){
  3661. if(!sayer.speaking){
  3662. if(Last_message.includes(": ")){
  3663. speech.text = Last_message.substring(0,Last_message.indexOf(":")).toLowerCase();
  3664. speech.rate = 2.25;
  3665. sayer.speak(speech);
  3666. speech.text = Last_message.substring(Last_message.indexOf(": ")+3).toLowerCase();
  3667. speech.rate = 1.25;
  3668. sayer.speak(speech);
  3669. }
  3670. else{
  3671. speech.text = Last_message.toLowerCase();
  3672. sayer.speak(speech);
  3673. }
  3674. }
  3675. }
  3676. }
  3677. if (ishost==true && new_message){
  3678. for(i=0;i<banned.length;i++){
  3679. if(Last_message.startsWith("* "+banned[i]+" has joined the game")){
  3680. chat("/kick '"+banned[i]+"'");
  3681. }
  3682. }
  3683. }
  3684. if(Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden" && ishost){
  3685. roundsperqp2 = 0;
  3686. }
  3687. if(Gdocument.getElementById("ingamewinner").style["visibility"]=="inherit" && ishost){
  3688. if(Gdocument.getElementById("ingamewinner").style["parsed"] != true){
  3689. if(stopquickplay!=1){
  3690. roundsperqp2++;
  3691. }
  3692. if(autorecord){
  3693. Gdocument.getElementById("pretty_top_replay").click();
  3694. }
  3695. }
  3696. if(Gdocument.getElementById("ingamewinner").style["parsed"] != true && wintext!="" && Gdocument.getElementById("ingamewinner_bottom").textContent!="DRAW"){
  3697. chat(flag_manage(wintext.replaceAll("username",Gdocument.getElementById("ingamewinner_top").textContent)));
  3698. }
  3699. Gdocument.getElementById("ingamewinner").style["parsed"] = true;
  3700. }
  3701. else{
  3702. Gdocument.getElementById("ingamewinner").style["parsed"] = false;
  3703. }
  3704. if(ishost && stopquickplay == 0){
  3705. if(checkboxhidden){
  3706. checkboxhidden = false;
  3707. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  3708. for(var i = 0; i<classes.length;i++){
  3709. classes[i].style["display"] = "block";
  3710. classes[i].className = "quickplaycheckbox quickplaychecked";
  3711. }
  3712. Gdocument.getElementById('clearallcheckboxes').style["display"] = "block";
  3713.  
  3714. }
  3715. if(nextafter>0 && gameStartTimeStamp+nextafter*1000<=now && Gdocument.getElementById("gamerenderer").style["visibility"] != "hidden" && dontswitch == false && Gdocument.getElementById("ingamewinner").style["visibility"]!="inherit"){
  3716. roundsperqp2 = 0;
  3717. if(shuffle){
  3718. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  3719. var available = [];
  3720. var availableindexes = [];
  3721. var notempty = false;
  3722. for(var i = 0; i<e.length;i++){
  3723. var a = false;
  3724. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  3725. available.push(a);
  3726. if(a){
  3727. availableindexes.push(i);
  3728. notempty = true;
  3729. }
  3730. }
  3731. if(notempty){
  3732. if(availableindexes.length!=1){
  3733. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  3734. }
  3735. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  3736. }
  3737. }
  3738. else{
  3739. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  3740. var available = [];
  3741. var availableindexes = [];
  3742. var notempty = false;
  3743. for(var i = 0; i<e.length;i++){
  3744. var a = false;
  3745. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  3746. available.push(a);
  3747. if(a){
  3748. availableindexes.push(i);
  3749. notempty = true;
  3750. }
  3751. }
  3752. if(notempty){
  3753. var above = [];
  3754. for(var i = 0;i<availableindexes.length;i++){
  3755. if(availableindexes[i]>quicki){
  3756. above.push(availableindexes[i]);
  3757. }
  3758. }
  3759. if(above.length>0){
  3760. quicki = above[0];
  3761. }
  3762. else{
  3763. quicki = availableindexes[0];
  3764. }
  3765. }
  3766. }
  3767. startedinqp = true;
  3768. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  3769. }
  3770. if(Gdocument.getElementById("ingamewinner").style["visibility"]=="inherit" && dontswitch == false && !document.hidden){
  3771. if(roundsperqp2>=roundsperqp){
  3772. if(shuffle){
  3773. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  3774. var available = [];
  3775. var availableindexes = [];
  3776. var notempty = false;
  3777. for(var i = 0; i<e.length;i++){
  3778. var a = false;
  3779. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  3780. available.push(a);
  3781. if(a){
  3782. availableindexes.push(i);
  3783. notempty = true;
  3784. }
  3785. }
  3786. if(notempty){
  3787.  
  3788. if(availableindexes.length!=1){
  3789. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  3790. }
  3791. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  3792. }
  3793. }
  3794. else{
  3795. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  3796. var available = [];
  3797. var availableindexes = [];
  3798. var notempty = false;
  3799. for(var i = 0; i<e.length;i++){
  3800. var a = false;
  3801. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  3802. available.push(a);
  3803. if(a){
  3804. availableindexes.push(i);
  3805. notempty = true;
  3806. }
  3807. }
  3808. if(notempty){
  3809. var above = [];
  3810. for(var i = 0;i<availableindexes.length;i++){
  3811. if(availableindexes[i]>quicki){
  3812. above.push(availableindexes[i]);
  3813. }
  3814. }
  3815. if(above.length>0){
  3816. quicki = above[0];
  3817. }
  3818. else{
  3819. quicki = availableindexes[0];
  3820. }
  3821. }
  3822. }
  3823. }
  3824. transitioning = true;
  3825. startedinqp = true;
  3826. map(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  3827. dontswitch = true;
  3828. setTimeout(function(){Gdocument.getElementById("ingamewinner").style["visibility"]="hidden"; dontswitch = false;},timedelay);
  3829. }
  3830. }
  3831. else{
  3832. if(!checkboxhidden){
  3833. checkboxhidden = true;
  3834. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  3835. for(var i = 0; i<classes.length;i++){
  3836. classes[i].style["display"] = "none";
  3837. classes[i].className = "quickplaycheckbox quickplayunchecked";
  3838. }
  3839. Gdocument.getElementById('clearallcheckboxes').style["display"] = "none";
  3840. }
  3841. }
  3842. new_message = false;
  3843. };
  3844. });