Bonk Commands

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

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

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