Bonk Commands

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

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

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

QingJ © 2025

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