Bonk Commands

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

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

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