LEGENDBOSS123

Bonk.io Aimbot

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