Bonk Commands

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

当前为 2023-02-11 提交的版本,查看 最新版本

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

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址