Bonk Commands

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

当前为 2022-12-17 提交的版本,查看 最新版本

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