Bonk Commands

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

当前为 2023-03-14 提交的版本,查看 最新版本

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

QingJ © 2025

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