Bonk Commands

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

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

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

QingJ © 2025

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