Bonk Commands

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

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

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