Bonk Commands

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

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

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