LEGENDBOSS123

Untitled

Mar 12th, 2023
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 204.03 KB | None | 0 0
  1. function BonkCommandsScriptInjector(f){
  2. if(window.location == window.parent.location){
  3. if(document.readyState == "complete"){f();}
  4. else{document.addEventListener('readystatechange',function(){setTimeout(f,1500);});}
  5. }
  6. }
  7.  
  8. BonkCommandsScriptInjector(function(){
  9. var scope = window;
  10. scope.scope = scope;
  11. scope.Gwindow = document.getElementById("maingameframe").contentWindow;
  12. scope.Gdocument = document.getElementById("maingameframe").contentDocument;
  13. Gwindow.Gwindow = window;
  14. Gwindow.Gdocument = document;
  15.  
  16. scope.link2pastebin = "https://pastebin.com/2b8XqqYu";
  17. scope.link2greasyfork = "https://greasyfork.org/en/scripts/451341-bonk-commands";
  18.  
  19. if(typeof(scope.injectedBonkCommandsScript)=='undefined'){
  20. scope.injectedBonkCommandsScript = true;
  21. }
  22. else{
  23. for (var i = 0; i < 100000; i++){
  24. clearInterval(i);
  25. }
  26. }
  27. scope.GENERATE_COPRIME_NUMBER = function(mini = 0,maxi = 0,coprimewith = 0,choices = []){
  28. if(choices.length == 0){
  29. for(var i = mini;i<maxi+1;i++){
  30. choices.push(i);
  31. }
  32. }
  33. firstTry = choices[Math.floor(Math.random()*choices.length)];
  34. for(var i = 2; i<firstTry+1;i++){
  35. if(firstTry%i == 0 && coprimewith%i == 0){
  36. choices.splice(choices.indexOf(firstTry),1);
  37. if(choices.length == 0){
  38. return 0;
  39. }
  40. return GENERATE_COPRIME_NUMBER(mini,maxi,coprimewith,choices);
  41. }
  42. }
  43. return firstTry;
  44. };
  45. scope.GENERATE_PRIME_NUMBER = function(mini = 0,maxi = 0,choices = []){
  46. if(choices.length == 0){
  47. for(var i = mini;i<maxi+1;i++){
  48. choices.push(i);
  49. }
  50. }
  51. firstTry = choices[Math.floor(Math.random()*choices.length)];
  52. for(var i = 2; i<Math.floor(Math.sqrt(firstTry)+1);i++){
  53. if(i!=firstTry){
  54. if(firstTry%i == 0){
  55. choices.splice(choices.indexOf(firstTry),1);
  56. if(choices.length == 0){
  57. return 0;
  58. }
  59. return GENERATE_PRIME_NUMBER(mini,maxi,choices);
  60. }
  61. }
  62. }
  63. return firstTry;
  64. };
  65. scope.SHUFFLE_LIST = function(x){
  66. var nl = x.slice();
  67. for(var i = nl.length - 1;i>0;i--){
  68. var r = Math.floor(Math.random()*(i+1));
  69. var t = nl[i];
  70. nl[i] = nl[r];
  71. nl[r] = t;
  72. }
  73. return nl;
  74. };
  75. scope.GENERATE_KEYS = function(){
  76. interval = [];
  77. for(var i = 100;i<301;i++){
  78. interval.push(i);
  79. }
  80. random_prime = [GENERATE_PRIME_NUMBER(0,0,choices = interval),0];
  81. interval.splice(interval.indexOf(random_prime[0]),1);
  82. random_prime[1] = GENERATE_PRIME_NUMBER(0,0,choices = interval);
  83.  
  84. n = random_prime[0]*random_prime[1];
  85. n2 = (random_prime[0]-1)*(random_prime[1]-1);
  86.  
  87. e = GENERATE_COPRIME_NUMBER(2,n2-1,n2);
  88. d = 0;
  89. redo = true;
  90. for(var i = 0;i<1000000;i++){
  91. if((e*i-1)%n2 == 0 && i!=e){
  92. d = i;
  93. redo = false;
  94. break;
  95. }
  96. }
  97. if(redo){
  98. return GENERATE_KEYS();
  99. }
  100. else{
  101. return [[n,e],[n,d]];
  102. }
  103.  
  104. };
  105. scope.CRYPT_NUMBER = function(key, data){
  106.  
  107. result = 1;
  108.  
  109. for(var i = 0;i<key[1];i++){
  110. result*=data;
  111. result = result%key[0];
  112. }
  113. return result%key[0];
  114.  
  115. };
  116.  
  117. scope.CRYPT_MESSAGE = function(key,data){
  118. var resulttext = [];
  119. for(var i = 0;i<data.length;i++){
  120. resulttext.push(CRYPT_NUMBER(key,data[i]));
  121. }
  122. return resulttext;
  123.  
  124. };
  125. if(typeof(scope.textdecoder)=='undefined'){scope.textdecoder = new Gwindow.TextDecoder;}
  126. if(typeof(scope.textencoder)=='undefined'){scope.textencoder = new Gwindow.TextEncoder;}
  127.  
  128. class bytebuffer2 {
  129. constructor() {
  130. var g1d = [arguments];
  131. this.index = 0;
  132. this.buffer = new ArrayBuffer(100*1024);
  133. this.view = new DataView(this.buffer);
  134. this.implicitClassAliasArray = [];
  135. this.implicitStringArray = [];
  136. this.bodgeCaptureZoneDataIdentifierArray = [];
  137. }
  138.  
  139. readByte() {
  140. var N0H = [arguments];
  141. N0H[4] = this.view.getUint8(this.index);
  142. this.index += 1;
  143. return N0H[4];
  144. }
  145. writeByte(z0w) {
  146. var v8$ = [arguments];
  147. this.view.setUint8(this.index, v8$[0][0]);
  148. this.index += 1;
  149. }
  150. readInt() {
  151. var A71 = [arguments];
  152. A71[6] = this.view.getInt32(this.index);
  153. this.index += 4;
  154. return A71[6];
  155. }
  156. writeInt(W6i) {
  157. var p5u = [arguments];
  158. this.view.setInt32(this.index, p5u[0][0]);
  159. this.index += 4;
  160. }
  161. readShort() {
  162. var R1R = [arguments];
  163. R1R[9] = this.view.getInt16(this.index);
  164. this.index += 2;
  165. return R1R[9];
  166. }
  167. writeShort(H8B) {
  168. var d_3 = [arguments];
  169. this.view.setInt16(this.index, d_3[0][0]);
  170. this.index += 2;
  171. }
  172. readUint() {
  173. var W2$ = [arguments];
  174. W2$[8] = this.view.getUint32(this.index);
  175. this.index += 4;
  176. return W2$[8];
  177. }
  178. writeUint(B2X) {
  179. var f8B = [arguments];
  180. this.view.setUint32(this.index, f8B[0][0]);
  181. this.index += 4;
  182. }
  183. readBoolean() {
  184. var h6P = [arguments];
  185. h6P[6] = this.readByte();
  186. return h6P[6] == 1;
  187. }
  188. writeBoolean(Y3I) {
  189. var l79 = [arguments];
  190. if (l79[0][0]) {
  191. this.writeByte(1);
  192. } else {
  193. this.writeByte(0);
  194. }
  195. }
  196. readDouble() {
  197. var V60 = [arguments];
  198. V60[4] = this.view.getFloat64(this.index);
  199. this.index += 8;
  200. return V60[4];
  201. }
  202. writeDouble(z4Z) {
  203. var O41 = [arguments];
  204. this.view.setFloat64(this.index, O41[0][0]);
  205. this.index += 8;
  206. }
  207. readFloat() {
  208. var I0l = [arguments];
  209. I0l[5] = this.view.getFloat32(this.index);
  210. this.index += 4;
  211. return I0l[5];
  212. }
  213. writeFloat(y4B) {
  214. var B0v = [arguments];
  215. this.view.setFloat32(this.index, B0v[0][0]);
  216. this.index += 4;
  217. }
  218. readUTF() {
  219. var d6I = [arguments];
  220. d6I[8] = this.readByte();
  221. d6I[7] = this.readByte();
  222. d6I[9] = d6I[8] * 256 + d6I[7];
  223. d6I[1] = new Uint8Array(d6I[9]);
  224. for (d6I[6] = 0; d6I[6] < d6I[9]; d6I[6]++) {
  225. d6I[1][d6I[6]] = this.readByte();
  226. }
  227. return textdecoder.decode(d6I[1]);
  228. }
  229. writeUTF(L3Z) {
  230. var Z75 = [arguments];
  231. Z75[4] = textencoder.encode(Z75[0][0]);
  232. Z75[3] = Z75[4].length;
  233. Z75[5] = Math.floor(Z75[3]/256);
  234. Z75[8] = Z75[3] % 256;
  235. this.writeByte(Z75[5]);
  236. this.writeByte(Z75[8]);
  237. Z75[7] = this;
  238. Z75[4].forEach(I_O);
  239. function I_O(s0Q, H4K, j$o) {
  240. var N0o = [arguments];
  241. Z75[7].writeByte(N0o[0][0]);
  242. }
  243. }
  244. toBase64() {
  245. var P4$ = [arguments];
  246. P4$[4] = "";
  247. P4$[9] = new Uint8Array(this.buffer);
  248. P4$[8] = this.index;
  249. for (P4$[7] = 0; P4$[7] < P4$[8]; P4$[7]++) {
  250. P4$[4] += String.fromCharCode(P4$[9][P4$[7]]);
  251. }
  252. return Gwindow.btoa(P4$[4]);
  253. }
  254. fromBase64(W69, A8Q) {
  255. var o0n = [arguments];
  256. o0n[8] = Gwindow.pako;
  257. o0n[6] = Gwindow.atob(o0n[0][0]);
  258. o0n[9] = o0n[6].length;
  259. o0n[4] = new Uint8Array(o0n[9]);
  260. for (o0n[1] = 0; o0n[1] < o0n[9]; o0n[1]++) {
  261. o0n[4][o0n[1]] = o0n[6].charCodeAt(o0n[1]);
  262. }
  263. if (o0n[0][1] === true) {
  264. o0n[5] = o0n[8].inflate(o0n[4]);
  265. o0n[4] = o0n[5];
  266. }
  267. this.buffer = o0n[4].buffer.slice(
  268. o0n[4].byteOffset,
  269. o0n[4].byteLength + o0n[4].byteOffset
  270. );
  271. this.view = new DataView(this.buffer);
  272. this.index = 0;
  273. }
  274. };
  275.  
  276. if(typeof(scope.originalSend)=='undefined'){scope.originalSend = Gwindow.WebSocket.prototype.send;}
  277. if(typeof(scope.originalXMLOpen)=='undefined'){scope.originalXMLOpen = Gwindow.XMLHttpRequest.prototype.open;}
  278. if(typeof(scope.originalXMLSend)=='undefined'){scope.originalXMLSend = Gwindow.XMLHttpRequest.prototype.send;}
  279. if(typeof(scope.searchrequested)=='undefined'){scope.searchrequested = false;}
  280. if(typeof(scope.originalDrawCircle)=='undefined'){scope.originalDrawCircle = Gwindow.PIXI.Graphics.prototype.drawCircle;}
  281. if(typeof(scope.parentDraw)=='undefined'){scope.parentDraw = 0;}
  282. if(typeof(scope.pixiCircle)=='undefined'){scope.pixiCircle = new Gwindow.PIXI.Graphics();}
  283. if(typeof(scope.container)=='undefined'){scope.container = new Gwindow.PIXI.Container();container.addChild(pixiCircle);}
  284. if(typeof(scope.canvasWidth)=='undefined'){scope.canvasWidth = -1;}
  285.  
  286. if(typeof(scope.requestAnimationFrameOriginal)=='undefined'){scope.requestAnimationFrameOriginal = Gwindow.requestAnimationFrame;}
  287.  
  288.  
  289. if(typeof(scope.bonkwss)=='undefined'){scope.bonkwss = 0;}
  290. if(typeof(scope.bonkwssextra)=='undefined'){scope.bonkwssextra = [];}
  291. if(typeof(scope.chatlog)=='undefined'){scope.chatlog = ["ROOM START"];}
  292. if(typeof(scope.wsssendrecievelog)=='undefined'){scope.wsssendrecievelog = [];}
  293. if(typeof(scope.wsssendlog)=='undefined'){scope.wsssendlog = [];}
  294. if(typeof(scope.wssrecievelog)=='undefined'){scope.wssrecievelog = [];}
  295. if(typeof(scope.wsslogpaused)=='undefined'){scope.wsslogpaused = false;}
  296. if(typeof(scope.debuggeropen)=='undefined'){scope.debuggeropen = false;}
  297. if(typeof(scope.debuggercount)=='undefined'){scope.debuggercount = true;}
  298. if(typeof(scope.packetcount)=='undefined'){scope.packetcount = 0;}
  299. if(typeof(scope.requestedmaps)=='undefined'){scope.requestedmaps = [];}
  300. if(typeof(scope.maponclick)=='undefined'){scope.maponclick = 0;}
  301. if(typeof(scope.LZString)=='undefined'){scope.LZString = Gwindow.LZString;}
  302. if(typeof(scope.PSON)=='undefined'){scope.PSON = Gwindow.dcodeIO.PSON;}
  303. if(typeof(scope.bytebuffer)=='undefined'){scope.bytebuffer = Gwindow.dcodeIO.ByteBuffer;}
  304. if(typeof(scope.speech)=='undefined'){scope.speech = new SpeechSynthesisUtterance();speech.pitch = 0.75;}
  305. if(typeof(scope.sayer)=='undefined'){scope.sayer = speechSynthesis;sayer.volume = 0.5;sayer.rate = 1.25;}
  306. if(typeof(scope.pollactive)=='undefined'){scope.pollactive = [false,0,0,[]];}
  307. if(typeof(scope.pollactive2)=='undefined'){scope.pollactive2 = [false,0,[]];}
  308.  
  309.  
  310.  
  311. 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]);}
  312. if(typeof(scope.sandboxon)=='undefined'){scope.sandboxon = false;}
  313. if(typeof(scope.sandboxid)=='undefined'){scope.sandboxid = 1;}
  314. if(typeof(scope.playerids)=='undefined'){scope.playerids = {};}
  315. if(typeof(scope.delplayerids)=='undefined'){scope.delplayerids = {};}
  316. if(typeof(scope.myid)=='undefined'){scope.myid = -1;}
  317. if(typeof(scope.hostid)=='undefined'){scope.hostid = -1;}
  318. if(typeof(scope.sandboxplayerids)=='undefined'){scope.sandboxplayerids = {};}
  319. if(typeof(scope.originalMapLoad)=='undefined'){scope.originalMapLoad = Gdocument.getElementById("maploadwindowmapscontainer").appendChild;}
  320. if(typeof(scope.originalLobbyChat)=='undefined'){scope.originalLobbyChat = Gdocument.getElementById("newbonklobby_chat_content").appendChild;}
  321. if(typeof(scope.originalIngameChat)=='undefined'){scope.originalIngameChat = Gdocument.getElementById("ingamechatcontent").appendChild;}
  322. 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];}
  323.  
  324.  
  325.  
  326. if(Gdocument.getElementById("maploadtypedropdowntitlerequested") == null){
  327. scope.clearmaprequests = Gdocument.createElement("div");
  328. clearmaprequests.id = "clearmaprequests";
  329. clearmaprequests.classList.value = "brownButton brownButton_classic buttonShadow";
  330. clearmaprequests.textContent = "Clear";
  331. clearmaprequests.style["position"] = "absolute";
  332. clearmaprequests.style["display"] = "none";
  333. if(typeof(ishost)!='undefined'){
  334. if(ishost && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS"){
  335. clearmaprequests.style["display"] = "block";
  336. }
  337. }
  338. clearmaprequests.style["right"] = "306px";
  339. clearmaprequests.style["top"] = "57px";
  340. clearmaprequests.style["height"] = "23px";
  341. clearmaprequests.style["width"] = "47px";
  342. clearmaprequests.style["line-height"] = "23px";
  343. clearmaprequests.style["font-size"] = "14px";
  344. clearmaprequests.addEventListener("click",function(){
  345. requestedmaps = [];
  346. Gdocument.getElementById("maploadwindowstatustext").style["visibility"] = "inherit";
  347. Gdocument.getElementById("maploadwindowstatustext").textContent = "No Maps";
  348. while(Gdocument.getElementById("maploadwindowmapscontainer").children.length>0){
  349. Gdocument.getElementById("maploadwindowmapscontainer").removeChild(Gdocument.getElementById("maploadwindowmapscontainer").firstChild);
  350. }
  351. });
  352. Gdocument.getElementById("maploadwindow").insertBefore(clearmaprequests,Gdocument.getElementById("maploadwindowsearchinput"));
  353.  
  354. scope.refreshmaprequests = Gdocument.createElement("div");
  355. refreshmaprequests.id = "refreshmaprequests";
  356. refreshmaprequests.classList.value = "brownButton brownButton_classic buttonShadow";
  357. refreshmaprequests.textContent = "Refresh";
  358. refreshmaprequests.style["position"] = "absolute";
  359. refreshmaprequests.style["display"] = "none";
  360. if(typeof(ishost)!='undefined'){
  361. if(ishost && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS"){
  362. refreshmaprequests.style["display"] = "block";
  363. }
  364. }
  365. refreshmaprequests.style["right"] = "357px";
  366. refreshmaprequests.style["top"] = "57px";
  367. refreshmaprequests.style["height"] = "23px";
  368. refreshmaprequests.style["width"] = "47px";
  369. refreshmaprequests.style["line-height"] = "23px";
  370. refreshmaprequests.style["font-size"] = "14px";
  371. refreshmaprequests.addEventListener("click",function(){
  372. Gdocument.getElementById("maploadtypedropdowntitle").textContent = dropdownrequested.textContent;
  373. Gdocument.getElementById("maploadwindowsearchinput").value = "";
  374. dropdownrequested.style["display"] = "none";
  375. clearmaprequests.style["display"] = "block";
  376. refreshmaprequests.style["display"] = "block";
  377. Gdocument.getElementById("maploadwindowhotnessslider").style["visibility"] = "hidden";
  378. Gdocument.getElementById("maploadwindowsearchoptions").style["visibility"] = "hidden";
  379. searchrequested = true;
  380. Gdocument.getElementById("maploadwindowsearchbutton").click();
  381.  
  382. Gdocument.getElementById("maploadtypedropdowntitle").textContent = "MAP REQUESTS";
  383. });
  384. Gdocument.getElementById("maploadwindow").insertBefore(refreshmaprequests,Gdocument.getElementById("maploadwindowsearchinput"));
  385.  
  386.  
  387.  
  388. scope.dropdownrequested = Gdocument.createElement("div");
  389. dropdownrequested.classList = "dropdown-option dropdown_classic";
  390. dropdownrequested.style["display"] = "none";
  391. dropdownrequested.id = "maploadtypedropdowntitlerequested";
  392.  
  393. if(Gdocument.getElementById("maploadtypedropdownoption10").style["display"] == "block"){
  394. dropdownrequested.style["display"] = "block";
  395. }
  396. dropdownrequested.textContent = "MAP REQUESTS";
  397. dropdownrequested.onclick = function(){
  398. Gdocument.getElementById("maploadtypedropdowntitle").textContent = dropdownrequested.textContent;
  399. Gdocument.getElementById("maploadwindowsearchinput").value = "";
  400. dropdownrequested.style["display"] = "none";
  401. clearmaprequests.style["display"] = "block";
  402. refreshmaprequests.style["display"] = "block";
  403. Gdocument.getElementById("maploadwindowhotnessslider").style["visibility"] = "hidden";
  404. Gdocument.getElementById("maploadwindowsearchoptions").style["visibility"] = "hidden";
  405. searchrequested = true;
  406. Gdocument.getElementById("maploadwindowsearchbutton").click();
  407.  
  408. Gdocument.getElementById("maploadtypedropdowntitle").textContent = "MAP REQUESTS";
  409. };
  410. (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});
  411.  
  412.  
  413.  
  414. Gdocument.getElementById("maploadtypedropdown").insertBefore(dropdownrequested,Gdocument.getElementById("maploadtypedropdownoption1"));
  415. Gdocument.getElementById("maploadwindowmapscontainer").__defineGetter__("clientHeight",function(){if(Gdocument.getElementById("maploadtypedropdowntitle").textContent != "MAP REQUESTS"){return Gdocument.getElementById("maploadwindowmapscontainer").getClientRects()[0].height;}else{return 0;}});
  416.  
  417. };
  418.  
  419.  
  420. function sandboxonclick(){
  421. Gdocument.getElementById("roomlistcreatewindowmaxplayers").value = 1;
  422. Gdocument.getElementById("roomlistcreatewindowunlistedcheckbox").checked = true;
  423. Gdocument.getElementById("roomlistcreatecreatebutton").click();
  424. sandboxon = true;
  425. }
  426. function checkboxclearbuttononclick(){
  427. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  428. var e = true;
  429. for(var i = 0; i<classes.length;i++){
  430. if(classes[i].checked == true){
  431. e = false
  432. }
  433. classes[i].checked = false;
  434. }
  435. if(e){
  436. for(var i = 0; i<classes.length;i++){
  437. classes[i].checked = true;
  438. }
  439. }
  440. }
  441. Gdocument.getElementById("ingamechatcontent").__defineGetter__("childElementCount",function(){return this.children.length/50;});
  442. if(Gdocument.getElementById("classic_mid_sandbox")==null){
  443. Gdocument.getElementById("roomlistrefreshbutton").click();
  444. scope.sandboxbutton = Gdocument.createElement("div");
  445. sandboxbutton.id = "classic_mid_sandbox";
  446. sandboxbutton.classList.value = "brownButton brownButton_classic classic_mid_buttons";
  447. sandboxbutton.textContent = "Sandbox";
  448. sandboxbutton.addEventListener("click",sandboxonclick);
  449. Gdocument.getElementById("classic_mid").insertBefore(sandboxbutton,Gdocument.getElementById("classic_mid_news"));
  450.  
  451. }
  452. if(Gdocument.getElementById("clearallcheckboxes")==null){
  453. scope.checkboxclearbutton = Gdocument.createElement("div");
  454. checkboxclearbutton.id = "clearallcheckboxes";
  455. checkboxclearbutton.classList.value = "brownButton brownButton_classic buttonShadow";
  456. checkboxclearbutton.textContent = "On/Off";
  457. checkboxclearbutton.style["position"] = "absolute";
  458. checkboxclearbutton.style["display"] = "none";
  459. if(typeof(ishost)!='undefined'){
  460. if(ishost && stopquickplay == 0){
  461. checkboxclearbutton.style["display"] = "block";
  462. }
  463. }
  464. checkboxclearbutton.style["right"] = "255px";
  465. checkboxclearbutton.style["top"] = "57px";
  466. checkboxclearbutton.style["height"] = "23px";
  467. checkboxclearbutton.style["width"] = "47px";
  468. checkboxclearbutton.style["line-height"] = "23px";
  469. checkboxclearbutton.style["font-size"] = "13px";
  470. checkboxclearbutton.addEventListener("click",checkboxclearbuttononclick);
  471. Gdocument.getElementById("maploadwindow").insertBefore(checkboxclearbutton,Gdocument.getElementById("maploadwindowsearchinput"));
  472.  
  473. }
  474. scope.holdloadbuttonTimeout = [];
  475. scope.holdloadbutton = function(){
  476. var scrollcount = 0;
  477. var mapwindow = Gdocument.getElementById("maploadwindowmapscontainer");
  478. mapwindow.scroll(0,mapwindow.scrollHeight);
  479. };
  480.  
  481.  
  482. if(Gdocument.getElementById("mapwindowloadall")==null){
  483. scope.loadall = Gdocument.createElement("div");
  484. loadall.id = "mapwindowloadall";
  485. loadall.classList.value = "brownButton brownButton_classic buttonShadow";
  486. loadall.textContent = "Load";
  487. loadall.style["position"] = "absolute";
  488. loadall.style["display"] = "block";
  489. loadall.style["left"] = "204px";
  490. loadall.style["top"] = "57px";
  491. loadall.style["height"] = "23px";
  492. loadall.style["width"] = "34px";
  493. loadall.style["line-height"] = "23px";
  494. loadall.style["font-size"] = "12px";
  495. var repeat = function(){holdloadbutton();holdloadbuttonTimeout.push(setTimeout(repeat,25));};
  496. loadall.onmousedown = function(){repeat();};
  497. loadall.onmouseup = function(){for(var i = 0; i<holdloadbuttonTimeout.length; i++){clearTimeout(holdloadbuttonTimeout[i]);}};
  498. loadall.onmouseout = function(){for(var i = 0; i<holdloadbuttonTimeout.length; i++){clearTimeout(holdloadbuttonTimeout[i]);}};
  499.  
  500. Gdocument.getElementById("maploadwindow").insertBefore(loadall,Gdocument.getElementById("maploadwindowsearchinput"));
  501.  
  502. }
  503. if(Gdocument.getElementById("BonkCommandsDebuggerContainer")==null){
  504. Gdocument.getElementById("leaveconfirmwindow").style["z-index"]=3;
  505. scope.debuggermenu = Gdocument.createElement("div");
  506. debuggermenu.id = "BonkCommandsDebuggerContainer";
  507. debuggermenu.style["position"] = "absolute";
  508. debuggermenu.style["display"] = "none";
  509. if(typeof(debuggeropen)!='undefined'){
  510. if(debuggeropen){
  511. debuggermenu.style["display"] = "block";
  512. }
  513. }
  514.  
  515. debuggermenu.style["width"] = Gdocument.getElementById("bonkiocontainer").style["width"];
  516. debuggermenu.style["height"] = Gdocument.getElementById("bonkiocontainer").style["height"];
  517.  
  518. debuggermenu.style["background"] = "rgb(26, 39, 51)";
  519.  
  520.  
  521. scope.width = parseInt(Gdocument.getElementById("bonkiocontainer").style["width"])-20;
  522. scope.height = parseInt(Gdocument.getElementById("bonkiocontainer").style["height"])-210;
  523.  
  524.  
  525. scope.logmenu = Gdocument.createElement("div");
  526. logmenu.id = "BonkCommandsWebSocketLog";
  527. logmenu.style["position"] = "absolute";
  528. logmenu.style["width"] = width.toString()+"px";
  529. logmenu.style["height"] = height.toString()+"px";
  530. logmenu.style["top"] = "80px";
  531. logmenu.style["left"] = "10px";
  532. logmenu.style["background"] = "rgb(207, 216, 220)";
  533.  
  534.  
  535.  
  536.  
  537. scope.logmenutopleft = Gdocument.createElement("div");
  538. logmenutopleft.id = "BonkCommandsWebSocketLog";
  539. logmenutopleft.style["position"] = "absolute";
  540. logmenutopleft.textContent = "Sending";
  541. logmenutopleft.classList = "newbonklobby_boxtop newbonklobby_boxtop_classic";
  542.  
  543. logmenutopleft.style["width"] = (width/2).toString()+"px";
  544. logmenutopleft.style["height"] = "30px";
  545. logmenutopleft.style["top"] = "-30px";
  546. logmenutopleft.style["background"] = "rgb(0, 150, 136)";
  547.  
  548.  
  549. logmenu.appendChild(logmenutopleft);
  550.  
  551. scope.logmenutopright = Gdocument.createElement("div");
  552. logmenutopright.id = "BonkCommandsWebSocketLog";
  553. logmenutopright.style["position"] = "absolute";
  554. logmenutopright.textContent = "Recieving";
  555. logmenutopright.classList = "newbonklobby_boxtop newbonklobby_boxtop_classic";
  556. logmenutopright.style["width"] = (width/2).toString()+"px";
  557. logmenutopright.style["height"] = "30px";
  558. logmenutopright.style["left"] = (width/2).toString()+"px";
  559. logmenutopright.style["top"] = "-30px";
  560. logmenutopright.style["background"] = "rgb(0, 150, 136)";
  561. logmenu.appendChild(logmenutopright);
  562.  
  563.  
  564. scope.logmenutable = Gdocument.createElement("table");
  565. logmenutable.id = "BonkCommandsWebSocketTable";
  566. logmenutable.style["position"] = "absolute";
  567. logmenutable.style["border-spacing"] = "0px";
  568. logmenutable.style["font-size"] = "12px";
  569. logmenutable.style["display"] = "table-cell";
  570. logmenutable.style["width"] = "50%";
  571. logmenutable.style["height"] = "100%";
  572. logmenutable.style["table-layout"] = "fixed";
  573. logmenutable.style["overflow-y"] = "scroll";
  574.  
  575. scope.logmenutable2 = Gdocument.createElement("table");
  576. logmenutable2.id = "BonkCommandsWebSocketTable2";
  577. logmenutable2.style["position"] = "absolute";
  578. logmenutable2.style["width"] = "50%";
  579. logmenutable2.style["left"] = "50%";
  580. logmenutable2.style["font-size"] = "12px";
  581. logmenutable2.style["display"] = "table-cell";
  582. logmenutable2.style["height"] = "100%";
  583. logmenutable2.style["table-layout"] = "fixed";
  584. logmenutable2.style["overflow-y"] = "scroll";
  585. logmenutable2.style["border-spacing"] = "0px";
  586. scope.leftsync = false;
  587. scope.rightsync = false;
  588. logmenutable2.onscroll = function(){
  589. if(!leftsync){
  590. rightsync = true;
  591. logmenutable.scrollTop = this.scrollTop;
  592. }
  593. else{
  594. leftsync = false;
  595. }
  596. };
  597. logmenutable.onscroll = function(){
  598. if(!rightsync){
  599. leftsync = true;
  600. logmenutable2.scrollTop = this.scrollTop;
  601. }
  602. else{
  603. rightsync = false
  604. }
  605. };
  606.  
  607. logmenu.appendChild(logmenutable);
  608. logmenu.appendChild(logmenutable2);
  609.  
  610. debuggermenu.appendChild(logmenu);
  611.  
  612. scope.debuggermenuclose = Gdocument.createElement("div");
  613. debuggermenuclose.id = "debuggerclose";
  614. debuggermenuclose.classList = "windowCloseButton brownButton brownButton_classic buttonShadow";
  615. debuggermenuclose.style["position"] = "absolute";
  616. debuggermenuclose.style["top"] = "40px";
  617. debuggermenuclose.style["right"] = "5px";
  618. debuggermenuclose.onclick = function(){debuggeropen = false;debuggermenu.style["display"] = "none";Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  619. Gdocument.getElementById("ingamechatinputtext").style["display"] = "";};
  620.  
  621. debuggermenu.appendChild(debuggermenuclose);
  622.  
  623.  
  624.  
  625. scope.debuggerform = Gdocument.createElement("form");
  626. debuggerform.autocomplete = "off";
  627.  
  628. scope.debuggerinput = Gdocument.createElement("input");
  629. debuggerinput.style["position"] = "absolute";
  630. debuggerinput.style["width"] = width.toString()+"px";
  631. debuggerinput.style["left"] = "10px";
  632. debuggerinput.style["top"] = (height+90).toString()+"px";
  633. debuggerinput.style["font-size"] = "12px";
  634. debuggerinput.style["height"] = "20px";
  635. debuggerform.appendChild(debuggerinput);
  636.  
  637.  
  638.  
  639. scope.debuggersendrecieve = Gdocument.createElement("div");
  640. debuggersendrecieve.style["position"] = "absolute";
  641. debuggersendrecieve.style["width"] = "140px";
  642. debuggersendrecieve.style["left"] = "10px";
  643. debuggersendrecieve.style["top"] = (height+120).toString()+"px";
  644. debuggersendrecieve.style["font-size"] = "15px";
  645. debuggersendrecieve.style["height"] = "20px";
  646. debuggersendrecieve.classList = "brownButton brownButton_classic buttonShadow";
  647. debuggersendrecieve.textContent = "Send";
  648. debuggersendrecieve.value = 0;
  649. debuggersendrecieve.onclick = function(){if(this.value == 0){this.textContent = "Recieve";this.value = 1;}else{this.textContent = "Send";this.value = 0;}};
  650.  
  651. debuggermenu.appendChild(debuggersendrecieve);
  652.  
  653. scope.debuggerpausebutton = Gdocument.createElement("div");
  654. debuggerpausebutton.style["position"] = "absolute";
  655. debuggerpausebutton.style["width"] = "140px";
  656. debuggerpausebutton.style["left"] = "10px";
  657. debuggerpausebutton.style["top"] = (height+150).toString()+"px";
  658. debuggerpausebutton.style["font-size"] = "15px";
  659. debuggerpausebutton.style["height"] = "20px";
  660. debuggerpausebutton.classList = "brownButton brownButton_classic buttonShadow";
  661. debuggerpausebutton.textContent = "Pause";
  662. debuggerpausebutton.value = 0;
  663. debuggerpausebutton.onclick = function(){if(this.value == 0){this.textContent = "Play";this.value = 1;wsslogpaused = true}else{this.textContent = "Pause";this.value = 0;wsslogpaused = false;}};
  664.  
  665. debuggermenu.appendChild(debuggerpausebutton);
  666.  
  667. scope.debuggereval = Gdocument.createElement("input");
  668. debuggereval.style["position"] = "absolute";
  669. debuggereval.style["width"] = (width-150).toString()+"px";
  670. debuggereval.style["right"] = "10px";
  671. debuggereval.style["top"] = (height+120).toString()+"px";
  672. debuggereval.style["font-size"] = "12px";
  673. debuggereval.style["height"] = "20px";
  674. debuggereval.addEventListener("keypress",function(e){if(e.repeat){return;}if(e.code == "Enter" && this.value.length>0){if(debuggersendrecieve.value == 0){SEND(this.value);}else{RECIEVE(this.value);}}});
  675.  
  676.  
  677. debuggerform.appendChild(debuggereval);
  678. debuggermenu.appendChild(debuggerform);
  679. Gdocument.getElementById("newbonkgamecontainer").appendChild(debuggermenu);
  680.  
  681. }
  682. scope.ISdecode = function(rawdata) {
  683. rawdata_caseflipped = "";
  684. for (i = 0; i < rawdata.length; i++) {
  685. if (i <= 100 && rawdata.charAt(i) === rawdata.charAt(i).toLowerCase()) {
  686. rawdata_caseflipped += rawdata.charAt(i).toUpperCase();
  687. } else if (i <= 100 && rawdata.charAt(i) === rawdata.charAt(i).toUpperCase()) {
  688. rawdata_caseflipped += rawdata.charAt(i).toLowerCase();
  689. } else {
  690. rawdata_caseflipped += rawdata.charAt(i);
  691. }
  692. }
  693.  
  694. data_deLZd = LZString.decompressFromEncodedURIComponent(rawdata_caseflipped);
  695. databuffer = bytebuffer.fromBase64(data_deLZd);
  696. data = ISpsonpair.decode(databuffer.buffer);
  697. return data;
  698. };
  699.  
  700. scope.ISencode = function(obj) {
  701. data = ISpsonpair.encode(obj);
  702. b64 = data.toBase64();
  703. lzd = LZString.compressToEncodedURIComponent(b64);
  704.  
  705. caseflipped = "";
  706. for (i = 0; i < lzd.length; i++) {
  707. if (i <= 100 && lzd.charAt(i) === lzd.charAt(i).toLowerCase()) {
  708. caseflipped += lzd.charAt(i).toUpperCase();
  709. } else if (i <= 100 && lzd.charAt(i) === lzd.charAt(i).toUpperCase()) {
  710. caseflipped += lzd.charAt(i).toLowerCase();
  711. } else {
  712. caseflipped += lzd.charAt(i);
  713. }
  714. }
  715.  
  716.  
  717. return caseflipped;
  718. };
  719.  
  720. scope.decodeIS = function(x){
  721. return ISdecode(x);
  722. };
  723. scope.encodeIS = function(x){
  724. return ISencode(x);
  725. };
  726.  
  727.  
  728.  
  729. encodeToDatabase = function(mapObject) {
  730. var H_B = [arguments];
  731. H_B[2] = new bytebuffer2;
  732. H_B[5] = mapObject.physics;
  733. mapObject.v = 13;
  734. H_B[2].writeShort(mapObject.v);
  735. H_B[2].writeBoolean(mapObject.s.re);
  736. H_B[2].writeBoolean(mapObject.s.nc);
  737. H_B[2].writeShort(mapObject.s.pq);
  738. H_B[2].writeFloat(mapObject.s.gd);
  739. H_B[2].writeBoolean(mapObject.s.fl);
  740. H_B[2].writeUTF(mapObject.m.rxn);
  741. H_B[2].writeUTF(mapObject.m.rxa);
  742. H_B[2].writeUint(mapObject.m.rxid);
  743. H_B[2].writeShort(mapObject.m.rxdb);
  744. H_B[2].writeUTF(mapObject.m.n);
  745. H_B[2].writeUTF(mapObject.m.a);
  746. H_B[2].writeUint(mapObject.m.vu);
  747. H_B[2].writeUint(mapObject.m.vd);
  748. H_B[2].writeShort(mapObject.m.cr.length);
  749. for (
  750. H_B[62] = 0;
  751. H_B[62] < mapObject.m.cr.length;
  752. H_B[62]++
  753. ) {
  754. H_B[2].writeUTF(mapObject.m.cr[H_B[62]]);
  755. }
  756. H_B[2].writeUTF(mapObject.m.mo);
  757. H_B[2].writeInt(mapObject.m.dbid);
  758. H_B[2].writeBoolean(mapObject.m.pub);
  759. H_B[2].writeInt(mapObject.m.dbv);
  760. H_B[2].writeShort(H_B[5].ppm);
  761. H_B[2].writeShort(H_B[5].bro.length);
  762. for (H_B[31] = 0; H_B[31] < H_B[5].bro.length; H_B[31]++) {
  763. H_B[2].writeShort(H_B[5].bro[H_B[31]]);
  764. }
  765. H_B[2].writeShort(H_B[5].shapes.length);
  766. for (H_B[61] = 0; H_B[61] < H_B[5].shapes.length; H_B[61]++) {
  767. H_B[3] = H_B[5].shapes[H_B[61]];
  768. if (H_B[3].type == "bx") {
  769. H_B[2].writeShort(1);
  770. H_B[2].writeDouble(H_B[3].w);
  771. H_B[2].writeDouble(H_B[3].h);
  772. H_B[2].writeDouble(H_B[3].c[0]);
  773. H_B[2].writeDouble(H_B[3].c[1]);
  774. H_B[2].writeDouble(H_B[3].a);
  775. H_B[2].writeBoolean(H_B[3].sk);
  776. }
  777. if (H_B[3].type == "ci") {
  778. H_B[2].writeShort(2);
  779. H_B[2].writeDouble(H_B[3].r);
  780. H_B[2].writeDouble(H_B[3].c[0]);
  781. H_B[2].writeDouble(H_B[3].c[1]);
  782. H_B[2].writeBoolean(H_B[3].sk);
  783. }
  784. if (H_B[3].type == "po") {
  785. H_B[2].writeShort(3);
  786. H_B[2].writeDouble(H_B[3].s);
  787. H_B[2].writeDouble(H_B[3].a);
  788. H_B[2].writeDouble(H_B[3].c[0]);
  789. H_B[2].writeDouble(H_B[3].c[1]);
  790. H_B[2].writeShort(H_B[3].v.length);
  791. for (H_B[45] = 0; H_B[45] < H_B[3].v.length; H_B[45]++) {
  792. H_B[2].writeDouble(H_B[3].v[H_B[45]][0]);
  793. H_B[2].writeDouble(H_B[3].v[H_B[45]][1]);
  794. }
  795. }
  796. }
  797. H_B[2].writeShort(H_B[5].fixtures.length);
  798. for (H_B[88] = 0; H_B[88] < H_B[5].fixtures.length; H_B[88]++) {
  799. H_B[4] = H_B[5].fixtures[H_B[88]];
  800. H_B[2].writeShort(H_B[4].sh);
  801. H_B[2].writeUTF(H_B[4].n);
  802. if (H_B[4].fr === null) {
  803. H_B[2].writeDouble(Number.MAX_VALUE);
  804. } else {
  805. H_B[2].writeDouble(H_B[4].fr);
  806. }
  807. if (H_B[4].fp === null) {
  808. H_B[2].writeShort(0);
  809. }
  810. if (H_B[4].fp === false) {
  811. H_B[2].writeShort(1);
  812. }
  813. if (H_B[4].fp === true) {
  814. H_B[2].writeShort(2);
  815. }
  816. if (H_B[4].re === null) {
  817. H_B[2].writeDouble(Number.MAX_VALUE);
  818. } else {
  819. H_B[2].writeDouble(H_B[4].re);
  820. }
  821. if (H_B[4].de === null) {
  822. H_B[2].writeDouble(Number.MAX_VALUE);
  823. } else {
  824. H_B[2].writeDouble(H_B[4].de);
  825. }
  826. H_B[2].writeUint(H_B[4].f);
  827. H_B[2].writeBoolean(H_B[4].d);
  828. H_B[2].writeBoolean(H_B[4].np);
  829. H_B[2].writeBoolean(H_B[4].ng);
  830. H_B[2].writeBoolean(H_B[4].ig);
  831. }
  832. H_B[2].writeShort(H_B[5].bodies.length);
  833. for (H_B[41] = 0; H_B[41] < H_B[5].bodies.length; H_B[41]++) {
  834. H_B[9] = H_B[5].bodies[H_B[41]];
  835. H_B[2].writeUTF(H_B[9].type);
  836. H_B[2].writeUTF(H_B[9].n);
  837. H_B[2].writeDouble(H_B[9].p[0]);
  838. H_B[2].writeDouble(H_B[9].p[1]);
  839. H_B[2].writeDouble(H_B[9].a);
  840. H_B[2].writeDouble(H_B[9].fric);
  841. H_B[2].writeBoolean(H_B[9].fricp);
  842. H_B[2].writeDouble(H_B[9].re);
  843. H_B[2].writeDouble(H_B[9].de);
  844. H_B[2].writeDouble(H_B[9].lv[0]);
  845. H_B[2].writeDouble(H_B[9].lv[1]);
  846. H_B[2].writeDouble(H_B[9].av);
  847. H_B[2].writeDouble(H_B[9].ld);
  848. H_B[2].writeDouble(H_B[9].ad);
  849. H_B[2].writeBoolean(H_B[9].fr);
  850. H_B[2].writeBoolean(H_B[9].bu);
  851. H_B[2].writeDouble(H_B[9].cf.x);
  852. H_B[2].writeDouble(H_B[9].cf.y);
  853. H_B[2].writeDouble(H_B[9].cf.ct);
  854. H_B[2].writeBoolean(H_B[9].cf.w);
  855. H_B[2].writeShort(H_B[9].f_c);
  856. H_B[2].writeBoolean(H_B[9].f_1);
  857. H_B[2].writeBoolean(H_B[9].f_2);
  858. H_B[2].writeBoolean(H_B[9].f_3);
  859. H_B[2].writeBoolean(H_B[9].f_4);
  860. H_B[2].writeBoolean(H_B[9].f_p);
  861. H_B[2].writeShort(H_B[9].fx.length);
  862. for (H_B[78] = 0; H_B[78] < H_B[9].fx.length; H_B[78]++) {
  863. H_B[2].writeShort(H_B[9].fx[H_B[78]]);
  864. }
  865. }
  866. H_B[2].writeShort(mapObject.spawns.length);
  867. for (
  868. H_B[74] = 0;
  869. H_B[74] < mapObject.spawns.length;
  870. H_B[74]++
  871. ) {
  872. H_B[6] = mapObject.spawns[H_B[74]];
  873. H_B[2].writeDouble(H_B[6].x);
  874. H_B[2].writeDouble(H_B[6].y);
  875. H_B[2].writeDouble(H_B[6].xv);
  876. H_B[2].writeDouble(H_B[6].yv);
  877. H_B[2].writeShort(H_B[6].priority);
  878. H_B[2].writeBoolean(H_B[6].r);
  879. H_B[2].writeBoolean(H_B[6].f);
  880. H_B[2].writeBoolean(H_B[6].b);
  881. H_B[2].writeBoolean(H_B[6].gr);
  882. H_B[2].writeBoolean(H_B[6].ye);
  883. H_B[2].writeUTF(H_B[6].n);
  884. }
  885. H_B[2].writeShort(mapObject.capZones.length);
  886. for (
  887. H_B[48] = 0;
  888. H_B[48] < mapObject.capZones.length;
  889. H_B[48]++
  890. ) {
  891. H_B[1] = mapObject.capZones[H_B[48]];
  892. H_B[2].writeUTF(H_B[1].n);
  893. H_B[2].writeDouble(H_B[1].l);
  894. H_B[2].writeShort(H_B[1].i);
  895. H_B[2].writeShort(H_B[1].ty);
  896. }
  897. H_B[2].writeShort(H_B[5].joints.length);
  898. for (H_B[69] = 0; H_B[69] < H_B[5].joints.length; H_B[69]++) {
  899. H_B[8] = H_B[5].joints[H_B[69]];
  900. if (H_B[8].type == "rv") {
  901. H_B[2].writeShort(1);
  902. H_B[2].writeDouble(H_B[8].d.la);
  903. H_B[2].writeDouble(H_B[8].d.ua);
  904. H_B[2].writeDouble(H_B[8].d.mmt);
  905. H_B[2].writeDouble(H_B[8].d.ms);
  906. H_B[2].writeBoolean(H_B[8].d.el);
  907. H_B[2].writeBoolean(H_B[8].d.em);
  908. H_B[2].writeDouble(H_B[8].aa[0]);
  909. H_B[2].writeDouble(H_B[8].aa[1]);
  910. }
  911. if (H_B[8].type == "d") {
  912. H_B[2].writeShort(2);
  913. H_B[2].writeDouble(H_B[8].d.fh);
  914. H_B[2].writeDouble(H_B[8].d.dr);
  915. H_B[2].writeDouble(H_B[8].aa[0]);
  916. H_B[2].writeDouble(H_B[8].aa[1]);
  917. H_B[2].writeDouble(H_B[8].ab[0]);
  918. H_B[2].writeDouble(H_B[8].ab[1]);
  919. }
  920. if (H_B[8].type == "lpj") {
  921. H_B[2].writeShort(3);
  922. H_B[2].writeDouble(H_B[8].pax);
  923. H_B[2].writeDouble(H_B[8].pay);
  924. H_B[2].writeDouble(H_B[8].pa);
  925. H_B[2].writeDouble(H_B[8].pf);
  926. H_B[2].writeDouble(H_B[8].pl);
  927. H_B[2].writeDouble(H_B[8].pu);
  928. H_B[2].writeDouble(H_B[8].plen);
  929. H_B[2].writeDouble(H_B[8].pms);
  930. }
  931. if (H_B[8].type == "lsj") {
  932. H_B[2].writeShort(4);
  933. H_B[2].writeDouble(H_B[8].sax);
  934. H_B[2].writeDouble(H_B[8].say);
  935. H_B[2].writeDouble(H_B[8].sf);
  936. H_B[2].writeDouble(H_B[8].slen);
  937. }
  938. H_B[2].writeShort(H_B[8].ba);
  939. H_B[2].writeShort(H_B[8].bb);
  940. H_B[2].writeBoolean(H_B[8].d.cc);
  941. H_B[2].writeDouble(H_B[8].d.bf);
  942. H_B[2].writeBoolean(H_B[8].d.dl);
  943. }
  944. H_B[15] = H_B[2].toBase64();
  945. H_B[30] = LZString.compressToEncodedURIComponent(H_B[15]);
  946. return H_B[30];
  947. };
  948.  
  949.  
  950.  
  951.  
  952.  
  953. scope.decodeFromDatabase = function(map) {
  954. var a8k = [arguments];
  955. b64mapdata = LZString.decompressFromEncodedURIComponent(map);
  956. var binaryReader = new bytebuffer2;
  957. binaryReader.fromBase64(b64mapdata, false);
  958. 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": "" } };
  959. map.v = binaryReader.readShort();
  960. if (map.v > 13) {
  961. throw new Error("New map format, this script needs to be updated.");
  962. }
  963. map.s.re = binaryReader.readBoolean();
  964. map.s.nc = binaryReader.readBoolean();
  965. if (map.v >= 3) {
  966. map.s.pq = binaryReader.readShort();
  967. }
  968. if (map.v >= 4 && map.v <= 12) {
  969. map.s.gd = binaryReader.readShort();
  970. } else if (map.v >= 13) {
  971. map.s.gd = binaryReader.readFloat();
  972. }
  973. if (map.v >= 9) {
  974. map.s.fl = binaryReader.readBoolean();
  975. }
  976. map.m.rxn = binaryReader.readUTF();
  977. map.m.rxa = binaryReader.readUTF();
  978. map.m.rxid = binaryReader.readUint();
  979. map.m.rxdb = binaryReader.readShort();
  980. map.m.n = binaryReader.readUTF();
  981. map.m.a = binaryReader.readUTF();
  982. if (map.v >= 10) {
  983. map.m.vu = binaryReader.readUint();
  984. map.m.vd = binaryReader.readUint();
  985. }
  986. if (map.v >= 4) {
  987. cr_count = binaryReader.readShort();
  988. for (cr_iterator = 0; cr_iterator < cr_count; cr_iterator++) {
  989. map.m.cr.push(binaryReader.readUTF());
  990. }
  991. }
  992. if (map.v >= 5) {
  993. map.m.mo = binaryReader.readUTF();
  994. map.m.dbid = binaryReader.readInt();
  995. }
  996. if (map.v >= 7) {
  997. map.m.pub = binaryReader.readBoolean();
  998. }
  999. if (map.v >= 8) {
  1000. map.m.dbv = binaryReader.readInt();
  1001. }
  1002. map.physics.ppm = binaryReader.readShort();
  1003. bro_count = binaryReader.readShort();
  1004. for (bro_iterator = 0; bro_iterator < bro_count; bro_iterator++) {
  1005. map.physics.bro[bro_iterator] = binaryReader.readShort();
  1006. }
  1007. shape_count = binaryReader.readShort();
  1008. for (shape_iterator = 0; shape_iterator < shape_count; shape_iterator++) {
  1009. shape_type = binaryReader.readShort();
  1010. if (shape_type == 1) {
  1011. map.physics.shapes[shape_iterator] = {"type":"bx","w":10,"h":40,"c":[0,0],"a":0,"sk":false};
  1012. map.physics.shapes[shape_iterator].w = binaryReader.readDouble();
  1013. map.physics.shapes[shape_iterator].h = binaryReader.readDouble();
  1014. map.physics.shapes[shape_iterator].c = [binaryReader.readDouble(), binaryReader.readDouble()];
  1015. map.physics.shapes[shape_iterator].a = binaryReader.readDouble();
  1016. map.physics.shapes[shape_iterator].sk = binaryReader.readBoolean();
  1017. }
  1018. if (shape_type == 2) {
  1019. map.physics.shapes[shape_iterator] = {"type":"ci","r":25,"c":[0,0],"sk":false};
  1020. map.physics.shapes[shape_iterator].r = binaryReader.readDouble();
  1021. map.physics.shapes[shape_iterator].c = [binaryReader.readDouble(), binaryReader.readDouble()];
  1022. map.physics.shapes[shape_iterator].sk = binaryReader.readBoolean();
  1023. }
  1024. if (shape_type == 3) {
  1025. map.physics.shapes[shape_iterator] = {"type":"po","v":[],"s":1,"a":0,"c":[0,0]};
  1026. map.physics.shapes[shape_iterator].s = binaryReader.readDouble();
  1027. map.physics.shapes[shape_iterator].a = binaryReader.readDouble();
  1028. map.physics.shapes[shape_iterator].c = [binaryReader.readDouble(), binaryReader.readDouble()];
  1029. point_count = binaryReader.readShort();
  1030. map.physics.shapes[shape_iterator].v = [];
  1031. for (point_iterator = 0; point_iterator < point_count; point_iterator++) {
  1032. map.physics.shapes[shape_iterator].v.push([binaryReader.readDouble(), binaryReader.readDouble()]);
  1033. }
  1034. }
  1035. }
  1036. a8k[31] = binaryReader.readShort();
  1037. for (a8k[89] = 0; a8k[89] < a8k[31]; a8k[89]++) {
  1038. 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};
  1039. map.physics.fixtures[a8k[89]].sh = binaryReader.readShort();
  1040. map.physics.fixtures[a8k[89]].n = binaryReader.readUTF();
  1041. map.physics.fixtures[a8k[89]].fr = binaryReader.readDouble();
  1042. if (map.physics.fixtures[a8k[89]].fr == Number.MAX_VALUE) {
  1043. map.physics.fixtures[a8k[89]].fr = null;
  1044. }
  1045. a8k[22] = binaryReader.readShort();
  1046. if (a8k[22] == 0) {
  1047. map.physics.fixtures[a8k[89]].fp = null;
  1048. }
  1049. if (a8k[22] == 1) {
  1050. map.physics.fixtures[a8k[89]].fp = false;
  1051. }
  1052. if (a8k[22] == 2) {
  1053. map.physics.fixtures[a8k[89]].fp = true;
  1054. }
  1055. map.physics.fixtures[a8k[89]].re = binaryReader.readDouble();
  1056. if (map.physics.fixtures[a8k[89]].re == Number.MAX_VALUE) {
  1057. map.physics.fixtures[a8k[89]].re = null;
  1058. }
  1059. map.physics.fixtures[a8k[89]].de = binaryReader.readDouble();
  1060. if (map.physics.fixtures[a8k[89]].de == Number.MAX_VALUE) {
  1061. map.physics.fixtures[a8k[89]].de = null;
  1062. }
  1063. map.physics.fixtures[a8k[89]].f = binaryReader.readUint();
  1064. map.physics.fixtures[a8k[89]].d = binaryReader.readBoolean();
  1065. map.physics.fixtures[a8k[89]].np = binaryReader.readBoolean();
  1066. if (map.v >= 11) {
  1067. map.physics.fixtures[a8k[89]].ng = binaryReader.readBoolean();
  1068. }
  1069. if (map.v >= 12) {
  1070. map.physics.fixtures[a8k[89]].ig = binaryReader.readBoolean();
  1071. }
  1072. }
  1073. a8k[41] = binaryReader.readShort();
  1074. for (a8k[20] = 0; a8k[20] < a8k[41]; a8k[20]++) {
  1075. 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};
  1076. map.physics.bodies[a8k[20]].type = binaryReader.readUTF();
  1077. map.physics.bodies[a8k[20]].n = binaryReader.readUTF();
  1078. map.physics.bodies[a8k[20]].p = [binaryReader.readDouble(), binaryReader.readDouble()];
  1079. map.physics.bodies[a8k[20]].a = binaryReader.readDouble();
  1080. map.physics.bodies[a8k[20]].fric = binaryReader.readDouble();
  1081. map.physics.bodies[a8k[20]].fricp = binaryReader.readBoolean();
  1082. map.physics.bodies[a8k[20]].re = binaryReader.readDouble();
  1083. map.physics.bodies[a8k[20]].de = binaryReader.readDouble();
  1084. map.physics.bodies[a8k[20]].lv = [binaryReader.readDouble(), binaryReader.readDouble()];
  1085. map.physics.bodies[a8k[20]].av = binaryReader.readDouble();
  1086. map.physics.bodies[a8k[20]].ld = binaryReader.readDouble();
  1087. map.physics.bodies[a8k[20]].ad = binaryReader.readDouble();
  1088. map.physics.bodies[a8k[20]].fr = binaryReader.readBoolean();
  1089. map.physics.bodies[a8k[20]].bu = binaryReader.readBoolean();
  1090. map.physics.bodies[a8k[20]].cf.x = binaryReader.readDouble();
  1091. map.physics.bodies[a8k[20]].cf.y = binaryReader.readDouble();
  1092. map.physics.bodies[a8k[20]].cf.ct = binaryReader.readDouble();
  1093. map.physics.bodies[a8k[20]].cf.w = binaryReader.readBoolean();
  1094. map.physics.bodies[a8k[20]].f_c = binaryReader.readShort();
  1095. map.physics.bodies[a8k[20]].f_1 = binaryReader.readBoolean();
  1096. map.physics.bodies[a8k[20]].f_2 = binaryReader.readBoolean();
  1097. map.physics.bodies[a8k[20]].f_3 = binaryReader.readBoolean();
  1098. map.physics.bodies[a8k[20]].f_4 = binaryReader.readBoolean();
  1099. if (map.v >= 2) {
  1100. map.physics.bodies[a8k[20]].f_p = binaryReader.readBoolean();
  1101. }
  1102. a8k[50] = binaryReader.readShort();
  1103. for (a8k[66] = 0; a8k[66] < a8k[50]; a8k[66]++) {
  1104. map.physics.bodies[a8k[20]].fx.push(binaryReader.readShort());
  1105. }
  1106. }
  1107. a8k[48] = binaryReader.readShort();
  1108. for (a8k[36] = 0; a8k[36] < a8k[48]; a8k[36]++) {
  1109. 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"};
  1110. a8k[80] = map.spawns[a8k[36]];
  1111. a8k[80].x = binaryReader.readDouble();
  1112. a8k[80].y = binaryReader.readDouble();
  1113. a8k[80].xv = binaryReader.readDouble();
  1114. a8k[80].yv = binaryReader.readDouble();
  1115. a8k[80].priority = binaryReader.readShort();
  1116. a8k[80].r = binaryReader.readBoolean();
  1117. a8k[80].f = binaryReader.readBoolean();
  1118. a8k[80].b = binaryReader.readBoolean();
  1119. a8k[80].gr = binaryReader.readBoolean();
  1120. a8k[80].ye = binaryReader.readBoolean();
  1121. a8k[80].n = binaryReader.readUTF();
  1122. }
  1123. a8k[40] = binaryReader.readShort();
  1124. for (a8k[18] = 0; a8k[18] < a8k[40]; a8k[18]++) {
  1125. map.capZones[a8k[18]] = {"n":"Cap Zone","ty":1,"l":10,"i":-1};
  1126. map.capZones[a8k[18]].n = binaryReader.readUTF();
  1127. map.capZones[a8k[18]].l = binaryReader.readDouble();
  1128. map.capZones[a8k[18]].i = binaryReader.readShort();
  1129. if (map.v >= 6) {
  1130. map.capZones[a8k[18]].ty = binaryReader.readShort();
  1131. }
  1132. }
  1133. a8k[39] = binaryReader.readShort();
  1134. for (a8k[94] = 0; a8k[94] < a8k[39]; a8k[94]++) {
  1135. a8k[75] = binaryReader.readShort();
  1136. if (a8k[75] == 1) {
  1137. 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]};
  1138. a8k[53] = map.physics.joints[a8k[94]];
  1139. a8k[53].d.la = binaryReader.readDouble();
  1140. a8k[53].d.ua = binaryReader.readDouble();
  1141. a8k[53].d.mmt = binaryReader.readDouble();
  1142. a8k[53].d.ms = binaryReader.readDouble();
  1143. a8k[53].d.el = binaryReader.readBoolean();
  1144. a8k[53].d.em = binaryReader.readBoolean();
  1145. a8k[53].aa = [binaryReader.readDouble(), binaryReader.readDouble()];
  1146. }
  1147. if (a8k[75] == 2) {
  1148. map.physics.joints[a8k[94]] = {"type":"d","d":{"fh":0,"dr":0,"cc":false,"bf":0,"dl":true},"aa":[0,0],"ab":[0,0]};
  1149. a8k[27] = map.physics.joints[a8k[94]];
  1150. a8k[27].d.fh = binaryReader.readDouble();
  1151. a8k[27].d.dr = binaryReader.readDouble();
  1152. a8k[27].aa = [binaryReader.readDouble(), binaryReader.readDouble()];
  1153. a8k[27].ab = [binaryReader.readDouble(), binaryReader.readDouble()];
  1154. }
  1155. if (a8k[75] == 3) {
  1156. 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};
  1157. a8k[23] = map.physics.joints[a8k[94]];
  1158. a8k[23].pax = binaryReader.readDouble();
  1159. a8k[23].pay = binaryReader.readDouble();
  1160. a8k[23].pa = binaryReader.readDouble();
  1161. a8k[23].pf = binaryReader.readDouble();
  1162. a8k[23].pl = binaryReader.readDouble();
  1163. a8k[23].pu = binaryReader.readDouble();
  1164. a8k[23].plen = binaryReader.readDouble();
  1165. a8k[23].pms = binaryReader.readDouble();
  1166. }
  1167. if (a8k[75] == 4) {
  1168. map.physics.joints[a8k[94]] = {"type":"lsj","d":{"cc":false,"bf":0,"dl":true},"sax":0,"say":0,"sf":0,"slen":0};
  1169. a8k[47] = map.physics.joints[a8k[94]];
  1170. a8k[47].sax = binaryReader.readDouble();
  1171. a8k[47].say = binaryReader.readDouble();
  1172. a8k[47].sf = binaryReader.readDouble();
  1173. a8k[47].slen = binaryReader.readDouble();
  1174. }
  1175. map.physics.joints[a8k[94]].ba = binaryReader.readShort();
  1176. map.physics.joints[a8k[94]].bb = binaryReader.readShort();
  1177. map.physics.joints[a8k[94]].d.cc = binaryReader.readBoolean();
  1178. map.physics.joints[a8k[94]].d.bf = binaryReader.readDouble();
  1179. map.physics.joints[a8k[94]].d.dl = binaryReader.readBoolean();
  1180.  
  1181. }
  1182. return map;
  1183. };
  1184.  
  1185.  
  1186.  
  1187. scope.updateWssLog = function(){
  1188. if(!wsslogpaused){
  1189. if(logmenutable.children.length < wsssendrecievelog.length){
  1190. var bottomscroll = logmenutable.clientHeight + logmenutable.scrollTop >= logmenutable.scrollHeight-1;
  1191. while (logmenutable.children.length>1000) {
  1192. logmenutable.removeChild(logmenutable.firstChild);
  1193. logmenutable2.removeChild(logmenutable2.firstChild);
  1194. }
  1195. var loopthro = wsssendrecievelog.slice(packetcount);
  1196. for(var i = 0; i < loopthro.length;i++){
  1197. packetcount++;
  1198. var row = document.createElement("tr");
  1199. var row2 = document.createElement("tr");
  1200.  
  1201. var cell1 = document.createElement("td");
  1202. cell1.style["overflow-x"] = "scroll";
  1203. cell1.style["padding"] = "0px";
  1204. cell1.style["width"] = "100000px";
  1205.  
  1206. var cell2 = document.createElement("td");
  1207. cell2.style["overflow-x"] = "scroll";
  1208. cell2.style["padding"] = "0px";
  1209. cell2.style["width"] = "100000px";
  1210.  
  1211. if(debuggercount){
  1212. cell1.style["background"] = "rgb(178, 185, 189)";
  1213. debuggercount = false;
  1214. }
  1215. else{
  1216. cell2.style["background"] = "rgb(178, 185, 189)";
  1217. debuggercount = true;
  1218. }
  1219. cell1.textContent = loopthro[i][1];
  1220. cell2.textContent = loopthro[i][1];
  1221. if(loopthro[i][0] == 0){
  1222. cell2.style["color"] = "transparent";
  1223. cell1.onclick = function(){debuggerinput.value = this.textContent};
  1224. }
  1225. else{
  1226. cell1.style["color"] = "transparent";
  1227. cell2.onclick = function(){debuggerinput.value = this.textContent};
  1228. }
  1229. row.appendChild(cell1);
  1230. row2.appendChild(cell2);
  1231. logmenutable.appendChild(row);
  1232. logmenutable2.appendChild(row2);
  1233. }
  1234. while (logmenutable.children.length>1000) {
  1235. logmenutable.removeChild(logmenutable.firstChild);
  1236. logmenutable2.removeChild(logmenutable2.firstChild);
  1237. }
  1238. if(bottomscroll){
  1239. logmenutable.scrollTop = logmenutable.scrollHeight;
  1240. logmenutable2.scrollTop = logmenutable.scrollHeight;
  1241. }
  1242. }
  1243. }
  1244. };
  1245. Gdocument.getElementById("maploadwindowmapscontainer").appendChild = function(args){
  1246.  
  1247. var checkbox = Gdocument.createElement("input");
  1248. checkbox.type = "checkbox";
  1249. checkbox.style["position"]="absolute";
  1250. checkbox.style["margin-top"] = "135px";
  1251. checkbox.style["margin-left"] = "140px";
  1252. checkbox.style["scale"] = "2";
  1253. checkbox.style["display"] = "none";
  1254. checkbox.className = "quickplaycheckbox quickplayunchecked";
  1255. if(ishost && stopquickplay==0){
  1256. checkbox.style["display"] = "block";
  1257. checkbox.className = "quickplaycheckbox quickplaychecked";
  1258. }
  1259. checkbox.checked = true;
  1260. checkbox.onclick = function(e){e.stopPropagation();};
  1261. args.appendChild(checkbox);
  1262. originalMapLoad.call(this,args);
  1263. };
  1264. Gdocument.getElementById("newbonklobby_chat_content").appendChild = function(args){
  1265. if(beenKickedTimeStamp+100>Date.now() && args.children.length>0){
  1266. if(args.children[0].textContent.endsWith(" has left the game ") && args.children[0].textContent.startsWith("* ")){
  1267. var kickedorbanned = "banned";
  1268. if(onlykicked){
  1269. kickedorbanned = "kicked";
  1270. }
  1271. args.children[0].textContent = args.children[0].textContent.substring(0,args.children[0].textContent.length-19)+" has been "+kickedorbanned+" from the game ";
  1272. }
  1273. }
  1274. setTimeout(function(){
  1275. if(args.textContent.startsWith("* ") && args.children.length>=5){
  1276. var newarg = args.cloneNode();
  1277. for(var i = 0;i<args.children.length;i++){
  1278. var newarg2 = args.children[i].cloneNode();
  1279. newarg2.textContent = args.children[i].textContent;
  1280. newarg2.style.color = '#ffffffd6';
  1281. newarg2.onclick = args.children[i].onclick;
  1282. newarg2.suggestID = args.children[i].suggestID;
  1283. newarg.appendChild(newarg2);
  1284. }
  1285. Gdocument.getElementById("ingamechatcontent").appendChild(newarg);
  1286. Gdocument.getElementById("ingamechatcontent").scrollTop = Number.MAX_SAFE_INTEGER;
  1287. }},0);
  1288. originalLobbyChat.call(this,args);
  1289. };
  1290. Gdocument.getElementById("ingamechatcontent").appendChild = function(args){
  1291. if(beenKickedTimeStamp+100>Date.now() && args.children.length>0){
  1292. if(args.children[0].textContent.endsWith(" has left the game.") && args.children[0].textContent.startsWith("* ")){
  1293. var kickedorbanned = "banned";
  1294. if(onlykicked){
  1295. kickedorbanned = "kicked";
  1296. }
  1297. args.children[0].textContent = args.children[0].textContent.substring(0,args.children[0].textContent.length-19)+" has been "+kickedorbanned+" from the game.";
  1298. }
  1299. }
  1300. if(recordedTimeStamp+100>Date.now() && args.children.length>0){
  1301. if(args.children[0].textContent.includes("seconds") && args.children[0].textContent.startsWith("* ")){
  1302. args.children[0].textContent = args.children[0].textContent + " - " + playerids[recordedId].userName;
  1303. }
  1304. }
  1305. originalIngameChat.call(this,args);
  1306. };
  1307.  
  1308. Gwindow.XMLHttpRequest.prototype.open = function(_, url) {
  1309. if (url.includes("scripts/map_get") || url.includes("scripts/map_b1_get") || url.includes("scripts/hotmaps/")) {
  1310. this.isSearchMap = true;
  1311. }
  1312.  
  1313. originalXMLOpen.call(this, ...arguments);
  1314. };
  1315.  
  1316. Gwindow.XMLHttpRequest.prototype.send = function(data) {
  1317. if (this.isSearchMap) {
  1318. this.onreadystatechange = function () {
  1319. if (this.readyState == 4 && searchrequested && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS") {
  1320. searchrequested = false;
  1321.  
  1322. var jsonargs = {r:"success",maps:[],more:true};
  1323.  
  1324. for(var i = 0; i<requestedmaps.length; i++){
  1325. var dec = requestedmaps[i][0];
  1326. var undec = requestedmaps[i][1];
  1327. var map = {};
  1328. map.id = dec["m"]["dbid"];
  1329. map.name = dec["m"]["n"];
  1330. map.authorname = dec["m"]["a"];
  1331. map.leveldata = undec;
  1332. map.publisheddate = dec["m"]["date"];
  1333. map.remixauthor = dec["m"]["rxa"];
  1334. map.remixdb = dec["m"]["rxdb"];
  1335. map.remixid = dec["m"]["rxid"];
  1336. map.remixname = dec["m"]["rxn"];
  1337. map.vd = dec["m"]["vd"];
  1338. map.vu = dec["m"]["vu"];
  1339. jsonargs.maps.push(map);
  1340.  
  1341. }
  1342. jsonargs2 = JSON.stringify(jsonargs);
  1343. function stringifyjsonargs(){
  1344. return jsonargs2;
  1345. }
  1346. this.__defineGetter__("responseText", stringifyjsonargs);
  1347. this.__defineGetter__("response", stringifyjsonargs);
  1348.  
  1349.  
  1350. }
  1351. }
  1352. }
  1353. originalXMLSend.call(this, ...arguments);
  1354. };
  1355. scope.STB = function(x){
  1356. if(x == "0"){
  1357. return 0;
  1358. }
  1359. else{
  1360. return 1;
  1361. }
  1362. };
  1363. scope.BTS = function(x){
  1364. if(x == 0){
  1365. return "0";
  1366. }
  1367. else{
  1368. return "1";
  1369. }
  1370. };
  1371. scope.GET_KEYS = function(x){
  1372. var x2 = ((x+64)>>>0).toString(2).substring(1).split("");
  1373. 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])}
  1374. };
  1375. scope.MAKE_KEYS = function(x){
  1376. return x.special*32+x.heavy*16+x.down*8+x.up*4+x.right*2+x.left
  1377. };
  1378.  
  1379. Gwindow.PIXI.Graphics.prototype.drawCircle = function(...args){
  1380.  
  1381. var This = this;
  1382. var Args = [...args];
  1383. setTimeout(function(){
  1384. if(This.parent){
  1385. var childs = This.parent.children;
  1386. var user = 0;
  1387. for(var i = 0;i<childs.length;i++){
  1388. if(childs[i]._text){
  1389. user = childs[i]._text;
  1390. }
  1391. }
  1392. var keys = Object.keys(playerids);
  1393. for(var i = 0;i<keys.length;i++){
  1394. if(playerids[keys[i]].userName == user){
  1395. playerids[keys[i]].playerData = This.parent;
  1396. playerids[keys[i]].playerData2 = {"alive":true,radius:Args[2],timeStamp:0,timeStamp2:0,px:0,py:0,pvx:0,pvy:0,xacc:0,yacc:0,xvel:0,yvel:0};
  1397. parentDraw = This.parent;
  1398. while(parentDraw.parent){
  1399. parentDraw = parentDraw.parent;
  1400. }
  1401. }
  1402. }
  1403. }
  1404. },0);
  1405. return originalDrawCircle.call(this,...args);
  1406. };
  1407.  
  1408. Gwindow.requestAnimationFrame = function(...args){
  1409. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden" && Object.keys(playerids).length>0 && playerids[myid].playerData && FollowCam){
  1410. if(playerids[myid].playerData.transform){
  1411. parentDraw = playerids[myid].playerData;
  1412. while(parentDraw.parent){
  1413. parentDraw = parentDraw.parent;
  1414. }
  1415. var canv = 0;
  1416. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  1417. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  1418. canv = Gdocument.getElementById("gamerenderer").children[i];
  1419. break;
  1420. }
  1421. }
  1422. var width = parseInt(canv.style["width"]);
  1423. var height = parseInt(canv.style["height"]);
  1424. var scale = (parseInt(canv.style["width"])/730);
  1425.  
  1426. if(canvasWidth!=width){
  1427. canvasWidth = width;
  1428. pixiCircle.clear();
  1429. pixiCircle.x = parseInt(canv.style["width"])/2;
  1430. pixiCircle.y = parseInt(canv.style["height"])/2;
  1431. pixiCircle.lineStyle(3, 0x8B8000);
  1432. pixiCircle.drawRect(-parseInt(canv.style["width"])/2,-parseInt(canv.style["height"])/2,parseInt(canv.style["width"]),parseInt(canv.style["height"]));
  1433. pixiCircle.lineStyle(3, 0xFF0000);
  1434. pixiCircle.arc(0, 0, 850*scale,Math.atan2(250,-100*Math.sqrt(66)),Math.atan2(250,100*Math.sqrt(66)));
  1435. pixiCircle.lineTo(-100*Math.sqrt(66)*scale,250*scale);
  1436. }
  1437. if(!parentDraw.children.includes(container)){
  1438. parentDraw.addChild(container);
  1439. }
  1440. pixiCircle.visible = true;
  1441. parentDraw.x = -playerids[myid].playerData.x+parseInt(width)/2;
  1442. parentDraw.y = -playerids[myid].playerData.y+parseInt(height)/2;
  1443. parentDraw.children[0].x = playerids[myid].playerData.x-parseInt(width)/2;
  1444. parentDraw.children[0].y = playerids[myid].playerData.y-parseInt(height)/2;
  1445. }
  1446. else{
  1447. parentDraw.x = 0;
  1448. parentDraw.y = 0;
  1449. parentDraw.children[0].x = 0;
  1450. parentDraw.children[0].y = 0;
  1451. pixiCircle.visible = false;
  1452. }
  1453. }
  1454. return requestAnimationFrameOriginal.call(this,...args);
  1455. };
  1456.  
  1457.  
  1458.  
  1459. scope.SENDFUNCTION = function(args){return args;};
  1460. scope.RECIEVEFUNCTION = function(args){return args;};
  1461. scope.EVENTLOOPFUNCTION = function(){};
  1462.  
  1463. Gwindow.WebSocket.prototype.send = function(args) {
  1464. if(this.url.includes(".bonk.io/socket.io/?EIO=3&transport=websocket&sid=")){
  1465. if(typeof(args) == "string" && !bonkwssextra.includes(this)){
  1466. args = SENDFUNCTION(args);
  1467. wsssendlog.push(args);
  1468. wsssendrecievelog.push([0,args]);
  1469. if(args.startsWith('42[26,')){
  1470. if(sandboxon){
  1471. var jsonargs = JSON.parse(args.substring(2))[1];
  1472. if(typeof(sandboxplayerids[jsonargs["targetID"]])!='undefined'){
  1473. RECIEVE('42[18,'+jsonargs["targetID"]+','+jsonargs["targetTeam"]+']');
  1474.  
  1475. }
  1476. }
  1477. }
  1478. if(args.startsWith('42[1,')){
  1479. return;
  1480. }
  1481.  
  1482. if(args.startsWith('42[4,')){
  1483. var jsonargs = JSON.parse(args.substring(2));
  1484.  
  1485. if(sandboxcopyme && typeof(jsonargs[1]["i"])!="undefined"){
  1486. var jsonkeys = Object.keys(sandboxplayerids);
  1487. for(var i = 0; i<jsonkeys.length;i++){
  1488. RECIEVE('42[7,'+jsonkeys[i].toString()+','+JSON.stringify(jsonargs[1])+']');
  1489. }
  1490. }
  1491. playerids[myid].lastmove = Date.now();
  1492. if(ishost && typeof(jsonargs[1]["i"])!="undefined"){
  1493. for(var i = 0;i<disabledkeys.length;i++){
  1494. if(GET_KEYS(jsonargs[1]["i"])[disabledkeys[i]]){
  1495. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden" && !killedids.includes(myid)){
  1496. killedids.push(myid);
  1497. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  1498. SEND('42[25,{"a":{"playersLeft":['+myid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  1499. RECIEVE('42[31,{"a":{"playersLeft":['+myid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  1500. break;
  1501. }
  1502. }
  1503. }
  1504. }
  1505.  
  1506. args = "42"+JSON.stringify(jsonargs);
  1507. }
  1508. if(args.startsWith('42[12,')){
  1509. playerids = {};
  1510. var jsonargs2 = JSON.parse(args.substring(2));
  1511. var jsonargs = jsonargs2[1];
  1512. playerids["0"] = {"peerID":jsonargs["peerID"],"userName":username,"level":Gdocument.getElementById("pretty_top_level").textContent == "Guest" ? 0 : parseInt(Gdocument.getElementById("pretty_top_level").textContent.substring(3)),"guest":typeof(jsonargs.token)=="undefined","team":1,"avatar":jsonargs["avatar"],ratelimit:{"pm":0,"mode":0,"team":0,"poll":0},vote:{"poll":-1}};
  1513. myid = 0;
  1514. bonkwss = this;
  1515. hostid = 0;
  1516. }
  1517. if(args.startsWith('42[23,') && recteams){
  1518. var jsonargs = JSON.parse(args.substring(2));
  1519. var map = decodeFromDatabase(jsonargs[1]["m"]);
  1520. var spawns = map["spawns"];
  1521. var teamsneeded = true;
  1522. var excludedindexes = [];
  1523. var ffaspawns = false;
  1524. var ffaforsure = false;
  1525. for(var i = 0; i<spawns.length;i++){
  1526. var currentSpawn = spawns[i];
  1527. if(Math.sqrt(currentSpawn.x**2 + currentSpawn.y**2)>=850 || currentSpawn.y>250){
  1528. excludedindexes.push(i);
  1529. }
  1530. else if(!(currentSpawn.f || currentSpawn.r || currentSpawn.b || currentSpawn.gr || currentSpawn.ye)){
  1531. excludedindexes.push(i);
  1532. }
  1533. else if(currentSpawn.f){
  1534. ffaspawns = true;
  1535. if(!(currentSpawn.r || currentSpawn.b || currentSpawn.gr || currentSpawn.ye)){
  1536. excludedindexes.push(i);
  1537. ffaforsure = true
  1538. }
  1539. }
  1540. }
  1541. if(!ffaspawns && !ffaforsure){
  1542. teamsneeded = true;
  1543. }
  1544. else{
  1545. teamsneeded = false;
  1546. }
  1547. if(teamsneeded){
  1548. var newspawns = [];
  1549. for(var i = 0; i<spawns.length;i++){
  1550. if(!excludedindexes.includes(i)){
  1551. 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"]});
  1552. }
  1553. }
  1554.  
  1555. if(newspawns.length>0){
  1556.  
  1557. var teamletters = ["r","g","b","y"];
  1558. var ratios = {"r":0,"g":0,"b":0,"y":0};
  1559. for(var i = 0; i < newspawns.length;i++){
  1560. for(var i2 = 0; i2<teamletters.length;i2++){
  1561. var ct = teamletters[i2];
  1562. if(newspawns[i]["priority"]!=0){
  1563. ratios[ct]+=(newspawns[i][ct])/newspawns[i]["total"]*newspawns[i]["priority"];
  1564. }
  1565. }
  1566. }
  1567. var highest = ["",0];
  1568. for(var i = 0; i<teamletters.length;i++){
  1569. var ct = teamletters[i];
  1570. if(ratios[ct]>0 && highest[1]<ratios[ct]){
  1571. highest = [ct,ratios[ct]];
  1572. }
  1573. }
  1574. if(highest[0]!=""){
  1575. for(var i = 0; i<teamletters.length;i++){
  1576. var ct = teamletters[i];
  1577. ratios[ct] = ratios[ct]/highest[1];
  1578. }
  1579. }
  1580. var playerids3 = Object.keys(playerids);
  1581. var playerids2 = [];
  1582. for(var i = 0; i<playerids3.length;i++){
  1583. if(playerids[playerids3[i]].team>0){
  1584. playerids2.push(playerids3[i]);
  1585. }
  1586. }
  1587.  
  1588. var pi2l = playerids2.length;
  1589. var ratios2 = {"r":0,"r1":0,"g":0,"g1":0,"b":0,"b1":0,"y":0,"y1":0};
  1590. var items = Object.entries(ratios);
  1591. items.sort(function(a,b){return a[1]-b[1];});
  1592. var items = items.map(function(e){return e[0];});
  1593. var highest2 = ["",0];
  1594. while(pi2l>0){
  1595. var done = false;
  1596. for(var i2 = 0; i2<items.length;i2++){
  1597. var ci = items[i2];
  1598. var ci2 = items[i2]+"1";
  1599. for(var i = 0; i<teamletters.length;i++){
  1600. var ct = teamletters[i];
  1601. if(ratios2[ct]>0 && highest2[1]<ratios2[ct]){
  1602. highest2 = [ct,ratios2[ct]];
  1603. }
  1604. }
  1605. if(highest2[0]!=""){
  1606. for(var i = 0; i<teamletters.length;i++){
  1607. var ct = teamletters[i];
  1608. ratios2[ct+"1"] = ratios2[ct]/highest2[1];
  1609. }
  1610. }
  1611. if(ratios[ci]>0 && ratios[ci]>=ratios2[ci2] && pi2l>0){
  1612. ratios2[ci]+=1;
  1613. pi2l--;
  1614. done = true;
  1615. }
  1616. }
  1617. if(pi2l>0 && !done){
  1618. ratios2[highest2[0]]+=1;
  1619. pi2l--;
  1620. }
  1621. }
  1622. SEND('42[32,{"t":true}]');
  1623. RECIEVE('42[39,true]');
  1624. for(var i = 0; i<ratios2["r"];i++){
  1625. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  1626. SEND('42[26,{"targetID":'+pid+',"targetTeam":2}]');
  1627. RECIEVE('42[18,'+pid+',2]');
  1628. }
  1629. for(var i = 0; i<ratios2["g"];i++){
  1630. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  1631. SEND('42[26,{"targetID":'+pid+',"targetTeam":4}]');
  1632. RECIEVE('42[18,'+pid+',4]');
  1633. }
  1634. for(var i = 0; i<ratios2["b"];i++){
  1635. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  1636. SEND('42[26,{"targetID":'+pid+',"targetTeam":3}]');
  1637. RECIEVE('42[18,'+pid+',3]');
  1638. }
  1639. for(var i = 0; i<ratios2["y"];i++){
  1640. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  1641. SEND('42[26,{"targetID":'+pid+',"targetTeam":5}]');
  1642. RECIEVE('42[18,'+pid+',5]');
  1643. }
  1644.  
  1645. }
  1646. }
  1647. else{
  1648. SEND('42[32,{"t":false}]');
  1649. RECIEVE('42[39,false]');
  1650. }
  1651.  
  1652.  
  1653. }
  1654.  
  1655. if(args.startsWith('42[47,') && stopquickplay == 0 && ishost && document.hidden && !qppaused){
  1656. roundsperqp2++;
  1657. if(roundsperqp2>=roundsperqp){
  1658. if(shuffle){
  1659. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  1660. var available = [];
  1661. var availableindexes = [];
  1662. var notempty = false;
  1663. for(var i = 0; i<e2.length;i++){
  1664. var a = false;
  1665. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  1666. available.push(a);
  1667. if(a){
  1668. availableindexes.push(i);
  1669. notempty = true;
  1670. }
  1671. }
  1672. if(notempty){
  1673.  
  1674. if(availableindexes.length!=1){
  1675. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  1676. }
  1677. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  1678. }
  1679. }
  1680. else{
  1681. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  1682. var available = [];
  1683. var availableindexes = [];
  1684. var notempty = false;
  1685. for(var i = 0; i<e2.length;i++){
  1686. var a = false;
  1687. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  1688. available.push(a);
  1689. if(a){
  1690. availableindexes.push(i);
  1691. notempty = true;
  1692. }
  1693. }
  1694. if(notempty){
  1695. var above = [];
  1696. for(var i = 0;i<availableindexes.length;i++){
  1697. if(availableindexes[i]>quicki){
  1698. above.push(availableindexes[i]);
  1699. }
  1700. }
  1701. if(above.length>0){
  1702. quicki = above[0];
  1703. }
  1704. else{
  1705. quicki = availableindexes[0];
  1706. }
  1707. }
  1708. }
  1709. }
  1710. canceled = false;
  1711. startedinqp = true;
  1712. window.map(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length),0);
  1713.  
  1714. }
  1715.  
  1716. if(args.startsWith('42[5,')){
  1717. var jsonargs = JSON.parse(args.substring(2));
  1718.  
  1719. if(stopquickplay!=1 && startedinqp){
  1720. startedinqp = false;
  1721. jsonargs[1]["gs"]["wl"] = 999;
  1722. if(!instaqp){
  1723. var jsonargs2 = decodeIS(jsonargs[1]["is"]);
  1724. jsonargs2["ftu"] = 60;
  1725. if(jsonargs2["mm"]["rxa"] != ""){
  1726. jsonargs2["mm"]["a"] = jsonargs2["mm"]["rxa"];
  1727. jsonargs2["mm"]["n"] = jsonargs2["mm"]["rxn"];
  1728. }
  1729. jsonargs2 = encodeIS(jsonargs2);
  1730. jsonargs[1]["is"] = jsonargs2;
  1731.  
  1732. var jsonargs3 = decodeFromDatabase(jsonargs[1]["gs"]["map"]);
  1733. if(jsonargs3["m"]["rxa"] != ""){
  1734. jsonargs3["m"]["a"] = jsonargs3["m"]["rxa"];
  1735. jsonargs3["m"]["n"] = jsonargs3["m"]["rxn"];
  1736. }
  1737.  
  1738. jsonargs3 = encodeToDatabase(jsonargs3);
  1739. jsonargs[1]["gs"]["map"] = jsonargs3;
  1740. }
  1741.  
  1742.  
  1743. }
  1744.  
  1745. args = "42"+JSON.stringify(jsonargs);
  1746. }
  1747. }
  1748.  
  1749. }
  1750. else{
  1751. if(args.includes("rport")){
  1752. return;
  1753. }
  1754. }
  1755. if(this.url.includes(".bonk.io/socket.io/?EIO=3&transport=websocket&sid=") && !this.injected){
  1756. this.injected = true;
  1757.  
  1758. var originalRecieve = this.onmessage;
  1759. this.onmessage = function(args){
  1760. if(!bonkwssextra.includes(this)){
  1761. wssrecievelog.push(args.data);
  1762. wsssendrecievelog.push([1,args.data]);
  1763. if(typeof(args.data)=="string"){
  1764. args.data = RECIEVEFUNCTION(args.data);
  1765. if(args.data.startsWith('42[1,')){
  1766. var jsonargs = JSON.parse(args.data.substring(2));
  1767. originalSend.call(this,'42[1,{"id":'+jsonargs[2]+'}]');
  1768. }
  1769.  
  1770. if(args.data.startsWith('42[24,')){
  1771. beenKickedTimeStamp = Date.now();
  1772. onlykicked = JSON.parse(args.data.substring(2))[2];
  1773. }
  1774. if(args.data.startsWith('42[16,')){
  1775. var jsonargs = JSON.parse(args.data.substring(2));
  1776. var now = Date.now();
  1777. if(jsonargs[1]=="chat_rate_limit"){
  1778. if(pollactive[1]+100>now){
  1779. pollactive = [false,0,0,[]];
  1780. displayInChat("Your poll failed due to chat rate limit.","#DA0808","#1EBCC1");
  1781. displayInChat("Please try again.","#DA0808","#1EBCC1");
  1782. }
  1783.  
  1784. }
  1785. }
  1786. if(args.data.startsWith('42[6,')){
  1787. var jsonargs = JSON.parse(args.data.substring(2));
  1788. if(typeof(playerids[jsonargs[1]])!='undefined'){
  1789. delplayerids[jsonargs[1]] = playerids[jsonargs[1]];
  1790. delete playerids[jsonargs[1]];
  1791. }
  1792. hostid = jsonargs[2];
  1793. }
  1794. if(args.data.startsWith('42[41,')){
  1795. var jsonargs = JSON.parse(args.data.substring(2));
  1796. hostid = jsonargs[1]["newHost"];
  1797. }
  1798. if(args.data.startsWith('42[20,')){
  1799. var jsonargs = JSON.parse(args.data.substring(2));
  1800. if(echo_list.includes(playerids[jsonargs[1]].userName)){
  1801. chat(flag_manage(echotext.replaceAll("username",playerids[jsonargs[1]].userName).replaceAll("message",jsonargs[2])));
  1802. }
  1803. if(pollactive[0] || pollactive2[0]){
  1804. var chatmessage = jsonargs[2].toUpperCase().trim().replace(")","");
  1805. var lettersindex = letters.indexOf(chatmessage);
  1806. if(ishost){
  1807. if(pollactive[3].length>0 && lettersindex!=-1 && lettersindex<pollactive[3].length){
  1808. playerids[jsonargs[1]].vote.poll = lettersindex;
  1809. }
  1810. }
  1811. else{
  1812. if(pollactive2[2].length>0 && lettersindex!=-1 && lettersindex<pollactive2[2].length){
  1813. playerids[jsonargs[1]].vote.poll = lettersindex;
  1814. }
  1815. }
  1816. }
  1817. }
  1818. if(args.data.startsWith('42[32')){
  1819. SEND('42[4,{"type":"inactive kick counter"}]');
  1820. }
  1821. if(args.data.startsWith('42[18')){
  1822. var jsonargs = JSON.parse(args.data.substring(2));
  1823. playerids[jsonargs[1]].team = jsonargs[2];
  1824. }
  1825. if(args.data.startsWith('42[40,')){
  1826. recordedTimeStamp = Date.now();
  1827. recordedId = JSON.parse(args.data.substring(2))[1];
  1828. }
  1829.  
  1830. if(args.data.startsWith('42[3,')){
  1831. playerids = {};
  1832. var jsonargs = JSON.parse(args.data.substring(2));
  1833. for(var i = 0; i<jsonargs[3].length;i++){
  1834. if(jsonargs[3][i]!=null){
  1835. playerids[i.toString()] = jsonargs[3][i];
  1836. playerids[i.toString()].ratelimit = {"pm":0,"mode":0,"team":0,"poll":0};
  1837. playerids[i.toString()].vote = {"poll":-1};
  1838. }
  1839. }
  1840. if(playerids[jsonargs[1]].userName.startsWith(Gdocument.getElementById("pretty_top_name").textContent)){
  1841. myid = jsonargs[1];
  1842. bonkwss = this;
  1843. }
  1844. else{
  1845. bonkwssextra.push(this);
  1846. }
  1847. hostid = jsonargs[2];
  1848. }
  1849. if(args.data.startsWith('42[15,')){
  1850. var jsonargs = JSON.parse(args.data.substring(2));
  1851. dontswitch = false;
  1852. gameStartTimeStamp = Date.now();
  1853. killedids = [];
  1854. }
  1855. if(args.data.startsWith('42[33,')){
  1856. var jsonargs = JSON.parse(args.data.substring(2));
  1857. var decodedmap = decodeFromDatabase(jsonargs[1]);
  1858. if(decodedmap!=0){
  1859. requestedmaps.push([decodedmap,jsonargs[1]]);
  1860. }
  1861. }
  1862. if(args.data.startsWith('42[7,')){
  1863. var jsonargs2 = JSON.parse(args.data.substring(2));
  1864. var idofpacket = jsonargs2[1];
  1865. jsonargs = jsonargs2[2];
  1866. if(typeof(jsonargs["i"]) == "undefined"){
  1867.  
  1868. if(jsonargs["type"]=="private chat" && jsonargs["to"] == username){
  1869. from = jsonargs["from"];
  1870. if(Object.keys(playerids).includes(idofpacket.toString())){
  1871. from = playerids[idofpacket].userName;
  1872. }
  1873. if(!ignorepmlist.includes(from)){
  1874. if(typeof(jsonargs["message"])=="object" && typeof(jsonargs["password"]) == "object"){
  1875. if(public_key[0]==jsonargs["public key"][0] && public_key[1]==jsonargs["public key"][1]){
  1876. var now = Date.now();
  1877. if(jsonargs["password"].length<=25 && playerids[idofpacket].ratelimit.pm+250<now){
  1878. playerids[idofpacket].ratelimit.pm = now;
  1879. var password = CRYPT_MESSAGE(private_key,jsonargs["password"]);
  1880. var decodedtext = jsonargs["message"].slice(0,400);
  1881. var encodedtext = "";
  1882. for(var i=0;i<decodedtext.length;i++){
  1883. if(password[i%password.length]<1000){
  1884. encodedtext+=String.fromCharCode(password[i%password.length]^decodedtext[i]);
  1885. }
  1886. }
  1887. 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);';
  1888. displayInChat('> '+'<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+from+'</a>'+': ',"#DA0808","#1EBCC1",{sanitize:false},encodedtext);
  1889.  
  1890. Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true;
  1891. Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true;
  1892.  
  1893. Laster_message = lastmessage();
  1894.  
  1895.  
  1896.  
  1897. }
  1898. }
  1899. else{
  1900. SEND("42"+JSON.stringify([4,{"type":"public key correction","from":username,"to":private_chat_public_key[0],"public key":public_key}]));
  1901. }
  1902. }
  1903. }
  1904. }
  1905.  
  1906. if(jsonargs["type"]=="request public key" && jsonargs["to"] == username){
  1907. SEND("42"+JSON.stringify([4,{"type":"public key","from":username,"public key":public_key}]));
  1908. }
  1909. if(jsonargs["type"]=="private chat users" && pmuserstimestamp+1500>Date.now()){
  1910.  
  1911. if(typeof(jsonargs["from"])!='undefined'){
  1912. from = jsonargs["from"];
  1913. if(Object.keys(playerids).includes(idofpacket.toString())){
  1914. from = playerids[idofpacket].userName;
  1915. }
  1916. if(!pmusers.includes(from) && username == jsonargs["to"]){
  1917. pmusers.push(from);
  1918. }
  1919. }
  1920. }
  1921. if(jsonargs["type"]=="request private chat users"){
  1922. if(typeof(jsonargs["from"])!='undefined'){
  1923. from = jsonargs["from"];
  1924. if(Object.keys(playerids).includes(idofpacket.toString())){
  1925. from = playerids[idofpacket].userName;
  1926. }
  1927. SEND("42"+JSON.stringify([4,{"type":"private chat users","from":username,"to":from}]));
  1928. }
  1929. }
  1930. if(jsonargs["type"]=="public key" && request_public_key_time_stamp+1500>Date.now()){
  1931. from = jsonargs["from"];
  1932. if(Object.keys(playerids).includes(idofpacket.toString())){
  1933. from = playerids[idofpacket].userName;
  1934. }
  1935. if(from == private_chat){
  1936. private_chat_public_key = [private_chat,jsonargs["public key"]];
  1937. displayInChat("Private chatting with "+private_chat+".","#DA0808","#1EBCC1");
  1938. }
  1939. }
  1940. if(jsonargs["type"]=="vote poll"){
  1941. from = jsonargs["from"];
  1942. if(Object.keys(playerids).includes(idofpacket.toString())){
  1943. from = playerids[idofpacket].userName;
  1944. }
  1945. if(typeof(jsonargs["vote"]) == 'number' && idofpacket!=hostid){
  1946. var now = Date.now();
  1947. if(ishost && pollactive[3].length>1 && pollactive[0]){
  1948. if(jsonargs["vote"]>=0 && jsonargs["vote"]<pollactive[3].length){
  1949. playerids[idofpacket].vote.poll = jsonargs["vote"];
  1950. }
  1951. }
  1952. else if(pollactive2[0] && pollactive2[2].length>1){
  1953. if(jsonargs["vote"]>=0 && jsonargs["vote"]<pollactive2[2].length){
  1954. playerids[idofpacket].vote.poll = jsonargs["vote"];
  1955. }
  1956. }
  1957. }
  1958.  
  1959. }
  1960. if(jsonargs["type"]=="poll end"){
  1961. from = jsonargs["from"];
  1962. if(Object.keys(playerids).includes(idofpacket.toString())){
  1963. from = playerids[idofpacket].userName;
  1964. }
  1965. var now = Date.now();
  1966. if(hostid == idofpacket && playerids[idofpacket].ratelimit.poll+5000<now){
  1967. playerids[idofpacket].ratelimit.poll = now;
  1968. var count = [0,0,0,0];
  1969. var keys = Object.keys(playerids);
  1970. for(var i = 0;i<keys.length;i++){
  1971. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive2[2].length-1){
  1972. count[playerids[keys[i]].vote.poll]++;
  1973. }
  1974. playerids[keys[i]].vote.poll = -1;
  1975. }
  1976. displayInChat("The poll ended.","#DA0808","#1EBCC1");
  1977. for(var i = 0;i<count.length;i++){
  1978. if(count[i]>1){
  1979. displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  1980. }
  1981. if(count[i]==1){
  1982. displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  1983. }
  1984. }
  1985. pollactive2 = [false,0,[]];
  1986. }
  1987.  
  1988. }
  1989. if(jsonargs["type"]=="poll" && idofpacket == hostid){
  1990. from = jsonargs["from"];
  1991. if(Object.keys(playerids).includes(idofpacket.toString())){
  1992. from = playerids[idofpacket].userName;
  1993. }
  1994. if(Array.isArray(jsonargs["poll"])){
  1995. var propperpoll = true;
  1996. var pollifproper = [];
  1997. if(jsonargs["poll"].length>5){
  1998. propperpoll = false;
  1999. }
  2000. else{
  2001. for(var i = 0;i<jsonargs["poll"].length;i++){
  2002. if(typeof(jsonargs["poll"][i]) == 'string'){
  2003. if(jsonargs["poll"][i].length>50){
  2004. propperpoll = false;
  2005. break;
  2006. }
  2007. else{
  2008. pollifproper.push(jsonargs["poll"][i]);
  2009. }
  2010. }
  2011. else{
  2012. propperpoll = false;
  2013. break;
  2014. }
  2015. }
  2016. }
  2017. if(propperpoll){
  2018. var now = Date.now();
  2019. var keys = Object.keys(playerids);
  2020. for(var i = 0;i<keys.length;i++){
  2021. playerids[keys[i]].vote.poll = -1;
  2022. }
  2023. pollactive2 = [true,now,pollifproper];
  2024. playerids[idofpacket].ratelimit.poll = now;
  2025. displayInChat(from+" started a poll:","#DA0808","#1EBCC1");
  2026. for(var i = 0;i<pollifproper.length;i++){
  2027. var code = 'Gwindow.displayInChat("You voted for option '+letters[i]+'.","#DA0808","#1EBCC1",{sanitize:false},"",true);Gwindow.SEND("42"+JSON.stringify([4,{"type":"vote poll","from":Gwindow.username,"vote":'+i+'}]));Gwindow.playerids[Gwindow.myid].vote.poll='+i+';Gwindow.Gdocument.getElementById("newbonklobby_chat_content").children[Gwindow.Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true;Gwindow.Gdocument.getElementById("ingamechatcontent").children[Gwindow.Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true;Gwindow.Laster_message = Gwindow.lastmessage();';
  2028.  
  2029.  
  2030. displayInChat('<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+letters[i]+')</a>',"#DA0808","#1EBCC1",{sanitize:false}," "+pollifproper[i]);
  2031. }
  2032.  
  2033. }
  2034. }
  2035.  
  2036. }
  2037. if(jsonargs["type"]=="request mode" && playerids[idofpacket].ratelimit.mode+1000<Date.now()){
  2038. playerids[idofpacket].ratelimit.mode = Date.now();
  2039. from = jsonargs["from"];
  2040. if(Object.keys(playerids).includes(idofpacket.toString())){
  2041. from = playerids[idofpacket].userName;
  2042. }
  2043. var req_mode = jsonargs["mode"];
  2044. var req_mode2 = "";
  2045. if(req_mode){
  2046. if(req_mode == "b"){
  2047. req_mode2 = "Classic";
  2048. }
  2049. else if(req_mode == "sp"){
  2050. req_mode2 = "Grapple";
  2051. }
  2052. else if(req_mode == "ar"){
  2053. req_mode2 = "Arrows";
  2054. }
  2055. else if(req_mode == "ard"){
  2056. req_mode2 = "Death Arrows";
  2057. }
  2058. }
  2059. if(req_mode2){
  2060. var code = 'if(!Gwindow.ishost){Gwindow.displayInChat("You must be host to change the mode.","#DA0808","#1EBCC1",{sanitize:false},"",true)}else{Gwindow.changemode("'+req_mode+'")}';
  2061.  
  2062. displayInChat('> '+playerids[idofpacket].userName+' requests [<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+req_mode2+'</a>]',"#DA0808","#1EBCC1",{sanitize:false}," mode.");
  2063. }
  2064.  
  2065. }
  2066. if(jsonargs["type"]=="public key correction" && private_chat_public_key[0] == private_chat){
  2067. from = jsonargs["from"];
  2068. if(Object.keys(playerids).includes(idofpacket.toString())){
  2069. from = playerids[idofpacket].userName;
  2070. }
  2071. if(from == private_chat){
  2072. private_chat_public_key = [private_chat,jsonargs["public key"]];
  2073. var text = pmlastmessage;
  2074. var password = [];
  2075. for(var i = 0;i<10;i++){
  2076. password.push(Math.floor(Math.random()*100+50));
  2077. }
  2078. var text2 = [];
  2079. for(var i = 0;i<text.length ;i++){
  2080. text2.push(password[i%password.length]^text.slice(0,400).charCodeAt(i));
  2081. }
  2082. 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)}]));
  2083. }
  2084. }
  2085.  
  2086. }
  2087. else{
  2088. var now = Date.now();
  2089. if(playerids[idofpacket.toString()]){
  2090. playerids[idofpacket.toString()].lastmove = now;
  2091. }
  2092. if(Math.abs(gameStartTimeStamp - (now-1000*jsonargs["f"]/30))>250){
  2093. gameStartTimeStamp = now-1000*jsonargs["f"]/30;
  2094. }
  2095. if(ishost){
  2096. for(var i = 0;i<disabledkeys.length;i++){
  2097. var get_keys_var = GET_KEYS(jsonargs["i"]);
  2098. if(get_keys_var[disabledkeys[i]]){
  2099. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden" && !killedids.includes(idofpacket)){
  2100. killedids.push(idofpacket);
  2101. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  2102. SEND('42[25,{"a":{"playersLeft":['+idofpacket.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  2103. RECIEVE('42[31,{"a":{"playersLeft":['+idofpacket.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  2104. break;
  2105. }
  2106. }
  2107. }
  2108. }
  2109. }
  2110. }
  2111.  
  2112. if(args.data.startsWith('42[4,')){
  2113. var jsonargs = JSON.parse(args.data.substring(2));
  2114. playerids[jsonargs[1]] = {"peerID":jsonargs[2],"userName":jsonargs[3],"guest":jsonargs[4],"level":jsonargs[5],"team":jsonargs[6],"avatar":jsonargs[7],"ratelimit":{"pm":0,"mode":0,"team":0,"poll":0},"vote":{"poll":-1}};
  2115. if(ishost){
  2116. if(jointext!=""){
  2117. chat(flag_manage(jointext.replaceAll("username",jsonargs[3])));
  2118. }
  2119. if(freejoin){
  2120. var count = 0;
  2121. var keys = Object.keys(playerids);
  2122. for(var i = 0; i<keys.length;i++){
  2123. if(playerids[keys[i]].team!=0){
  2124. count++;
  2125. }
  2126. }
  2127. if(count <= 2 && jsonargs[6]!=0){
  2128. setTimeout(function(){
  2129. Gdocument.getElementById("newbonklobby_editorbutton").click();
  2130. Gdocument.getElementById("mapeditor_close").click();
  2131. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  2132. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  2133. if(transitioning == true){
  2134. canceled = true;
  2135. }
  2136. },150);
  2137. }
  2138. }
  2139. }
  2140.  
  2141.  
  2142. }
  2143. if(args.data.startsWith('42[5,')){
  2144. var jsonargs = JSON.parse(args.data.substring(2));
  2145. if(typeof(playerids[jsonargs[1]])!='undefined'){
  2146. delplayerids[jsonargs[1]] = playerids[jsonargs[1]];
  2147. delete playerids[jsonargs[1]];
  2148. }
  2149. }
  2150. }}
  2151. return originalRecieve.call(this,args);
  2152. };
  2153.  
  2154. var originalClose = this.onclose;
  2155. this.onclose = function () {
  2156.  
  2157. if(bonkwssextra.includes(this)){
  2158. bonkwssextra.splice(bonkwssextra.indexOf(this),1)
  2159. }
  2160. else{
  2161. window.bonkwss = 0;
  2162. }
  2163. return originalClose.call(this);
  2164. }
  2165.  
  2166. }
  2167. return originalSend.call(this,args);
  2168. };
  2169.  
  2170. scope.SEND = function(args){
  2171. if(bonkwss!=0){
  2172. bonkwss.send(args);
  2173. }
  2174. };
  2175. scope.RECIEVE = function(args){
  2176. if(bonkwss!=0){
  2177. bonkwss.onmessage({data:args});
  2178. }
  2179. };
  2180.  
  2181.  
  2182.  
  2183. scope.dontswitch = false;
  2184. scope.username = 0;
  2185. scope.timedelay = 1400;
  2186. scope.ishost = false;
  2187. scope.checkboxhidden = true;
  2188. scope.quicki=0;
  2189. scope.defaultmode = "d";
  2190. scope.recmodebool = false;
  2191. scope.shuffle = false;
  2192. scope.startedinqp = false;
  2193. scope.instaqp = false;
  2194. scope.freejoin = false;
  2195. scope.recordedTimeStamp = 0;
  2196. scope.recordedId = 0;
  2197. scope.smartteams = false;
  2198. scope.beenKickedTimeStamp = 0;
  2199. scope.stopquickplay = 1;
  2200. scope.currentFrame = 0;
  2201. scope.text2speech = false;
  2202. scope.gameStartTimeStamp = 0;
  2203. scope.canceled = false;
  2204. scope.wintext = "";
  2205. scope.banned = [];
  2206. scope.transitioning = false;
  2207. scope.echo_list = [];
  2208. scope.echoAppend = "";
  2209. scope.message = "";
  2210. scope.mode = "";
  2211. scope.private_chat = "";
  2212. scope.private_chat_public_key = ["",[0,0]];
  2213. scope.disabledkeys = [];
  2214. scope.actuallyhost = false;
  2215. scope.pmusers = [];
  2216. scope.pmlastmessage = "";
  2217. scope.pmuserstimestamp = 0;
  2218. scope.ignorepmlist = [];
  2219. scope.scroll = false;
  2220. scope.elem = Gdocument.getElementById("maploadwindowmapscontainer");
  2221. scope.npermissions = 1;
  2222. scope.space_flag = false;
  2223. scope.rcaps_flag = false;
  2224. scope.number_flag = false;
  2225. scope.reverse_flag = false;
  2226. scope.request_public_key_time_stamp = 0;
  2227. scope.sandboxcopyme = false;
  2228. scope.recteams = false;
  2229. scope.chatheight = 128;
  2230. scope.onlykicked = false;
  2231. scope.killedids = [];
  2232. scope.jointext = "";
  2233. scope.afkkill = -1;
  2234. scope.tournament_mode = "";
  2235. scope.tournament_scores = [];
  2236. scope.tournament_in_and_out = {"in":[],"out":[]};
  2237. scope.echotext = "message";
  2238. scope.nextafter = 0;
  2239. scope.nextafterbuffer = -1;
  2240. scope.roundsperqp = 1;
  2241. scope.roundsperqp2 = 0;
  2242. scope.autorecord = false;
  2243. scope.poll = [];
  2244. scope.letters = ["A","B","C","D","E"];
  2245. scope.qppaused = false;
  2246. scope.FollowCam = false;
  2247. scope.help = ["All the commands are:","/help","/?","/advhelp [command]","/space","/rcaps","/number","/speech","/followcam","/echo [username]","/clearecho","/remove [username]","/echotext [text]","/chatw [username]","/msg [text]","/ignorepm [username]","/pmusers","/pollstat","/lobby","/score","/team [letter]","/mode [mode]","/scroll","/hidechat","/showchat","/notify","/stopnotify","Host commands are:","/startqp","/stopqp","/pauseqp","/next","/nextafter [seconds]","/previous","/shuffle","/instaqp","/freejoin","/recmode","/recteam","/defaultmode [mode]","/start","/balanceA [number]","/moveA [letter]","/rounds [number]","/roundsperqp [number]","/disablekeys [keys]","/jointext [text]","/wintext [text]","/autorecord","/afkkill [number]","/ban [username]","/kill [username]","/resetpoll","/addoption [text]","/deloption [letter]","/startpoll [seconds]","/endpoll","Sandbox commands are:","/addplayer [number]","/delplayer [number]","/copyme","Debugging commands are:","/eval [code]","/debugger","Hotkeys are:","Alt L","Alt B","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"];
  2248.  
  2249. scope.adv_help = {"help":"Shows all command names.",
  2250. "?":"Shows all command names.",
  2251. "advhelp":"Shows a command in detail.",
  2252. "space":"Toggles space. When space is on, whatever you type will be spaced apart.",
  2253. "rcaps":"Toggles rcaps. When rcaps is on, each letter will randomly get capitalized.",
  2254. "number":"Toggles number. When number is on, 'a' becomes 4, 'e' becomes 3, 's' becomes 5, 'o' becomes 0, 'l' and 'i' become 1.",
  2255. "speech":"Turns on text to speech for the chat.",
  2256. "echo":"Echoes a username. It copies the username's chat messages.",
  2257. "echotext":"Sets a message when someone who is echoed chats. \"message\" will get replaced by the person's message. \"username\" will get replaced by the person's username.",
  2258. "remove":"Removes username from echo list. You will not echo that username anymore.",
  2259. "clearecho":"Clears echo list. You will not echo anyone anymore.",
  2260. "chatw":"It private chats with username. Type /msg to message that username.",
  2261. "msg":"Messages with what username you are chatting with. Type /chatw to chat with a username.",
  2262. "ignorepm":"Ignores the username's private chat messages. To unignore, type '/ignorepm [username]'.",
  2263. "pmusers":"Dispays who you can private chat with.",
  2264. "pollstat":"Displays the current poll and its votes.",
  2265. "eval":"Evaluates code. Only use this if you are experienced in javascript.",
  2266. "debugger":"Opens debugger.",
  2267. "lobby":"Makes lobby visible when you are ingame. Type '/lobby' again to close lobby.",
  2268. "score":"Displays the current score while ingame. Type '/score' again to hide the score.",
  2269. "team":"Joins a specific team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  2270. "scroll":"Toggles a scrollbar in ingame chat.",
  2271. "followcam":"Enables follow camera. Your character will be centered on the screen.",
  2272. "hidechat":"Hides ingame chat. Type '/showchat' to show it again.",
  2273. "showchat":"Shows ingame chat. '/hidechat' hides the chat.",
  2274. "notify":"You will be notified if a person types @username",
  2275. "stopnotify":"You will not be notified if a person types @username",
  2276. "startqp":"Starts cycling maps in your map menu.",
  2277. "stopqp":"Stops cycling maps in your map menu.",
  2278. "pauseqp":"Only pauses the quickplay cycle due to round end. '/next', '/previous' still work. Type 'pauseqp' to unpause quickplay.",
  2279. "next":"Skips the map. Usable only with '/startqp'.",
  2280. "nextafter":"Skips the map if no one is able to win/draw within a certain amount of time.",
  2281. "previous":"Goes to previous map. Usable only with '/startqp'.",
  2282. "shuffle":"Makes quickplay play random maps instead of in order.",
  2283. "freejoin":"Toggles freejoin. If freejoin is on, starts the game instantly if there are 1 or less players currently playing.",
  2284. "recmode":"In quickplay, it switches mode to recommended mode, according to editor.",
  2285. "recteam":"In quickplay, it sorts people into teams when teams are necessary.",
  2286. "defaultmode":"Switches mode to defaultmode if there is no recmode.",
  2287. "start":"Starts game instantly.",
  2288. "instaqp":"Rounds will instantly start without a countdown.",
  2289. "balanceA":"Balances everyone with balance number.",
  2290. "moveA":"Sets everyones team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  2291. "rounds":"Sets rounds to win.",
  2292. "roundsperqp":"After that many rounds, the map will change. Normally, the map will change after 1 round.",
  2293. "autorecord":"After a round ends, automatically records the last 15 seconds.",
  2294. "mode":"If host, switches mode. Otherwise, it requests the host to switch mode, as long as the host has this mod.",
  2295. "disablekeys":"If anyone presses a disabled key, they get killed. Key options: left right up down heavy special.",
  2296. "jointext":"Chats the jointext whenever someone joins. \"username\" will get replaced by the joining person's username.",
  2297. "wintext":"Chats the wintext whenever someone wins. \"username\" will get replaced by the winning person's username.",
  2298. "afkkill":"If a person stays afk for that many seconds, they get automatically killed.",
  2299. "ban":"Bans username from lobby. If they rejoin, it automatically bans.",
  2300. "kill":"Kills the person ingame.",
  2301. "resetpoll":"Clears the poll.",
  2302. "addoption":"Adds the option to the poll. You can only have 4 maximum options. Type '/deloption [letter]' to remove an option.",
  2303. "deloption":"Removes the option with that letter.",
  2304. "startpoll":"Starts a poll that lasts for at least 10 seconds. Type '/endpoll' to end it early.",
  2305. "endpoll":"Ends the poll early if the poll lasted for at least 10 seconds.",
  2306. "addplayer":"In sandbox, it adds players.",
  2307. "delplayer":"In sandbox, it deletes players.",
  2308. "copyme":"In sandbox, it makes each player copy your movements.",
  2309. "Alt L":"Makes lobby visible when you are ingame. Press Alt L again to close lobby.",
  2310. "Alt C":"Hides ingame chat. Press Alt C again to show ingame chat.",
  2311. "Alt S":"Starts game instantly.",
  2312. "Alt T":"Toggles teams.",
  2313. "Alt E":"Toggles editor.",
  2314. "Alt K":"Exits ingame and returns to lobby.",
  2315. "Alt M":"Switches modes.",
  2316. "Alt Q":"Toggles quickplay.",
  2317. "Alt B":"Displays the current score while ingame. Press Alt B again to hide the score.",
  2318. "Alt A":"Skips the map if quickplay is on.",
  2319. "Alt D":"Goes to previous map if quickplay is on.",
  2320. "Alt F":"Toggles freejoin. If freejoin is on, starts the game instantly if there are 1 or less players currently playing.",
  2321. "Alt R":"In quickplay, it switches mode to recommended mode, according to editor.",
  2322. "Alt I":"Opens debugger.",
  2323. "Alt <":"Lowers ingame chat height.",
  2324. "Alt >":"Highers ingame chat height."
  2325. };
  2326. scope.displayadvhelp = function(command){
  2327. displayInChat(adv_help[command],"#009398","#DA0808",{sanitize:true},"",true);
  2328. };
  2329. scope.changemode = function(mode){
  2330. SEND('42[20,{"ga":"b","mo":"'+mode+'"}]');
  2331. RECIEVE('42[26,"b","'+mode+'"]');
  2332. };
  2333. Gdocument.getElementById("ingamechatcontent").style["pointer-events"]="all";
  2334. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  2335. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  2336. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  2337.  
  2338. document.getElementById('adboxverticalCurse').style["display"] = "none";
  2339. document.getElementById('adboxverticalleftCurse').style["display"] = "none";
  2340. elem.onclick=function(e){
  2341. if(stopquickplay==0 && ishost == true && e.isTrusted == true){
  2342. quicki = (Array.from(e.target.parentElement.parentNode.children).indexOf(e.target.parentNode)-1)%(Gdocument.getElementById("maploadwindowmapscontainer").children.length);
  2343. }
  2344. };
  2345. scope.urlify = function(text) {
  2346. if(!Gdocument.getElementById('bl_Menu')){
  2347. return text.replace(/(?:https?:\/\/)?(?:[A-Za-z0-9-ßàÁâãóôþüúðæåïçèõöÿýòäœêëìíøùîûñé]+)(?:\.[A-Za-z0-9-ßàÁâãóôþüúðæåïçèõöÿýòäœêëìíøùîûñé]+)+(?:\/(?:[A-Za-z0-9-._~:/?#\[\]@!$&'()*+,;=]|%[0-9a-fA-F]{2})*)?(?:\?(?:[^=]+=[^&](?:&[^=]+=[^&])*)?)?/g, function(url) {
  2348. if(url.startsWith('https://') || url.startsWith('http://')){return '<a href="' + url + '" target="_blank" style = "color:orange">' + url + '</a>';}
  2349. else{return '<a href="https://' + url + '" target="_blank" style = "color:orange">' + url + '</a>';}
  2350. })}return text;
  2351. };
  2352.  
  2353. scope.fire = function(type,options,d = Gdocument){
  2354. var event= document.createEvent("HTMLEvents");
  2355. event.initEvent(type,true,false);
  2356. for(var p in options){
  2357. event[p]=options[p];
  2358. }
  2359. d.dispatchEvent(event);
  2360. };
  2361.  
  2362. scope.chat = function(message){
  2363. SEND('42[10,{"message":'+JSON.stringify(message)+'}]');
  2364. };
  2365. scope.chat2 = function(message,enteragain=false){
  2366. mess = Gdocument.getElementById("newbonklobby_chat_input").value;
  2367. mess2 = Gdocument.getElementById("ingamechatinputtext").value;
  2368. Gdocument.getElementById("newbonklobby_chat_input").value = message;
  2369. Gdocument.getElementById("ingamechatinputtext").value = message;
  2370. fire("keydown",{keyCode:13});
  2371. if(!enteragain){
  2372. fire("keydown",{keyCode:13});
  2373. }
  2374. Gdocument.getElementById("newbonklobby_chat_input").value = mess;
  2375. Gdocument.getElementById("ingamechatinputtext").value = mess2;
  2376. };
  2377. scope.displayInChat = function(message, LobbyColor, InGameColor, options, message2, BringDown,urlifyon = urlify) {
  2378. options = options ?? {};
  2379. BringDown = BringDown ?? false;
  2380. message2 = message2 ?? "";
  2381. urlifyon = urlifyon ?? function(e){return e};
  2382. LobbyColor = LobbyColor ?? "#8800FF";
  2383. InGameColor = InGameColor ?? "#AA88FF";
  2384. let A = Gdocument.createElement("div");
  2385. let B = Gdocument.createElement("span");
  2386. B.className = "newbonklobby_chat_status";
  2387. B.style.color = LobbyColor;
  2388. A.appendChild(B);
  2389. B.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  2390. B.innerHTML+=urlify(message2.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;'));
  2391. let C = Gdocument.createElement("div");
  2392. let D = Gdocument.createElement("span");
  2393. D.style.color = InGameColor;
  2394. C.appendChild(D);
  2395. D.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  2396. D.innerHTML+=urlify(message2.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;'));
  2397. let a = BringDown;
  2398. if(Gdocument.getElementById("newbonklobby_chat_content").clientHeight + Gdocument.getElementById("newbonklobby_chat_content").scrollTop >= Gdocument.getElementById("newbonklobby_chat_content").scrollHeight-1) {
  2399. a = true;
  2400. }
  2401. A.style["parsed"] = true;
  2402. C.style["parsed"] = true;
  2403. Gdocument.getElementById("newbonklobby_chat_content").appendChild(A);
  2404. Gdocument.getElementById("ingamechatcontent").appendChild(C);
  2405. if (a) { Gdocument.getElementById("newbonklobby_chat_content").scrollTop = Number.MAX_SAFE_INTEGER;};
  2406. Gdocument.getElementById("ingamechatcontent").scrollTop = Number.MAX_SAFE_INTEGER;
  2407. chat2("");
  2408. };
  2409.  
  2410. scope.lobby = function(){
  2411. if (Gdocument.getElementById("newbonklobby").style["display"]=="none"){
  2412.  
  2413. Gdocument.getElementById("newbonklobby_editorbutton").click();
  2414. Gdocument.getElementById("mapeditor_close").click();
  2415. if(Gdocument.getElementById("newbonklobby_playerbox_elementcontainer").children.length+Gdocument.getElementById("newbonklobby_specbox_elementcontainer").children.length-3>0){
  2416. Gdocument.getElementById("newbonklobby").style["z-index"]=1;
  2417. Gdocument.getElementById("maploadwindowcontainer").style["z-index"]=1;
  2418. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=1;
  2419. Gdocument.getElementById("pretty_top").style["z-index"]=3;
  2420. Gdocument.getElementById("settingsContainer").style["z-index"]=3;
  2421. Gdocument.getElementById("leaveconfirmwindow").style["z-index"]=3;
  2422. Gdocument.getElementById("hostleaveconfirmwindow").style["z-index"]=3;
  2423. debuggermenu.style["z-index"] = 2;
  2424. }
  2425. else{
  2426. Gdocument.getElementById("newbonklobby").style["opacity"]=0;
  2427. Gdocument.getElementById("newbonklobby").style["display"]="none";
  2428. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
  2429.  
  2430. }
  2431.  
  2432. }
  2433. else if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  2434. Gdocument.getElementById("newbonklobby").style["opacity"]=0;
  2435. Gdocument.getElementById("newbonklobby").style["display"]="none";
  2436. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
  2437.  
  2438. }
  2439. };
  2440.  
  2441. scope.lastmessage = function(){
  2442. if(Gdocument.getElementById("newbonklobby_chat_content").children.length!=0){
  2443. var lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  2444. var lm2 = "";
  2445. for(var i = 0; i<lm.length;i++){
  2446. lm2+=" "+lm[i].textContent.trim();
  2447. }
  2448. lm2 = lm2.trim();
  2449. if(lm2.startsWith("*")){
  2450. return lm2;
  2451. }
  2452. }
  2453. if(Gdocument.getElementById("ingamechatcontent").children.length!=0){
  2454. var lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  2455. var lm2 = "";
  2456. for(var i = 0; i<lm.length;i++){
  2457. lm2+=" "+lm[i].textContent.trim();
  2458. }
  2459. return lm2.trim();
  2460. }
  2461. return "";
  2462.  
  2463. };
  2464. scope.map = function(e,t=timedelay){
  2465. if(e<0){
  2466. displayInChat("There is no previous map.","#DA0808","#1EBCC1");
  2467. quicki = 0;
  2468. return;
  2469. }
  2470. if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
  2471. displayInChat("Click the maps button.","#DA0808","#1EBCC1");
  2472. return;
  2473. }
  2474.  
  2475. setTimeout(function(){if(!canceled){
  2476. startedinqp = true;
  2477. if(roundsperqp2>=roundsperqp){
  2478. roundsperqp2 = 0;
  2479. }
  2480. gameStartTimeStamp = Date.now();
  2481. Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
  2482. Gdocument.getElementById("newbonklobby_editorbutton").click();
  2483. if(recmodebool && ishost){
  2484. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  2485. if(mode == "" && defaultmode!="d"){
  2486. mode = defaultmode;
  2487. }
  2488. if(mode != ""){
  2489. RECIEVE('42[26,"b","'+mode+'"]');
  2490. }
  2491. }
  2492. var displayblock = Gdocument.getElementById("newbonklobby").style["display"] == "block";
  2493. Gdocument.getElementById("mapeditorcontainer").style["display"] = "none";
  2494. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  2495. if(displayblock){
  2496. Gdocument.getElementById("newbonklobby").style["display"] = "block";
  2497. }
  2498. Gdocument.getElementById("mapeditor_midbox_testbutton").click();}
  2499. canceled = false;
  2500. transitioning = false;
  2501. },t);
  2502.  
  2503. };
  2504.  
  2505. scope.gotonextmap = function(e){
  2506. if(e<0){
  2507. displayInChat("There is no previous map.","#DA0808","#1EBCC1");
  2508. quicki = 0;
  2509. return;
  2510. }
  2511. if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
  2512. displayInChat("Click the maps button.","#DA0808","#1EBCC1");
  2513. return;
  2514. }
  2515. Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
  2516. Gdocument.getElementById("newbonklobby_editorbutton").click();
  2517. if(recmodebool && ishost){
  2518. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  2519. if(mode == "" && defaultmode!="d"){
  2520. mode = defaultmode;
  2521. }
  2522. if(mode != ""){
  2523. RECIEVE('42[26,"b","'+mode+'"]');
  2524. }
  2525. }
  2526. startedinqp = true;
  2527. if(roundsperqp2>=roundsperqp){
  2528. roundsperqp2 = 0;
  2529. }
  2530. gameStartTimeStamp = Date.now();
  2531. var displayblock = Gdocument.getElementById("newbonklobby").style["display"] == "block";
  2532. Gdocument.getElementById("mapeditorcontainer").style["display"] = "none";
  2533. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  2534. if(displayblock){
  2535. Gdocument.getElementById("newbonklobby").style["display"] = "block";
  2536. }
  2537. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  2538. Gdocument.getElementById("newbonklobby").style["visibility"] = "visible";
  2539. };
  2540. scope.commandhandle = function(chat_val){
  2541. if (chat_val.substring(1,6)=="echo " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  2542. if (chat_val.substring(6).replace(/^\s+|\s+$/g, '')==username){
  2543. displayInChat("You cannot echo yourself.","#DA0808","#1EBCC1");
  2544. return "";
  2545. }
  2546. else if (echo_list.indexOf(chat_val.substring(6).replace(/^\s+|\s+$/g, ''))===-1) {
  2547.  
  2548. echo_list.push(chat_val.substring(6).replace(/^\s+|\s+$/g, ''));
  2549. displayInChat(chat_val.substring(6).replace(/^\s+|\s+$/g, '') + " is being echoed.","#DA0808","#1EBCC1");
  2550. return "";
  2551. }
  2552. else{
  2553. displayInChat(chat_val.substring(6).replace(/^\s+|\s+$/g, '') + " is already being echoed.","#DA0808","#1EBCC1");
  2554. return "";
  2555. }
  2556. }
  2557. else if (chat_val.substring(1,8)=="remove " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  2558. if (echo_list.indexOf(chat_val.substring(7).replace(/^\s+|\s+$/g, ''))!==-1){
  2559. echo_list.splice(echo_list.indexOf(chat_val.substring(7).replace(/^\s+|\s+$/g, '')),1);
  2560. displayInChat(chat_val.substring(7).replace(/^\s+|\s+$/g, '')+" is not being echoed.","#DA0808","#1EBCC1");
  2561. return "";
  2562. }
  2563. else{
  2564. displayInChat("You cannot remove someone that you didn't echo.","#DA0808","#1EBCC1");
  2565. return "";
  2566. }
  2567.  
  2568. }
  2569. else if (chat_val.substring(1,10)=="echotext " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  2570. echotext = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  2571. displayInChat("Set echotext as: "+echotext,"#DA0808","#1EBCC1");
  2572. displayInChat("Type '/echotext' to reset echotext.","#DA0808","#1EBCC1");
  2573. return "";
  2574.  
  2575. }
  2576. else if (chat_val.substring(1,9)=="echotext"){
  2577. echotext = "message";
  2578. displayInChat("Reset echotext.","#DA0808","#1EBCC1");
  2579. return "";
  2580.  
  2581. }
  2582. else if (chat_val.substring(1,10)=="clearecho"){
  2583. echo_list = [];
  2584. displayInChat("Cleared the echo list.","#DA0808","#1EBCC1");
  2585. return "";
  2586. }
  2587. else if (chat_val.substring(1,6)=="space"){
  2588. if(space_flag == true){
  2589. displayInChat("Space is now off.","#DA0808","#1EBCC1");
  2590. space_flag = false;
  2591. }
  2592. else{
  2593. displayInChat("Space is now on.","#DA0808","#1EBCC1");
  2594. space_flag = true;
  2595. }
  2596. return "";
  2597. }
  2598. else if (chat_val.substring(1,6)=="rcaps"){
  2599. if(rcaps_flag == true){
  2600. displayInChat("Rcaps is now off.","#DA0808","#1EBCC1");
  2601. rcaps_flag = false;
  2602. }
  2603. else{
  2604. displayInChat("Rcaps is now on.","#DA0808","#1EBCC1");
  2605. rcaps_flag = true;
  2606. }
  2607.  
  2608. return "";
  2609. }
  2610. else if (chat_val.substring(1,7)=="number"){
  2611. if(number_flag == true){
  2612. displayInChat("Number is now off.","#DA0808","#1EBCC1");
  2613. number_flag = false;
  2614. }
  2615. else{
  2616. displayInChat("Number is now on.","#DA0808","#1EBCC1");
  2617. number_flag = true;
  2618. }
  2619.  
  2620. return "";
  2621. }
  2622. else if (chat_val.substring(1,8)=="reverse"){
  2623. if(reverse_flag == true){
  2624. displayInChat("Reverse is now off.","#DA0808","#1EBCC1");
  2625. reverse_flag = false;
  2626. }
  2627. else{
  2628. displayInChat("Reverse is now on.","#DA0808","#1EBCC1");
  2629. reverse_flag = true;
  2630. }
  2631.  
  2632. return "";
  2633. }
  2634. else if (chat_val.substring(1,7)=="speech"){
  2635. if(text2speech == true){
  2636. displayInChat("Text to speech is now off.","#DA0808","#1EBCC1");
  2637. text2speech = false;
  2638. }
  2639. else{
  2640. displayInChat("Text to speech is now on.","#DA0808","#1EBCC1");
  2641. text2speech = true;
  2642. }
  2643.  
  2644. return "";
  2645. }
  2646.  
  2647. else if (chat_val.substring(1,6)=="eval " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  2648. var ev = "";
  2649. try{
  2650. ev = eval(chat_val.substring(6).replace(/^\s+|\s+$/g, ''));
  2651. }
  2652. catch(e){
  2653. displayInChat(e.message,"#DA0808","#1EBCC1");
  2654. }
  2655. try{
  2656. displayInChat(ev.toString(),"#DA0808","#1EBCC1");
  2657. }
  2658. catch{
  2659. }
  2660.  
  2661. return "";
  2662.  
  2663. }
  2664. else if (chat_val.substring(1,10)=="followcam"){
  2665. if(FollowCam == true){
  2666. displayInChat("Follow Camera is now off.","#DA0808","#1EBCC1");
  2667. FollowCam = false;
  2668. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  2669. parentDraw.x = 0;
  2670. parentDraw.y = 0;
  2671. parentDraw.children[0].x = 0;
  2672. parentDraw.children[0].y = 0;
  2673. pixiCircle.visible = false;
  2674. }
  2675. }
  2676. else{
  2677. displayInChat("Follow Camera is now on.","#DA0808","#1EBCC1");
  2678. FollowCam = true;
  2679. }
  2680.  
  2681. return "";
  2682. }
  2683. else if (chat_val.substring(1,9)=="hidechat"){
  2684. Gdocument.getElementById("ingamechatcontent").style["max-height"]="0px";
  2685. return "";
  2686. }
  2687. else if (chat_val.substring(1,9)=="showchat"){
  2688. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  2689. return "";
  2690. }
  2691. else if (chat_val.substring(1,6)=="score"){
  2692. var element = Gdocument.getElementById("ingamewinner_scores");
  2693. element.style["visibility"] = "visible";
  2694. if(element.style["opacity"]<1){
  2695. element.style["opacity"] = 1;
  2696. }
  2697. else{
  2698. element.style["opacity"] = 0;
  2699. }
  2700. return "";
  2701. }
  2702.  
  2703. else if (chat_val.substring(1,7)=="scroll"){
  2704. if(scroll==false){
  2705. scroll = true;
  2706. Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="scroll";
  2707. Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
  2708. }
  2709. else if(scroll==true){
  2710. scroll = false;
  2711. Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="hidden";
  2712. Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
  2713. }
  2714.  
  2715. return "";
  2716. }
  2717.  
  2718. else if (chat_val.substring(1,7)=="chatw "){
  2719. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '');
  2720.  
  2721. if(username == text){
  2722. displayInChat("You cannot private chat with yourself.","#DA0808","#1EBCC1");
  2723. return "";
  2724. }
  2725. private_chat = text;
  2726.  
  2727. SEND("42"+JSON.stringify([4,{"type":"request public key","from":username,"to":private_chat}]));
  2728. request_public_key_time_stamp = Date.now();
  2729. 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);
  2730. return "";
  2731. }
  2732.  
  2733. else if (chat_val.substring(1,5)=="msg " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  2734. if(private_chat_public_key[1][0] != 0 && private_chat_public_key[1][1] != 0 && private_chat_public_key[0] == private_chat){
  2735. var text = chat_val.substring(5).replace(/^\s+|\s+$/g, '');
  2736. var password = [];
  2737. for(var i = 0;i<10;i++){
  2738. password.push(Math.floor(Math.random()*100+50));
  2739. }
  2740. var text2 = [];
  2741. for(var i = 0;i<text.slice(0,400).length ;i++){
  2742. text2.push(password[i%password.length]^text.slice(0,400).charCodeAt(i));
  2743. }
  2744. pmlastmessage = text.slice(0,400);
  2745. 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)}]));
  2746. displayInChat("> "+username+": ","#DA0808","#1EBCC1",{sanitize:false},text,false);
  2747. Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true;
  2748. Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true;
  2749. Laster_message = lastmessage();
  2750.  
  2751. }
  2752. return "";
  2753. }
  2754. else if (chat_val.substring(1,10)=="ignorepm " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  2755. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  2756. if(ignorepmlist.includes(text)){
  2757. var index = ignorepmlist.indexOf(text);
  2758. ignorepmlist.splice(index,1);
  2759. displayInChat("You are not ignoring private messages from "+text+".","#DA0808","#1EBCC1");
  2760.  
  2761. }
  2762. else{
  2763. ignorepmlist.push(text);
  2764. displayInChat("You are now ignoring private messages from "+text+".","#DA0808","#1EBCC1");
  2765. }
  2766.  
  2767. return "";
  2768. }
  2769. else if (chat_val.substring(1,8)=="pmusers"){
  2770. pmusers = [];
  2771. SEND("42"+JSON.stringify([4,{"type":"request private chat users","from":username}]));
  2772. pmuserstimestamp = Date.now();
  2773.  
  2774. setTimeout(function(){if(pmusers.length == 0){displayInChat("You cannot private chat with anyone.","#DA0808","#1EBCC1");
  2775. }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);
  2776. return "";
  2777. }
  2778. else if (chat_val.substring(1,6)=="lobby"){
  2779. lobby();
  2780. return "";
  2781. }
  2782. else if (chat_val.substring(1,9)=="debugger"){
  2783. if(Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"] == "none"){
  2784. debuggeropen = true;
  2785. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="block";
  2786. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="none";
  2787. Gdocument.getElementById("ingamechatinputtext").style["display"] = "none";
  2788. }
  2789. else{
  2790. debuggeropen = false;
  2791. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="none";
  2792. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  2793. Gdocument.getElementById("ingamechatinputtext").style["display"] = "";
  2794. }
  2795. return "";
  2796. }
  2797. else if (chat_val.substring(1,6)=="team " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  2798. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  2799. if(text == "r"){Gdocument.getElementById("newbonklobby_redbutton").click();}
  2800. else if(text == "g"){Gdocument.getElementById("newbonklobby_greenbutton").click();}
  2801. else if(text == "y"){Gdocument.getElementById("newbonklobby_yellowbutton").click();}
  2802. else if(text == "b"){Gdocument.getElementById("newbonklobby_bluebutton").click();}
  2803. else if(text == "s"){Gdocument.getElementById("newbonklobby_specbutton").click();}
  2804. else if(text == "f"){Gdocument.getElementById("newbonklobby_ffabutton").click();}
  2805. return "";
  2806. }
  2807. else if (chat_val.substring(1,7)=="notify"){
  2808.  
  2809. npermissions = 1;
  2810. return "";
  2811. }
  2812. else if (chat_val.substring(1,11)=="stopnotify"){
  2813.  
  2814. npermissions = 0;
  2815. return "";
  2816. }
  2817. else if (chat_val.substring(1,9)=="pollstat"){
  2818. if(pollactive[0] || pollactive2[0]){
  2819. var count = [0,0,0,0];
  2820. var keys = Object.keys(playerids);
  2821. for(var i = 0;i<keys.length;i++){
  2822. if(ishost){
  2823. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive[3].length-1){
  2824. count[playerids[keys[i]].vote.poll]++;
  2825. }
  2826. }
  2827. else{
  2828. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive2[2].length-1){
  2829. count[playerids[keys[i]].vote.poll]++;
  2830. }
  2831. }
  2832. }
  2833. for(var i = 0;i<count.length;i++){
  2834. if(count[i]>1){
  2835. displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  2836. }
  2837. if(count[i]==1){
  2838. displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  2839. }
  2840. }
  2841. if(ishost){
  2842. displayInChat("The poll will end in: "+((pollactive[2]-Date.now())/1000).toString()+" seconds.","#DA0808","#1EBCC1");
  2843. }
  2844. displayInChat("The poll is:","#DA0808","#1EBCC1");
  2845. if(ishost){
  2846. for(var i = 0;i<pollactive[3].length;i++){
  2847. displayInChat(letters[i]+") "+pollactive[3][i],"#DA0808","#1EBCC1");
  2848. }
  2849. }
  2850. else{
  2851. for(var i = 0;i<pollactive2[2].length;i++){
  2852. displayInChat(letters[i]+") "+pollactive2[2][i],"#DA0808","#1EBCC1");
  2853. }
  2854. }
  2855. }
  2856. else{
  2857. displayInChat("No poll has been started.","#DA0808","#1EBCC1");
  2858. if(ishost){
  2859. displayInChat("Type '/startpoll [seconds]' to start a poll.","#DA0808","#1EBCC1");
  2860. if(poll.length>0){
  2861. displayInChat("The poll is:","#DA0808","#1EBCC1");
  2862. for(var i = 0;i<poll.length;i++){
  2863. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  2864. }
  2865. }
  2866. }
  2867. }
  2868. return "";
  2869. }
  2870. else if (chat_val.substring(1,5)=="help" || chat_val.substring(1,2)=="?"){
  2871. for(var i = 0;i<help.length;i++){
  2872. if(help[i].startsWith("/")){
  2873. var splitted = help[i].substring(1).split(" ");
  2874. var command = splitted[0];
  2875. var rest = "";
  2876. if(splitted.length>1){
  2877. rest = " "+splitted.slice(1).join(" ");
  2878. }
  2879. displayInChat("/"+'<a onclick = \'Gwindow.displayadvhelp("'+command+'");\' style = "color:green;" href = "javascript:void(0);">'+command+'</a>'+rest,"#DA0808","#1EBCC1",{sanitize:false},"",false);
  2880. }
  2881. else if(help[i].startsWith("Alt ")){
  2882. displayInChat('<a onclick = \'Gwindow.displayadvhelp("'+help[i]+'");\' style = "color:green;" href = "javascript:void(0);">'+help[i]+'</a>',"#DA0808","#1EBCC1",{sanitize:false},"",false);
  2883. }
  2884. else{
  2885. displayInChat(help[i],"#DA0808","#1EBCC1");
  2886. }
  2887.  
  2888.  
  2889. }
  2890. return "";
  2891. }
  2892. else if (chat_val.substring(1,9)=="advhelp " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  2893. var text = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  2894. if(typeof(adv_help[text])!='undefined'){
  2895. displayInChat(adv_help[text],"#DA0808","#1EBCC1");
  2896. }
  2897. return "";
  2898. }
  2899. else if (chat_val.substring(1,6)=="mode " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  2900. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  2901. var mode = "";
  2902. var text2 = text;
  2903. if(text == "arrows"){
  2904. text2 = "Arrows";
  2905. mode = "ar";
  2906. }
  2907. else if(text == "death arrows"){
  2908. mode = "ard";
  2909. text2 = "Death Arrows";
  2910. }
  2911. else if(text == "grapple"){
  2912. mode = "sp";
  2913. text2 = "Grapple";
  2914. }
  2915. else if(text == "classic"){
  2916. mode = "b";
  2917. text2 = "Classic";
  2918. }
  2919. else{
  2920. displayInChat("Mode options:","#DA0808","#1EBCC1");
  2921. displayInChat("classic","#DA0808","#1EBCC1");
  2922. displayInChat("arrows","#DA0808","#1EBCC1");
  2923. displayInChat("death arrows","#DA0808","#1EBCC1");
  2924. displayInChat("grapple","#DA0808","#1EBCC1");
  2925. }
  2926. if(mode != ""){
  2927. if(ishost){
  2928. SEND('42[20,{"ga":"b","mo":"'+mode+'"}]');
  2929. RECIEVE('42[26,"b","'+mode+'"]');
  2930. displayInChat("Changed mode to "+text+".","#DA0808","#1EBCC1");
  2931. }
  2932. else{
  2933. if(playerids[myid].ratelimit.mode+1000<Date.now()){
  2934. playerids[myid].ratelimit.mode=Date.now();
  2935. SEND("42"+JSON.stringify([4,{"type":"request mode","from":username,"mode":mode}]));
  2936. var code = 'if(!Gwindow.ishost){Gwindow.displayInChat("You must be host to change the mode.","#DA0808","#1EBCC1",{sanitize:false},"",true)}else{Gwindow.changemode("'+mode+'")}';
  2937. displayInChat('> '+username+' requests [<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+text2+'</a>]',"#DA0808","#1EBCC1",{sanitize:false}," mode.");
  2938.  
  2939. }
  2940. else{
  2941. displayInChat("You are requesting modes too quickly.","#DA0808","#1EBCC1");
  2942. }
  2943. }
  2944. }
  2945. return "";
  2946.  
  2947. }
  2948. else if(ishost){
  2949. if (chat_val.substring(1,11)=="nextafter " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  2950. var text = parseFloat(chat_val.substring(11).replace(/^\s+|\s+$/g, ''));
  2951. if(isNaN(text)){
  2952. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  2953. return "";
  2954. }
  2955. else if(text<=0){
  2956. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  2957. return "";
  2958. }
  2959. nextafter = text;
  2960. displayInChat("Set next after to: " + text.toString()+" seconds.","#DA0808","#1EBCC1");
  2961. displayInChat("Type '/nextafter' to reset next after.","#DA0808","#1EBCC1");
  2962. return "";
  2963.  
  2964. }
  2965. else if (chat_val.substring(1,10)=="nextafter"){
  2966. nextafter = 0;
  2967. displayInChat("Reset next after.","#DA0808","#1EBCC1");
  2968. return "";
  2969.  
  2970. }
  2971. else if (chat_val.substring(1,5)=="next" && stopquickplay == 0){
  2972. roundsperqp2 = 0;
  2973. if(shuffle){
  2974. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  2975. var available = [];
  2976. var availableindexes = [];
  2977. var notempty = false;
  2978. for(var i = 0; i<e.length;i++){
  2979. var a = false;
  2980. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  2981. available.push(a);
  2982. if(a){
  2983. availableindexes.push(i);
  2984. notempty = true;
  2985. }
  2986. }
  2987. if(notempty){
  2988.  
  2989. if(availableindexes.length!=1){
  2990. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  2991. }
  2992. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  2993. }
  2994. }
  2995. else{
  2996. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  2997. var available = [];
  2998. var availableindexes = [];
  2999. var notempty = false;
  3000. for(var i = 0; i<e.length;i++){
  3001. var a = false;
  3002. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  3003. available.push(a);
  3004. if(a){
  3005. availableindexes.push(i);
  3006. notempty = true;
  3007. }
  3008. }
  3009. if(notempty){
  3010. var above = [];
  3011. for(var i = 0;i<availableindexes.length;i++){
  3012. if(availableindexes[i]>quicki){
  3013. above.push(availableindexes[i]);
  3014. }
  3015. }
  3016. if(above.length>0){
  3017. quicki = above[0];
  3018. }
  3019. else{
  3020. quicki = availableindexes[0];
  3021. }
  3022. }
  3023. }
  3024. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  3025. displayInChat("Switched to next map.","#DA0808","#1EBCC1");
  3026. return "";
  3027.  
  3028. }
  3029. else if (chat_val.substring(1,9)=="freejoin"){
  3030. if(freejoin == false){
  3031. freejoin = true;
  3032. displayInChat("Freejoin is now on.","#DA0808","#1EBCC1");
  3033.  
  3034. }
  3035. else{
  3036. freejoin = false;
  3037. displayInChat("Freejoin is now off.","#DA0808","#1EBCC1");
  3038. }
  3039.  
  3040. return "";
  3041.  
  3042. }
  3043. else if (chat_val.substring(1,8)=="instaqp"){
  3044. if(instaqp == false){
  3045. instaqp = true;
  3046. displayInChat("Instaqp is now on.","#DA0808","#1EBCC1");
  3047.  
  3048. }
  3049. else{
  3050. instaqp = false;
  3051. displayInChat("Instaqp is now off.","#DA0808","#1EBCC1");
  3052. }
  3053.  
  3054. return "";
  3055.  
  3056. }
  3057.  
  3058. else if (chat_val.substring(1,9)=="previous" && stopquickplay == 0){
  3059. roundsperqp2 = 0;
  3060. if(shuffle){
  3061. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  3062. var available = [];
  3063. var availableindexes = [];
  3064. var notempty = false;
  3065. for(var i = 0; i<e.length;i++){
  3066. var a = false;
  3067. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  3068. available.push(a);
  3069. if(a){
  3070. availableindexes.push(i);
  3071. notempty = true;
  3072. }
  3073. }
  3074. if(notempty){
  3075.  
  3076. if(availableindexes.length!=1){
  3077. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  3078. }
  3079. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  3080. }
  3081. }
  3082. else{
  3083. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  3084. var available = [];
  3085. var availableindexes = [];
  3086. var notempty = false;
  3087. for(var i = 0; i<e.length;i++){
  3088. var a = false;
  3089. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  3090. available.push(a);
  3091. if(a){
  3092. availableindexes.push(i);
  3093. notempty = true;
  3094. }
  3095. }
  3096. if(notempty){
  3097. var above = [];
  3098. for(var i = 0;i<availableindexes.length;i++){
  3099. if(availableindexes[i]<quicki){
  3100. above.push(availableindexes[i]);
  3101. }
  3102. }
  3103. if(above.length>0){
  3104. quicki = above[above.length-1];
  3105. }
  3106. else{
  3107. quicki = availableindexes[availableindexes.length-1];
  3108. }
  3109. }
  3110. }
  3111. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  3112.  
  3113. displayInChat("Switched to previous map.","#DA0808","#1EBCC1");
  3114. return "";
  3115. }
  3116. else if (chat_val.substring(1,6)=="start" && chat_val.length == 6){
  3117. Gdocument.getElementById("newbonklobby_editorbutton").click();
  3118. if(recmodebool && ishost){
  3119. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  3120. if(mode == "" && defaultmode!="d"){
  3121. mode = defaultmode;
  3122. }
  3123. if(mode != ""){
  3124. RECIEVE('42[26,"b","'+mode+'"]');
  3125. }
  3126. }
  3127. Gdocument.getElementById("mapeditor_close").click();
  3128. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  3129. roundsperqp2 = 0;
  3130. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  3131.  
  3132. return "";
  3133. }
  3134.  
  3135. else if (chat_val.substring(1,8)=="startqp" && stopquickplay == 1){
  3136. stopquickplay = 0;
  3137. quicki = 0;
  3138. qppaused = false;
  3139. displayInChat("Enabled quickplay.","#DA0808","#1EBCC1");
  3140. return "";
  3141. }
  3142. else if (chat_val.substring(1,7)=="stopqp" && stopquickplay == 0){
  3143. stopquickplay = 1;
  3144. quicki = 0;
  3145. qppaused = false;
  3146. displayInChat("Disabled quickplay.","#DA0808","#1EBCC1");
  3147. return "";
  3148. }
  3149. else if (chat_val.substring(1,8)=="pauseqp" && stopquickplay == 0){
  3150. if(qppaused == false){
  3151. qppaused = true;
  3152. displayInChat("Paused quickplay.","#DA0808","#1EBCC1");
  3153. }
  3154. else{
  3155. qppaused = false;
  3156. displayInChat("Unpaused quickplay.","#DA0808","#1EBCC1");
  3157. }
  3158. return "";
  3159. }
  3160.  
  3161. else if (chat_val.substring(1,5)=="ban " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  3162. banned.push(chat_val.substring(5).replace(/^\s+|\s+$/g, ''));
  3163. displayInChat("Banned "+chat_val.substring(5).replace(/^\s+|\s+$/g, '')+".","#DA0808","#1EBCC1");
  3164. return "/kick '" + chat_val.substring(5).replace(/^\s+|\s+$/g, '') + "'";
  3165. }
  3166. else if (chat_val.substring(1,6)=="kill " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  3167. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  3168. var keys = Object.keys(playerids);
  3169. var killid = undefined;
  3170. for(var i = 0; i<keys.length; i++){
  3171. if(playerids[keys[i]].userName == text){
  3172. killid = keys[i];
  3173. }
  3174. }
  3175. if(typeof(killid)!="undefined" && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden" && !killedids.includes(killid)){
  3176. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  3177.  
  3178. killedids.push(killid);
  3179. SEND('42[25,{"a":{"playersLeft":['+killid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  3180. RECIEVE('42[31,{"a":{"playersLeft":['+killid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  3181. }
  3182.  
  3183. return "";
  3184. }
  3185. else if (chat_val.substring(1,10)=="balanceA " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  3186. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  3187. if(!isNaN(parseInt(text))){
  3188. if(parseInt(text)>=-100 && parseInt(text)<=100){
  3189. var keys = Object.keys(playerids);
  3190. for(var i = 0; i<keys.length;i++){
  3191. SEND('42[29,{"sid":'+keys[i]+',"bal":'+text+'}]');
  3192. RECIEVE('42[36,'+keys[i]+','+text+']');
  3193. }
  3194. }
  3195. }
  3196. return "";
  3197.  
  3198. }
  3199. else if (chat_val.substring(1,10)=="resetpoll"){
  3200. poll = [];
  3201. displayInChat("The poll has been reset.","#DA0808","#1EBCC1");
  3202. return "";
  3203. }
  3204. else if (chat_val.substring(1,11)=="addoption " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  3205. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  3206. if(text.length>50){
  3207. displayInChat("Your option is greater than 50 characters.","#DA0808","#1EBCC1");
  3208. return "";
  3209. }
  3210. if(poll.includes(text)){
  3211. displayInChat("This option already exists.","#DA0808","#1EBCC1");
  3212. }
  3213. else if(poll.length>=4){
  3214. displayInChat("Your poll already has the max 4 amounts of options.","#DA0808","#1EBCC1");
  3215. displayInChat("Type '/deloption [letter]' to remove a option.","#DA0808","#1EBCC1");
  3216. displayInChat("The poll is:","#DA0808","#1EBCC1");
  3217. for(var i = 0;i<poll.length;i++){
  3218. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  3219. }
  3220. }
  3221. else{
  3222. poll.push(text);
  3223. displayInChat("The poll is now:","#DA0808","#1EBCC1");
  3224. for(var i = 0;i<poll.length;i++){
  3225. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  3226. }
  3227. }
  3228. return "";
  3229. }
  3230. else if (chat_val.substring(1,11)=="deloption " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  3231. var text = letters.indexOf(chat_val.substring(11).replace(/^\s+|\s+$/g, ''));
  3232. if(text==-1 || text>=poll.length){
  3233. if(poll.length>0){
  3234. displayInChat("Available options are:","#DA0808","#1EBCC1");
  3235. for(var i = 0;i<poll.length;i++){
  3236. displayInChat(letters[i],"#DA0808","#1EBCC1");
  3237. }
  3238. }
  3239. else{
  3240. displayInChat("Your poll is empty.","#DA0808","#1EBCC1");
  3241. displayInChat("Type '/addoption [text]' to add an option.","#DA0808","#1EBCC1");
  3242. }
  3243. }
  3244. else{
  3245. poll.splice(text,1);
  3246. displayInChat("The poll is now:","#DA0808","#1EBCC1");
  3247. for(var i = 0;i<poll.length;i++){
  3248. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  3249. }
  3250. }
  3251. return "";
  3252. }
  3253. else if (chat_val.substring(1,11)=="startpoll " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  3254. var text = parseFloat(chat_val.substring(11).replace(/^\s+|\s+$/g, ''));
  3255. if(isNaN(text)){
  3256. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  3257. return "";
  3258. }
  3259. else if(text<=0){
  3260. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  3261. return "";
  3262. }
  3263. else if(text<10){
  3264. displayInChat("Your poll has to last for at least 10 seconds.","#DA0808","#1EBCC1");
  3265. return "";
  3266. }
  3267. if(pollactive[0]){
  3268. displayInChat("There is already an ongoing poll.","#DA0808","#1EBCC1");
  3269. displayInChat("Type '/endpoll' to end the poll.","#DA0808","#1EBCC1");
  3270. return "";
  3271. }
  3272. if(poll.length<2){
  3273. displayInChat("Your poll needs at least 2 options.","#DA0808","#1EBCC1");
  3274. displayInChat("Type '/addoption' to add to the poll.","#DA0808","#1EBCC1");
  3275. return "";
  3276. }
  3277.  
  3278. var now = Date.now();
  3279. pollactive = [true,now,now+text*1000,[...poll]];
  3280. playerids[myid].ratelimit.poll = now;
  3281. var chatpoll = [...poll];
  3282. chatpoll.push("Cancel vote.");
  3283. pollactive[3].push("Cancel vote.");
  3284. for(var i = 0;i<chatpoll.length;i++){
  3285. chatpoll[i] = letters[i]+") "+chatpoll[i];
  3286. }
  3287. chat(chatpoll.join("     "));
  3288. setTimeout(function(){
  3289. if(pollactive[0]){
  3290. SEND("42"+JSON.stringify([4,{"type":"poll","from":username,"poll":pollactive[3]}]));
  3291. var keys = Object.keys(playerids);
  3292. for(var i = 0;i<keys.length;i++){
  3293. playerids[keys[i]].vote.poll = -1;
  3294. }
  3295. displayInChat("The poll will end in: " + text.toString()+" seconds.","#DA0808","#1EBCC1");
  3296. displayInChat("Type '/endpoll' to end the poll early.","#DA0808","#1EBCC1");
  3297. }
  3298. },200);
  3299. return "";
  3300. }
  3301. else if (chat_val.substring(1,8)=="endpoll"){
  3302. if(pollactive[0]){
  3303. if(playerids[myid].ratelimit.poll+10000>Date.now()){
  3304. displayInChat("Your poll has to be at least 10 seconds.","#DA0808","#1EBCC1");
  3305. displayInChat("There are "+((playerids[myid].ratelimit.poll+10000-Date.now())/1000).toString()+" seconds left until you can end the poll early.","#DA0808","#1EBCC1");
  3306. return "";
  3307. }
  3308. playerids[myid].ratelimit.poll = Date.now();
  3309. SEND("42"+JSON.stringify([4,{"type":"poll end","from":username}]));
  3310. displayInChat("The poll ended.","#DA0808","#1EBCC1");
  3311. var count = [0,0,0,0];
  3312. var keys = Object.keys(playerids);
  3313. for(var i = 0;i<keys.length;i++){
  3314. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive[3].length-1){
  3315. count[playerids[keys[i]].vote.poll]++;
  3316. }
  3317. playerids[keys[i]].vote.poll = -1;
  3318. }
  3319. for(var i = 0;i<count.length;i++){
  3320. if(count[i]>1){
  3321. displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  3322. }
  3323. if(count[i]==1){
  3324. displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  3325. }
  3326. }
  3327. displayInChat("The poll was:","#DA0808","#1EBCC1");
  3328. for(var i = 0;i<pollactive[3].length;i++){
  3329. displayInChat(letters[i]+") "+pollactive[3][i],"#DA0808","#1EBCC1");
  3330. }
  3331. pollactive = [false,0,0,[]];
  3332. }
  3333. else{
  3334. displayInChat("No poll has been started","#DA0808","#1EBCC1");
  3335. displayInChat("Type '/startpoll [seconds]' to start a poll.","#DA0808","#1EBCC1");
  3336. }
  3337. return "";
  3338. }
  3339. else if (chat_val.substring(1,7)=="moveA " && chat_val.replace(/^\s+|\s+$/g, '').length>=8){
  3340. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '');
  3341. var keys = Object.keys(playerids);
  3342. if(text == "f"){
  3343. for(var i = 0; i<keys.length;i++){
  3344. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":1}]')
  3345. }
  3346. }
  3347. else if(text == "b"){
  3348. for(var i = 0; i<keys.length;i++){
  3349. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":3}]')
  3350. }
  3351. }
  3352. else if(text == "g"){
  3353. for(var i = 0; i<keys.length;i++){
  3354. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":4}]')
  3355. }
  3356. }
  3357. else if(text == "r"){
  3358. for(var i = 0; i<keys.length;i++){
  3359. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":2}]')
  3360. }
  3361. }
  3362. else if(text == "y"){
  3363. for(var i = 0; i<keys.length;i++){
  3364. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":5}]')
  3365. }
  3366. }
  3367. else if(text == "s"){
  3368. for(var i = 0; i<keys.length;i++){
  3369. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":0}]')
  3370. }
  3371. }
  3372.  
  3373. return "";
  3374. }
  3375. if (chat_val.substring(1,13)=="roundsperqp " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  3376. var text = parseInt(chat_val.substring(13).replace(/^\s+|\s+$/g, ''));
  3377. if(isNaN(text)){
  3378. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  3379. return "";
  3380. }
  3381. else if(text<=0){
  3382. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  3383. return "";
  3384. }
  3385. roundsperqp = text;
  3386. roundsperqp2 = 0;
  3387. displayInChat("Set rounds per quickplay to: " + text.toString(),"#DA0808","#1EBCC1");
  3388. displayInChat("Type '/roundsperqp' to reset rounds per quickplay.","#DA0808","#1EBCC1");
  3389. return "";
  3390.  
  3391. }
  3392. else if (chat_val.substring(1,12)=="roundsperqp"){
  3393. roundsperqp = 1;
  3394. roundsperqp2 = 0;
  3395. displayInChat("Reset rounds per quickplay.","#DA0808","#1EBCC1");
  3396. return "";
  3397.  
  3398. }
  3399. else if (chat_val.substring(1,8)=="rounds " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  3400. var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '');
  3401. if(!isNaN(parseInt(text))){
  3402. text = parseInt(text).toString();
  3403. SEND('42[21,{"w":'+text+'}]');
  3404. RECIEVE('42[27,'+text+']');
  3405. }
  3406. return "";
  3407.  
  3408. }
  3409. else if (chat_val.substring(1,13)=="disablekeys " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  3410. var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '');
  3411. var keys = text.split(" ");
  3412. var disabledkeys2 = [];
  3413. var possiblekeys = ["left","right","up","down","heavy","special"];
  3414. for(var i = 0; i<keys.length; i++){
  3415. if(keys[i]!="" && !disabledkeys2.includes(keys[i])){
  3416. if(possiblekeys.includes(keys[i])){
  3417. disabledkeys2.push(keys[i]);
  3418. }
  3419. else{
  3420. displayInChat("Key options: " + possiblekeys.join(" ") + ".","#DA0808","#1EBCC1");
  3421. return "";
  3422. }
  3423. }
  3424.  
  3425. }
  3426. disabledkeys = disabledkeys2;
  3427. displayInChat("Set disabled keys to: " + disabledkeys.join(" ") + ".","#DA0808","#1EBCC1");
  3428. displayInChat("Type '/disablekeys' to reset disabled keys.","#DA0808","#1EBCC1");
  3429. return "";
  3430.  
  3431. }
  3432. else if (chat_val.substring(1,12)=="disablekeys"){
  3433. displayInChat("Reset disabled keys.","#DA0808","#1EBCC1");
  3434. disabledkeys = [];
  3435. return "";
  3436.  
  3437. }
  3438. else if (chat_val.substring(1,10)=="jointext " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  3439. jointext = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  3440. displayInChat("Set jointext to: " + jointext,"#DA0808","#1EBCC1");
  3441. displayInChat("Type '/jointext' to reset jointext.","#DA0808","#1EBCC1");
  3442. return "";
  3443.  
  3444. }
  3445. else if (chat_val.substring(1,9)=="jointext"){
  3446. jointext = "";
  3447. displayInChat("Reset jointext.","#DA0808","#1EBCC1");
  3448. return "";
  3449.  
  3450. }
  3451. else if (chat_val.substring(1,9)=="wintext " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  3452. wintext = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  3453. displayInChat("Set wintext to: " + wintext,"#DA0808","#1EBCC1");
  3454. displayInChat("Type '/wintext' to reset wintext.","#DA0808","#1EBCC1");
  3455. return "";
  3456.  
  3457. }
  3458. else if (chat_val.substring(1,8)=="wintext"){
  3459. wintext = "";
  3460. displayInChat("Reset wintext.","#DA0808","#1EBCC1");
  3461. return "";
  3462.  
  3463. }
  3464. else if (chat_val.substring(1,11)=="autorecord"){
  3465. if(autorecord){
  3466. autorecord = false;
  3467. displayInChat("Autorecord is now off.","#DA0808","#1EBCC1");
  3468. }
  3469. else{
  3470. autorecord = true;
  3471. displayInChat("Autorecord is now on.","#DA0808","#1EBCC1");
  3472. }
  3473. return "";
  3474.  
  3475. }
  3476. else if (chat_val.substring(1,9)=="afkkill " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  3477. var text = parseFloat(chat_val.substring(9).replace(/^\s+|\s+$/g, ''));
  3478. if(!isNaN(text)){
  3479. if(text>0){
  3480. displayInChat("Set afk kill to: " + text.toString()+" seconds.","#DA0808","#1EBCC1");
  3481. displayInChat("Type '/afkkill' to reset afk kill.","#DA0808","#1EBCC1");
  3482. var keys = Object.keys(playerids);
  3483. var now = Date.now();
  3484. for(var i = 0;i<keys.length;i++){
  3485. playerids[keys[i]].lastmove = now;
  3486. }
  3487. afkkill = text;
  3488. }
  3489. else{
  3490. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  3491. }
  3492. }
  3493. else{
  3494. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  3495. }
  3496. return "";
  3497.  
  3498. }
  3499. else if (chat_val.substring(1,9)=="afkkill"){
  3500. afkkill = -1;
  3501. displayInChat("Reset afk kill.","#DA0808","#1EBCC1");
  3502. return "";
  3503.  
  3504. }
  3505. else if (chat_val.substring(1,13)=="defaultmode " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  3506. var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '');
  3507. if(text == "default"){
  3508. defaultmode = "";
  3509. displayInChat("Changed default mode to default.","#DA0808","#1EBCC1");
  3510. }
  3511. else if(text == "arrows"){
  3512. defaultmode = "ar";
  3513. displayInChat("Changed default mode to arrows.","#DA0808","#1EBCC1");
  3514. }
  3515. else if(text == "death arrows"){
  3516. defaultmode = "ard";
  3517. displayInChat("Changed default mode to death arrows.","#DA0808","#1EBCC1");
  3518. }
  3519. else if(text == "grapple"){
  3520. defaultmode = "sp";
  3521. displayInChat("Changed default mode to grapple.","#DA0808","#1EBCC1");
  3522. }
  3523. else if(text == "classic"){
  3524. defaultmode = "b";
  3525. displayInChat("Changed default mode to classic.","#DA0808","#1EBCC1");
  3526.  
  3527. }
  3528. else{
  3529. displayInChat("Default mode options:","#DA0808","#1EBCC1");
  3530. displayInChat("default","#DA0808","#1EBCC1");
  3531. displayInChat("classic","#DA0808","#1EBCC1");
  3532. displayInChat("arrows","#DA0808","#1EBCC1");
  3533. displayInChat("death arrows","#DA0808","#1EBCC1");
  3534. displayInChat("grapple","#DA0808","#1EBCC1");
  3535. }
  3536. return "";
  3537.  
  3538. }
  3539. else if (chat_val.substring(1,8)=="recmode"){
  3540. if(recmodebool == true){
  3541. recmodebool = false;
  3542. displayInChat("Recmode is now off.","#DA0808","#1EBCC1");
  3543.  
  3544. }
  3545. else{
  3546. recmodebool = true;
  3547. displayInChat("Recmode is now on.","#DA0808","#1EBCC1");
  3548.  
  3549. }
  3550.  
  3551. return "";
  3552.  
  3553. }
  3554. else if (chat_val.substring(1,8)=="recteam"){
  3555. if(recteams == true){
  3556. recteams = false;
  3557. displayInChat("Recteam is now off.","#DA0808","#1EBCC1");
  3558.  
  3559. }
  3560. else{
  3561. recteams = true;
  3562. displayInChat("Recteam is now on.","#DA0808","#1EBCC1");
  3563.  
  3564. }
  3565. return "";
  3566. }
  3567. else if (chat_val.substring(1,8)=="shuffle"){
  3568. if(shuffle == true){
  3569. shuffle = false;
  3570. displayInChat("Shuffle is now off.","#DA0808","#1EBCC1");
  3571.  
  3572. }
  3573. else{
  3574. shuffle = true;
  3575. displayInChat("Shuffle is now on.","#DA0808","#1EBCC1");
  3576.  
  3577. }
  3578.  
  3579. return "";
  3580.  
  3581. }
  3582.  
  3583. else if(sandboxon){
  3584. if (chat_val.substring(1,11)=="addplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  3585. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  3586. if(!isNaN(parseInt(text))){
  3587. var text2 = parseInt(text);
  3588. if(text2>0){
  3589. for(var i = 0;i<text2;i++){
  3590. RECIEVE('42[4,'+sandboxid+',"0123456789abcdef","'+sandboxid.toString()+'",true,0,1,{"layers":[],"bc":'+Math.floor(Math.random() * 16777215).toString()+'}]');
  3591. sandboxplayerids[sandboxid] = sandboxid.toString();
  3592. sandboxid+=1;
  3593. }
  3594.  
  3595. }
  3596. }
  3597. return "";
  3598.  
  3599. }
  3600. else if (chat_val.substring(1,11)=="delplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  3601. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  3602. if(!isNaN(parseInt(text))){
  3603. var text2 = parseInt(text);
  3604. if(text2>0){
  3605. if(Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden"){
  3606. var jsonkeys = Object.keys(sandboxplayerids).reverse();
  3607. for(var i = 0;i<text2 && i<jsonkeys.length;i++){
  3608. RECIEVE('42[5,'+jsonkeys[i]+',0]');
  3609. delete sandboxplayerids[jsonkeys[i]];
  3610. }
  3611. }
  3612. else{
  3613. displayInChat("Cannot delete players while ingame.","#DA0808","#1EBCC1");
  3614. }
  3615.  
  3616. }
  3617. }
  3618. return "";
  3619. }
  3620. else if (chat_val.substring(1,7)=="copyme"){
  3621. if(sandboxcopyme == true){
  3622. displayInChat("Copyme is now off.","#DA0808","#1EBCC1");
  3623. sandboxcopyme = false;
  3624. }
  3625. else{
  3626. displayInChat("Copyme is now on.","#DA0808","#1EBCC1");
  3627. sandboxcopyme = true;
  3628. }
  3629.  
  3630. return "";
  3631. }
  3632. }
  3633. }
  3634. return chat_val;
  3635. };
  3636.  
  3637. scope.flag_manage = function(t){
  3638. var text = t;
  3639. if(reverse_flag == true){
  3640. text = text.split("").reverse().join("")
  3641. }
  3642. if(rcaps_flag == true){
  3643. text = text.split('');
  3644. for(var i = 0; i<text.length;i++){
  3645. if(Math.floor(Math.random()*2)){
  3646. text[i] = text[i].toUpperCase();
  3647. }
  3648. else{
  3649. text[i] = text[i].toLowerCase();
  3650. }
  3651. }
  3652. text = text.join('');
  3653. }
  3654. if(space_flag == true){
  3655. text = text.split('').join(' ')
  3656. }
  3657. if(number_flag == true){
  3658. text = text.replace(/[t|T][Oo]+/g,"2");
  3659. text = text.replace(/[f|F][o|O][r|R]/g,"4");
  3660. text = text.replace(/[a|A][t|T][e|E]/g,"8");
  3661. text = text.replace(/[e|E]/g,"3");
  3662. text = text.replace(/[a|A]/g,"4");
  3663. text = text.replace(/[o|O]/g,"0");
  3664. text = text.replace(/[s|S]/g,"5");
  3665. text = text.replace(/[i|I|l|L]/g,"1");
  3666. }
  3667. return text;
  3668. };
  3669. Gdocument.getElementById("newbonklobby_chat_input").onkeydown = function(e){
  3670. if(e.keyCode==13){
  3671.  
  3672. var chat_val = Gdocument.getElementById("newbonklobby_chat_input").value;
  3673.  
  3674. if (chat_val!="" && chat_val[0]=="/"){
  3675.  
  3676. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  3677. chat2(commandhandle(chat_val));
  3678. }
  3679. else{
  3680. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  3681. chat2(flag_manage(chat_val));
  3682. }
  3683.  
  3684. }
  3685. };
  3686. Gdocument.getElementById("ingamechatinputtext").onkeydown = function(e){
  3687. if(e.keyCode==13){
  3688.  
  3689. var chat_val = Gdocument.getElementById("ingamechatinputtext").value;
  3690.  
  3691. if (chat_val!="" && chat_val[0]=="/"){
  3692.  
  3693. Gdocument.getElementById("ingamechatinputtext").value = "";
  3694. chat2(commandhandle(chat_val));
  3695. }
  3696. else{
  3697. Gdocument.getElementById("ingamechatinputtext").value = "";
  3698. chat2(flag_manage(chat_val));
  3699. }
  3700. }
  3701. };
  3702. scope.Last_message = "";
  3703. scope.Laster_message = "";
  3704. scope.new_message = false;
  3705. scope.changed_chat = false;
  3706. scope.interval = setInterval(timeout123,60);
  3707.  
  3708.  
  3709. scope.hotkeys = function(e){
  3710.  
  3711.  
  3712. var keycode = e.code;
  3713. if(e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  3714. if(keycode == "Period"){
  3715. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]!="0px"){
  3716. chatheight+=5;
  3717. if(chatheight>600){chatheight = 600;}
  3718. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  3719. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  3720. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  3721. }
  3722. e.preventDefault();
  3723. }
  3724. if(keycode == "Comma"){
  3725. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]!="0px"){
  3726. chatheight-=5;
  3727. if(chatheight<100){chatheight = 100;}
  3728. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  3729. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  3730. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  3731. }
  3732. e.preventDefault();
  3733. }
  3734. }
  3735. if(e.repeat){return;}
  3736.  
  3737. if(e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  3738. if(ishost){
  3739. if(keycode == "KeyE"){
  3740. if(Gdocument.getElementById("newbonklobby").style["display"] == "block"){
  3741. Gdocument.getElementById("newbonklobby_editorbutton").click();
  3742. }
  3743. else if(Gdocument.getElementById("mapeditorcontainer").style["display"] == "block"){
  3744. Gdocument.getElementById("mapeditor_close").click();
  3745. }
  3746. e.preventDefault();
  3747.  
  3748. }
  3749. else if(keycode == "KeyT"){
  3750. Gdocument.getElementById("newbonklobby_teamsbutton").click();
  3751. e.preventDefault();
  3752. }
  3753. else if(keycode == "KeyM"){
  3754. Gdocument.getElementById("newbonklobby_modebutton").click();
  3755. e.preventDefault();
  3756. }
  3757. else if(keycode == "KeyK"){
  3758. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  3759. Gdocument.getElementById("pretty_top_exit").click();
  3760. }
  3761. e.preventDefault();
  3762. }
  3763. else if(keycode == "KeyS"){
  3764. Gdocument.getElementById("newbonklobby_editorbutton").click();
  3765. if(recmodebool && ishost){
  3766. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  3767. if(mode == "" && defaultmode!="d"){
  3768. mode = defaultmode;
  3769. }
  3770. if(mode != ""){
  3771. RECIEVE('42[26,"b","'+mode+'"]');
  3772. }
  3773. }
  3774. Gdocument.getElementById("mapeditor_close").click();
  3775. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  3776. roundsperqp2 = 0;
  3777. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  3778. e.preventDefault();
  3779. }
  3780. else if(keycode == "KeyD"){
  3781. roundsperqp2 = 0;
  3782. if(stopquickplay == 0){
  3783. if(shuffle){
  3784. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  3785. var available = [];
  3786. var availableindexes = [];
  3787. var notempty = false;
  3788. for(var i = 0; i<e2.length;i++){
  3789. var a = false;
  3790. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  3791. available.push(a);
  3792. if(a){
  3793. availableindexes.push(i);
  3794. notempty = true;
  3795. }
  3796. }
  3797. if(notempty){
  3798.  
  3799. if(availableindexes.length!=1){
  3800. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  3801. }
  3802. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  3803. }
  3804. }
  3805. else{
  3806. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  3807. var available = [];
  3808. var availableindexes = [];
  3809. var notempty = false;
  3810. for(var i = 0; i<e2.length;i++){
  3811. var a = false;
  3812. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  3813. available.push(a);
  3814. if(a){
  3815. availableindexes.push(i);
  3816. notempty = true;
  3817. }
  3818. }
  3819. if(notempty){
  3820. var above = [];
  3821. for(var i = 0;i<availableindexes.length;i++){
  3822. if(availableindexes[i]>quicki){
  3823. above.push(availableindexes[i]);
  3824. }
  3825. }
  3826. if(above.length>0){
  3827. quicki = above[0];
  3828. }
  3829. else{
  3830. quicki = availableindexes[0];
  3831. }
  3832. }
  3833. }
  3834. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  3835. }
  3836. e.preventDefault();
  3837. }
  3838. else if(keycode == "KeyA"){
  3839. if(stopquickplay == 0){
  3840. roundsperqp2 = 0;
  3841. if(shuffle){
  3842. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  3843. var available = [];
  3844. var availableindexes = [];
  3845. var notempty = false;
  3846. for(var i = 0; i<e2.length;i++){
  3847. var a = false;
  3848. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  3849. available.push(a);
  3850. if(a){
  3851. availableindexes.push(i);
  3852. notempty = true;
  3853. }
  3854. }
  3855. if(notempty){
  3856.  
  3857. if(availableindexes.length!=1){
  3858. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  3859. }
  3860. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  3861. }
  3862. }
  3863. else{
  3864. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  3865. var available = [];
  3866. var availableindexes = [];
  3867. var notempty = false;
  3868. for(var i = 0; i<e2.length;i++){
  3869. var a = false;
  3870. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  3871. available.push(a);
  3872. if(a){
  3873. availableindexes.push(i);
  3874. notempty = true;
  3875. }
  3876. }
  3877. if(notempty){
  3878. var above = [];
  3879. for(var i = 0;i<availableindexes.length;i++){
  3880. if(availableindexes[i]<quicki){
  3881. above.push(availableindexes[i]);
  3882. }
  3883. }
  3884. if(above.length>0){
  3885. quicki = above[above.length-1];
  3886. }
  3887. else{
  3888. quicki = availableindexes[availableindexes.length-1];
  3889. }
  3890. }
  3891. }
  3892. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  3893. }
  3894. e.preventDefault();
  3895. }
  3896. else if(keycode == "KeyQ"){
  3897. if(stopquickplay == 1){
  3898. stopquickplay = 0;
  3899. quicki = 0;
  3900. qppaused = false;
  3901. displayInChat("Enabled quickplay.","#DA0808","#1EBCC1");
  3902. }
  3903. else{
  3904. stopquickplay = 1;
  3905. quicki = 0;
  3906. qppaused = false;
  3907. displayInChat("Disabled quickplay.","#DA0808","#1EBCC1");
  3908. }
  3909. e.preventDefault();
  3910. }
  3911. else if(keycode == "KeyP" && stopquickplay==0){
  3912. if(qppaused == true){
  3913. qppaused = false;
  3914. displayInChat("Unpaused quickplay.","#DA0808","#1EBCC1");
  3915. }
  3916. else{
  3917. qppaused = true;
  3918. displayInChat("Paused quickplay.","#DA0808","#1EBCC1");
  3919. }
  3920. e.preventDefault();
  3921. }
  3922. else if(keycode == "KeyR"){
  3923. if(recmodebool == true){
  3924. recmodebool = false;
  3925. displayInChat("Recmode is now off.","#DA0808","#1EBCC1");
  3926.  
  3927. }
  3928. else{
  3929. recmodebool = true;
  3930. displayInChat("Recmode is now on.","#DA0808","#1EBCC1");
  3931.  
  3932. }
  3933. }
  3934. else if(keycode == "KeyF"){
  3935. if(freejoin == false){
  3936. freejoin = true;
  3937. displayInChat("Freejoin is now on.","#DA0808","#1EBCC1");
  3938.  
  3939. }
  3940. else{
  3941. freejoin = false;
  3942. displayInChat("Freejoin is now off.","#DA0808","#1EBCC1");
  3943. }
  3944. e.preventDefault();
  3945. }
  3946.  
  3947. }
  3948. else{
  3949. if(keycode == "KeyE"){
  3950. e.preventDefault();
  3951. }
  3952. else if(keycode == "KeyT"){
  3953. e.preventDefault();
  3954. }
  3955. else if(keycode == "KeyM"){
  3956. e.preventDefault();
  3957. }
  3958. else if(keycode == "KeyK"){
  3959. e.preventDefault();
  3960. }
  3961. else if(keycode == "KeyS"){
  3962. e.preventDefault();
  3963. }
  3964. else if(keycode == "KeyD"){
  3965. e.preventDefault();
  3966. }
  3967. else if(keycode == "KeyA"){
  3968. e.preventDefault();
  3969. }
  3970. else if(keycode == "KeyQ"){
  3971. e.preventDefault();
  3972. }
  3973. else if(keycode == "KeyP"){
  3974. e.preventDefault();
  3975. }
  3976. else if(keycode == "KeyF"){
  3977. e.preventDefault();
  3978. }
  3979. else if(keycode == "KeyR"){
  3980. e.preventDefault();
  3981. }
  3982.  
  3983. }
  3984.  
  3985. if(keycode == "KeyL"){
  3986. lobby();
  3987. e.preventDefault();
  3988. }
  3989. if(keycode == "KeyC"){
  3990. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  3991. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]=="0px"){
  3992. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  3993. }
  3994. else{
  3995. Gdocument.getElementById("ingamechatcontent").style["max-height"]="0px";
  3996. }
  3997. }
  3998. e.preventDefault();
  3999. }
  4000. if(keycode == "KeyI"){
  4001. if(Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"] == "none"){
  4002. debuggeropen = true;
  4003. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="block";
  4004. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="none";
  4005. Gdocument.getElementById("ingamechatinputtext").style["display"] = "none";
  4006. }
  4007. else{
  4008. debuggeropen = false;
  4009. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="none";
  4010. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  4011. Gdocument.getElementById("ingamechatinputtext").style["display"] = "";
  4012. }
  4013. e.preventDefault();
  4014. }
  4015. if(keycode == "KeyB"){
  4016. var element = Gdocument.getElementById("ingamewinner_scores");
  4017. element.style["visibility"] = "visible";
  4018. if(element.style["opacity"]<1){
  4019. element.style["opacity"] = 1;
  4020. }
  4021. else{
  4022. element.style["opacity"] = 0;
  4023. }
  4024. e.preventDefault();
  4025. }
  4026.  
  4027.  
  4028. }
  4029. if(!e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  4030. if(keycode == "Slash" && !(Gdocument.getElementById("gmeditor")?.style["transform"] == "scale(1)")){
  4031. 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"]==""){
  4032. Gdocument.getElementById("newbonklobby_chat_input").value = "/";
  4033. if(Gdocument.getElementById("newbonklobby_chat_input").style["pointer-events"] == "none"){
  4034. fire("keydown",{keyCode:13});
  4035. }
  4036. else{
  4037. Gdocument.getElementById("newbonklobby_chat_input").focus();
  4038. }
  4039. e.preventDefault();
  4040.  
  4041. }
  4042. else if(Gdocument.getElementById("ingamechatinputtext").style["visibility"]=="visible" && Gdocument.getElementById("ingamechatinputtext").style["display"]=="" && Gdocument.getElementById("mapeditorcontainer").style["display"]!="block" && Gdocument.getElementById("ingamechatinputtext").value == ""){
  4043. Gdocument.getElementById("ingamechatinputtext").value = "/";
  4044. if(!Gdocument.getElementById("ingamechatinputtext").classList.value.includes("ingamechatinputtextbg")){
  4045. fire("keydown",{keyCode:13});
  4046. }
  4047. else{
  4048. Gdocument.getElementById("ingamechatinputtext").focus();
  4049. }
  4050. e.preventDefault();
  4051.  
  4052. }
  4053.  
  4054. }
  4055. }
  4056. };
  4057.  
  4058. Gdocument.onkeydown = hotkeys;
  4059.  
  4060. Gwindow.addEventListener('resize',function(e){
  4061. debuggermenu.style["width"] = Gdocument.getElementById("bonkiocontainer").style["width"];
  4062. debuggermenu.style["height"] = Gdocument.getElementById("bonkiocontainer").style["height"];
  4063. scope.width = parseInt(Gdocument.getElementById("bonkiocontainer").style["width"])-20;
  4064. scope.height = parseInt(Gdocument.getElementById("bonkiocontainer").style["height"])-210;
  4065. logmenu.style["width"] = width.toString()+"px";
  4066. logmenu.style["height"] = height.toString()+"px";
  4067. logmenutopleft.style["width"] = (width/2).toString()+"px";
  4068. logmenutopright.style["width"] = (width/2).toString()+"px";
  4069. logmenutopright.style["left"] = (width/2).toString()+"px";
  4070. debuggerinput.style["width"] = width.toString()+"px";
  4071. debuggerinput.style["top"] = (height+90).toString()+"px";
  4072. debuggersendrecieve.style["top"] = (height+120).toString()+"px";
  4073. debuggerpausebutton.style["top"] = (height+150).toString()+"px";
  4074. debuggereval.style["width"] = (width-150).toString()+"px";
  4075. debuggereval.style["top"] = (height+120).toString()+"px";},true);
  4076.  
  4077.  
  4078. function timeout123() {
  4079. updateWssLog();
  4080. EVENTLOOPFUNCTION();
  4081. var now = Date.now();
  4082. var keys = Object.keys(playerids);
  4083. for(var i = 0;i<keys.length;i++){
  4084.  
  4085. if(playerids[keys[i]].playerData){
  4086. if(playerids[keys[i]].playerData2){
  4087. if(playerids[keys[i]].playerData.transform){
  4088. if(playerids[keys[i]].playerData2.timeStamp == 0){
  4089. playerids[keys[i]].playerData2.px = playerids[keys[i]].playerData.transform.position.x;
  4090. playerids[keys[i]].playerData2.py = playerids[keys[i]].playerData.transform.position.y;
  4091. playerids[keys[i]].playerData2.timeStamp = now;
  4092. }
  4093. else{
  4094. playerids[keys[i]].playerData2.xvel = (playerids[keys[i]].playerData2.px - playerids[keys[i]].playerData.transform.position.x)/(playerids[keys[i]].playerData2.timeStamp-now);
  4095. playerids[keys[i]].playerData2.yvel = (playerids[keys[i]].playerData2.py - playerids[keys[i]].playerData.transform.position.y)/(playerids[keys[i]].playerData2.timeStamp-now);
  4096. playerids[keys[i]].playerData2.px = playerids[keys[i]].playerData.transform.position.x;
  4097. playerids[keys[i]].playerData2.py = playerids[keys[i]].playerData.transform.position.y;
  4098. playerids[keys[i]].playerData2.timeStamp = now;
  4099. }
  4100. if(playerids[keys[i]].playerData2.timeStamp2 == 0){
  4101. playerids[keys[i]].playerData2.pvx = playerids[keys[i]].playerData2.xvel;
  4102. playerids[keys[i]].playerData2.pvx = playerids[keys[i]].playerData2.yvel;
  4103. playerids[keys[i]].playerData2.timeStamp2 = now;
  4104. }
  4105. else{
  4106. playerids[keys[i]].playerData2.xacc = (playerids[keys[i]].playerData2.pvx - playerids[keys[i]].playerData2.xvel)/((playerids[keys[i]].playerData2.timeStamp2-now)**2);
  4107. playerids[keys[i]].playerData2.yacc = (playerids[keys[i]].playerData2.pvy - playerids[keys[i]].playerData2.yvel)/((playerids[keys[i]].playerData2.timeStamp2-now)**2);
  4108. playerids[keys[i]].playerData2.pvx = playerids[keys[i]].playerData2.xvel;
  4109. playerids[keys[i]].playerData2.pvx = playerids[keys[i]].playerData2.yvel;
  4110. playerids[keys[i]].playerData2.timeStamp2 = now;
  4111. }
  4112. }
  4113. else{
  4114. if(playerids[keys[i]].playerData2.alive){
  4115.  
  4116. }
  4117. playerids[keys[i]].playerData2.alive = false;
  4118. }
  4119. }
  4120. else{
  4121. playerids[keys[i]].playerData2 = {"alive":true,radius:12,timeStamp:0,timeStamp2:0,px:0,py:0,pvx:0,pvy:0,xacc:0,yacc:0,xvel:0,yvel:0};
  4122. }
  4123. }
  4124. }
  4125. if(pollactive[0] && pollactive[2]<now && ishost){
  4126. playerids[myid].ratelimit.poll = Date.now();
  4127. SEND("42"+JSON.stringify([4,{"type":"poll end","from":username}]));
  4128. var count = [0,0,0,0];
  4129. var keys = Object.keys(playerids);
  4130. for(var i = 0;i<keys.length;i++){
  4131. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive[3].length-1){
  4132. count[playerids[keys[i]].vote.poll]++;
  4133. }
  4134. playerids[keys[i]].vote.poll = -1;
  4135. }
  4136. displayInChat("The poll ended due to time.","#DA0808","#1EBCC1");
  4137. for(var i = 0;i<count.length;i++){
  4138. if(count[i]>1){
  4139. displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  4140. }
  4141. if(count[i]==1){
  4142. displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  4143. }
  4144. }
  4145. displayInChat("The poll was:","#DA0808","#1EBCC1");
  4146. for(var i = 0;i<pollactive[3].length;i++){
  4147. displayInChat(letters[i]+") "+pollactive[3][i],"#DA0808","#1EBCC1");
  4148. }
  4149. pollactive = [false,0,0,[]];
  4150. }
  4151. if(afkkill>0 && ishost){
  4152. var keys = Object.keys(playerids);
  4153. currentFrame = Math.floor((now - gameStartTimeStamp)/1000*30);
  4154. for(var i = 0; i<keys.length;i++){
  4155. if(typeof(playerids[keys[i]].lastmove)=="undefined"){
  4156. playerids[keys[i]].lastmove = now;
  4157. }
  4158. else{
  4159. if(playerids[keys[i]].playerData2?.alive && now-playerids[keys[i]].lastmove>=afkkill*1000 && now-gameStartTimeStamp>=afkkill*1000 && !killedids.includes(keys[i])){
  4160. killedids.push(keys[i]);
  4161. SEND('42[25,{"a":{"playersLeft":['+keys[i]+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  4162. RECIEVE('42[31,{"a":{"playersLeft":['+keys[i]+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  4163. break;
  4164. }
  4165. }
  4166. }
  4167. }
  4168. if(ishost && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS"){
  4169. clearmaprequests.style["display"] = "block";
  4170. refreshmaprequests.style["display"] = "block";
  4171. }
  4172. else{
  4173. clearmaprequests.style["display"] = "none";
  4174. refreshmaprequests.style["display"] = "none";
  4175. }
  4176. if(Gdocument.getElementById("gamerenderer").style["visibility"]=="hidden"){
  4177. Gdocument.getElementById("ingamewinner_scores").style["visibility"] = "unset";;
  4178. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  4179. }
  4180. if(Gdocument.getElementById("maploadwindowmapscontainer").children.length>0 && maponclick == 0){
  4181. maponclick = Gdocument.getElementById("maploadwindowmapscontainer").children[0].onclick;
  4182. }
  4183.  
  4184. if(Gdocument.getElementById("sm_connectingContainer").style["visibility"] == "hidden"){
  4185. var chatbox = Gdocument.getElementById("newbonklobby_chat_content");
  4186. while (chatbox.firstChild) {
  4187. chatbox.removeChild(chatbox.firstChild);
  4188. }
  4189. rcaps_flag = false;
  4190. space_flag = false;
  4191. number_flag = false;
  4192. reverse_flag = false;
  4193. echo_list = [];
  4194. scroll = false;
  4195. FollowCam = false;
  4196. stopquickplay = 1;
  4197. roundsperqp = 1;
  4198. roundsperqp2 = 0;
  4199. checkboxhidden = false;
  4200. freejoin = false;
  4201. shuffle = false;
  4202. defaultmode = "";
  4203. recmodebool = false;
  4204. recteams = false;
  4205. autorecord = false;
  4206. pollactive = [false,0,0,[]];
  4207. pollactive2 = [false,0,[]];
  4208. afkkill = -1;
  4209. nextafter = 0;
  4210. jointext = "";
  4211. ishost = false;
  4212. sandboxplayerids = {};
  4213. sandboxcopyme = false;
  4214. wintext = "";
  4215. sandboxon = false;
  4216. sandboxid = 1;
  4217. disabledkeys = [];
  4218. myid = -1;
  4219. qppaused = false;
  4220. nextafterbuffer = -1;
  4221. hostid = -1;
  4222. if(chatlog[chatlog.length-1]!="ROOM END"){
  4223. chatlog.push("ROOM END");
  4224. }
  4225. }
  4226. else{
  4227. if(chatlog[chatlog.length-1]=="ROOM END"){
  4228. chatlog.push("ROOM START");
  4229. }
  4230.  
  4231. }
  4232.  
  4233. if(Gdocument.getElementById("newbonklobby").style["display"]=="block"){
  4234. Gdocument.getElementById("ingamechatinputtext").style["visibility"]="hidden";
  4235. }
  4236. else{
  4237. Gdocument.getElementById("ingamechatinputtext").style["visibility"]="visible";
  4238.  
  4239. }
  4240. mode = Gdocument.getElementById("newbonklobby_modetext").textContent;
  4241. if(Gdocument.getElementsByClassName('newbonklobby_settings_button brownButton brownButton_classic buttonShadow brownButtonDisabled').length == 0 && Gdocument.getElementById("newbonklobby_playerbox_elementcontainer").children.length+Gdocument.getElementById("newbonklobby_specbox_elementcontainer").children.length-3
  4242. >0){
  4243. ishost = true;
  4244. }
  4245. else{
  4246. ishost = actuallyhost;
  4247. }
  4248.  
  4249. if(Gdocument.getElementById("pretty_top_name")!=null){
  4250. username = Gdocument.getElementById("pretty_top_name").textContent;
  4251. if(myid!=-1){
  4252. username = playerids[myid].userName;
  4253. }
  4254. }
  4255. try{
  4256. Last_message = lastmessage()
  4257. } catch{
  4258. Last_message = "";
  4259. }
  4260. if (Laster_message != Last_message){
  4261. Laster_message = Last_message;
  4262. if(changed_chat==false){
  4263. new_message = true;
  4264. }
  4265. else{
  4266. changed_chat = false;
  4267. }
  4268. }
  4269. if(new_message){
  4270. chatlog.push(Last_message);
  4271. var lm = "";
  4272. try{
  4273. lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  4274. if(typeof(lm[0].parentElement.style["parsed"]) == 'undefined'){
  4275. if (lm[0].className == "newbonklobby_chat_msg_colorbox"){
  4276. lm[2].innerHTML = urlify(lm[2].innerHTML);
  4277. Laster_message = lastmessage();
  4278. lm[0].parentElement.style["parsed"] = true;
  4279. }
  4280. if (lm[0].className == "newbonklobby_chat_status"){
  4281. lm[0].innerHTML = urlify(lm[0].innerHTML);
  4282. Laster_message = lastmessage();
  4283. lm[0].parentElement.style["parsed"] = true;
  4284. }
  4285. }
  4286. }
  4287. catch{
  4288. lm = "";
  4289. }
  4290.  
  4291. if(Last_message.indexOf("@"+username)!=-1 && npermissions == 1){
  4292. if(Notification.requestPermission()){
  4293. var n = new Notification(Last_message);
  4294. }
  4295. }
  4296.  
  4297. try{
  4298. lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  4299. if(typeof(lm[0].parentElement.style["parsed"])=='undefined'){
  4300. if(lm[0].className == "ingamechatname"){
  4301. lm[1].innerHTML = urlify(lm[1].innerHTML);
  4302. Laster_message = lastmessage();
  4303. lm[0].parentElement.style["parsed"] = true;
  4304. }
  4305. if(lm[0].className == ""){
  4306. lm[0].innerHTML = urlify(lm[0].innerHTML);
  4307. Laster_message = lastmessage();
  4308. lm[0].parentElement.style["parsed"] = true;
  4309. }
  4310. }
  4311. }
  4312. catch{
  4313. lm = "";
  4314. }
  4315.  
  4316. if(text2speech){
  4317. if(!sayer.speaking){
  4318. if(Last_message.includes(": ")){
  4319. speech.text = Last_message.substring(0,Last_message.indexOf(":")).toLowerCase();
  4320. speech.rate = 2.25;
  4321. sayer.speak(speech);
  4322. speech.text = Last_message.substring(Last_message.indexOf(": ")+3).toLowerCase();
  4323. speech.rate = 1.25;
  4324. sayer.speak(speech);
  4325. }
  4326. else{
  4327. speech.text = Last_message.toLowerCase();
  4328. sayer.speak(speech);
  4329. }
  4330. }
  4331. }
  4332. }
  4333. if (ishost==true && new_message){
  4334. for(i=0;i<banned.length;i++){
  4335. if(Last_message.startsWith("* "+banned[i]+" has joined the game")){
  4336. chat2("/kick '"+banned[i]+"'");
  4337. }
  4338. }
  4339. }
  4340. if(Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden" && ishost){
  4341. roundsperqp2 = 0;
  4342. }
  4343. if(Gdocument.getElementById("ingamewinner").style["visibility"]=="inherit" && ishost){
  4344. if(Gdocument.getElementById("ingamewinner").style["parsed"] != true){
  4345. if(stopquickplay!=1){
  4346. roundsperqp2++;
  4347. }
  4348. if(autorecord){
  4349. Gdocument.getElementById("pretty_top_replay").click();
  4350. }
  4351. }
  4352. if(Gdocument.getElementById("ingamewinner").style["parsed"] != true && wintext!="" && Gdocument.getElementById("ingamewinner_bottom").textContent!="DRAW"){
  4353. chat(flag_manage(wintext.replaceAll("username",Gdocument.getElementById("ingamewinner_top").textContent)));
  4354. }
  4355. Gdocument.getElementById("ingamewinner").style["parsed"] = true;
  4356. }
  4357. else{
  4358. Gdocument.getElementById("ingamewinner").style["parsed"] = false;
  4359. }
  4360. if(ishost && stopquickplay == 0){
  4361. if(checkboxhidden){
  4362. checkboxhidden = false;
  4363. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  4364. for(var i = 0; i<classes.length;i++){
  4365. classes[i].style["display"] = "block";
  4366. classes[i].className = "quickplaycheckbox quickplaychecked";
  4367. }
  4368. Gdocument.getElementById('clearallcheckboxes').style["display"] = "block";
  4369.  
  4370. }
  4371. if(nextafter>0 && gameStartTimeStamp+nextafter*1000<=now && Gdocument.getElementById("gamerenderer").style["visibility"] != "hidden" && dontswitch == false && Gdocument.getElementById("ingamewinner").style["visibility"]!="inherit" && !qppaused){
  4372. roundsperqp2 = 0;
  4373. if(shuffle){
  4374. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4375. var available = [];
  4376. var availableindexes = [];
  4377. var notempty = false;
  4378. for(var i = 0; i<e.length;i++){
  4379. var a = false;
  4380. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4381. available.push(a);
  4382. if(a){
  4383. availableindexes.push(i);
  4384. notempty = true;
  4385. }
  4386. }
  4387. if(notempty){
  4388.  
  4389. if(availableindexes.length!=1){
  4390. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  4391. }
  4392. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  4393. }
  4394. }
  4395. else{
  4396. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4397. var available = [];
  4398. var availableindexes = [];
  4399. var notempty = false;
  4400. for(var i = 0; i<e.length;i++){
  4401. var a = false;
  4402. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4403. available.push(a);
  4404. if(a){
  4405. availableindexes.push(i);
  4406. notempty = true;
  4407. }
  4408. }
  4409. if(notempty){
  4410. var above = [];
  4411. for(var i = 0;i<availableindexes.length;i++){
  4412. if(availableindexes[i]>quicki){
  4413. above.push(availableindexes[i]);
  4414. }
  4415. }
  4416. if(above.length>0){
  4417. quicki = above[0];
  4418. }
  4419. else{
  4420. quicki = availableindexes[0];
  4421. }
  4422. }
  4423. }
  4424. startedinqp = true;
  4425. dontswitch = true;
  4426. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  4427. }
  4428. if(Gdocument.getElementById("ingamewinner").style["visibility"]=="inherit" && dontswitch == false && !document.hidden && !qppaused){
  4429. if(roundsperqp2>=roundsperqp){
  4430. if(shuffle){
  4431. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4432. var available = [];
  4433. var availableindexes = [];
  4434. var notempty = false;
  4435. for(var i = 0; i<e.length;i++){
  4436. var a = false;
  4437. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4438. available.push(a);
  4439. if(a){
  4440. availableindexes.push(i);
  4441. notempty = true;
  4442. }
  4443. }
  4444. if(notempty){
  4445.  
  4446. if(availableindexes.length!=1){
  4447. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  4448. }
  4449. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  4450. }
  4451. }
  4452. else{
  4453. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4454. var available = [];
  4455. var availableindexes = [];
  4456. var notempty = false;
  4457. for(var i = 0; i<e.length;i++){
  4458. var a = false;
  4459. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4460. available.push(a);
  4461. if(a){
  4462. availableindexes.push(i);
  4463. notempty = true;
  4464. }
  4465. }
  4466. if(notempty){
  4467. var above = [];
  4468. for(var i = 0;i<availableindexes.length;i++){
  4469. if(availableindexes[i]>quicki){
  4470. above.push(availableindexes[i]);
  4471. }
  4472. }
  4473. if(above.length>0){
  4474. quicki = above[0];
  4475. }
  4476. else{
  4477. quicki = availableindexes[0];
  4478. }
  4479. }
  4480. }
  4481. }
  4482. transitioning = true;
  4483. startedinqp = true;
  4484. map(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  4485. dontswitch = true;
  4486. setTimeout(function(){Gdocument.getElementById("ingamewinner").style["visibility"]="hidden"; dontswitch = false;},timedelay);
  4487.  
  4488. }
  4489. }
  4490. else{
  4491. if(!checkboxhidden){
  4492. checkboxhidden = true;
  4493. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  4494. for(var i = 0; i<classes.length;i++){
  4495. classes[i].style["display"] = "none";
  4496. classes[i].className = "quickplaycheckbox quickplayunchecked";
  4497. }
  4498. Gdocument.getElementById('clearallcheckboxes').style["display"] = "none";
  4499. }
  4500. }
  4501. new_message = false;
  4502. };
  4503. });
  4504.  
Add Comment
Please, Sign In to add comment