Bonk Commands

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

当前为 2023-01-28 提交的版本,查看 最新版本

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

QingJ © 2025

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