Bonk Commands

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

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

  1. // ==UserScript==
  2. // @name Bonk Commands
  3. // @namespace https://greasyfork.org/en/scripts/451341-bonk-commands
  4. // @version 9.6
  5. // @description Adds lots of commands to bonk.io. Type /? or /help in bonk chat to get started.
  6. // @author LEGENDBOSS123 + left paren + mastery3
  7. // @match https://bonk.io/*
  8. // @run-at document-idle
  9. // @grant none
  10. // @unwrap
  11. // ==/UserScript==
  12. function BonkCommandsScriptInjector(f){
  13. if(window.location == window.parent.location){
  14. if(document.readyState == "complete"){f();}
  15. else{document.addEventListener('readystatechange',function(){setTimeout(f,1500);});}
  16. }
  17. }
  18.  
  19. BonkCommandsScriptInjector(function(){
  20. var scope = window;
  21.  
  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.originalingamechatremovechild)=='undefined'){scope.originalingamechatremovechild = Gdocument.getElementById("ingamechatcontent").removeChild;}
  344. 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];}
  345. if(Gdocument.getElementById("maploadtypedropdowntitlerequested") == null){
  346. scope.clearmaprequests = Gdocument.createElement("div");
  347. clearmaprequests.id = "clearmaprequests";
  348. clearmaprequests.classList.value = "brownButton brownButton_classic buttonShadow";
  349. clearmaprequests.textContent = "Clear";
  350. clearmaprequests.style["position"] = "absolute";
  351. clearmaprequests.style["display"] = "none";
  352. if(typeof(ishost)!='undefined'){
  353. if(ishost && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS"){
  354. clearmaprequests.style["display"] = "block";
  355. }
  356. }
  357. clearmaprequests.style["right"] = "306px";
  358. clearmaprequests.style["top"] = "57px";
  359. clearmaprequests.style["height"] = "23px";
  360. clearmaprequests.style["width"] = "47px";
  361. clearmaprequests.style["line-height"] = "23px";
  362. clearmaprequests.style["font-size"] = "14px";
  363. clearmaprequests.addEventListener("click",function(){
  364. requestedmaps = [];
  365. Gdocument.getElementById("maploadwindowstatustext").style["visibility"] = "inherit";
  366. Gdocument.getElementById("maploadwindowstatustext").textContent = "No Maps";
  367. while(Gdocument.getElementById("maploadwindowmapscontainer").children.length>0){
  368. Gdocument.getElementById("maploadwindowmapscontainer").removeChild(Gdocument.getElementById("maploadwindowmapscontainer").firstChild);
  369. }
  370. });
  371. Gdocument.getElementById("maploadwindow").insertBefore(clearmaprequests,Gdocument.getElementById("maploadwindowsearchinput"));
  372. scope.refreshmaprequests = Gdocument.createElement("div");
  373. refreshmaprequests.id = "refreshmaprequests";
  374. refreshmaprequests.classList.value = "brownButton brownButton_classic buttonShadow";
  375. refreshmaprequests.textContent = "Refresh";
  376. refreshmaprequests.style["position"] = "absolute";
  377. refreshmaprequests.style["display"] = "none";
  378. if(typeof(ishost)!='undefined'){
  379. if(ishost && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS"){
  380. refreshmaprequests.style["display"] = "block";
  381. }
  382. }
  383. refreshmaprequests.style["right"] = "357px";
  384. refreshmaprequests.style["top"] = "57px";
  385. refreshmaprequests.style["height"] = "23px";
  386. refreshmaprequests.style["width"] = "47px";
  387. refreshmaprequests.style["line-height"] = "23px";
  388. refreshmaprequests.style["font-size"] = "14px";
  389. refreshmaprequests.addEventListener("click",function(){
  390. Gdocument.getElementById("maploadtypedropdowntitle").textContent = dropdownrequested.textContent;
  391. Gdocument.getElementById("maploadwindowsearchinput").value = "";
  392. dropdownrequested.style["display"] = "none";
  393. clearmaprequests.style["display"] = "block";
  394. refreshmaprequests.style["display"] = "block";
  395. Gdocument.getElementById("maploadwindowhotnessslider").style["visibility"] = "hidden";
  396. Gdocument.getElementById("maploadwindowsearchoptions").style["visibility"] = "hidden";
  397. searchrequested = true;
  398. Gdocument.getElementById("maploadwindowsearchbutton").click();
  399.  
  400. Gdocument.getElementById("maploadtypedropdowntitle").textContent = "MAP REQUESTS";
  401. });
  402. Gdocument.getElementById("maploadwindow").insertBefore(refreshmaprequests,Gdocument.getElementById("maploadwindowsearchinput"));
  403.  
  404. scope.dropdownrequested = Gdocument.createElement("div");
  405. dropdownrequested.classList = "dropdown-option dropdown_classic";
  406. dropdownrequested.style["display"] = "none";
  407. dropdownrequested.id = "maploadtypedropdowntitlerequested";
  408.  
  409. if(Gdocument.getElementById("maploadtypedropdownoption10").style["display"] == "block"){
  410. dropdownrequested.style["display"] = "block";
  411. }
  412. dropdownrequested.textContent = "MAP REQUESTS";
  413. dropdownrequested.onclick = function(){
  414. Gdocument.getElementById("maploadtypedropdowntitle").textContent = dropdownrequested.textContent;
  415. Gdocument.getElementById("maploadwindowsearchinput").value = "";
  416. dropdownrequested.style["display"] = "none";
  417. clearmaprequests.style["display"] = "block";
  418. refreshmaprequests.style["display"] = "block";
  419. Gdocument.getElementById("maploadwindowhotnessslider").style["visibility"] = "hidden";
  420. Gdocument.getElementById("maploadwindowsearchoptions").style["visibility"] = "hidden";
  421. searchrequested = true;
  422. Gdocument.getElementById("maploadwindowsearchbutton").click();
  423.  
  424. Gdocument.getElementById("maploadtypedropdowntitle").textContent = "MAP REQUESTS";
  425. };
  426. (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});
  427. Gdocument.getElementById("maploadtypedropdown").insertBefore(dropdownrequested,Gdocument.getElementById("maploadtypedropdownoption1"));
  428. };
  429.  
  430. function sandboxonclick(){
  431. Gdocument.getElementById("roomlistcreatewindowmaxplayers").value = 1;
  432. Gdocument.getElementById("roomlistcreatewindowunlistedcheckbox").checked = true;
  433. Gdocument.getElementById("roomlistcreatecreatebutton").click();
  434. sandboxon = true;
  435. }
  436. function checkboxclearbuttononclick(){
  437. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  438. var e = true;
  439. for(var i = 0; i<classes.length;i++){
  440. if(classes[i].checked == true){
  441. e = false
  442. }
  443. classes[i].checked = false;
  444. }
  445. if(e){
  446. for(var i = 0; i<classes.length;i++){
  447. classes[i].checked = true;
  448. }
  449. }
  450. }
  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. Gdocument.getElementById("ingamechatcontent").removeChild = function(...arguments) {
  1261. if([...arguments][1] || Gdocument.getElementById("leaveconfirmwindowcontainer").style["visibility"] != "hidden" || gotbanned){
  1262. originalingamechatremovechild.call(this, ...arguments);
  1263. }
  1264. else{
  1265. return;
  1266. }
  1267. };
  1268. Gwindow.XMLHttpRequest.prototype.open = function(_, url) {
  1269. if (url.includes("scripts/map_get") || url.includes("scripts/map_b1_get") || url.includes("scripts/hotmaps/")) {
  1270. this.isSearchMap = true;
  1271. }
  1272. originalXMLOpen.call(this, ...arguments);
  1273. };
  1274. Gwindow.XMLHttpRequest.prototype.send = function(data) {
  1275. if (this.isSearchMap) {
  1276. this.onreadystatechange = function () {
  1277. if (this.readyState == 4 && searchrequested && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS") {
  1278. searchrequested = false;
  1279. var jsonargs = {r:"success",maps:[],more:true};
  1280. for(var i = 0; i<requestedmaps.length; i++){
  1281. var dec = requestedmaps[i][0];
  1282. var undec = requestedmaps[i][1];
  1283. var map = {};
  1284. map.id = dec["m"]["dbid"];
  1285. map.name = dec["m"]["n"];
  1286. map.authorname = dec["m"]["a"];
  1287. map.leveldata = undec;
  1288. map.publisheddate = dec["m"]["date"];
  1289. map.remixauthor = dec["m"]["rxa"];
  1290. map.remixdb = dec["m"]["rxdb"];
  1291. map.remixid = dec["m"]["rxid"];
  1292. map.remixname = dec["m"]["rxn"];
  1293. map.vd = dec["m"]["vd"];
  1294. map.vu = dec["m"]["vu"];
  1295. jsonargs.maps.push(map);
  1296. }
  1297. jsonargs2 = JSON.stringify(jsonargs);
  1298. function stringifyjsonargs(){
  1299. return jsonargs2;
  1300. }
  1301. this.__defineGetter__("responseText", stringifyjsonargs);
  1302. this.__defineGetter__("response", stringifyjsonargs);
  1303. }
  1304. }
  1305. }
  1306. originalXMLSend.call(this, ...arguments);
  1307. };
  1308.  
  1309. Gwindow.WebSocket.prototype.send = function(args) {
  1310. if(this.url.includes(".bonk.io/socket.io/?EIO=3&transport=websocket&sid=")){
  1311. bonkwss = this;
  1312. wsssendlog.push(args);
  1313. wsssendrecievelog.push([0,args]);
  1314. if(typeof(args) == "string"){
  1315. if(args.startsWith('42[26,')){
  1316. if(sandboxon){
  1317. var jsonargs = JSON.parse(args.substring(2))[1];
  1318. if(typeof(sandboxplayerids[jsonargs["targetID"]])!='undefined'){
  1319. RECIEVE('42[18,'+jsonargs["targetID"]+','+jsonargs["targetTeam"]+']');
  1320.  
  1321. }
  1322. }
  1323. }
  1324. if(args.startsWith('42[1,')){
  1325. return;
  1326. }
  1327.  
  1328. if(args.startsWith('42[4,')){
  1329. var jsonargs = JSON.parse(args.substring(2));
  1330. if(sandboxcopyme && typeof(jsonargs[1]["type"])=="undefined"){
  1331. var jsonkeys = Object.keys(sandboxplayerids);
  1332. for(var i = 0; i<jsonkeys.length;i++){
  1333. RECIEVE('42[7,'+jsonkeys[i].toString()+','+JSON.stringify(jsonargs[1])+']');
  1334. }
  1335. }
  1336. args = "42"+JSON.stringify(jsonargs);
  1337. }
  1338. if(args.startsWith('42[12,')){
  1339. playerids["0"] = username;
  1340. }
  1341. if(args.startsWith('42[23,')){
  1342. var jsonargs = JSON.parse(args.substring(2));
  1343. var map = decodeFromDatabase(jsonargs[1]["m"]);
  1344. var spawns = map["spawns"];
  1345. var caps = map["capZones"];
  1346. var teamsneeded = true;
  1347. var ffacaps = false;
  1348. var ffaforsure = false;
  1349. for(var i = 0; i<caps.length;i++){
  1350. var currentCap = caps[i];
  1351. if(currentCap.ty==0){
  1352. ffacaps = true;
  1353. }
  1354. }
  1355. var excludedindexes = [];
  1356. var ffaspawns = false;
  1357. for(var i = 0; i<spawns.length;i++){
  1358. var currentSpawn = spawns[i];
  1359. if(currentSpawn.f){
  1360. ffaspawns = true;
  1361. }
  1362. if(currentSpawn.f && !(currentSpawn.r || currentSpawn.b || currentSpawn.gr || currentSpawn.ye)){
  1363. excludedindexes.push(i);
  1364. }
  1365. if(Math.sqrt(currentSpawn.x**2 + currentSpawn.y**2)>=850 && currentSpawn.y>250){
  1366. excludedindexes.push(i);
  1367. }
  1368. else if(!(currentSpawn.f || currentSpawn.r || currentSpawn.b || currentSpawn.gr || currentSpawn.ye)){
  1369. excludedindexes.push(i);
  1370. }
  1371. }
  1372. if((!(ffaspawns && (spawns.length>0)) || (!ffacaps && (caps.length > 0))) && !ffaforsure){
  1373. teamsneeded = true;
  1374. }
  1375. else{
  1376. teamsneeded = false;
  1377. }
  1378. if(teamsneeded){
  1379. var newspawns = [];
  1380. for(var i = 0; i<spawns.length;i++){
  1381. if(!excludedindexes.includes(i)){
  1382. newspawns.push(spawns[i]);
  1383. }
  1384. }
  1385. newspawns.sort(function(a,b){return b.priority - a.priority});
  1386. }
  1387. }
  1388.  
  1389. if(args.startsWith('42[47,') && stopquickplay == 0 && ishost && document.hidden){
  1390. if(shuffle){
  1391. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  1392. var available = [];
  1393. var availableindexes = [];
  1394. var notempty = false;
  1395. for(var i = 0; i<e2.length;i++){
  1396. var a = false;
  1397. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  1398. available.push(a);
  1399. if(a){
  1400. availableindexes.push(i);
  1401. notempty = true;
  1402. }
  1403. }
  1404. if(notempty){
  1405.  
  1406. if(availableindexes.length!=1){
  1407. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  1408. }
  1409. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  1410. }
  1411. }
  1412. else{
  1413. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  1414. var available = [];
  1415. var availableindexes = [];
  1416. var notempty = false;
  1417. for(var i = 0; i<e2.length;i++){
  1418. var a = false;
  1419. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  1420. available.push(a);
  1421. if(a){
  1422. availableindexes.push(i);
  1423. notempty = true;
  1424. }
  1425. }
  1426. if(notempty){
  1427. var above = [];
  1428. for(var i = 0;i<availableindexes.length;i++){
  1429. if(availableindexes[i]>quicki){
  1430. above.push(availableindexes[i]);
  1431. }
  1432. }
  1433. if(above.length>0){
  1434. quicki = above[0];
  1435. }
  1436. else{
  1437. quicki = availableindexes[0];
  1438. }
  1439. }
  1440. }
  1441. canceled = false;
  1442. startedinqp = true;
  1443. window.map(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length),0);
  1444. }
  1445.  
  1446. if(args.startsWith('42[5,')){
  1447. var jsonargs = JSON.parse(args.substring(2));
  1448. if(stopquickplay!=1 && startedinqp){
  1449. startedinqp = false;
  1450. jsonargs[1]["gs"]["wl"] = 999;
  1451. if(!instaqp){
  1452. var jsonargs2 = decodeIS(jsonargs[1]["is"]);
  1453. jsonargs2["ftu"] = 60;
  1454. if(jsonargs2["mm"]["rxa"] != ""){
  1455. jsonargs2["mm"]["a"] = jsonargs2["mm"]["rxa"];
  1456. jsonargs2["mm"]["n"] = jsonargs2["mm"]["rxn"];
  1457. }
  1458. jsonargs2 = encodeIS(jsonargs2);
  1459. jsonargs[1]["is"] = jsonargs2;
  1460. var jsonargs3 = decodeFromDatabase(jsonargs[1]["gs"]["map"]);
  1461. jsonargs3["m"]["a"] = jsonargs3["m"]["rxa"];
  1462. jsonargs3["m"]["n"] = jsonargs3["m"]["rxn"];
  1463.  
  1464. jsonargs3 = encodeToDatabase(jsonargs3);
  1465. jsonargs[1]["gs"]["map"] = jsonargs3;
  1466. }
  1467. }
  1468.  
  1469. args = "42"+JSON.stringify(jsonargs);
  1470. }
  1471. }
  1472.  
  1473. }
  1474. else{
  1475. this.onmessage = function(args){return;};
  1476. return;
  1477.  
  1478. }
  1479. if(this.url.includes(".bonk.io/socket.io/?EIO=3&transport=websocket&sid=") && !this.injected){
  1480. this.injected = true;
  1481.  
  1482. var originalRecieve = this.onmessage;
  1483. this.onmessage = function(args){
  1484. wssrecievelog.push(args.data);
  1485. wsssendrecievelog.push([1,args.data]);
  1486. if(typeof(args.data)=="string"){
  1487. if(args.data.startsWith('42[1,')){
  1488. var jsonargs = JSON.parse(args.data.substring(2));
  1489. originalSend.call(this,'42[1,{"id":'+jsonargs[2]+'}]');
  1490. }
  1491. if(args.data.startsWith('42[24,')){
  1492. var jsonargs = JSON.parse(args.substring(2));
  1493. var jsonkeys = Object.keys(playerids);
  1494. for(var i = 0; i<jsonkeys.length;i++){
  1495. if(playerids[jsonkeys[i]] == username){
  1496. gotbanned = true;
  1497. }
  1498. }
  1499. beenKickedTimeStamp = Date.now();
  1500. }
  1501. if(args.data.startsWith('42[6,')){
  1502. var jsonargs = JSON.parse(args.data.substring(2));
  1503. if(typeof(playerids[jsonargs[1]])!='undefined'){
  1504. delete playerids[jsonargs[1]];
  1505. }
  1506. }
  1507. if(args.data.startsWith('42[32')){
  1508. SEND('42[4,{"type":"inactive kick counter"}]');
  1509. }
  1510. if(args.data.startsWith('42[40,')){
  1511. recordedTimeStamp = Date.now();
  1512. recordedId = JSON.parse(args.data.substring(2))[1];
  1513. }
  1514. if(args.data.startsWith('42[3,')){
  1515. var jsonargs = JSON.parse(args.data.substring(2));
  1516. for(var i = 0; i<jsonargs[3].length;i++){
  1517. if(jsonargs[3][i]!=null){
  1518. playerids[i.toString()] = jsonargs[3][i]["userName"];
  1519. }
  1520. }
  1521. }
  1522. if(args.data.startsWith('42[15,')){
  1523. var jsonargs = JSON.parse(args.data.substring(2));
  1524. gameStartTimeStamp = jsonargs[1];
  1525. }
  1526. if(args.data.startsWith('42[33,')){
  1527. var jsonargs = JSON.parse(args.data.substring(2));
  1528. var decodedmap = decodeFromDatabase(jsonargs[1]);
  1529. if(decodedmap!=0){
  1530. requestedmaps.push([decodedmap,jsonargs[1]]);
  1531. }
  1532. }
  1533. if(args.data.startsWith('42[7,')){
  1534. var jsonargs2 = JSON.parse(args.data.substring(2));
  1535. var idofpacket = jsonargs2[1];
  1536. jsonargs = jsonargs2[2];
  1537. if(typeof(jsonargs["type"]) != "undefined"){
  1538. if(jsonargs["type"]=="private chat" && jsonargs["to"] == username){
  1539. from = jsonargs["from"];
  1540. if(Object.keys(playerids).includes(idofpacket.toString())){
  1541. from = playerids[idofpacket];
  1542. }
  1543. if(!ignorepmlist.includes(from)){
  1544. if(typeof(jsonargs["message"])=="object" && typeof(jsonargs["password"]) == "object"){
  1545. if(public_key[0]==jsonargs["public key"][0] && public_key[1]==jsonargs["public key"][1]){
  1546. if(jsonargs["password"].length<=25){
  1547. var password = CRYPT_MESSAGE(private_key,jsonargs["password"]);
  1548. var decodedtext = jsonargs["message"].slice(0,400);
  1549. var encodedtext = "";
  1550. for(var i=0;i<decodedtext.length;i++){
  1551. if(password[i%password.length]<1000){
  1552. encodedtext+=String.fromCharCode(password[i%password.length]^decodedtext[i]);
  1553. }
  1554. }
  1555. 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);';
  1556. displayInChat('> '+'<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+from+'</a>'+': ',"#DA0808","#1EBCC1",{sanitize:false},encodedtext);
  1557.  
  1558. Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true;
  1559. Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true;
  1560. Laster_message = lastmessage();
  1561. }
  1562. }
  1563. else{
  1564. SEND("42"+JSON.stringify([4,{"type":"public key correction","from":username,"to":private_chat_public_key[0],"public key":public_key}]));
  1565. }
  1566. }
  1567. }
  1568. }
  1569. if(jsonargs["type"]=="request public key" && jsonargs["to"] == username){
  1570. SEND("42"+JSON.stringify([4,{"type":"public key","from":username,"public key":public_key}]));
  1571. }
  1572. if(jsonargs["type"]=="private chat users" && pmuserstimestamp+1500>Date.now()){
  1573. if(typeof(jsonargs["from"])!='undefined'){
  1574. from = jsonargs["from"];
  1575. if(Object.keys(playerids).includes(idofpacket.toString())){
  1576. from = playerids[idofpacket];
  1577. }
  1578. if(!pmusers.includes(from) && username == jsonargs["to"]){
  1579. pmusers.push(from);
  1580. }
  1581. }
  1582. }
  1583. if(jsonargs["type"]=="request private chat users"){
  1584. if(typeof(jsonargs["from"])!='undefined'){
  1585. from = jsonargs["from"];
  1586. if(Object.keys(playerids).includes(idofpacket.toString())){
  1587. from = playerids[idofpacket];
  1588. }
  1589. SEND("42"+JSON.stringify([4,{"type":"private chat users","from":username,"to":from}]));
  1590. }
  1591. }
  1592. if(jsonargs["type"]=="public key" && request_public_key_time_stamp+1500>Date.now()){
  1593. from = jsonargs["from"];
  1594. if(Object.keys(playerids).includes(idofpacket.toString())){
  1595. from = playerids[idofpacket];
  1596. }
  1597. if(from == private_chat){
  1598. private_chat_public_key = [private_chat,jsonargs["public key"]];
  1599. displayInChat("Private chatting with "+private_chat+".","#DA0808","#1EBCC1");
  1600. }
  1601.  
  1602. }
  1603. if(jsonargs["type"]=="public key correction" && private_chat_public_key[0] == private_chat){
  1604. from = jsonargs["from"];
  1605. if(Object.keys(playerids).includes(idofpacket.toString())){
  1606. from = playerids[idofpacket];
  1607. }
  1608. if(from == private_chat){
  1609. private_chat_public_key = [private_chat,jsonargs["public key"]];
  1610. var text = pmlastmessage;
  1611. var password = [];
  1612. for(var i = 0;i<10;i++){
  1613. password.push(Math.floor(Math.random()*100+50));
  1614. }
  1615. var text2 = [];
  1616. for(var i = 0;i<text.length ;i++){
  1617. text2.push(password[i%password.length]^text.slice(0,400).charCodeAt(i));
  1618. }
  1619. 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)}]));
  1620. }
  1621. }
  1622.  
  1623. }
  1624. else{
  1625. gameStartTimeStamp = Date.now()-1000*jsonargs["f"]/30;
  1626. }
  1627. }
  1628.  
  1629. if(args.data.startsWith('42[4,')){
  1630. var jsonargs = JSON.parse(args.data.substring(2));
  1631. playerids[jsonargs[1]] = jsonargs[3];
  1632.  
  1633. }
  1634. if(args.data.startsWith('42[5,')){
  1635. var jsonargs = JSON.parse(args.data.substring(2));
  1636. if(typeof(playerids[jsonargs[1]])!='undefined'){
  1637. delete playerids[jsonargs[1]];
  1638. }
  1639. }
  1640. }
  1641. return originalRecieve.call(this,args);
  1642. };
  1643.  
  1644. var originalClose = this.onclose;
  1645. this.onclose = function () {
  1646. window.bonkwss = 0;
  1647. return originalClose.call(this);
  1648. }
  1649.  
  1650. }
  1651. return originalSend.call(this,args);
  1652. };
  1653.  
  1654. scope.SEND = function(args){
  1655. if(bonkwss!=0){
  1656. bonkwss.send(args);
  1657. }
  1658. };
  1659. scope.RECIEVE = function(args){
  1660. if(bonkwss!=0){
  1661. bonkwss.onmessage({data:args});
  1662. }
  1663. };
  1664.  
  1665.  
  1666.  
  1667. scope.dontswitch = false;
  1668. scope.username = 0;
  1669. scope.timedelay = 1400;
  1670. scope.ishost = false;
  1671. scope.checkboxhidden = true;
  1672. scope.quicki=0;
  1673. scope.defaultmode = "d";
  1674. scope.recmodebool = false;
  1675. scope.shuffle = false;
  1676. scope.startedinqp = false;
  1677. scope.instaqp = false;
  1678. scope.freejoin = false;
  1679. scope.recordedTimeStamp = 0;
  1680. scope.recordedId = 0;
  1681. scope.smartteams = false;
  1682. scope.beenKickedTimeStamp = 0;
  1683. scope.stopquickplay = 1;
  1684. scope.currentFrame = 0;
  1685. scope.text2speech = false;
  1686. scope.gameStartTimeStamp = 0;
  1687. scope.canceled = false;
  1688. scope.banned = [];
  1689. scope.transitioning = false;
  1690. scope.echo_list = [];
  1691. scope.echoAppend = "";
  1692. scope.message = "";
  1693. scope.mode = "";
  1694. scope.private_chat = "";
  1695. scope.private_chat_public_key = ["",[0,0]];
  1696. scope.users = [];
  1697. scope.pmusers = [];
  1698. scope.pmlastmessage = "";
  1699. scope.pmuserstimestamp = 0;
  1700. scope.ignorepmlist = [];
  1701. scope.scroll = false;
  1702. scope.elem = Gdocument.getElementById("maploadwindowmapscontainer");
  1703. scope.npermissions = 1;
  1704. scope.space_flag = false;
  1705. scope.rcaps_flag = false;
  1706. scope.number_flag = false;
  1707. scope.request_public_key_time_stamp = 0;
  1708. scope.sandboxcopyme = false;
  1709. scope.chatheight = 128;
  1710. scope.gotbanned = false;
  1711. 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"];
  1712.  
  1713. scope.adv_help = {"help":"Shows all command names.",
  1714. "?":"Shows all command names.",
  1715. "advhelp":"Shows a command in detail.",
  1716. "space":"Toggles space. When space is on, whatever you type will be spaced apart.",
  1717. "rcaps":"Toggles rcaps. When rcaps is on, each letter will randomly get capitalized.",
  1718. "number":"Toggles number. When number is on, 'a' becomes 4, 'e' becomes 3, 's' becomes 5, 'o' becomes 0, 'l' and 'i' become 1.",
  1719. "speech":"Turns on text to speech for the chat.",
  1720. "echo":"Echoes a username. It copies the username's chat messages.",
  1721. "echoappend":"Appends the text to the end of each echo.",
  1722. "remove":"Removes username from echo list. You will not echo that username anymore.",
  1723. "clearecho":"Clears echo list. You will not echo anyone anymore.",
  1724. "chatw":"It private chats with username. Type /msg to message that username.",
  1725. "msg":"Messages with what username you are chatting with. Type /chatw to chat with a username.",
  1726. "ignorepm":"Ignores the username's private chat messages. To unignore, type /ignorepm [username].",
  1727. "pmusers":"Dispays who you can private chat with.",
  1728. "eval":"Evaluates code. Only use this if you are experienced in javascript.",
  1729. "debugger":"Opens debugger.",
  1730. "lobby":"Makes lobby visible when you are ingame. Type /lobby again to close lobby.",
  1731. "team":"Joins a specific team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  1732. "scroll":"Toggles a scrollbar in ingame chat.",
  1733. "hidechat":"Hides ingame chat. Type /showchat to show it again.",
  1734. "showchat":"Shows ingame chat. /hidechat hides the chat.",
  1735. "notify":"You will be notified if a person types @MYUSERNAME",
  1736. "stopnotify":"You will not be notified if a person types @MYUSERNAME",
  1737. "startqp":"Starts cycling maps in your map menu.",
  1738. "stopqp":"Stops cycling maps in your map menu.",
  1739. "next":"Skips the map. Usable only with /startqp.",
  1740. "previous":"Goes to previous map. Usable only with /startqp.",
  1741. "shuffle":"Makes quickplay play random maps instead of in order.",
  1742. "freejoin":"Toggles freejoin. If freejoin is on, starts the game instantly if there are 1 or less players currently playing.",
  1743. "recmode":"In quickplay, it switches mode to recommended mode, according to editor.",
  1744. "defaultmode":"Switches mode to defaultmode if there is no recmode.",
  1745. "start":"Starts game instantly.",
  1746. "instaqp":"Rounds will instantly start without a countdown.",
  1747. "balanceA":"Balances everyone with balance number.",
  1748. "moveA":"Sets everyones team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  1749. "rounds":"Sets rounds to win.",
  1750. "mode":"Switches modes.",
  1751. "ban":"Bans username from lobby. If they rejoin, it automatically bans.",
  1752. "kill":"Kills the person ingame.",
  1753. "addplayer":"In sandbox, it adds players.",
  1754. "delplayer":"In sandbox, it deletes players.",
  1755. "copyme":"In sandbox, it makes each player copy your movements.",
  1756. "Alt L":"Makes lobby visible when you are ingame. Press Alt L again to close lobby.",
  1757. "Alt C":"Hides ingame chat. Press Alt C again to show ingame chat.",
  1758. "Alt S":"Starts game instantly.",
  1759. "Alt T":"Toggles teams.",
  1760. "Alt E":"Toggles editor.",
  1761. "Alt K":"Exits ingame and returns to lobby.",
  1762. "Alt M":"Switches modes.",
  1763. "Alt Q":"Toggles quickplay.",
  1764. "Alt A":"Skips the map if quickplay is on.",
  1765. "Alt D":"Goes to previous map if quickplay is on.",
  1766. "Alt F":"Toggles freejoin. If freejoin is on, starts the game instantly if there are 1 or less players currently playing",
  1767. "Alt R":"In quickplay, it switches mode to recommended mode, according to editor.",
  1768. "Alt I":"Opens debugger.",
  1769. "Alt <":"Lowers ingame chat height.",
  1770. "Alt >":"Highers ingame chat height"
  1771. };
  1772. Gdocument.getElementById("ingamechatcontent").style["pointer-events"]="all";
  1773. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  1774. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  1775. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  1776.  
  1777. document.getElementById('adboxverticalCurse').style["display"] = "none";
  1778. document.getElementById('adboxverticalleftCurse').style["display"] = "none";
  1779. elem.onclick=function(e){
  1780. if(stopquickplay==0 && ishost == true && e.isTrusted == true){
  1781. quicki = (Array.from(e.target.parentElement.parentNode.children).indexOf(e.target.parentNode)-1)%(Gdocument.getElementById("maploadwindowmapscontainer").children.length);
  1782. }
  1783. };
  1784. scope.urlify = function(text) {
  1785. return text.replace(/(?:https?:\/\/)?(?:[A-Za-z0-9-ßàÁâãóôþüúðæåïçèõöÿýòäœêëìíøùîûñé]+)(?:\.[A-Za-z0-9-ßàÁâãóôþüúðæåïçèõöÿýòäœêëìíøùîûñé]+)+(?:\/(?:[A-Za-z0-9-._~:/?#\[\]@!$&'()*+,;=]|%[0-9a-fA-F]{2})*)?(?:\?(?:[^=]+=[^&](?:&[^=]+=[^&])*)?)?/g, function(url) {
  1786. if(url.startsWith('https://')){return '<a href="' + url + '" target="_blank" style = "color:orange">' + url + '</a>';}
  1787. else{return '<a href="https://' + url + '" target="_blank" style = "color:orange">' + url + '</a>';}
  1788. })
  1789. };
  1790.  
  1791. scope.fire = function(type,options,d = Gdocument){
  1792. var event=new CustomEvent(type);
  1793. for(var p in options){
  1794. event[p]=options[p];
  1795. }
  1796. d.dispatchEvent(event);
  1797. };
  1798.  
  1799. scope.chat = function(message){
  1800. mess = Gdocument.getElementById("newbonklobby_chat_input").value;
  1801. mess2 = Gdocument.getElementById("ingamechatinputtext").value;
  1802. Gdocument.getElementById("newbonklobby_chat_input").value = message;
  1803. Gdocument.getElementById("ingamechatinputtext").value = message;
  1804. fire("keydown",{keyCode:13});
  1805. fire("keydown",{keyCode:13});
  1806. Gdocument.getElementById("newbonklobby_chat_input").value = mess;
  1807. Gdocument.getElementById("ingamechatinputtext").value = mess2;
  1808. };
  1809. scope.displayInChat = function(message, LobbyColor, InGameColor, options, message2) {
  1810. options = options ?? {};
  1811. message2 = message2 ?? "";
  1812. LobbyColor = LobbyColor ?? "#8800FF";
  1813. InGameColor = InGameColor ?? "#AA88FF";
  1814. let A = Gdocument.createElement("div");
  1815. let B = Gdocument.createElement("span");
  1816. B.className = "newbonklobby_chat_status";
  1817. B.style.color = LobbyColor;
  1818. A.appendChild(B);
  1819. B.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  1820. B.innerHTML+=urlify(message2.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;'));
  1821. let C = Gdocument.createElement("div");
  1822. let D = Gdocument.createElement("span");
  1823. D.style.color = InGameColor;
  1824. C.appendChild(D);
  1825. D.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  1826. D.innerHTML+=urlify(message2.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;'));
  1827.  
  1828. let a = false;
  1829. if(Gdocument.getElementById("newbonklobby_chat_content").clientHeight + Gdocument.getElementById("newbonklobby_chat_content").scrollTop >= Gdocument.getElementById("newbonklobby_chat_content").scrollHeight-1) {
  1830. a = true;
  1831. }
  1832. Gdocument.getElementById("newbonklobby_chat_content").appendChild(A);
  1833. Gdocument.getElementById("ingamechatcontent").appendChild(C);
  1834. if (a) { Gdocument.getElementById("newbonklobby_chat_content").scrollTop = Number.MAX_SAFE_INTEGER;};
  1835. Gdocument.getElementById("ingamechatcontent").scrollTop = Number.MAX_SAFE_INTEGER;
  1836. chat("");
  1837. };
  1838.  
  1839. scope.lobby = function(){
  1840. if (Gdocument.getElementById("newbonklobby").style["display"]=="none"){
  1841.  
  1842. Gdocument.getElementById("newbonklobby_editorbutton").click();
  1843. Gdocument.getElementById("mapeditor_close").click();
  1844. if(Gdocument.getElementsByClassName("newbonklobby_playerentry").length>0){
  1845. Gdocument.getElementById("newbonklobby").style["z-index"]=1;
  1846. Gdocument.getElementById("maploadwindowcontainer").style["z-index"]=1;
  1847. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=1;
  1848. Gdocument.getElementById("pretty_top").style["z-index"]=3;
  1849. Gdocument.getElementById("settingsContainer").style["z-index"]=3;
  1850. Gdocument.getElementById("leaveconfirmwindow").style["z-index"]=3;
  1851. Gdocument.getElementById("hostleaveconfirmwindow").style["z-index"]=3;
  1852. debuggermenu.style["z-index"] = 2;
  1853. }
  1854. else{
  1855. Gdocument.getElementById("newbonklobby").style["opacity"]=0;
  1856. Gdocument.getElementById("newbonklobby").style["display"]="none";
  1857. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
  1858.  
  1859. }
  1860.  
  1861. }
  1862. else if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  1863. Gdocument.getElementById("newbonklobby").style["opacity"]=0;
  1864. Gdocument.getElementById("newbonklobby").style["display"]="none";
  1865. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
  1866.  
  1867. }
  1868. };
  1869.  
  1870. scope.lastmessage = function(){
  1871. if(Gdocument.getElementById("newbonklobby_chat_content").children.length!=0){
  1872. var lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  1873. var lm2 = "";
  1874. for(var i = 0; i<lm.length;i++){
  1875. lm2+=" "+lm[i].textContent.trim();
  1876. }
  1877. lm2 = lm2.trim();
  1878. if(lm2.startsWith("*")){
  1879. return lm2;
  1880. }
  1881. }
  1882. if(Gdocument.getElementById("ingamechatcontent").children.length!=0){
  1883. var lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  1884. var lm2 = "";
  1885. for(var i = 0; i<lm.length;i++){
  1886. lm2+=" "+lm[i].textContent.trim();
  1887. }
  1888. return lm2.trim();
  1889. }
  1890. return "";
  1891.  
  1892. };
  1893. scope.map = function(e,t=timedelay){
  1894. if(e<0){
  1895. displayInChat("There is no previous map.","#DA0808","#1EBCC1");
  1896. quicki = 0;
  1897. return;
  1898. }
  1899. if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
  1900. displayInChat("Click the maps button.","#DA0808","#1EBCC1");
  1901. return;
  1902. }
  1903.  
  1904. setTimeout(function(){if(!canceled){
  1905. startedinqp = true;
  1906. Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
  1907. Gdocument.getElementById("newbonklobby_editorbutton").click();
  1908. if(recmodebool && ishost){
  1909. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  1910. if(mode == "" && defaultmode!="d"){
  1911. mode = defaultmode;
  1912. }
  1913. if(mode != ""){
  1914. RECIEVE('42[26,"b","'+mode+'"]');
  1915. }
  1916. }
  1917. var displayblock = Gdocument.getElementById("newbonklobby").style["display"] == "block";
  1918. Gdocument.getElementById("mapeditorcontainer").style["display"] = "none";
  1919. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  1920. if(displayblock){
  1921. Gdocument.getElementById("newbonklobby").style["display"] = "block";
  1922. }
  1923. Gdocument.getElementById("mapeditor_midbox_testbutton").click();}
  1924. canceled = false;
  1925. transitioning = false;
  1926. },t);
  1927.  
  1928. };
  1929.  
  1930. scope.gotonextmap = function(e){
  1931. if(e<0){
  1932. displayInChat("There is no previous map.","#DA0808","#1EBCC1");
  1933. quicki = 0;
  1934. return;
  1935. }
  1936. if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
  1937. displayInChat("Click the maps button.","#DA0808","#1EBCC1");
  1938. return;
  1939. }
  1940. Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
  1941. Gdocument.getElementById("newbonklobby_editorbutton").click();
  1942. if(recmodebool && ishost){
  1943. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  1944. if(mode == "" && defaultmode!="d"){
  1945. mode = defaultmode;
  1946. }
  1947. if(mode != ""){
  1948. RECIEVE('42[26,"b","'+mode+'"]');
  1949. }
  1950. }
  1951. startedinqp = true;
  1952. var displayblock = Gdocument.getElementById("newbonklobby").style["display"] == "block";
  1953. Gdocument.getElementById("mapeditorcontainer").style["display"] = "none";
  1954. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  1955. if(displayblock){
  1956. Gdocument.getElementById("newbonklobby").style["display"] = "block";
  1957. }
  1958. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  1959. Gdocument.getElementById("newbonklobby").style["visibility"] = "visible";
  1960. };
  1961. scope.commandhandle = function(chat_val){
  1962. if (chat_val.substring(1,6)=="echo " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  1963. if (chat_val.substring(6).replace(/^\s+|\s+$/g, '')==username){
  1964. displayInChat("You cannot echo yourself.","#DA0808","#1EBCC1");
  1965. return "";
  1966. }
  1967. else if (echo_list.indexOf(chat_val.substring(6).replace(/^\s+|\s+$/g, ''))===-1) {
  1968.  
  1969. echo_list.push(chat_val.substring(6).replace(/^\s+|\s+$/g, ''));
  1970. displayInChat(chat_val.substring(6).replace(/^\s+|\s+$/g, '') + " is being echoed.","#DA0808","#1EBCC1");
  1971. return "";
  1972. }
  1973. else{
  1974. displayInChat(chat_val.substring(6).replace(/^\s+|\s+$/g, '') + " is already being echoed.","#DA0808","#1EBCC1");
  1975. return "";
  1976. }
  1977. }
  1978. else if (chat_val.substring(1,8)=="remove " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  1979. if (echo_list.indexOf(chat_val.substring(7).replace(/^\s+|\s+$/g, ''))!==-1){
  1980. echo_list.splice(echo_list.indexOf(chat_val.substring(7).replace(/^\s+|\s+$/g, '')),1);
  1981. displayInChat(chat_val.substring(7).replace(/^\s+|\s+$/g, '')+" is not being echoed.","#DA0808","#1EBCC1");
  1982. return "";
  1983. }
  1984. else{
  1985. displayInChat("You cannot remove someone that you didn't echo.","#DA0808","#1EBCC1");
  1986. return "";
  1987. }
  1988.  
  1989. }
  1990. else if (chat_val.substring(1,12)=="echoappend " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  1991. echoAppend = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  1992. displayInChat(echoAppend +" will be appended to each echo. Type \"/echoappend\" to reset echoappend.","#DA0808","#1EBCC1");
  1993. return "";
  1994.  
  1995. }
  1996. else if (chat_val.substring(1,11)=="echoappend"){
  1997. echoAppend = "";
  1998. displayInChat("Reset echoappend.","#DA0808","#1EBCC1");
  1999. return "";
  2000.  
  2001. }
  2002. else if (chat_val.substring(1,10)=="clearecho"){
  2003. echo_list = [];
  2004. displayInChat("Cleared the echo list.","#DA0808","#1EBCC1");
  2005. return "";
  2006. }
  2007. else if (chat_val.substring(1,6)=="space"){
  2008. if(space_flag == true){
  2009. displayInChat("Space is now off.","#DA0808","#1EBCC1");
  2010. space_flag = false;
  2011. }
  2012. else{
  2013. displayInChat("Space is now on.","#DA0808","#1EBCC1");
  2014. space_flag = true;
  2015. }
  2016. return "";
  2017. }
  2018. else if (chat_val.substring(1,6)=="rcaps"){
  2019. if(rcaps_flag == true){
  2020. displayInChat("Rcaps is now off.","#DA0808","#1EBCC1");
  2021. rcaps_flag = false;
  2022. }
  2023. else{
  2024. displayInChat("Rcaps is now on.","#DA0808","#1EBCC1");
  2025. rcaps_flag = true;
  2026. }
  2027.  
  2028. return "";
  2029. }
  2030. else if (chat_val.substring(1,7)=="number"){
  2031. if(number_flag == true){
  2032. displayInChat("Number is now off.","#DA0808","#1EBCC1");
  2033. number_flag = false;
  2034. }
  2035. else{
  2036. displayInChat("Number is now on.","#DA0808","#1EBCC1");
  2037. number_flag = true;
  2038. }
  2039.  
  2040. return "";
  2041. }
  2042. else if (chat_val.substring(1,7)=="speech"){
  2043. if(text2speech == true){
  2044. displayInChat("Text to speech is now off.","#DA0808","#1EBCC1");
  2045. text2speech = false;
  2046. }
  2047. else{
  2048. displayInChat("Text to speech is now on.","#DA0808","#1EBCC1");
  2049. text2speech = true;
  2050. }
  2051.  
  2052. return "";
  2053. }
  2054. else if (chat_val.substring(1,6)=="eval " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  2055. var ev = "";
  2056. try{
  2057. ev = eval(chat_val.substring(6).replace(/^\s+|\s+$/g, ''));
  2058. }
  2059. catch(e){
  2060. displayInChat(e.message,"#DA0808","#1EBCC1");
  2061. }
  2062. try{
  2063. displayInChat(ev.toString(),"#DA0808","#1EBCC1");
  2064. }
  2065. catch{
  2066. }
  2067.  
  2068. return "";
  2069.  
  2070. }
  2071.  
  2072. else if (chat_val.substring(1,9)=="hidechat"){
  2073. Gdocument.getElementById("ingamechatcontent").style["max-height"]="0px";
  2074. return "";
  2075. }
  2076. else if (chat_val.substring(1,9)=="showchat"){
  2077. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  2078. return "";
  2079. }
  2080.  
  2081. else if (chat_val.substring(1,7)=="scroll"){
  2082. if(scroll==false){
  2083. scroll = true;
  2084. Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="scroll";
  2085. Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
  2086. }
  2087. else if(scroll==true){
  2088. scroll = false;
  2089. Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="hidden";
  2090. Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
  2091. }
  2092.  
  2093. return "";
  2094. }
  2095.  
  2096. else if (chat_val.substring(1,7)=="chatw "){
  2097. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '');
  2098.  
  2099. if(username == text){
  2100. displayInChat("You cannot private chat with yourself.","#DA0808","#1EBCC1");
  2101. return "";
  2102. }
  2103. private_chat = text;
  2104.  
  2105. SEND("42"+JSON.stringify([4,{"type":"request public key","from":username,"to":private_chat}]));
  2106. request_public_key_time_stamp = Date.now();
  2107. 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);
  2108. return "";
  2109. }
  2110.  
  2111. else if (chat_val.substring(1,5)=="msg " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  2112. if(private_chat_public_key[1][0] != 0 && private_chat_public_key[1][1] != 0 && private_chat_public_key[0] == private_chat){
  2113. var text = chat_val.substring(5).replace(/^\s+|\s+$/g, '');
  2114. var password = [];
  2115. for(var i = 0;i<10;i++){
  2116. password.push(Math.floor(Math.random()*100+50));
  2117. }
  2118. var text2 = [];
  2119. for(var i = 0;i<text.slice(0,400).length ;i++){
  2120. text2.push(password[i%password.length]^text.slice(0,400).charCodeAt(i));
  2121. }
  2122. pmlastmessage = text.slice(0,400);
  2123. 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)}]));
  2124. displayInChat("> "+username+": "+text,"#DA0808","#1EBCC1");
  2125.  
  2126. }
  2127. return "";
  2128. }
  2129. else if (chat_val.substring(1,10)=="ignorepm " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  2130. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  2131. if(ignorepmlist.includes(text)){
  2132. var index = ignorepmlist.indexOf(text);
  2133. ignorepmlist.splice(index,1);
  2134. displayInChat("You are not ignoring private messages from "+text+".","#DA0808","#1EBCC1");
  2135.  
  2136. }
  2137. else{
  2138. ignorepmlist.push(text);
  2139. displayInChat("You are now ignoring private messages from "+text+".","#DA0808","#1EBCC1");
  2140. }
  2141. return "";
  2142. }
  2143. else if (chat_val.substring(1,8)=="pmusers"){
  2144. pmusers = [];
  2145. SEND("42"+JSON.stringify([4,{"type":"request private chat users","from":username}]));
  2146. pmuserstimestamp = Date.now();
  2147. setTimeout(function(){if(pmusers.length == 0){displayInChat("You cannot private chat with anyone.","#DA0808","#1EBCC1");
  2148. }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);
  2149. return "";
  2150. }
  2151. else if (chat_val.substring(1,6)=="lobby"){
  2152. lobby();
  2153. return "";
  2154. }
  2155. else if (chat_val.substring(1,9)=="debugger"){
  2156. if(Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"] == "none"){
  2157. debuggeropen = true;
  2158. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="block";
  2159. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="none";
  2160. Gdocument.getElementById("ingamechatinputtext").style["display"] = "none";
  2161. }
  2162. else{
  2163. debuggeropen = false;
  2164. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="none";
  2165. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  2166. Gdocument.getElementById("ingamechatinputtext").style["display"] = "";
  2167. }
  2168. return "";
  2169. }
  2170. else if (chat_val.substring(1,6)=="team " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  2171. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  2172. if(text == "r"){Gdocument.getElementById("newbonklobby_redbutton").click();}
  2173. else if(text == "g"){Gdocument.getElementById("newbonklobby_greenbutton").click();}
  2174. else if(text == "y"){Gdocument.getElementById("newbonklobby_yellowbutton").click();}
  2175. else if(text == "b"){Gdocument.getElementById("newbonklobby_bluebutton").click();}
  2176. else if(text == "s"){Gdocument.getElementById("newbonklobby_specbutton").click();}
  2177. else if(text == "f"){Gdocument.getElementById("newbonklobby_ffabutton").click();}
  2178. return "";
  2179. }
  2180. else if (chat_val.substring(1,7)=="notify"){
  2181.  
  2182. npermissions = 1;
  2183. return "";
  2184. }
  2185. else if (chat_val.substring(1,11)=="stopnotify"){
  2186.  
  2187. npermissions = 0;
  2188. return "";
  2189. }
  2190. else if (chat_val.substring(1,5)=="help" || chat_val.substring(1,2)=="?"){
  2191. for(var i = 0;i<help.length;i++){
  2192. displayInChat(help[i],"#DA0808","#1EBCC1");
  2193.  
  2194. }
  2195. return "";
  2196. }
  2197. else if (chat_val.substring(1,9)=="advhelp " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  2198. var text = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  2199. if(typeof(adv_help[text])!='undefined'){
  2200. displayInChat(adv_help[text],"#DA0808","#1EBCC1");
  2201. }
  2202. return "";
  2203. }
  2204. else if(ishost){
  2205.  
  2206. if (chat_val.substring(1,5)=="next" && stopquickplay == 0){
  2207. if(shuffle){
  2208. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  2209. var available = [];
  2210. var availableindexes = [];
  2211. var notempty = false;
  2212. for(var i = 0; i<e.length;i++){
  2213. var a = false;
  2214. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  2215. available.push(a);
  2216. if(a){
  2217. availableindexes.push(i);
  2218. notempty = true;
  2219. }
  2220. }
  2221. if(notempty){
  2222.  
  2223. if(availableindexes.length!=1){
  2224. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  2225. }
  2226. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  2227. }
  2228. }
  2229. else{
  2230. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  2231. var available = [];
  2232. var availableindexes = [];
  2233. var notempty = false;
  2234. for(var i = 0; i<e.length;i++){
  2235. var a = false;
  2236. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  2237. available.push(a);
  2238. if(a){
  2239. availableindexes.push(i);
  2240. notempty = true;
  2241. }
  2242. }
  2243. if(notempty){
  2244. var above = [];
  2245. for(var i = 0;i<availableindexes.length;i++){
  2246. if(availableindexes[i]>quicki){
  2247. above.push(availableindexes[i]);
  2248. }
  2249. }
  2250. if(above.length>0){
  2251. quicki = above[0];
  2252. }
  2253. else{
  2254. quicki = availableindexes[0];
  2255. }
  2256. }
  2257. }
  2258. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  2259. displayInChat("Switched to next map.","#DA0808","#1EBCC1");
  2260. return "";
  2261.  
  2262. }
  2263. else if (chat_val.substring(1,9)=="freejoin"){
  2264. if(freejoin == false){
  2265. freejoin = true;
  2266. displayInChat("Freejoin is now on.","#DA0808","#1EBCC1");
  2267.  
  2268. }
  2269. else{
  2270. freejoin = false;
  2271. displayInChat("Freejoin is now off.","#DA0808","#1EBCC1");
  2272. }
  2273.  
  2274. return "";
  2275.  
  2276. }
  2277. else if (chat_val.substring(1,8)=="instaqp"){
  2278. if(instaqp == false){
  2279. instaqp = true;
  2280. displayInChat("Instaqp is now on.","#DA0808","#1EBCC1");
  2281.  
  2282. }
  2283. else{
  2284. instaqp = false;
  2285. displayInChat("Instaqp is now off.","#DA0808","#1EBCC1");
  2286. }
  2287.  
  2288. return "";
  2289.  
  2290. }
  2291.  
  2292. else if (chat_val.substring(1,9)=="previous" && stopquickplay == 0){
  2293. if(shuffle){
  2294. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  2295. var available = [];
  2296. var availableindexes = [];
  2297. var notempty = false;
  2298. for(var i = 0; i<e.length;i++){
  2299. var a = false;
  2300. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  2301. available.push(a);
  2302. if(a){
  2303. availableindexes.push(i);
  2304. notempty = true;
  2305. }
  2306. }
  2307. if(notempty){
  2308.  
  2309. if(availableindexes.length!=1){
  2310. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  2311. }
  2312. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  2313. }
  2314. }
  2315. else{
  2316. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  2317. var available = [];
  2318. var availableindexes = [];
  2319. var notempty = false;
  2320. for(var i = 0; i<e.length;i++){
  2321. var a = false;
  2322. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  2323. available.push(a);
  2324. if(a){
  2325. availableindexes.push(i);
  2326. notempty = true;
  2327. }
  2328. }
  2329. if(notempty){
  2330. var above = [];
  2331. for(var i = 0;i<availableindexes.length;i++){
  2332. if(availableindexes[i]<quicki){
  2333. above.push(availableindexes[i]);
  2334. }
  2335. }
  2336. if(above.length>0){
  2337. quicki = above[above.length-1];
  2338. }
  2339. else{
  2340. quicki = availableindexes[availableindexes.length-1];
  2341. }
  2342. }
  2343. }
  2344. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  2345.  
  2346. displayInChat("Switched to previous map.","#DA0808","#1EBCC1");
  2347. return "";
  2348. }
  2349. else if (chat_val.substring(1,6)=="start" && chat_val.length == 6){
  2350. Gdocument.getElementById("newbonklobby_editorbutton").click();
  2351. if(recmodebool && ishost){
  2352. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  2353. if(mode == "" && defaultmode!="d"){
  2354. mode = defaultmode;
  2355. }
  2356. if(mode != ""){
  2357. RECIEVE('42[26,"b","'+mode+'"]');
  2358. }
  2359. }
  2360. Gdocument.getElementById("mapeditor_close").click();
  2361. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  2362. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  2363.  
  2364. return "";
  2365. }
  2366.  
  2367. else if (chat_val.substring(1,8)=="startqp" && stopquickplay == 1){
  2368. stopquickplay = 0;
  2369. quicki = 0;
  2370. displayInChat("Enabled quickplay.","#DA0808","#1EBCC1");
  2371. return "";
  2372. }
  2373. else if (chat_val.substring(1,7)=="stopqp" && stopquickplay == 0){
  2374. stopquickplay = 1;
  2375. quicki = 0;
  2376. displayInChat("Disabled quickplay.","#DA0808","#1EBCC1");
  2377. return "";
  2378. }
  2379.  
  2380. else if (chat_val.substring(1,5)=="ban " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  2381. banned.push(chat_val.substring(5).replace(/^\s+|\s+$/g, ''));
  2382. displayInChat("Banned "+chat_val.substring(5).replace(/^\s+|\s+$/g, '')+".","#DA0808","#1EBCC1");
  2383. return "/kick '" + chat_val.substring(5).replace(/^\s+|\s+$/g, '') + "'";
  2384. }
  2385. else if (chat_val.substring(1,6)=="kill " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  2386. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  2387. var keys = Object.keys(playerids);
  2388. var killid = undefined;
  2389. for(var i = 0; i<keys.length; i++){
  2390. if(playerids[keys[i]] == text){
  2391. killid = keys[i];
  2392. }
  2393. }
  2394. if(typeof(killid)!="undefined" && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  2395. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  2396. SEND('42[25,{"a":{"playersLeft":['+killid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  2397. RECIEVE('42[31,{"a":{"playersLeft":['+killid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  2398. }
  2399. return "";
  2400. }
  2401. else if (chat_val.substring(1,10)=="balanceA " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  2402. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  2403. if(!isNaN(parseInt(text))){
  2404. if(parseInt(text)>=-100 && parseInt(text)<=100){
  2405. var keys = Object.keys(playerids);
  2406. for(var i = 0; i<keys.length;i++){
  2407. SEND('42[29,{"sid":'+keys[i]+',"bal":'+text+'}]');
  2408. RECIEVE('42[36,'+keys[i]+','+text+']');
  2409. }
  2410. }
  2411. }
  2412. return "";
  2413.  
  2414. }
  2415. else if (chat_val.substring(1,7)=="moveA " && chat_val.replace(/^\s+|\s+$/g, '').length>=8){
  2416. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '');
  2417. var keys = Object.keys(playerids);
  2418. if(text == "f"){
  2419. for(var i = 0; i<keys.length;i++){
  2420. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":1}]')
  2421. }
  2422. }
  2423. else if(text == "b"){
  2424. for(var i = 0; i<keys.length;i++){
  2425. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":3}]')
  2426. }
  2427. }
  2428. else if(text == "g"){
  2429. for(var i = 0; i<keys.length;i++){
  2430. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":4}]')
  2431. }
  2432. }
  2433. else if(text == "r"){
  2434. for(var i = 0; i<keys.length;i++){
  2435. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":2}]')
  2436. }
  2437. }
  2438. else if(text == "y"){
  2439. for(var i = 0; i<keys.length;i++){
  2440. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":5}]')
  2441. }
  2442. }
  2443. else if(text == "s"){
  2444. for(var i = 0; i<keys.length;i++){
  2445. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":0}]')
  2446. }
  2447. }
  2448. return "";
  2449. }
  2450. else if (chat_val.substring(1,8)=="rounds " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  2451. var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '');
  2452. if(!isNaN(parseInt(text))){
  2453. text = parseInt(text).toString();
  2454. SEND('42[21,{"w":'+text+'}]');
  2455. RECIEVE('42[27,'+text+']');
  2456. }
  2457. return "";
  2458.  
  2459. }
  2460. else if (chat_val.substring(1,6)=="mode " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  2461. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  2462. var mode = "";
  2463. if(text == "arrows"){
  2464. mode = "ar";
  2465. displayInChat("Changed mode to arrows.","#DA0808","#1EBCC1");
  2466. }
  2467. else if(text == "death arrows"){
  2468. mode = "ard";
  2469. displayInChat("Changed mode to death arrows.","#DA0808","#1EBCC1");
  2470. }
  2471. else if(text == "grapple"){
  2472. mode = "sp";
  2473. displayInChat("Changed mode to grapple.","#DA0808","#1EBCC1");
  2474. }
  2475. else if(text == "classic"){
  2476. mode = "b";
  2477. displayInChat("Changed mode to classic.","#DA0808","#1EBCC1");
  2478.  
  2479. }
  2480. else{
  2481. displayInChat("Mode options:","#DA0808","#1EBCC1");
  2482. displayInChat("classic","#DA0808","#1EBCC1");
  2483. displayInChat("arrows","#DA0808","#1EBCC1");
  2484. displayInChat("death arrows","#DA0808","#1EBCC1");
  2485. displayInChat("grapple","#DA0808","#1EBCC1");
  2486. }
  2487. if(mode != ""){
  2488. SEND('42[20,{"ga":"b","mo":"'+mode+'"}]');
  2489. RECIEVE('42[26,"b","'+mode+'"]');
  2490. }
  2491. return "";
  2492.  
  2493. }
  2494. else if (chat_val.substring(1,13)=="defaultmode " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  2495. var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '');
  2496. if(text == "default"){
  2497. defaultmode = "";
  2498. displayInChat("Changed default mode to default.","#DA0808","#1EBCC1");
  2499. }
  2500. else if(text == "arrows"){
  2501. defaultmode = "ar";
  2502. displayInChat("Changed default mode to arrows.","#DA0808","#1EBCC1");
  2503. }
  2504. else if(text == "death arrows"){
  2505. defaultmode = "ard";
  2506. displayInChat("Changed default mode to death arrows.","#DA0808","#1EBCC1");
  2507. }
  2508. else if(text == "grapple"){
  2509. defaultmode = "sp";
  2510. displayInChat("Changed default mode to grapple.","#DA0808","#1EBCC1");
  2511. }
  2512. else if(text == "classic"){
  2513. defaultmode = "b";
  2514. displayInChat("Changed default mode to classic.","#DA0808","#1EBCC1");
  2515.  
  2516. }
  2517. else{
  2518. displayInChat("Default mode options:","#DA0808","#1EBCC1");
  2519. displayInChat("default","#DA0808","#1EBCC1");
  2520. displayInChat("classic","#DA0808","#1EBCC1");
  2521. displayInChat("arrows","#DA0808","#1EBCC1");
  2522. displayInChat("death arrows","#DA0808","#1EBCC1");
  2523. displayInChat("grapple","#DA0808","#1EBCC1");
  2524. }
  2525. return "";
  2526.  
  2527. }
  2528. else if (chat_val.substring(1,8)=="recmode"){
  2529. if(recmodebool == true){
  2530. recmodebool = false;
  2531. displayInChat("Recmode is now off.","#DA0808","#1EBCC1");
  2532.  
  2533. }
  2534. else{
  2535. recmodebool = true;
  2536. displayInChat("Recmode is now on.","#DA0808","#1EBCC1");
  2537.  
  2538. }
  2539.  
  2540. return "";
  2541.  
  2542. }
  2543. else if (chat_val.substring(1,8)=="shuffle"){
  2544. if(shuffle == true){
  2545. shuffle = false;
  2546. displayInChat("Shuffle is now off.","#DA0808","#1EBCC1");
  2547.  
  2548. }
  2549. else{
  2550. shuffle = true;
  2551. displayInChat("Shuffle is now on.","#DA0808","#1EBCC1");
  2552.  
  2553. }
  2554.  
  2555. return "";
  2556.  
  2557. }
  2558. else if(sandboxon){
  2559. if (chat_val.substring(1,11)=="addplayer " && 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. for(var i = 0;i<text2;i++){
  2565. RECIEVE('42[4,'+sandboxid+',"0123456789abcdef","'+sandboxid.toString()+'",true,0,1,{"layers":[],"bc":'+Math.floor(Math.random() * 16777215).toString()+'}]');
  2566. sandboxplayerids[sandboxid] = sandboxid.toString();
  2567. sandboxid+=1;
  2568. }
  2569.  
  2570. }
  2571. }
  2572. return "";
  2573.  
  2574. }
  2575. else if (chat_val.substring(1,11)=="delplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  2576. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  2577. if(!isNaN(parseInt(text))){
  2578. var text2 = parseInt(text);
  2579. if(text2>0){
  2580. if(Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden"){
  2581. var jsonkeys = Object.keys(sandboxplayerids).reverse();
  2582. for(var i = 0;i<text2 && i<jsonkeys.length;i++){
  2583. RECIEVE('42[5,'+jsonkeys[i]+',0]');
  2584. delete sandboxplayerids[jsonkeys[i]];
  2585. }
  2586. }
  2587. else{
  2588. displayInChat("Cannot delete players while ingame.","#DA0808","#1EBCC1");
  2589. }
  2590.  
  2591. }
  2592. }
  2593. return "";
  2594. }
  2595. else if (chat_val.substring(1,7)=="copyme"){
  2596. if(sandboxcopyme == true){
  2597. displayInChat("Copyme is now off.","#DA0808","#1EBCC1");
  2598. sandboxcopyme = false;
  2599. }
  2600. else{
  2601. displayInChat("Copyme is now on.","#DA0808","#1EBCC1");
  2602. sandboxcopyme = true;
  2603. }
  2604.  
  2605. return "";
  2606. }
  2607. }
  2608. }
  2609. return chat_val;
  2610. };
  2611.  
  2612. scope.flag_manage = function(t){
  2613. var text = t;
  2614.  
  2615. if(rcaps_flag == true){
  2616. text = text.split('');
  2617. for(var i = 0; i<text.length;i++){
  2618. if(Math.floor(Math.random()*2)){
  2619. text[i] = text[i].toUpperCase();
  2620. }
  2621. else{
  2622. text[i] = text[i].toLowerCase();
  2623. }
  2624. }
  2625. text = text.join('');
  2626. }
  2627. if(space_flag == true){
  2628. text = text.split('').join(' ')
  2629. }
  2630. if(number_flag == true){
  2631. text = text.replace(/[t|T][Oo]+/g,"2");
  2632. text = text.replace(/[f|F][o|O][r|R]/g,"4");
  2633. text = text.replace(/[a|A][t|T][e|E]/g,"8");
  2634. text = text.replace(/[e|E]/g,"3");
  2635. text = text.replace(/[a|A]/g,"4");
  2636. text = text.replace(/[o|O]/g,"0");
  2637. text = text.replace(/[s|S]/g,"5");
  2638. text = text.replace(/[i|I|l|L]/g,"1");
  2639. }
  2640. return text;
  2641. };
  2642. Gdocument.getElementById("newbonklobby_chat_input").onkeydown = function(e){
  2643. if(e.keyCode==13){
  2644.  
  2645. var chat_val = Gdocument.getElementById("newbonklobby_chat_input").value;
  2646.  
  2647. if (chat_val!="" && chat_val[0]=="/"){
  2648.  
  2649. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  2650. chat(commandhandle(chat_val));
  2651. }
  2652. else{
  2653. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  2654. chat(flag_manage(chat_val));
  2655. }
  2656.  
  2657. }
  2658. };
  2659. Gdocument.getElementById("ingamechatinputtext").onkeydown = function(e){
  2660. if(e.keyCode==13){
  2661.  
  2662. var chat_val = Gdocument.getElementById("ingamechatinputtext").value;
  2663.  
  2664. if (chat_val!="" && chat_val[0]=="/"){
  2665.  
  2666. Gdocument.getElementById("ingamechatinputtext").value = "";
  2667. chat(commandhandle(chat_val));
  2668. }
  2669. else{
  2670. Gdocument.getElementById("ingamechatinputtext").value = "";
  2671. chat(flag_manage(chat_val));
  2672. }
  2673. }
  2674. };
  2675. scope.Last_message = "";
  2676. scope.Laster_message = "";
  2677. scope.new_message = false;
  2678. scope.changed_chat = false;
  2679. scope.interval = setInterval(timeout123,60);
  2680.  
  2681. scope.hotkeys = function(e){
  2682. var keycode = e.code;
  2683. if(e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  2684. if(keycode == "Period"){
  2685. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]!="0px"){
  2686. chatheight+=5;
  2687. if(chatheight>600){chatheight = 600;}
  2688. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  2689. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  2690. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  2691. }
  2692. e.preventDefault();
  2693. }
  2694. if(keycode == "Comma"){
  2695. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]!="0px"){
  2696. chatheight-=5;
  2697. if(chatheight<100){chatheight = 100;}
  2698. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  2699. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  2700. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  2701. }
  2702. e.preventDefault();
  2703. }
  2704. }
  2705. if(e.repeat){return;}
  2706. if(e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  2707. if(ishost){
  2708. if(keycode == "KeyE"){
  2709. if(Gdocument.getElementById("newbonklobby").style["display"] == "block"){
  2710. Gdocument.getElementById("newbonklobby_editorbutton").click();
  2711. }
  2712. else if(Gdocument.getElementById("mapeditorcontainer").style["display"] == "block"){
  2713. Gdocument.getElementById("mapeditor_close").click();
  2714. }
  2715. e.preventDefault();
  2716.  
  2717. }
  2718. else if(keycode == "KeyT"){
  2719. Gdocument.getElementById("newbonklobby_teamsbutton").click();
  2720. e.preventDefault();
  2721. }
  2722. else if(keycode == "KeyM"){
  2723. Gdocument.getElementById("newbonklobby_modebutton").click();
  2724. e.preventDefault();
  2725. }
  2726. else if(keycode == "KeyK"){
  2727. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  2728. Gdocument.getElementById("pretty_top_exit").click();
  2729. }
  2730. e.preventDefault();
  2731. }
  2732. else if(keycode == "KeyS"){
  2733. Gdocument.getElementById("newbonklobby_editorbutton").click();
  2734. if(recmodebool && ishost){
  2735. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  2736. if(mode == "" && defaultmode!="d"){
  2737. mode = defaultmode;
  2738. }
  2739. if(mode != ""){
  2740. RECIEVE('42[26,"b","'+mode+'"]');
  2741. }
  2742. }
  2743. Gdocument.getElementById("mapeditor_close").click();
  2744. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  2745. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  2746. e.preventDefault();
  2747. }
  2748. else if(keycode == "KeyD"){
  2749. if(stopquickplay == 0){
  2750. if(shuffle){
  2751. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  2752. var available = [];
  2753. var availableindexes = [];
  2754. var notempty = false;
  2755. for(var i = 0; i<e2.length;i++){
  2756. var a = false;
  2757. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  2758. available.push(a);
  2759. if(a){
  2760. availableindexes.push(i);
  2761. notempty = true;
  2762. }
  2763. }
  2764. if(notempty){
  2765.  
  2766. if(availableindexes.length!=1){
  2767. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  2768. }
  2769. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  2770. }
  2771. }
  2772. else{
  2773. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  2774. var available = [];
  2775. var availableindexes = [];
  2776. var notempty = false;
  2777. for(var i = 0; i<e2.length;i++){
  2778. var a = false;
  2779. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  2780. available.push(a);
  2781. if(a){
  2782. availableindexes.push(i);
  2783. notempty = true;
  2784. }
  2785. }
  2786. if(notempty){
  2787. var above = [];
  2788. for(var i = 0;i<availableindexes.length;i++){
  2789. if(availableindexes[i]>quicki){
  2790. above.push(availableindexes[i]);
  2791. }
  2792. }
  2793. if(above.length>0){
  2794. quicki = above[0];
  2795. }
  2796. else{
  2797. quicki = availableindexes[0];
  2798. }
  2799. }
  2800. }
  2801. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  2802. }
  2803. e.preventDefault();
  2804. }
  2805. else if(keycode == "KeyA"){
  2806. if(stopquickplay == 0){
  2807. if(shuffle){
  2808. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  2809. var available = [];
  2810. var availableindexes = [];
  2811. var notempty = false;
  2812. for(var i = 0; i<e2.length;i++){
  2813. var a = false;
  2814. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  2815. available.push(a);
  2816. if(a){
  2817. availableindexes.push(i);
  2818. notempty = true;
  2819. }
  2820. }
  2821. if(notempty){
  2822.  
  2823. if(availableindexes.length!=1){
  2824. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  2825. }
  2826. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  2827. }
  2828. }
  2829. else{
  2830. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  2831. var available = [];
  2832. var availableindexes = [];
  2833. var notempty = false;
  2834. for(var i = 0; i<e2.length;i++){
  2835. var a = false;
  2836. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  2837. available.push(a);
  2838. if(a){
  2839. availableindexes.push(i);
  2840. notempty = true;
  2841. }
  2842. }
  2843. if(notempty){
  2844. var above = [];
  2845. for(var i = 0;i<availableindexes.length;i++){
  2846. if(availableindexes[i]<quicki){
  2847. above.push(availableindexes[i]);
  2848. }
  2849. }
  2850. if(above.length>0){
  2851. quicki = above[above.length-1];
  2852. }
  2853. else{
  2854. quicki = availableindexes[availableindexes.length-1];
  2855. }
  2856. }
  2857. }
  2858. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  2859. }
  2860. e.preventDefault();
  2861. }
  2862. else if(keycode == "KeyQ"){
  2863. if(stopquickplay == 1){
  2864. stopquickplay = 0;
  2865. quicki = 0;
  2866. displayInChat("Enabled quickplay.","#DA0808","#1EBCC1");
  2867. }
  2868. else{
  2869. stopquickplay = 1;
  2870. quicki = 0;
  2871. displayInChat("Disabled quickplay.","#DA0808","#1EBCC1");
  2872. }
  2873. e.preventDefault();
  2874. }
  2875. else if(keycode == "KeyR"){
  2876. if(recmodebool == true){
  2877. recmodebool = false;
  2878. displayInChat("Recmode is now off.","#DA0808","#1EBCC1");
  2879.  
  2880. }
  2881. else{
  2882. recmodebool = true;
  2883. displayInChat("Recmode is now on.","#DA0808","#1EBCC1");
  2884.  
  2885. }
  2886. }
  2887. else if(keycode == "KeyF"){
  2888. if(freejoin == false){
  2889. freejoin = true;
  2890. displayInChat("Freejoin is now on.","#DA0808","#1EBCC1");
  2891.  
  2892. }
  2893. else{
  2894. freejoin = false;
  2895. displayInChat("Freejoin is now off.","#DA0808","#1EBCC1");
  2896. }
  2897. e.preventDefault();
  2898. }
  2899. }
  2900. else{
  2901. if(keycode == "KeyE"){
  2902. e.preventDefault();
  2903. }
  2904. else if(keycode == "KeyT"){
  2905. e.preventDefault();
  2906. }
  2907. else if(keycode == "KeyM"){
  2908. e.preventDefault();
  2909. }
  2910. else if(keycode == "KeyK"){
  2911. e.preventDefault();
  2912. }
  2913. else if(keycode == "KeyS"){
  2914. e.preventDefault();
  2915. }
  2916. else if(keycode == "KeyD"){
  2917. e.preventDefault();
  2918. }
  2919. else if(keycode == "KeyA"){
  2920. e.preventDefault();
  2921. }
  2922. else if(keycode == "KeyQ"){
  2923. e.preventDefault();
  2924. }
  2925. else if(keycode == "KeyF"){
  2926. e.preventDefault();
  2927. }
  2928. else if(keycode == "KeyR"){
  2929. e.preventDefault();
  2930. }
  2931.  
  2932. }
  2933. if(keycode == "KeyL"){
  2934. lobby();
  2935. e.preventDefault();
  2936. }
  2937. if(keycode == "KeyC"){
  2938. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  2939. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]=="0px"){
  2940. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  2941. }
  2942. else{
  2943. Gdocument.getElementById("ingamechatcontent").style["max-height"]="0px";
  2944. }
  2945. }
  2946. e.preventDefault();
  2947. }
  2948. if(keycode == "KeyI"){
  2949. if(Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"] == "none"){
  2950. debuggeropen = true;
  2951. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="block";
  2952. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="none";
  2953. Gdocument.getElementById("ingamechatinputtext").style["display"] = "none";
  2954. }
  2955. else{
  2956. debuggeropen = false;
  2957. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="none";
  2958. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  2959. Gdocument.getElementById("ingamechatinputtext").style["display"] = "";
  2960. }
  2961. e.preventDefault();
  2962. }
  2963. }
  2964. if(!e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  2965. if(keycode == "Slash"){
  2966. 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"]==""){
  2967. Gdocument.getElementById("newbonklobby_chat_input").value = "/";
  2968. if(Gdocument.getElementById("newbonklobby_chat_input").style["pointer-events"] == "none"){
  2969. fire("keydown",{keyCode:13});
  2970. }
  2971. else{
  2972. Gdocument.getElementById("newbonklobby_chat_input").focus();
  2973. }
  2974. e.preventDefault();
  2975.  
  2976. }
  2977. else if(Gdocument.getElementById("ingamechatinputtext").style["visibility"]=="visible" && Gdocument.getElementById("ingamechatinputtext").style["display"]=="" && Gdocument.getElementById("mapeditorcontainer").style["display"]!="block" && Gdocument.getElementById("ingamechatinputtext").value == ""){
  2978. Gdocument.getElementById("ingamechatinputtext").value = "/";
  2979. if(!Gdocument.getElementById("ingamechatinputtext").classList.value.includes("ingamechatinputtextbg")){
  2980. fire("keydown",{keyCode:13});
  2981. }
  2982. else{
  2983. Gdocument.getElementById("ingamechatinputtext").focus();
  2984. }
  2985. e.preventDefault();
  2986.  
  2987. }
  2988. }
  2989. }
  2990. };
  2991.  
  2992. Gdocument.onkeydown = hotkeys;
  2993.  
  2994. Gwindow.addEventListener('resize',function(e){
  2995. debuggermenu.style["width"] = Gdocument.getElementById("bonkiocontainer").style["width"];
  2996. debuggermenu.style["height"] = Gdocument.getElementById("bonkiocontainer").style["height"];
  2997. scope.width = parseInt(Gdocument.getElementById("bonkiocontainer").style["width"])-20;
  2998. scope.height = parseInt(Gdocument.getElementById("bonkiocontainer").style["height"])-210;
  2999. logmenu.style["width"] = width.toString()+"px";
  3000. logmenu.style["height"] = height.toString()+"px";
  3001. logmenutopleft.style["width"] = (width/2).toString()+"px";
  3002. logmenutopright.style["width"] = (width/2).toString()+"px";
  3003. logmenutopright.style["left"] = (width/2).toString()+"px";
  3004. debuggerinput.style["width"] = width.toString()+"px";
  3005. debuggerinput.style["top"] = (height+90).toString()+"px";
  3006. debuggersendrecieve.style["top"] = (height+120).toString()+"px";
  3007. debuggerpausebutton.style["top"] = (height+150).toString()+"px";
  3008. debuggereval.style["width"] = (width-150).toString()+"px";
  3009. debuggereval.style["top"] = (height+120).toString()+"px";},true);
  3010.  
  3011.  
  3012. function timeout123() {
  3013. updateWssLog();
  3014. if(ishost && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS"){
  3015. clearmaprequests.style["display"] = "block";
  3016. refreshmaprequests.style["display"] = "block";
  3017. }
  3018. else{
  3019. clearmaprequests.style["display"] = "none";
  3020. refreshmaprequests.style["display"] = "none";
  3021. }
  3022. if(Gdocument.getElementById("gamerenderer").style["visibility"]=="hidden"){
  3023. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  3024. }
  3025. if(Gdocument.getElementById("maploadwindowmapscontainer").children.length>0 && maponclick == 0){
  3026. maponclick = Gdocument.getElementById("maploadwindowmapscontainer").children[0].onclick;
  3027. }
  3028. if(Gdocument.getElementById("ingamechatcontent").children.length>150){
  3029. var chatbox2 = Gdocument.getElementById("ingamechatcontent");
  3030. while (chatbox2.children.length>150) {
  3031. chatbox2.removeChild(chatbox2.firstChild,true);
  3032. }
  3033. }
  3034. if(Gdocument.getElementById("sm_connectingContainer").style["visibility"] == "hidden"){
  3035. var chatbox = Gdocument.getElementById("newbonklobby_chat_content");
  3036. while (chatbox.firstChild) {
  3037. chatbox.removeChild(chatbox.firstChild);
  3038. }
  3039. rcaps_flag = false;
  3040. space_flag = false;
  3041. number_flag = false;
  3042. echo_list = [];
  3043. gotbanned = false;
  3044. scroll = false;
  3045. stopquickplay = 1;
  3046. checkboxhidden = false;
  3047. freejoin = false;
  3048. shuffle = false;
  3049. defaultmode = "";
  3050. recmodebool = false;
  3051. playerids = {};
  3052. ishost = false;
  3053. sandboxplayerids = {};
  3054. sandboxcopyme = false;
  3055. sandboxon = false;
  3056. sandboxid = 1;
  3057. if(chatlog[chatlog.length-1]!="ROOM END"){
  3058. chatlog.push("ROOM END");
  3059. }
  3060. }
  3061. else{
  3062. if(chatlog[chatlog.length-1]=="ROOM END"){
  3063. chatlog.push("ROOM START");
  3064. }
  3065. }
  3066.  
  3067. if(Gdocument.getElementById("newbonklobby").style["display"]=="block"){
  3068. Gdocument.getElementById("ingamechatinputtext").style["visibility"]="hidden";
  3069. }
  3070. else{
  3071. Gdocument.getElementById("ingamechatinputtext").style["visibility"]="visible";
  3072.  
  3073. }
  3074. mode = Gdocument.getElementById("newbonklobby_modetext").textContent;
  3075. var userlist = Gdocument.getElementsByClassName("newbonklobby_playerentry_name");
  3076. users = [];
  3077. for(var i = 0;i<userlist.length;i++){
  3078. users.push(userlist[i].textContent);
  3079. }
  3080. if(Gdocument.getElementsByClassName('newbonklobby_settings_button brownButton brownButton_classic buttonShadow brownButtonDisabled').length == 0){
  3081. ishost = true;
  3082. }
  3083. else{
  3084. ishost = false;
  3085. }
  3086.  
  3087. if(Gdocument.getElementById("pretty_top_name")!=null){
  3088. username = Gdocument.getElementById("pretty_top_name").textContent;
  3089. }
  3090. try{
  3091. Last_message = lastmessage()
  3092. } catch{
  3093. Last_message = "";
  3094. }
  3095. if (Laster_message != Last_message){
  3096. Laster_message = Last_message;
  3097. if(changed_chat==false){
  3098. new_message = true;
  3099. }
  3100. else{
  3101. changed_chat = false;
  3102. }
  3103. }
  3104. if(new_message){
  3105. chatlog.push(Last_message);
  3106. if(freejoin && Last_message.startsWith("* ") && Last_message.endsWith(" has joined the game") && ishost){
  3107.  
  3108. var userjoined = Last_message.substring(2,Last_message.length-20);
  3109.  
  3110. if(Gdocument.getElementById("newbonklobby").style["display"] != "block"){
  3111. mess2 = Gdocument.getElementById("ingamechatinputtext").value;
  3112. Gdocument.getElementById("ingamechatinputtext").value = "";
  3113. Gdocument.getElementById("newbonklobby_editorbutton").click();
  3114. Gdocument.getElementById("mapeditor_close").click();
  3115. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  3116. Gdocument.getElementById("ingamechatinputtext").value = mess2;
  3117.  
  3118. }
  3119. var playing = Gdocument.getElementsByClassName("newbonklobby_playerentry newbonklobby_playerentry_half");
  3120. var inplaying = false;
  3121. for(var i = 0;i<playing.length;i++){
  3122. if(userjoined == playing[i].children[1].textContent){
  3123. inplaying = true;
  3124. break;
  3125. }
  3126. }
  3127.  
  3128. if(playing.length<=2 && inplaying){
  3129. Gdocument.getElementById("newbonklobby_editorbutton").click();
  3130. Gdocument.getElementById("mapeditor_close").click();
  3131. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  3132. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  3133. if(transitioning == true){
  3134. canceled = true;
  3135. }
  3136. }
  3137.  
  3138. }
  3139. var lm = "";
  3140. try{
  3141. lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  3142. if(typeof(lm[0].parentElement.style["parsed"]) == 'undefined'){
  3143. if (lm[0].className == "newbonklobby_chat_msg_colorbox"){
  3144. lm[2].innerHTML = urlify(lm[2].innerHTML);
  3145. Laster_message = lastmessage();
  3146. lm[0].parentElement.style["parsed"] = true;
  3147. }
  3148. if (lm[0].className == "newbonklobby_chat_status"){
  3149. lm[0].innerHTML = urlify(lm[0].innerHTML);
  3150. Laster_message = lastmessage();
  3151. lm[0].parentElement.style["parsed"] = true;
  3152. }
  3153. }
  3154. }
  3155. catch{
  3156. lm = "";
  3157. }
  3158.  
  3159. if(Last_message.indexOf("@"+username)!=-1 && npermissions == 1){
  3160. if(Notification.requestPermission()){
  3161. var n = new Notification(Last_message);
  3162. }
  3163. }
  3164.  
  3165. try{
  3166. lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  3167. if(typeof(lm[0].parentElement.style["parsed"])=='undefined'){
  3168. if(lm[0].className == "ingamechatname"){
  3169. lm[1].innerHTML = urlify(lm[1].innerHTML);
  3170. Laster_message = lastmessage();
  3171. lm[0].parentElement.style["parsed"] = true;
  3172. }
  3173. if(lm[0].className == ""){
  3174. lm[0].innerHTML = urlify(lm[0].innerHTML);
  3175. Laster_message = lastmessage();
  3176. lm[0].parentElement.style["parsed"] = true;
  3177. }
  3178. }
  3179. }
  3180. catch{
  3181. lm = "";
  3182. }
  3183. for(i=0;i<echo_list.length;i++){
  3184. if(Last_message.substring(0,echo_list[i].length+2) == echo_list[i]+": "){
  3185. message = Last_message.substring(echo_list[i].length+2);
  3186. chat(flag_manage(message+" "+echoAppend));
  3187. }
  3188. }
  3189. if(text2speech){
  3190. if(!sayer.speaking){
  3191. if(Last_message.includes(": ")){
  3192. speech.text = Last_message.substring(0,Last_message.indexOf(":")).toLowerCase();
  3193. speech.rate = 2.25;
  3194. sayer.speak(speech);
  3195. speech.text = Last_message.substring(Last_message.indexOf(": ")+3).toLowerCase();
  3196. speech.rate = 1.25;
  3197. sayer.speak(speech);
  3198. }
  3199. else{
  3200. speech.text = Last_message.toLowerCase();
  3201. sayer.speak(speech);
  3202. }
  3203. }
  3204. }
  3205. }
  3206. if (ishost==true && new_message){
  3207. for(i=0;i<banned.length;i++){
  3208. if(Last_message.startsWith("* "+banned[i]+" has joined the game")){
  3209. chat("/kick '"+banned[i]+"'");
  3210. }
  3211. }
  3212. }
  3213. if(ishost && stopquickplay == 0){
  3214. if(checkboxhidden){
  3215. checkboxhidden = false;
  3216. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  3217. for(var i = 0; i<classes.length;i++){
  3218. classes[i].style["display"] = "block";
  3219. classes[i].className = "quickplaycheckbox quickplaychecked";
  3220. }
  3221. Gdocument.getElementById('clearallcheckboxes').style["display"] = "block";
  3222.  
  3223. }
  3224. if(Gdocument.getElementById("ingamewinner").style["visibility"]=="inherit" && stopquickplay == 0 && dontswitch == false && !document.hidden){
  3225. if(shuffle){
  3226. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  3227. var available = [];
  3228. var availableindexes = [];
  3229. var notempty = false;
  3230. for(var i = 0; i<e.length;i++){
  3231. var a = false;
  3232. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  3233. available.push(a);
  3234. if(a){
  3235. availableindexes.push(i);
  3236. notempty = true;
  3237. }
  3238. }
  3239. if(notempty){
  3240. if(availableindexes.length!=1){
  3241. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  3242. }
  3243. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  3244. }
  3245. }
  3246. else{
  3247. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  3248. var available = [];
  3249. var availableindexes = [];
  3250. var notempty = false;
  3251. for(var i = 0; i<e.length;i++){
  3252. var a = false;
  3253. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  3254. available.push(a);
  3255. if(a){
  3256. availableindexes.push(i);
  3257. notempty = true;
  3258. }
  3259. }
  3260. if(notempty){
  3261. var above = [];
  3262. for(var i = 0;i<availableindexes.length;i++){
  3263. if(availableindexes[i]>quicki){
  3264. above.push(availableindexes[i]);
  3265. }
  3266. }
  3267. if(above.length>0){
  3268. quicki = above[0];
  3269. }
  3270. else{
  3271. quicki = availableindexes[0];
  3272. }
  3273. }
  3274. }
  3275. transitioning = true;
  3276. startedinqp = true;
  3277. map(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  3278. dontswitch = true;
  3279. setTimeout(function(){Gdocument.getElementById("ingamewinner").style["visibility"]="hidden"; dontswitch = false;},timedelay);
  3280. }
  3281. }
  3282. else{
  3283. if(!checkboxhidden){
  3284. checkboxhidden = true;
  3285. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  3286. for(var i = 0; i<classes.length;i++){
  3287. classes[i].style["display"] = "none";
  3288. classes[i].className = "quickplaycheckbox quickplayunchecked";
  3289. }
  3290. Gdocument.getElementById('clearallcheckboxes').style["display"] = "none";
  3291. }
  3292. }
  3293. new_message = false;
  3294. };
  3295. });