Bonk Commands

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

当前为 2022-12-07 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Bonk Commands
  3. // @namespace https://gf.qytechs.cn/en/scripts/451341-bonk-commands
  4. // @version 8.6
  5. // @description Adds lots of commands to bonk.io. Type /? or /help in bonk chat to get started.
  6. // @author LEGENDBOSS123 + left paren + mastery3
  7. // @match https://bonk.io/*
  8. // @run-at document-idle
  9. // @grant none
  10. // @unwrap
  11. // ==/UserScript==
  12. function BonkCommandsScriptInjector(f){
  13. if(window.location == window.parent.location){
  14. if(document.readyState == "complete"){f();}
  15. else{document.addEventListener('readystatechange',function(){setTimeout(f,1500);});}
  16. }
  17. }
  18.  
  19. BonkCommandsScriptInjector(function(){
  20. var scope = window;
  21.  
  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.  
  77. scope.GENERATE_KEYS = function(){
  78. interval = [];
  79. for(var i = 100;i<301;i++){
  80. interval.push(i);
  81. }
  82. random_prime = [GENERATE_PRIME_NUMBER(0,0,choices = interval),0];
  83. interval.splice(interval.indexOf(random_prime[0]),1);
  84. random_prime[1] = GENERATE_PRIME_NUMBER(0,0,choices = interval);
  85.  
  86. n = random_prime[0]*random_prime[1];
  87. n2 = (random_prime[0]-1)*(random_prime[1]-1);
  88.  
  89. e = GENERATE_COPRIME_NUMBER(2,n2-1,n2);
  90. d = 0;
  91. redo = true;
  92. for(var i = 0;i<1000000;i++){
  93. if((e*i-1)%n2 == 0 && i!=e){
  94. d = i;
  95. redo = false;
  96. break;
  97. }
  98. }
  99. if(redo){
  100. return GENERATE_KEYS();
  101. }
  102. else{
  103. return [[n,e],[n,d]];
  104. }
  105.  
  106. };
  107. scope.CRYPT_NUMBER = function(key, data){
  108.  
  109. result = 1;
  110.  
  111. for(var i = 0;i<key[1];i++){
  112. result*=data;
  113. result = result%key[0];
  114. }
  115. return result%key[0];
  116.  
  117. };
  118.  
  119. scope.CRYPT_MESSAGE = function(key,data){
  120. var resulttext = [];
  121. for(var i = 0;i<data.length;i++){
  122. resulttext.push(CRYPT_NUMBER(key,data[i]));
  123. }
  124. return resulttext;
  125.  
  126. };
  127.  
  128. if(typeof(scope.originalSend)=='undefined'){scope.originalSend = Gwindow.WebSocket.prototype.send;}
  129. if(typeof(scope.originalXMLOpen)=='undefined'){scope.originalXMLOpen = Gwindow.XMLHttpRequest.prototype.open;}
  130. if(typeof(scope.originalXMLSend)=='undefined'){scope.originalXMLSend = Gwindow.XMLHttpRequest.prototype.send;}
  131. if(typeof(scope.searchrequested)=='undefined'){scope.searchrequested = false;}
  132. if(typeof(scope.originalmanualscroll)=='undefined'){scope.originalmanualscroll = null;}
  133.  
  134. if(typeof(scope.bonkwss)=='undefined'){scope.bonkwss = 0;}
  135. if(typeof(scope.chatlog)=='undefined'){scope.chatlog = ["ROOM START"];}
  136. if(typeof(scope.wsssendrecievelog)=='undefined'){scope.wsssendrecievelog = [];}
  137. if(typeof(scope.wsssendlog)=='undefined'){scope.wsssendlog = [];}
  138. if(typeof(scope.wssrecievelog)=='undefined'){scope.wssrecievelog = [];}
  139. if(typeof(scope.wsslogpaused)=='undefined'){scope.wsslogpaused = false;}
  140. if(typeof(scope.debuggeropen)=='undefined'){scope.debuggeropen = false;}
  141. if(typeof(scope.debuggercount)=='undefined'){scope.debuggercount = true;}
  142. if(typeof(scope.packetcount)=='undefined'){scope.packetcount = 0;}
  143. if(typeof(scope.requestedmaps)=='undefined'){scope.requestedmaps = [];}
  144. if(typeof(scope.maponclick)=='undefined'){scope.maponclick = 0;}
  145. if(typeof(scope.LZString)=='undefined'){scope.LZString = Gwindow.LZString;}
  146. if(typeof(scope.PSON)=='undefined'){scope.PSON = Gwindow.dcodeIO.PSON;}
  147. if(typeof(scope.bytebuffer)=='undefined'){scope.bytebuffer = Gwindow.dcodeIO.ByteBuffer;}
  148. 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]);}
  149. if(typeof(scope.sandboxon)=='undefined'){scope.sandboxon = false;}
  150. if(typeof(scope.sandboxid)=='undefined'){scope.sandboxid = 1;}
  151. if(typeof(scope.playerids)=='undefined'){scope.playerids = {};}
  152. if(typeof(scope.sandboxplayerids)=='undefined'){scope.sandboxplayerids = {};}
  153. if(typeof(scope.originalMapLoad)=='undefined'){scope.originalMapLoad = Gdocument.getElementById("maploadwindowmapscontainer").appendChild;}
  154. if(typeof(scope.originalLobbyChat)=='undefined'){scope.originalLobbyChat = Gdocument.getElementById("newbonklobby_chat_content").appendChild;}
  155. if(typeof(scope.originalIngameChat)=='undefined'){scope.originalIngameChat = Gdocument.getElementById("ingamechatcontent").appendChild;}
  156. 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];}
  157. if(Gdocument.getElementById("maploadtypedropdowntitlerequested") == null){
  158. scope.clearmaprequests = Gdocument.createElement("div");
  159. clearmaprequests.id = "clearmaprequests";
  160. clearmaprequests.classList.value = "brownButton brownButton_classic buttonShadow";
  161. clearmaprequests.textContent = "Clear";
  162. clearmaprequests.style["position"] = "absolute";
  163. clearmaprequests.style["display"] = "none";
  164. if(typeof(ishost)!='undefined'){
  165. if(ishost && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS"){
  166. clearmaprequests.style["display"] = "block";
  167. }
  168. }
  169. clearmaprequests.style["right"] = "306px";
  170. clearmaprequests.style["top"] = "57px";
  171. clearmaprequests.style["height"] = "23px";
  172. clearmaprequests.style["width"] = "47px";
  173. clearmaprequests.style["line-height"] = "23px";
  174. clearmaprequests.style["font-size"] = "14px";
  175. clearmaprequests.addEventListener("click",function(){
  176. requestedmaps = [];
  177. Gdocument.getElementById("maploadwindowstatustext").style["visibility"] = "inherit";
  178. Gdocument.getElementById("maploadwindowstatustext").textContent = "No Maps";
  179. while(Gdocument.getElementById("maploadwindowmapscontainer").children.length>0){
  180. Gdocument.getElementById("maploadwindowmapscontainer").removeChild(Gdocument.getElementById("maploadwindowmapscontainer").firstChild);
  181. }
  182. });
  183. Gdocument.getElementById("maploadwindow").insertBefore(clearmaprequests,Gdocument.getElementById("maploadwindowsearchinput"));
  184. scope.refreshmaprequests = Gdocument.createElement("div");
  185. refreshmaprequests.id = "refreshmaprequests";
  186. refreshmaprequests.classList.value = "brownButton brownButton_classic buttonShadow";
  187. refreshmaprequests.textContent = "Refresh";
  188. refreshmaprequests.style["position"] = "absolute";
  189. refreshmaprequests.style["display"] = "none";
  190. if(typeof(ishost)!='undefined'){
  191. if(ishost && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS"){
  192. refreshmaprequests.style["display"] = "block";
  193. }
  194. }
  195. refreshmaprequests.style["right"] = "357px";
  196. refreshmaprequests.style["top"] = "57px";
  197. refreshmaprequests.style["height"] = "23px";
  198. refreshmaprequests.style["width"] = "47px";
  199. refreshmaprequests.style["line-height"] = "23px";
  200. refreshmaprequests.style["font-size"] = "14px";
  201. refreshmaprequests.addEventListener("click",function(){
  202. Gdocument.getElementById("maploadtypedropdowntitle").textContent = dropdownrequested.textContent;
  203. Gdocument.getElementById("maploadwindowsearchinput").value = "";
  204. dropdownrequested.style["display"] = "none";
  205. clearmaprequests.style["display"] = "block";
  206. refreshmaprequests.style["display"] = "block";
  207. Gdocument.getElementById("maploadwindowhotnessslider").style["visibility"] = "hidden";
  208. Gdocument.getElementById("maploadwindowsearchoptions").style["visibility"] = "hidden";
  209. searchrequested = true;
  210. Gdocument.getElementById("maploadwindowsearchbutton").click();
  211.  
  212. Gdocument.getElementById("maploadtypedropdowntitle").textContent = "MAP REQUESTS";
  213. });
  214. Gdocument.getElementById("maploadwindow").insertBefore(refreshmaprequests,Gdocument.getElementById("maploadwindowsearchinput"));
  215.  
  216. scope.dropdownrequested = Gdocument.createElement("div");
  217. dropdownrequested.classList = "dropdown-option dropdown_classic";
  218. dropdownrequested.style["display"] = "none";
  219. dropdownrequested.id = "maploadtypedropdowntitlerequested";
  220.  
  221. if(Gdocument.getElementById("maploadtypedropdownoption10").style["display"] == "block"){
  222. dropdownrequested.style["display"] = "block";
  223. }
  224. dropdownrequested.textContent = "MAP REQUESTS";
  225. dropdownrequested.onclick = function(){
  226. Gdocument.getElementById("maploadtypedropdowntitle").textContent = dropdownrequested.textContent;
  227. Gdocument.getElementById("maploadwindowsearchinput").value = "";
  228. dropdownrequested.style["display"] = "none";
  229. clearmaprequests.style["display"] = "block";
  230. refreshmaprequests.style["display"] = "block";
  231. Gdocument.getElementById("maploadwindowhotnessslider").style["visibility"] = "hidden";
  232. Gdocument.getElementById("maploadwindowsearchoptions").style["visibility"] = "hidden";
  233. searchrequested = true;
  234. Gdocument.getElementById("maploadwindowsearchbutton").click();
  235.  
  236. Gdocument.getElementById("maploadtypedropdowntitle").textContent = "MAP REQUESTS";
  237. };
  238. (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});
  239. Gdocument.getElementById("maploadtypedropdown").insertBefore(dropdownrequested,Gdocument.getElementById("maploadtypedropdownoption1"));
  240. };
  241.  
  242. function sandboxonclick(){
  243. Gdocument.getElementById("roomlistcreatewindowmaxplayers").value = 1;
  244. Gdocument.getElementById("roomlistcreatewindowunlistedcheckbox").checked = true;
  245. Gdocument.getElementById("roomlistcreatecreatebutton").click();
  246. sandboxon = true;
  247. }
  248. function checkboxclearbuttononclick(){
  249. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  250. var e = true;
  251. for(var i = 0; i<classes.length;i++){
  252. if(classes[i].checked == true){
  253. e = false
  254. }
  255. classes[i].checked = false;
  256. }
  257. if(e){
  258. for(var i = 0; i<classes.length;i++){
  259. classes[i].checked = true;
  260. }
  261. }
  262. }
  263. if(Gdocument.getElementById("classic_mid_sandbox")==null){
  264. Gdocument.getElementById("roomlistrefreshbutton").click();
  265. scope.sandboxbutton = Gdocument.createElement("div");
  266. sandboxbutton.id = "classic_mid_sandbox";
  267. sandboxbutton.classList.value = "brownButton brownButton_classic classic_mid_buttons";
  268. sandboxbutton.textContent = "Sandbox";
  269. sandboxbutton.addEventListener("click",sandboxonclick);
  270. Gdocument.getElementById("classic_mid").insertBefore(sandboxbutton,Gdocument.getElementById("classic_mid_news"));
  271.  
  272. }
  273. if(Gdocument.getElementById("clearallcheckboxes")==null){
  274. scope.checkboxclearbutton = Gdocument.createElement("div");
  275. checkboxclearbutton.id = "clearallcheckboxes";
  276. checkboxclearbutton.classList.value = "brownButton brownButton_classic buttonShadow";
  277. checkboxclearbutton.textContent = "On/Off";
  278. checkboxclearbutton.style["position"] = "absolute";
  279. checkboxclearbutton.style["display"] = "none";
  280. if(typeof(ishost)!='undefined'){
  281. if(ishost && stopquickplay == 0){
  282. checkboxclearbutton.style["display"] = "block";
  283. }
  284. }
  285. checkboxclearbutton.style["right"] = "255px";
  286. checkboxclearbutton.style["top"] = "57px";
  287. checkboxclearbutton.style["height"] = "23px";
  288. checkboxclearbutton.style["width"] = "47px";
  289. checkboxclearbutton.style["line-height"] = "23px";
  290. checkboxclearbutton.style["font-size"] = "13px";
  291. checkboxclearbutton.addEventListener("click",checkboxclearbuttononclick);
  292. Gdocument.getElementById("maploadwindow").insertBefore(checkboxclearbutton,Gdocument.getElementById("maploadwindowsearchinput"));
  293.  
  294. }
  295. if(Gdocument.getElementById("BonkCommandsDebuggerContainer")==null){
  296. Gdocument.getElementById("leaveconfirmwindow").style["z-index"]=3;
  297. scope.debuggermenu = Gdocument.createElement("div");
  298. debuggermenu.id = "BonkCommandsDebuggerContainer";
  299. debuggermenu.style["position"] = "absolute";
  300. debuggermenu.style["display"] = "none";
  301. if(typeof(debuggeropen)!='undefined'){
  302. if(debuggeropen){
  303. debuggermenu.style["display"] = "block";
  304. }
  305. }
  306. debuggermenu.style["width"] = Gdocument.getElementById("bonkiocontainer").style["width"];
  307. debuggermenu.style["height"] = Gdocument.getElementById("bonkiocontainer").style["height"];
  308.  
  309. debuggermenu.style["background"] = "rgb(26, 39, 51)";
  310.  
  311. scope.width = parseInt(Gdocument.getElementById("bonkiocontainer").style["width"])-20;
  312. scope.height = parseInt(Gdocument.getElementById("bonkiocontainer").style["height"])-210;
  313.  
  314. scope.logmenu = Gdocument.createElement("div");
  315. logmenu.id = "BonkCommandsWebSocketLog";
  316. logmenu.style["position"] = "absolute";
  317. logmenu.style["width"] = width.toString()+"px";
  318. logmenu.style["height"] = height.toString()+"px";
  319. logmenu.style["top"] = "80px";
  320. logmenu.style["left"] = "10px";
  321. logmenu.style["background"] = "rgb(207, 216, 220)";
  322. scope.logmenutopleft = Gdocument.createElement("div");
  323. logmenutopleft.id = "BonkCommandsWebSocketLog";
  324. logmenutopleft.style["position"] = "absolute";
  325. logmenutopleft.textContent = "Sending";
  326. logmenutopleft.classList = "newbonklobby_boxtop newbonklobby_boxtop_classic";
  327. logmenutopleft.style["width"] = (width/2).toString()+"px";
  328. logmenutopleft.style["height"] = "30px";
  329. logmenutopleft.style["top"] = "-30px";
  330. logmenutopleft.style["background"] = "rgb(0, 150, 136)";
  331. logmenu.appendChild(logmenutopleft);
  332. scope.logmenutopright = Gdocument.createElement("div");
  333. logmenutopright.id = "BonkCommandsWebSocketLog";
  334. logmenutopright.style["position"] = "absolute";
  335. logmenutopright.textContent = "Recieving";
  336. logmenutopright.classList = "newbonklobby_boxtop newbonklobby_boxtop_classic";
  337. logmenutopright.style["width"] = (width/2).toString()+"px";
  338. logmenutopright.style["height"] = "30px";
  339. logmenutopright.style["left"] = (width/2).toString()+"px";
  340. logmenutopright.style["top"] = "-30px";
  341. logmenutopright.style["background"] = "rgb(0, 150, 136)";
  342. logmenu.appendChild(logmenutopright);
  343. scope.logmenutable = Gdocument.createElement("table");
  344. logmenutable.id = "BonkCommandsWebSocketTable";
  345. logmenutable.style["position"] = "absolute";
  346. logmenutable.style["border-spacing"] = "0px";
  347. logmenutable.style["font-size"] = "12px";
  348. logmenutable.style["display"] = "table-cell";
  349. logmenutable.style["width"] = "50%";
  350. logmenutable.style["height"] = "100%";
  351. logmenutable.style["table-layout"] = "fixed";
  352. logmenutable.style["overflow-y"] = "scroll";
  353.  
  354. scope.logmenutable2 = Gdocument.createElement("table");
  355. logmenutable2.id = "BonkCommandsWebSocketTable2";
  356. logmenutable2.style["position"] = "absolute";
  357. logmenutable2.style["width"] = "50%";
  358. logmenutable2.style["left"] = "50%";
  359. logmenutable2.style["font-size"] = "12px";
  360. logmenutable2.style["display"] = "table-cell";
  361. logmenutable2.style["height"] = "100%";
  362. logmenutable2.style["table-layout"] = "fixed";
  363. logmenutable2.style["overflow-y"] = "scroll";
  364. logmenutable2.style["border-spacing"] = "0px";
  365. scope.leftsync = false;
  366. scope.rightsync = false;
  367. logmenutable2.onscroll = function(){
  368. if(!leftsync){
  369. rightsync = true;
  370. logmenutable.scrollTop = this.scrollTop;
  371. }
  372. else{
  373. leftsync = false;
  374. }
  375. };
  376. logmenutable.onscroll = function(){
  377. if(!rightsync){
  378. leftsync = true;
  379. logmenutable2.scrollTop = this.scrollTop;
  380. }
  381. else{
  382. rightsync = false
  383. }
  384. };
  385. logmenu.appendChild(logmenutable);
  386. logmenu.appendChild(logmenutable2);
  387. debuggermenu.appendChild(logmenu);
  388. scope.debuggermenuclose = Gdocument.createElement("div");
  389. debuggermenuclose.id = "debuggerclose";
  390. debuggermenuclose.classList = "windowCloseButton brownButton brownButton_classic buttonShadow";
  391. debuggermenuclose.style["position"] = "absolute";
  392. debuggermenuclose.style["top"] = "40px";
  393. debuggermenuclose.style["right"] = "5px";
  394. debuggermenuclose.onclick = function(){debuggeropen = false;debuggermenu.style["display"] = "none";Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  395. Gdocument.getElementById("ingamechatinputtext").style["display"] = "";};
  396. debuggermenu.appendChild(debuggermenuclose);
  397. scope.debuggerform = Gdocument.createElement("form");
  398. debuggerform.autocomplete = "off";
  399. scope.debuggerinput = Gdocument.createElement("input");
  400. debuggerinput.style["position"] = "absolute";
  401. debuggerinput.style["width"] = width.toString()+"px";
  402. debuggerinput.style["left"] = "10px";
  403. debuggerinput.style["top"] = (height+90).toString()+"px";
  404. debuggerinput.style["font-size"] = "12px";
  405. debuggerinput.style["height"] = "20px";
  406. debuggerform.appendChild(debuggerinput);
  407. scope.debuggersendrecieve = Gdocument.createElement("div");
  408. debuggersendrecieve.style["position"] = "absolute";
  409. debuggersendrecieve.style["width"] = "140px";
  410. debuggersendrecieve.style["left"] = "10px";
  411. debuggersendrecieve.style["top"] = (height+120).toString()+"px";
  412. debuggersendrecieve.style["font-size"] = "15px";
  413. debuggersendrecieve.style["height"] = "20px";
  414. debuggersendrecieve.classList = "brownButton brownButton_classic buttonShadow";
  415. debuggersendrecieve.textContent = "Send";
  416. debuggersendrecieve.value = 0;
  417. debuggersendrecieve.onclick = function(){if(this.value == 0){this.textContent = "Recieve";this.value = 1;}else{this.textContent = "Send";this.value = 0;}};
  418.  
  419. debuggermenu.appendChild(debuggersendrecieve);
  420. scope.debuggerpausebutton = Gdocument.createElement("div");
  421. debuggerpausebutton.style["position"] = "absolute";
  422. debuggerpausebutton.style["width"] = "140px";
  423. debuggerpausebutton.style["left"] = "10px";
  424. debuggerpausebutton.style["top"] = (height+150).toString()+"px";
  425. debuggerpausebutton.style["font-size"] = "15px";
  426. debuggerpausebutton.style["height"] = "20px";
  427. debuggerpausebutton.classList = "brownButton brownButton_classic buttonShadow";
  428. debuggerpausebutton.textContent = "Pause";
  429. debuggerpausebutton.value = 0;
  430. debuggerpausebutton.onclick = function(){if(this.value == 0){this.textContent = "Play";this.value = 1;wsslogpaused = true}else{this.textContent = "Pause";this.value = 0;wsslogpaused = false;}};
  431.  
  432. debuggermenu.appendChild(debuggerpausebutton);
  433. scope.debuggereval = Gdocument.createElement("input");
  434. debuggereval.style["position"] = "absolute";
  435. debuggereval.style["width"] = (width-150).toString()+"px";
  436. debuggereval.style["right"] = "10px";
  437. debuggereval.style["top"] = (height+120).toString()+"px";
  438. debuggereval.style["font-size"] = "12px";
  439. debuggereval.style["height"] = "20px";
  440. debuggereval.addEventListener("keypress",function(e){if(e.repeat){return;}if(e.code == "Enter"){if(debuggersendrecieve.value == 0){SEND(this.value);}else{RECIEVE(this.value);}}});
  441. debuggerform.appendChild(debuggereval);
  442. debuggermenu.appendChild(debuggerform);
  443. Gdocument.getElementById("newbonkgamecontainer").appendChild(debuggermenu);
  444.  
  445. }
  446. scope.ISdecode = function(rawdata) {
  447. rawdata_caseflipped = "";
  448. for (i = 0; i < rawdata.length; i++) {
  449. if (i <= 100 && rawdata.charAt(i) === rawdata.charAt(i).toLowerCase()) {
  450. rawdata_caseflipped += rawdata.charAt(i).toUpperCase();
  451. } else if (i <= 100 && rawdata.charAt(i) === rawdata.charAt(i).toUpperCase()) {
  452. rawdata_caseflipped += rawdata.charAt(i).toLowerCase();
  453. } else {
  454. rawdata_caseflipped += rawdata.charAt(i);
  455. }
  456. }
  457.  
  458. data_deLZd = LZString.decompressFromEncodedURIComponent(rawdata_caseflipped);
  459. databuffer = bytebuffer.fromBase64(data_deLZd);
  460. data = ISpsonpair.decode(databuffer.buffer);
  461. return data;
  462. };
  463. scope.ISencode = function(obj) {
  464. data = ISpsonpair.encode(obj);
  465. b64 = data.toBase64();
  466. lzd = LZString.compressToEncodedURIComponent(b64);
  467.  
  468. caseflipped = "";
  469. for (i = 0; i < lzd.length; i++) {
  470. if (i <= 100 && lzd.charAt(i) === lzd.charAt(i).toLowerCase()) {
  471. caseflipped += lzd.charAt(i).toUpperCase();
  472. } else if (i <= 100 && lzd.charAt(i) === lzd.charAt(i).toUpperCase()) {
  473. caseflipped += lzd.charAt(i).toLowerCase();
  474. } else {
  475. caseflipped += lzd.charAt(i);
  476. }
  477. }
  478.  
  479.  
  480. return caseflipped;
  481. };
  482. scope.decodeIS = function(x){
  483. return ISdecode(x);
  484. };
  485. scope.encodeIS = function(x){
  486. return ISencode(x);
  487. };
  488. bytebuffer.prototype.readBoolean = function() {
  489. return this.readByte() > 0;
  490. };
  491.  
  492. bytebuffer.prototype.readUTF = function() {
  493. return this.readString(this.readShort());
  494. };
  495.  
  496. bytebuffer.prototype.readUint = bytebuffer.prototype.readUint32;
  497.  
  498. scope.decodeFromDatabase = function(map) {
  499. var a8k = [arguments];
  500. b64mapdata = LZString.decompressFromEncodedURIComponent(map);
  501. binaryReader = bytebuffer.fromBase64(b64mapdata, false);
  502. 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": "" } };
  503. map.v = binaryReader.readShort();
  504. if (map.v > 13) {
  505. throw new Error("New map format, this script needs to be updated.");
  506. }
  507. map.s.re = binaryReader.readBoolean();
  508. map.s.nc = binaryReader.readBoolean();
  509. if (map.v >= 3) {
  510. map.s.pq = binaryReader.readShort();
  511. }
  512. if (map.v >= 4 && map.v <= 12) {
  513. map.s.gd = binaryReader.readShort();
  514. } else if (map.v >= 13) {
  515. map.s.gd = binaryReader.readFloat();
  516. }
  517. if (map.v >= 9) {
  518. map.s.fl = binaryReader.readBoolean();
  519. }
  520. map.m.rxn = binaryReader.readUTF();
  521. map.m.rxa = binaryReader.readUTF();
  522. map.m.rxid = binaryReader.readUint();
  523. map.m.rxdb = binaryReader.readShort();
  524. map.m.n = binaryReader.readUTF();
  525. map.m.a = binaryReader.readUTF();
  526. if (map.v >= 10) {
  527. map.m.vu = binaryReader.readUint();
  528. map.m.vd = binaryReader.readUint();
  529. }
  530. if (map.v >= 4) {
  531. cr_count = binaryReader.readShort();
  532. for (cr_iterator = 0; cr_iterator < cr_count; cr_iterator++) {
  533. map.m.cr.push(binaryReader.readUTF());
  534. }
  535. }
  536. if (map.v >= 5) {
  537. map.m.mo = binaryReader.readUTF();
  538. map.m.dbid = binaryReader.readInt();
  539. }
  540. if (map.v >= 7) {
  541. map.m.pub = binaryReader.readBoolean();
  542. }
  543. if (map.v >= 8) {
  544. map.m.dbv = binaryReader.readInt();
  545. }
  546. map.physics.ppm = binaryReader.readShort();
  547. bro_count = binaryReader.readShort();
  548. for (bro_iterator = 0; bro_iterator < bro_count; bro_iterator++) {
  549. map.physics.bro[bro_iterator] = binaryReader.readShort();
  550. }
  551. shape_count = binaryReader.readShort();
  552. for (shape_iterator = 0; shape_iterator < shape_count; shape_iterator++) {
  553. shape_type = binaryReader.readShort();
  554. if (shape_type == 1) {
  555. map.physics.shapes[shape_iterator] = {"type":"bx","w":10,"h":40,"c":[0,0],"a":0,"sk":false};
  556. map.physics.shapes[shape_iterator].w = binaryReader.readDouble();
  557. map.physics.shapes[shape_iterator].h = binaryReader.readDouble();
  558. map.physics.shapes[shape_iterator].c = [binaryReader.readDouble(), binaryReader.readDouble()];
  559. map.physics.shapes[shape_iterator].a = binaryReader.readDouble();
  560. map.physics.shapes[shape_iterator].sk = binaryReader.readBoolean();
  561. }
  562. if (shape_type == 2) {
  563. map.physics.shapes[shape_iterator] = {"type":"ci","r":25,"c":[0,0],"sk":false};
  564. map.physics.shapes[shape_iterator].r = binaryReader.readDouble();
  565. map.physics.shapes[shape_iterator].c = [binaryReader.readDouble(), binaryReader.readDouble()];
  566. map.physics.shapes[shape_iterator].sk = binaryReader.readBoolean();
  567. }
  568. if (shape_type == 3) {
  569. map.physics.shapes[shape_iterator] = {"type":"po","v":[],"s":1,"a":0,"c":[0,0]};
  570. map.physics.shapes[shape_iterator].s = binaryReader.readDouble();
  571. map.physics.shapes[shape_iterator].a = binaryReader.readDouble();
  572. map.physics.shapes[shape_iterator].c = [binaryReader.readDouble(), binaryReader.readDouble()];
  573. point_count = binaryReader.readShort();
  574. map.physics.shapes[shape_iterator].v = [];
  575. for (point_iterator = 0; point_iterator < point_count; point_iterator++) {
  576. map.physics.shapes[shape_iterator].v.push([binaryReader.readDouble(), binaryReader.readDouble()]);
  577. }
  578. }
  579. }
  580. a8k[31] = binaryReader.readShort();
  581. for (a8k[89] = 0; a8k[89] < a8k[31]; a8k[89]++) {
  582. 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};
  583. map.physics.fixtures[a8k[89]].sh = binaryReader.readShort();
  584. map.physics.fixtures[a8k[89]].n = binaryReader.readUTF();
  585. map.physics.fixtures[a8k[89]].fr = binaryReader.readDouble();
  586. if (map.physics.fixtures[a8k[89]].fr == Number.MAX_VALUE) {
  587. map.physics.fixtures[a8k[89]].fr = null;
  588. }
  589. a8k[22] = binaryReader.readShort();
  590. if (a8k[22] == 0) {
  591. map.physics.fixtures[a8k[89]].fp = null;
  592. }
  593. if (a8k[22] == 1) {
  594. map.physics.fixtures[a8k[89]].fp = false;
  595. }
  596. if (a8k[22] == 2) {
  597. map.physics.fixtures[a8k[89]].fp = true;
  598. }
  599. map.physics.fixtures[a8k[89]].re = binaryReader.readDouble();
  600. if (map.physics.fixtures[a8k[89]].re == Number.MAX_VALUE) {
  601. map.physics.fixtures[a8k[89]].re = null;
  602. }
  603. map.physics.fixtures[a8k[89]].de = binaryReader.readDouble();
  604. if (map.physics.fixtures[a8k[89]].de == Number.MAX_VALUE) {
  605. map.physics.fixtures[a8k[89]].de = null;
  606. }
  607. map.physics.fixtures[a8k[89]].f = binaryReader.readUint();
  608. map.physics.fixtures[a8k[89]].d = binaryReader.readBoolean();
  609. map.physics.fixtures[a8k[89]].np = binaryReader.readBoolean();
  610. if (map.v >= 11) {
  611. map.physics.fixtures[a8k[89]].ng = binaryReader.readBoolean();
  612. }
  613. if (map.v >= 12) {
  614. map.physics.fixtures[a8k[89]].ig = binaryReader.readBoolean();
  615. }
  616. }
  617. a8k[41] = binaryReader.readShort();
  618. for (a8k[20] = 0; a8k[20] < a8k[41]; a8k[20]++) {
  619. 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};
  620. map.physics.bodies[a8k[20]].type = binaryReader.readUTF();
  621. map.physics.bodies[a8k[20]].n = binaryReader.readUTF();
  622. map.physics.bodies[a8k[20]].p = [binaryReader.readDouble(), binaryReader.readDouble()];
  623. map.physics.bodies[a8k[20]].a = binaryReader.readDouble();
  624. map.physics.bodies[a8k[20]].fric = binaryReader.readDouble();
  625. map.physics.bodies[a8k[20]].fricp = binaryReader.readBoolean();
  626. map.physics.bodies[a8k[20]].re = binaryReader.readDouble();
  627. map.physics.bodies[a8k[20]].de = binaryReader.readDouble();
  628. map.physics.bodies[a8k[20]].lv = [binaryReader.readDouble(), binaryReader.readDouble()];
  629. map.physics.bodies[a8k[20]].av = binaryReader.readDouble();
  630. map.physics.bodies[a8k[20]].ld = binaryReader.readDouble();
  631. map.physics.bodies[a8k[20]].ad = binaryReader.readDouble();
  632. map.physics.bodies[a8k[20]].fr = binaryReader.readBoolean();
  633. map.physics.bodies[a8k[20]].bu = binaryReader.readBoolean();
  634. map.physics.bodies[a8k[20]].cf.x = binaryReader.readDouble();
  635. map.physics.bodies[a8k[20]].cf.y = binaryReader.readDouble();
  636. map.physics.bodies[a8k[20]].cf.ct = binaryReader.readDouble();
  637. map.physics.bodies[a8k[20]].cf.w = binaryReader.readBoolean();
  638. map.physics.bodies[a8k[20]].f_c = binaryReader.readShort();
  639. map.physics.bodies[a8k[20]].f_1 = binaryReader.readBoolean();
  640. map.physics.bodies[a8k[20]].f_2 = binaryReader.readBoolean();
  641. map.physics.bodies[a8k[20]].f_3 = binaryReader.readBoolean();
  642. map.physics.bodies[a8k[20]].f_4 = binaryReader.readBoolean();
  643. if (map.v >= 2) {
  644. map.physics.bodies[a8k[20]].f_p = binaryReader.readBoolean();
  645. }
  646. a8k[50] = binaryReader.readShort();
  647. for (a8k[66] = 0; a8k[66] < a8k[50]; a8k[66]++) {
  648. map.physics.bodies[a8k[20]].fx.push(binaryReader.readShort());
  649. }
  650. }
  651. a8k[48] = binaryReader.readShort();
  652. for (a8k[36] = 0; a8k[36] < a8k[48]; a8k[36]++) {
  653. 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"};
  654. a8k[80] = map.spawns[a8k[36]];
  655. a8k[80].x = binaryReader.readDouble();
  656. a8k[80].y = binaryReader.readDouble();
  657. a8k[80].xv = binaryReader.readDouble();
  658. a8k[80].yv = binaryReader.readDouble();
  659. a8k[80].priority = binaryReader.readShort();
  660. a8k[80].r = binaryReader.readBoolean();
  661. a8k[80].f = binaryReader.readBoolean();
  662. a8k[80].b = binaryReader.readBoolean();
  663. a8k[80].gr = binaryReader.readBoolean();
  664. a8k[80].ye = binaryReader.readBoolean();
  665. a8k[80].n = binaryReader.readUTF();
  666. }
  667. a8k[40] = binaryReader.readShort();
  668. for (a8k[18] = 0; a8k[18] < a8k[40]; a8k[18]++) {
  669. map.capZones[a8k[18]] = {"n":"Cap Zone","ty":1,"l":10,"i":-1};
  670. map.capZones[a8k[18]].n = binaryReader.readUTF();
  671. map.capZones[a8k[18]].l = binaryReader.readDouble();
  672. map.capZones[a8k[18]].i = binaryReader.readShort();
  673. if (map.v >= 6) {
  674. map.capZones[a8k[18]].ty = binaryReader.readShort();
  675. }
  676. }
  677. a8k[39] = binaryReader.readShort();
  678. for (a8k[94] = 0; a8k[94] < a8k[39]; a8k[94]++) {
  679. a8k[75] = binaryReader.readShort();
  680. if (a8k[75] == 1) {
  681. 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]};
  682. a8k[53] = map.physics.joints[a8k[94]];
  683. a8k[53].d.la = binaryReader.readDouble();
  684. a8k[53].d.ua = binaryReader.readDouble();
  685. a8k[53].d.mmt = binaryReader.readDouble();
  686. a8k[53].d.ms = binaryReader.readDouble();
  687. a8k[53].d.el = binaryReader.readBoolean();
  688. a8k[53].d.em = binaryReader.readBoolean();
  689. a8k[53].aa = [binaryReader.readDouble(), binaryReader.readDouble()];
  690. }
  691. if (a8k[75] == 2) {
  692. map.physics.joints[a8k[94]] = {"type":"d","d":{"fh":0,"dr":0,"cc":false,"bf":0,"dl":true},"aa":[0,0],"ab":[0,0]};
  693. a8k[27] = map.physics.joints[a8k[94]];
  694. a8k[27].d.fh = binaryReader.readDouble();
  695. a8k[27].d.dr = binaryReader.readDouble();
  696. a8k[27].aa = [binaryReader.readDouble(), binaryReader.readDouble()];
  697. a8k[27].ab = [binaryReader.readDouble(), binaryReader.readDouble()];
  698. }
  699. if (a8k[75] == 3) {
  700. 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};
  701. a8k[23] = map.physics.joints[a8k[94]];
  702. a8k[23].pax = binaryReader.readDouble();
  703. a8k[23].pay = binaryReader.readDouble();
  704. a8k[23].pa = binaryReader.readDouble();
  705. a8k[23].pf = binaryReader.readDouble();
  706. a8k[23].pl = binaryReader.readDouble();
  707. a8k[23].pu = binaryReader.readDouble();
  708. a8k[23].plen = binaryReader.readDouble();
  709. a8k[23].pms = binaryReader.readDouble();
  710. }
  711. if (a8k[75] == 4) {
  712. map.physics.joints[a8k[94]] = {"type":"lsj","d":{"cc":false,"bf":0,"dl":true},"sax":0,"say":0,"sf":0,"slen":0};
  713. a8k[47] = map.physics.joints[a8k[94]];
  714. a8k[47].sax = binaryReader.readDouble();
  715. a8k[47].say = binaryReader.readDouble();
  716. a8k[47].sf = binaryReader.readDouble();
  717. a8k[47].slen = binaryReader.readDouble();
  718. }
  719. map.physics.joints[a8k[94]].ba = binaryReader.readShort();
  720. map.physics.joints[a8k[94]].bb = binaryReader.readShort();
  721. map.physics.joints[a8k[94]].d.cc = binaryReader.readBoolean();
  722. map.physics.joints[a8k[94]].d.bf = binaryReader.readDouble();
  723. map.physics.joints[a8k[94]].d.dl = binaryReader.readBoolean();
  724.  
  725. }
  726. return map;
  727. };
  728.  
  729.  
  730. scope.updateWssLog = function(){
  731. if(!wsslogpaused){
  732. if(logmenutable.children.length < wsssendrecievelog.length){
  733. var bottomscroll = logmenutable.clientHeight + logmenutable.scrollTop >= logmenutable.scrollHeight-1;
  734. while (logmenutable.children.length>1000) {
  735. logmenutable.removeChild(logmenutable.firstChild);
  736. logmenutable2.removeChild(logmenutable2.firstChild);
  737. }
  738. var loopthro = wsssendrecievelog.slice(packetcount);
  739. for(var i = 0; i < loopthro.length;i++){
  740. packetcount++;
  741. var row = document.createElement("tr");
  742. var row2 = document.createElement("tr");
  743.  
  744. var cell1 = document.createElement("td");
  745. cell1.style["overflow-x"] = "scroll";
  746. cell1.style["padding"] = "0px";
  747. cell1.style["width"] = "100000px";
  748.  
  749. var cell2 = document.createElement("td");
  750. cell2.style["overflow-x"] = "scroll";
  751. cell2.style["padding"] = "0px";
  752. cell2.style["width"] = "100000px";
  753. if(debuggercount){
  754. cell1.style["background"] = "rgb(178, 185, 189)";
  755. debuggercount = false;
  756. }
  757. else{
  758. cell2.style["background"] = "rgb(178, 185, 189)";
  759. debuggercount = true;
  760. }
  761. cell1.textContent = loopthro[i][1];
  762. cell2.textContent = loopthro[i][1];
  763. if(loopthro[i][0] == 0){
  764. cell2.style["color"] = "transparent";
  765. cell1.onclick = function(){debuggerinput.value = this.textContent};
  766. }
  767. else{
  768. cell1.style["color"] = "transparent";
  769. cell2.onclick = function(){debuggerinput.value = this.textContent};
  770. }
  771. row.appendChild(cell1);
  772. row2.appendChild(cell2);
  773. logmenutable.appendChild(row);
  774. logmenutable2.appendChild(row2);
  775. }
  776. while (logmenutable.children.length>1000) {
  777. logmenutable.removeChild(logmenutable.firstChild);
  778. logmenutable2.removeChild(logmenutable2.firstChild);
  779. }
  780. if(bottomscroll){
  781. logmenutable.scrollTop = logmenutable.scrollHeight;
  782. logmenutable2.scrollTop = logmenutable.scrollHeight;
  783. }
  784. }
  785. }
  786. };
  787. Gdocument.getElementById("maploadwindowmapscontainer").appendChild = function(args){
  788.  
  789. var checkbox = Gdocument.createElement("input");
  790. checkbox.type = "checkbox";
  791. checkbox.style["position"]="absolute";
  792. checkbox.style["margin-top"] = "135px";
  793. checkbox.style["margin-left"] = "140px";
  794. checkbox.style["scale"] = "2";
  795. checkbox.style["display"] = "none";
  796. checkbox.className = "quickplaycheckbox quickplayunchecked";
  797. if(ishost && stopquickplay==0){
  798. checkbox.style["display"] = "block";
  799. checkbox.className = "quickplaycheckbox quickplaychecked";
  800. }
  801. checkbox.checked = true;
  802. checkbox.onclick = function(e){e.stopPropagation();};
  803. args.appendChild(checkbox);
  804. originalMapLoad.call(this,args);
  805. };
  806. Gdocument.getElementById("newbonklobby_chat_content").appendChild = function(args){
  807. if(beenKickedTimeStamp+100>Date.now() && args.children.length>0){
  808. if(args.children[0].textContent.endsWith(" has left the game ") && args.children[0].textContent.startsWith("* ")){
  809. args.children[0].textContent = args.children[0].textContent.substring(0,args.children[0].textContent.length-19)+" has been kicked from the game ";
  810. }
  811. }
  812. originalLobbyChat.call(this,args);
  813. };
  814. Gdocument.getElementById("ingamechatcontent").appendChild = function(args){
  815. if(beenKickedTimeStamp+100>Date.now() && args.children.length>0){
  816. if(args.children[0].textContent.endsWith(" has left the game.") && args.children[0].textContent.startsWith("* ")){
  817. args.children[0].textContent = args.children[0].textContent.substring(0,args.children[0].textContent.length-19)+" has been kicked from the game.";
  818. }
  819. }
  820. if(recordedTimeStamp+100>Date.now() && args.children.length>0){
  821. if(args.children[0].textContent.includes("seconds") && args.children[0].textContent.startsWith("* ")){
  822. args.children[0].textContent = args.children[0].textContent + " - " + playerids[recordedId]
  823. }
  824. }
  825. originalIngameChat.call(this,args);
  826. };
  827. Gwindow.XMLHttpRequest.prototype.open = function(_, url) {
  828. if (url.includes("scripts/map_get") || url.includes("scripts/map_b1_get") || url.includes("scripts/hotmaps/")) {
  829. this.isSearchMap = true;
  830. }
  831. originalXMLOpen.call(this, ...arguments);
  832. };
  833. Gwindow.XMLHttpRequest.prototype.send = function(data) {
  834. if (this.isSearchMap) {
  835. this.onreadystatechange = function () {
  836. if (this.readyState == 4 && searchrequested) {
  837. searchrequested = false;
  838. Gdocument.getElementById("maploadtypedropdowntitle").textContent = "MAP REQUESTS";
  839. var jsonargs = {r:"success",maps:[],more:true};
  840. for(var i = 0; i<requestedmaps.length; i++){
  841. var dec = requestedmaps[i][0];
  842. var undec = requestedmaps[i][1];
  843. var map = {};
  844. map.id = dec["m"]["dbid"];
  845. map.name = dec["m"]["n"];
  846. map.authorname = dec["m"]["a"];
  847. map.leveldata = undec;
  848. map.publisheddate = dec["m"]["date"];
  849. map.remixauthor = dec["m"]["rxa"];
  850. map.remixdb = dec["m"]["rxdb"];
  851. map.remixid = dec["m"]["rxid"];
  852. map.remixname = dec["m"]["rxn"];
  853. map.vd = dec["m"]["vd"];
  854. map.vu = dec["m"]["vu"];
  855. jsonargs.maps.push(map);
  856. }
  857. function stringifyjsonargs(){
  858. return JSON.stringify(jsonargs);
  859. }
  860. this.__defineGetter__("responseText", stringifyjsonargs);
  861. this.__defineGetter__("response", stringifyjsonargs);
  862. }
  863. }
  864. }
  865. originalXMLSend.call(this, ...arguments);
  866. };
  867. Gwindow.WebSocket.prototype.send = function(args) {
  868. if(this.url.includes(".bonk.io/socket.io/?EIO=3&transport=websocket&sid=")){
  869. bonkwss = this;
  870. wsssendlog.push(args);
  871. wsssendrecievelog.push([0,args]);
  872. if(typeof(args) == "string"){
  873. if(args.startsWith('42[26,')){
  874. if(sandboxon){
  875. var jsonargs = JSON.parse(args.substring(2))[1];
  876. if(typeof(sandboxplayerids[jsonargs["targetID"]])!='undefined'){
  877. RECIEVE('42[18,'+jsonargs["targetID"]+','+jsonargs["targetTeam"]+']');
  878.  
  879. }
  880. }
  881. }
  882. if(args.startsWith('42[1,')){
  883. return;
  884. }
  885.  
  886. if(args.startsWith('42[4,')){
  887. var jsonargs = JSON.parse(args.substring(2));
  888. if(sandboxcopyme && typeof(jsonargs[1]["type"])=="undefined"){
  889. var jsonkeys = Object.keys(sandboxplayerids);
  890. for(var i = 0; i<jsonkeys.length;i++){
  891. RECIEVE('42[7,'+jsonkeys[i].toString()+','+JSON.stringify(jsonargs[1])+']');
  892. }
  893. }
  894. args = "42"+JSON.stringify(jsonargs);
  895. }
  896.  
  897. if(args.startsWith('42[5,')){
  898. var jsonargs = JSON.parse(args.substring(2));
  899.  
  900. if(stopquickplay!=1){
  901. jsonargs[1]["gs"]["wl"] = 999;
  902. }
  903.  
  904. args = "42"+JSON.stringify(jsonargs);
  905. }
  906. }
  907.  
  908. }
  909. else{
  910. this.onmessage = function(args){return;};
  911. return;
  912.  
  913. }
  914. if(this.url.includes(".bonk.io/socket.io/?EIO=3&transport=websocket&sid=") && !this.injected){
  915. this.injected = true;
  916.  
  917. var originalRecieve = this.onmessage;
  918. this.onmessage = function(args){
  919. wssrecievelog.push(args.data);
  920. wsssendrecievelog.push([1,args.data]);
  921. if(typeof(args.data)=="string"){
  922. if(args.data.startsWith('42[1,')){
  923. var jsonargs = JSON.parse(args.data.substring(2));
  924. originalSend.call(this,'42[1,{"id":'+jsonargs[2]+'}]');
  925. }
  926. if(args.data.startsWith('42[24,')){
  927. beenKickedTimeStamp = Date.now();
  928. }
  929. if(args.data.startsWith('42[32')){
  930. SEND('42[4,{"type":"inactive kick counter"}]');
  931. }
  932. if(args.data.startsWith('42[40,')){
  933. recordedTimeStamp = Date.now();
  934. recordedId = JSON.parse(args.data.substring(2))[1];
  935. }
  936. if(args.data.startsWith('42[3,')){
  937. var jsonargs = JSON.parse(args.data.substring(2));
  938. for(var i = 0; i<jsonargs[3].length;i++){
  939. if(jsonargs[3][i]!=null){
  940. playerids[i.toString()] = jsonargs[3][i]["userName"];
  941. }
  942. }
  943. }
  944. if(args.data.startsWith('42[15,')){
  945. var jsonargs = JSON.parse(args.data.substring(2));
  946. gameStartTimeStamp = jsonargs[1];
  947. }
  948. if(args.data.startsWith('42[33,')){
  949. var jsonargs = JSON.parse(args.data.substring(2));
  950. var decodedmap = decodeFromDatabase(jsonargs[1]);
  951. if(decodedmap!=0){
  952. requestedmaps.push([decodedmap,jsonargs[1]]);
  953. }
  954. }
  955. if(args.data.startsWith('42[7,')){
  956. var jsonargs2 = JSON.parse(args.data.substring(2));
  957. var idofpacket = jsonargs2[1];
  958. jsonargs = jsonargs2[2];
  959. if(typeof(jsonargs["type"]) != "undefined"){
  960. if(jsonargs["type"]=="private chat" && jsonargs["to"] == username){
  961. from = jsonargs["from"];
  962. if(Object.keys(playerids).includes(idofpacket.toString())){
  963. from = playerids[idofpacket];
  964. }
  965. if(!ignorepmlist.includes(from)){
  966. if(typeof(jsonargs["message"])=="object" && typeof(jsonargs["password"]) == "object"){
  967. if(public_key[0]==jsonargs["public key"][0] && public_key[1]==jsonargs["public key"][1]){
  968. if(jsonargs["password"].length<=25){
  969. var password = CRYPT_MESSAGE(private_key,jsonargs["password"]);
  970. var decodedtext = jsonargs["message"].slice(0,400);
  971. var encodedtext = "";
  972. for(var i=0;i<decodedtext.length;i++){
  973. if(password[i%password.length]<1000){
  974. encodedtext+=String.fromCharCode(password[i%password.length]^decodedtext[i]);
  975. }
  976. }
  977. 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);';
  978. displayInChat('> '+'<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+from+'</a>'+': ',"#DA0808","#1EBCC1",{sanitize:false},encodedtext);
  979.  
  980. Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true;
  981. Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true;
  982. Laster_message = lastmessage();
  983. }
  984. }
  985. else{
  986. SEND("42"+JSON.stringify([4,{"type":"public key correction","from":username,"to":private_chat_public_key[0],"public key":public_key}]));
  987. }
  988. }
  989. }
  990. }
  991. if(jsonargs["type"]=="request public key" && jsonargs["to"] == username){
  992. SEND("42"+JSON.stringify([4,{"type":"public key","from":username,"public key":public_key}]));
  993. }
  994. if(jsonargs["type"]=="private chat users" && pmuserstimestamp+1500>Date.now()){
  995. if(typeof(jsonargs["from"])!='undefined'){
  996. from = jsonargs["from"];
  997. if(Object.keys(playerids).includes(idofpacket.toString())){
  998. from = playerids[idofpacket];
  999. }
  1000. if(!pmusers.includes(from) && username == jsonargs["to"]){
  1001. pmusers.push(from);
  1002. }
  1003. }
  1004. }
  1005. if(jsonargs["type"]=="request private chat users"){
  1006. if(typeof(jsonargs["from"])!='undefined'){
  1007. from = jsonargs["from"];
  1008. if(Object.keys(playerids).includes(idofpacket.toString())){
  1009. from = playerids[idofpacket];
  1010. }
  1011. SEND("42"+JSON.stringify([4,{"type":"private chat users","from":username,"to":from}]));
  1012. }
  1013. }
  1014. if(jsonargs["type"]=="public key" && request_public_key_time_stamp+1500>Date.now()){
  1015. from = jsonargs["from"];
  1016. if(Object.keys(playerids).includes(idofpacket.toString())){
  1017. from = playerids[idofpacket];
  1018. }
  1019. if(from == private_chat){
  1020. private_chat_public_key = [private_chat,jsonargs["public key"]];
  1021. displayInChat("Private chatting with "+private_chat+".","#DA0808","#1EBCC1");
  1022. }
  1023.  
  1024. }
  1025. if(jsonargs["type"]=="public key correction" && private_chat_public_key[0] == private_chat){
  1026. from = jsonargs["from"];
  1027. if(Object.keys(playerids).includes(idofpacket.toString())){
  1028. from = playerids[idofpacket];
  1029. }
  1030. if(from == private_chat){
  1031. private_chat_public_key = [private_chat,jsonargs["public key"]];
  1032. var text = pmlastmessage;
  1033. var password = [];
  1034. for(var i = 0;i<10;i++){
  1035. password.push(Math.floor(Math.random()*100+50));
  1036. }
  1037. var text2 = [];
  1038. for(var i = 0;i<text.length ;i++){
  1039. text2.push(password[i%password.length]^text.slice(0,400).charCodeAt(i));
  1040. }
  1041. 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)}]));
  1042. }
  1043. }
  1044.  
  1045. }
  1046. else{
  1047. gameStartTimeStamp = Date.now()-1000*jsonargs["f"]/30;
  1048. }
  1049. }
  1050.  
  1051. if(args.data.startsWith('42[4,')){
  1052. var jsonargs = JSON.parse(args.data.substring(2));
  1053. playerids[jsonargs[1]] = jsonargs[3];
  1054.  
  1055. }
  1056. if(args.data.startsWith('42[5,')){
  1057. var jsonargs = JSON.parse(args.data.substring(2));
  1058. if(typeof(playerids[jsonargs[1]])!='undefined'){
  1059. delete playerids[jsonargs[1]];
  1060. }
  1061. }
  1062. }
  1063. return originalRecieve.call(this,args);
  1064. };
  1065.  
  1066. var originalClose = this.onclose;
  1067. this.onclose = function () {
  1068. window.bonkwss = 0;
  1069. return originalClose.call(this);
  1070. }
  1071.  
  1072. }
  1073. return originalSend.call(this,args);
  1074. };
  1075.  
  1076. scope.SEND = function(args){
  1077. if(bonkwss!=0){
  1078. bonkwss.send(args);
  1079. }
  1080. };
  1081. scope.RECIEVE = function(args){
  1082. if(bonkwss!=0){
  1083. bonkwss.onmessage({data:args});
  1084. }
  1085. };
  1086. Gdocument.getElementById("ingamechatcontent").style["pointer-events"]="all";
  1087. Gdocument.getElementById("ingamechatcontent").style["max-height"]="250px";
  1088. Gdocument.getElementById("ingamechatcontent").style["height"]="128px";
  1089. Gdocument.getElementById("ingamechatbox").style["height"]="250px";
  1090.  
  1091. document.getElementById('adboxverticalCurse').style["display"] = "none";
  1092. document.getElementById('adboxverticalleftCurse').style["display"] = "none";
  1093.  
  1094.  
  1095. scope.dontswitch = false;
  1096. scope.username = 0;
  1097. scope.timedelay = 1400;
  1098. scope.ishost = false;
  1099. scope.checkboxhidden = true;
  1100. scope.quicki=0;
  1101. scope.defaultmode = "d";
  1102. scope.recmodebool = false;
  1103. scope.shuffle = false;
  1104. scope.freejoin = false;
  1105. scope.recordedTimeStamp = 0;
  1106. scope.recordedId = 0;
  1107. scope.beenKickedTimeStamp = 0;
  1108. scope.stopquickplay = 1;
  1109. scope.currentFrame = 0;
  1110. scope.gameStartTimeStamp = 0;
  1111. scope.canceled = false;
  1112. scope.banned = [];
  1113. scope.transitioning = false;
  1114. scope.echo_list = [];
  1115. scope.message = "";
  1116. scope.mode = "";
  1117. scope.private_chat = "";
  1118. scope.private_chat_public_key = ["",[0,0]];
  1119. scope.users = [];
  1120. scope.pmusers = [];
  1121. scope.pmlastmessage = "";
  1122. scope.pmuserstimestamp = 0;
  1123. scope.ignorepmlist = [];
  1124. scope.scroll = false;
  1125. scope.elem = Gdocument.getElementById("maploadwindowmapscontainer");
  1126. scope.npermissions = 1;
  1127. scope.space_flag = false;
  1128. scope.rcaps_flag = false;
  1129. scope.number_flag = false;
  1130. scope.request_public_key_time_stamp = 0;
  1131. scope.sandboxcopyme = false;
  1132. scope.help = ["All the commands are:","/help","/?","/advhelp [command]","/space","/rcaps","/number","/echo [username]","/clearecho","/remove [username]","/chatw [username]","/msg [text]","/ignorepm [username]","/pmusers","/lobby","/team [letter]","/scroll","/hidechat","/showchat","/notify","/stopnotify","Host commands are:","/startqp","/stopqp","/next","/previous","/shuffle","/freejoin","/recmode","/defaultmode [mode]","/start","/balanceA [number]","/moveA [letter]","/rounds [number]","/mode [mode]","/ban [username]","/kill [username]","Sandbox commands are:","/addplayer [number]","/delplayer [number]","/copyme","Debugging commands are:","/eval [code]","/debugger","Hotkeys are:","Alt L","Alt C","Host hotkeys are:","Alt S","Alt T","Alt E","Alt K","Alt M","Alt Q","Alt A","Alt D","Alt F","Alt R","Alt I"];
  1133.  
  1134. scope.adv_help = {"help":"Shows all command names.",
  1135. "?":"Shows all command names.",
  1136. "advhelp":"Shows a command in detail.",
  1137. "space":"Toggles space. When space is on, whatever you type will be spaced apart.",
  1138. "rcaps":"Toggles rcaps. When rcaps is on, each letter will randomly get capitalized.",
  1139. "number":"Toggles number. When number is on, 'a' becomes 4, 'e' becomes 3, 's' becomes 5, 'o' becomes 0, 'l' and 'i' become 1.",
  1140. "echo":"Echoes a username. It copies the username's chat messages.",
  1141. "remove":"Removes username from echo list. You will not echo that username anymore.",
  1142. "clearecho":"Clears echo list. You will not echo anyone anymore.",
  1143. "chatw":"It private chats with username. Type /msg to message that username.",
  1144. "msg":"Messages with what username you are chatting with. Type /chatw to chat with a username.",
  1145. "ignorepm":"Ignores the username's private chat messages. To unignore, type /ignorepm [username].",
  1146. "pmusers":"Dispays who you can private chat with.",
  1147. "eval":"Evaluates code. Only use this if you are experienced in javascript.",
  1148. "debugger":"Opens debugger.",
  1149. "lobby":"Makes lobby visible when you are ingame. Type /lobby again to close lobby.",
  1150. "team":"Joins a specific team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  1151. "scroll":"Toggles a scrollbar in ingame chat.",
  1152. "hidechat":"Hides ingame chat. Type /showchat to show it again.",
  1153. "showchat":"Shows ingame chat. /hidechat hides the chat.",
  1154. "notify":"You will be notified if a person types @MYUSERNAME",
  1155. "stopnotify":"You will not be notified if a person types @MYUSERNAME",
  1156. "startqp":"Starts cycling maps in your map menu.",
  1157. "stopqp":"Stops cycling maps in your map menu.",
  1158. "next":"Skips the map. Usable only with /startqp.",
  1159. "previous":"Goes to previous map. Usable only with /startqp.",
  1160. "shuffle":"Makes quickplay play random maps instead of in order.",
  1161. "freejoin":"Toggles freejoin. If freejoin is on, starts the game instantly if there are 1 or less players currently playing.",
  1162. "recmode":"In quickplay, it switches mode to recommended mode, according to editor.",
  1163. "defaultmode":"Switches mode to defaultmode if there is no recmode.",
  1164. "start":"Starts game instantly.",
  1165. "balanceA":"Balances everyone with balance number.",
  1166. "moveA":"Sets everyones team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  1167. "rounds":"Sets rounds to win.",
  1168. "mode":"Switches modes.",
  1169. "ban":"Bans username from lobby. If they rejoin, it automatically bans.",
  1170. "kill":"Kills the person ingame.",
  1171. "addplayer":"In sandbox, it adds players.",
  1172. "delplayer":"In sandbox, it deletes players.",
  1173. "copyme":"In sandbox, it makes each player copy your movements.",
  1174. "Alt L":"Makes lobby visible when you are ingame. Press Alt L again to close lobby.",
  1175. "Alt C":"Hides ingame chat. Press Alt C again to show ingame chat.",
  1176. "Alt S":"Starts game instantly.",
  1177. "Alt T":"Toggles teams.",
  1178. "Alt E":"Toggles editor.",
  1179. "Alt K":"Exits ingame and returns to lobby.",
  1180. "Alt M":"Switches modes.",
  1181. "Alt Q":"Toggles quickplay.",
  1182. "Alt A":"Skips the map if quickplay is on.",
  1183. "Alt D":"Goes to previous map if quickplay is on.",
  1184. "Alt F":"Toggles freejoin. If freejoin is on, starts the game instantly if there are 1 or less players currently playing",
  1185. "Alt R":"In quickplay, it switches mode to recommended mode, according to editor.",
  1186. "Alt I":"Opens debugger."
  1187. };
  1188.  
  1189. elem.onclick=function(e){
  1190. if(stopquickplay==0 && ishost == true && e.isTrusted == true){
  1191. quicki = (Array.from(e.target.parentElement.parentNode.children).indexOf(e.target.parentNode)-1)%(Gdocument.getElementById("maploadwindowmapscontainer").children.length);
  1192. }
  1193. };
  1194. scope.urlify = function(text) {
  1195. return text.replace(/(?:https?:\/\/)?(?:[A-Za-z0-9-ßàÁâãóôþüúðæåïçèõöÿýòäœêëìíøùîûñé]+)(?:\.[A-Za-z0-9-ßàÁâãóôþüúðæåïçèõöÿýòäœêëìíøùîûñé]+)+(?:\/(?:[A-Za-z0-9-._~:/?#\[\]@!$&'()*+,;=]|%[0-9a-fA-F]{2})*)?(?:\?(?:[^=]+=[^&](?:&[^=]+=[^&])*)?)?/g, function(url) {
  1196. if(url.startsWith('https://')){return '<a href="' + url + '" target="_blank" style = "color:orange">' + url + '</a>';}
  1197. else{return '<a href="https://' + url + '" target="_blank" style = "color:orange">' + url + '</a>';}
  1198. })
  1199. };
  1200.  
  1201. scope.fire = function(type,options,d = Gdocument){
  1202. var event=new CustomEvent(type);
  1203. for(var p in options){
  1204. event[p]=options[p];
  1205. }
  1206. d.dispatchEvent(event);
  1207. };
  1208.  
  1209. scope.chat = function(message){
  1210. mess = Gdocument.getElementById("newbonklobby_chat_input").value;
  1211. mess2 = Gdocument.getElementById("ingamechatinputtext").value;
  1212. Gdocument.getElementById("newbonklobby_chat_input").value = message;
  1213. Gdocument.getElementById("ingamechatinputtext").value = message;
  1214. fire("keydown",{keyCode:13});
  1215. fire("keydown",{keyCode:13});
  1216. Gdocument.getElementById("newbonklobby_chat_input").value = mess;
  1217. Gdocument.getElementById("ingamechatinputtext").value = mess2;
  1218. };
  1219. scope.displayInChat = function(message, LobbyColor, InGameColor, options, message2) {
  1220. options = options ?? {};
  1221. message2 = message2 ?? "";
  1222. LobbyColor = LobbyColor ?? "#8800FF";
  1223. InGameColor = InGameColor ?? "#AA88FF";
  1224. let A = Gdocument.createElement("div");
  1225. let B = Gdocument.createElement("span");
  1226. B.className = "newbonklobby_chat_status";
  1227. B.style.color = LobbyColor;
  1228. A.appendChild(B);
  1229. B.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  1230. B.innerHTML+=urlify(message2.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;'));
  1231. let C = Gdocument.createElement("div");
  1232. let D = Gdocument.createElement("span");
  1233. D.style.color = InGameColor;
  1234. C.appendChild(D);
  1235. D.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  1236. D.innerHTML+=urlify(message2.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;'));
  1237.  
  1238. let a = false;
  1239. if(Gdocument.getElementById("newbonklobby_chat_content").clientHeight + Gdocument.getElementById("newbonklobby_chat_content").scrollTop >= Gdocument.getElementById("newbonklobby_chat_content").scrollHeight-1) {
  1240. a = true;
  1241. }
  1242. Gdocument.getElementById("newbonklobby_chat_content").appendChild(A);
  1243. Gdocument.getElementById("ingamechatcontent").appendChild(C);
  1244. if (a) { Gdocument.getElementById("newbonklobby_chat_content").scrollTop = Number.MAX_SAFE_INTEGER;};
  1245. Gdocument.getElementById("ingamechatcontent").scrollTop = Number.MAX_SAFE_INTEGER;
  1246. chat("");
  1247. };
  1248.  
  1249. scope.lobby = function(){
  1250. if (Gdocument.getElementById("newbonklobby").style["display"]=="none"){
  1251.  
  1252. Gdocument.getElementById("newbonklobby_editorbutton").click();
  1253. Gdocument.getElementById("mapeditor_close").click();
  1254. if(Gdocument.getElementsByClassName("newbonklobby_playerentry").length>0){
  1255. Gdocument.getElementById("newbonklobby").style["z-index"]=1;
  1256. Gdocument.getElementById("maploadwindowcontainer").style["z-index"]=1;
  1257. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=1;
  1258. Gdocument.getElementById("pretty_top").style["z-index"]=3;
  1259. Gdocument.getElementById("settingsContainer").style["z-index"]=3;
  1260. Gdocument.getElementById("leaveconfirmwindow").style["z-index"]=3;
  1261. Gdocument.getElementById("hostleaveconfirmwindow").style["z-index"]=3;
  1262. debuggermenu.style["z-index"] = 2;
  1263. }
  1264. else{
  1265. Gdocument.getElementById("newbonklobby").style["opacity"]=0;
  1266. Gdocument.getElementById("newbonklobby").style["display"]="none";
  1267. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
  1268.  
  1269. }
  1270.  
  1271. }
  1272. else if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  1273. Gdocument.getElementById("newbonklobby").style["opacity"]=0;
  1274. Gdocument.getElementById("newbonklobby").style["display"]="none";
  1275. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
  1276.  
  1277. }
  1278. };
  1279.  
  1280. scope.lastmessage = function(){
  1281. if(Gdocument.getElementById("newbonklobby_chat_content").children.length!=0){
  1282. var lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  1283. var lm2 = "";
  1284. for(var i = 0; i<lm.length;i++){
  1285. lm2+=" "+lm[i].textContent.trim();
  1286. }
  1287. lm2 = lm2.trim();
  1288. if(lm2.startsWith("*")){
  1289. return lm2;
  1290. }
  1291. }
  1292. if(Gdocument.getElementById("ingamechatcontent").children.length!=0){
  1293. var lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  1294. var lm2 = "";
  1295. for(var i = 0; i<lm.length;i++){
  1296. lm2+=" "+lm[i].textContent.trim();
  1297. }
  1298. return lm2.trim();
  1299. }
  1300. return "";
  1301.  
  1302. };
  1303. scope.map = function(e){
  1304. if(e<0){
  1305. displayInChat("There is no previous map.","#DA0808","#1EBCC1");
  1306. quicki = 0;
  1307. return;
  1308. }
  1309. if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
  1310. displayInChat("Click the maps button.","#DA0808","#1EBCC1");
  1311. return;
  1312. }
  1313.  
  1314. setTimeout(function(){if(!canceled){
  1315. Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
  1316. Gdocument.getElementById("newbonklobby_editorbutton").click();
  1317. if(recmodebool && ishost){
  1318. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  1319. if(mode == "" && defaultmode!="d"){
  1320. mode = defaultmode;
  1321. }
  1322. if(mode != ""){
  1323. RECIEVE('42[26,"b","'+mode+'"]');
  1324. }
  1325. }
  1326. Gdocument.getElementById("mapeditor_close").click();
  1327. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  1328. Gdocument.getElementById("mapeditor_midbox_testbutton").click();}
  1329. canceled = false;
  1330. transitioning = false;
  1331. },timedelay);
  1332.  
  1333. };
  1334.  
  1335. scope.gotonextmap = function(e){
  1336. if(e<0){
  1337. displayInChat("There is no previous map.","#DA0808","#1EBCC1");
  1338. quicki = 0;
  1339. return;
  1340. }
  1341. if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
  1342. displayInChat("Click the maps button.","#DA0808","#1EBCC1");
  1343. return;
  1344. }
  1345. Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
  1346. Gdocument.getElementById("newbonklobby_editorbutton").click();
  1347. if(recmodebool && ishost){
  1348. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  1349. if(mode == "" && defaultmode!="d"){
  1350. mode = defaultmode;
  1351. }
  1352. if(mode != ""){
  1353. RECIEVE('42[26,"b","'+mode+'"]');
  1354. }
  1355. }
  1356. Gdocument.getElementById("mapeditor_close").click();
  1357. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  1358. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  1359. Gdocument.getElementById("newbonklobby").style["visibility"] = "visible";
  1360. };
  1361. scope.commandhandle = function(chat_val){
  1362. if (chat_val.substring(1,6)=="echo " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  1363. if (chat_val.substring(6).replace(/^\s+|\s+$/g, '')==username){
  1364. displayInChat("You cannot echo yourself.","#DA0808","#1EBCC1");
  1365. return "";
  1366. }
  1367. else if (echo_list.indexOf(chat_val.substring(6).replace(/^\s+|\s+$/g, ''))===-1) {
  1368.  
  1369. echo_list.push(chat_val.substring(6).replace(/^\s+|\s+$/g, ''));
  1370. displayInChat(chat_val.substring(6).replace(/^\s+|\s+$/g, '') + " is being echoed.","#DA0808","#1EBCC1");
  1371. return "";
  1372. }
  1373. else{
  1374. displayInChat(chat_val.substring(6).replace(/^\s+|\s+$/g, '') + " is already being echoed.","#DA0808","#1EBCC1");
  1375. return "";
  1376. }
  1377. }
  1378. else if (chat_val.substring(1,8)=="remove " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  1379. if (echo_list.indexOf(chat_val.substring(7).replace(/^\s+|\s+$/g, ''))!==-1){
  1380. echo_list.splice(echo_list.indexOf(chat_val.substring(7).replace(/^\s+|\s+$/g, '')),1);
  1381. displayInChat(chat_val.substring(7).replace(/^\s+|\s+$/g, '')+" is not being echoed.","#DA0808","#1EBCC1");
  1382. return "";
  1383. }
  1384. else{
  1385. displayInChat("You cannot remove someone that you didn't echo.","#DA0808","#1EBCC1");
  1386. return "";
  1387. }
  1388.  
  1389. }
  1390. else if (chat_val.substring(1,10)=="clearecho"){
  1391. echo_list = [];
  1392. displayInChat("Cleared the echo list.","#DA0808","#1EBCC1");
  1393. return "";
  1394. }
  1395. else if (chat_val.substring(1,6)=="space"){
  1396. if(space_flag == true){
  1397. displayInChat("Space is now off.","#DA0808","#1EBCC1");
  1398. space_flag = false;
  1399. }
  1400. else{
  1401. displayInChat("Space is now on.","#DA0808","#1EBCC1");
  1402. space_flag = true;
  1403. }
  1404. return "";
  1405. }
  1406. else if (chat_val.substring(1,6)=="rcaps"){
  1407. if(rcaps_flag == true){
  1408. displayInChat("Rcaps is now off.","#DA0808","#1EBCC1");
  1409. rcaps_flag = false;
  1410. }
  1411. else{
  1412. displayInChat("Rcaps is now on.","#DA0808","#1EBCC1");
  1413. rcaps_flag = true;
  1414. }
  1415.  
  1416. return "";
  1417. }
  1418. else if (chat_val.substring(1,7)=="number"){
  1419. if(number_flag == true){
  1420. displayInChat("Number is now off.","#DA0808","#1EBCC1");
  1421. number_flag = false;
  1422. }
  1423. else{
  1424. displayInChat("Number is now on.","#DA0808","#1EBCC1");
  1425. number_flag = true;
  1426. }
  1427.  
  1428. return "";
  1429. }
  1430. else if (chat_val.substring(1,6)=="eval " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  1431. var ev = "";
  1432. try{
  1433. ev = eval(chat_val.substring(6).replace(/^\s+|\s+$/g, ''));
  1434. }
  1435. catch(e){
  1436. displayInChat(e.message,"#DA0808","#1EBCC1");
  1437. }
  1438. try{
  1439. displayInChat(ev.toString(),"#DA0808","#1EBCC1");
  1440. }
  1441. catch{
  1442. }
  1443.  
  1444. return "";
  1445.  
  1446. }
  1447.  
  1448. else if (chat_val.substring(1,9)=="hidechat"){
  1449. Gdocument.getElementById("ingamechatcontent").style["max-height"]="0px";
  1450. return "";
  1451. }
  1452. else if (chat_val.substring(1,9)=="showchat"){
  1453. Gdocument.getElementById("ingamechatcontent").style["max-height"]="250px";
  1454. return "";
  1455. }
  1456.  
  1457. else if (chat_val.substring(1,7)=="scroll"){
  1458. if(scroll==false){
  1459. scroll = true;
  1460. Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="scroll";
  1461. Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
  1462. }
  1463. else if(scroll==true){
  1464. scroll = false;
  1465. Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="hidden";
  1466. Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
  1467. }
  1468.  
  1469. return "";
  1470. }
  1471.  
  1472. else if (chat_val.substring(1,7)=="chatw "){
  1473. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '');
  1474.  
  1475. if(username == text){
  1476. displayInChat("You cannot private chat with yourself.","#DA0808","#1EBCC1");
  1477. return "";
  1478. }
  1479. private_chat = text;
  1480.  
  1481. SEND("42"+JSON.stringify([4,{"type":"request public key","from":username,"to":private_chat}]));
  1482. request_public_key_time_stamp = Date.now();
  1483. 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);
  1484. return "";
  1485. }
  1486.  
  1487. else if (chat_val.substring(1,5)=="msg " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  1488. if(private_chat_public_key[1][0] != 0 && private_chat_public_key[1][1] != 0 && private_chat_public_key[0] == private_chat){
  1489. var text = chat_val.substring(5).replace(/^\s+|\s+$/g, '');
  1490. var password = [];
  1491. for(var i = 0;i<10;i++){
  1492. password.push(Math.floor(Math.random()*100+50));
  1493. }
  1494. var text2 = [];
  1495. for(var i = 0;i<text.slice(0,400).length ;i++){
  1496. text2.push(password[i%password.length]^text.slice(0,400).charCodeAt(i));
  1497. }
  1498. pmlastmessage = text.slice(0,400);
  1499. 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)}]));
  1500. displayInChat("> "+username+": "+text,"#DA0808","#1EBCC1");
  1501.  
  1502. }
  1503. return "";
  1504. }
  1505. else if (chat_val.substring(1,10)=="ignorepm " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  1506. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  1507. if(ignorepmlist.includes(text)){
  1508. var index = ignorepmlist.indexOf(text);
  1509. ignorepmlist.splice(index,1);
  1510. displayInChat("You are not ignoring private messages from "+text+".","#DA0808","#1EBCC1");
  1511.  
  1512. }
  1513. else{
  1514. ignorepmlist.push(text);
  1515. displayInChat("You are now ignoring private messages from "+text+".","#DA0808","#1EBCC1");
  1516. }
  1517. return "";
  1518. }
  1519. else if (chat_val.substring(1,8)=="pmusers"){
  1520. pmusers = [];
  1521. SEND("42"+JSON.stringify([4,{"type":"request private chat users","from":username}]));
  1522. pmuserstimestamp = Date.now();
  1523. setTimeout(function(){if(pmusers.length == 0){displayInChat("You cannot private chat with anyone.","#DA0808","#1EBCC1");
  1524. }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);
  1525. return "";
  1526. }
  1527. else if (chat_val.substring(1,6)=="lobby"){
  1528. lobby();
  1529. return "";
  1530. }
  1531. else if (chat_val.substring(1,9)=="debugger"){
  1532. if(Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"] == "none"){
  1533. debuggeropen = true;
  1534. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="block";
  1535. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="none";
  1536. Gdocument.getElementById("ingamechatinputtext").style["display"] = "none";
  1537. }
  1538. else{
  1539. debuggeropen = false;
  1540. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="none";
  1541. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  1542. Gdocument.getElementById("ingamechatinputtext").style["display"] = "";
  1543. }
  1544. return "";
  1545. }
  1546. else if (chat_val.substring(1,6)=="team " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  1547. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  1548. if(text == "r"){Gdocument.getElementById("newbonklobby_redbutton").click();}
  1549. else if(text == "g"){Gdocument.getElementById("newbonklobby_greenbutton").click();}
  1550. else if(text == "y"){Gdocument.getElementById("newbonklobby_yellowbutton").click();}
  1551. else if(text == "b"){Gdocument.getElementById("newbonklobby_bluebutton").click();}
  1552. else if(text == "s"){Gdocument.getElementById("newbonklobby_specbutton").click();}
  1553. else if(text == "f"){Gdocument.getElementById("newbonklobby_ffabutton").click();}
  1554. return "";
  1555. }
  1556. else if (chat_val.substring(1,7)=="notify"){
  1557.  
  1558. npermissions = 1;
  1559. return "";
  1560. }
  1561. else if (chat_val.substring(1,11)=="stopnotify"){
  1562.  
  1563. npermissions = 0;
  1564. return "";
  1565. }
  1566. else if (chat_val.substring(1,5)=="help" || chat_val.substring(1,2)=="?"){
  1567. for(var i = 0;i<help.length;i++){
  1568. displayInChat(help[i],"#DA0808","#1EBCC1");
  1569.  
  1570. }
  1571. return "";
  1572. }
  1573. else if (chat_val.substring(1,9)=="advhelp " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  1574. var text = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  1575. if(typeof(adv_help[text])!='undefined'){
  1576. displayInChat(adv_help[text],"#DA0808","#1EBCC1");
  1577. }
  1578. return "";
  1579. }
  1580. else if(ishost){
  1581.  
  1582. if (chat_val.substring(1,5)=="next" && stopquickplay == 0){
  1583. if(shuffle){
  1584. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  1585. var available = [];
  1586. var availableindexes = [];
  1587. var notempty = false;
  1588. for(var i = 0; i<e.length;i++){
  1589. var a = false;
  1590. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  1591. available.push(a);
  1592. if(a){
  1593. availableindexes.push(i);
  1594. notempty = true;
  1595. }
  1596. }
  1597. if(notempty){
  1598.  
  1599. if(availableindexes.length!=1){
  1600. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  1601. }
  1602. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  1603. }
  1604. }
  1605. else{
  1606. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  1607. var available = [];
  1608. var availableindexes = [];
  1609. var notempty = false;
  1610. for(var i = 0; i<e.length;i++){
  1611. var a = false;
  1612. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  1613. available.push(a);
  1614. if(a){
  1615. availableindexes.push(i);
  1616. notempty = true;
  1617. }
  1618. }
  1619. if(notempty){
  1620. var above = [];
  1621. for(var i = 0;i<availableindexes.length;i++){
  1622. if(availableindexes[i]>quicki){
  1623. above.push(availableindexes[i]);
  1624. }
  1625. }
  1626. if(above.length>0){
  1627. quicki = above[0];
  1628. }
  1629. else{
  1630. quicki = availableindexes[0];
  1631. }
  1632. }
  1633. }
  1634. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  1635. displayInChat("Switched to next map.","#DA0808","#1EBCC1");
  1636. return "";
  1637.  
  1638. }
  1639. else if (chat_val.substring(1,9)=="freejoin"){
  1640. if(freejoin == false){
  1641. freejoin = true;
  1642. displayInChat("Freejoin is now on.","#DA0808","#1EBCC1");
  1643.  
  1644. }
  1645. else{
  1646. freejoin = false;
  1647. displayInChat("Freejoin is now off.","#DA0808","#1EBCC1");
  1648. }
  1649.  
  1650. return "";
  1651.  
  1652. }
  1653.  
  1654. else if (chat_val.substring(1,9)=="previous" && stopquickplay == 0){
  1655. if(shuffle){
  1656. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  1657. var available = [];
  1658. var availableindexes = [];
  1659. var notempty = false;
  1660. for(var i = 0; i<e.length;i++){
  1661. var a = false;
  1662. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  1663. available.push(a);
  1664. if(a){
  1665. availableindexes.push(i);
  1666. notempty = true;
  1667. }
  1668. }
  1669. if(notempty){
  1670.  
  1671. if(availableindexes.length!=1){
  1672. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  1673. }
  1674. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  1675. }
  1676. }
  1677. else{
  1678. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  1679. var available = [];
  1680. var availableindexes = [];
  1681. var notempty = false;
  1682. for(var i = 0; i<e.length;i++){
  1683. var a = false;
  1684. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  1685. available.push(a);
  1686. if(a){
  1687. availableindexes.push(i);
  1688. notempty = true;
  1689. }
  1690. }
  1691. if(notempty){
  1692. var above = [];
  1693. for(var i = 0;i<availableindexes.length;i++){
  1694. if(availableindexes[i]<quicki){
  1695. above.push(availableindexes[i]);
  1696. }
  1697. }
  1698. if(above.length>0){
  1699. quicki = above[above.length-1];
  1700. }
  1701. else{
  1702. quicki = availableindexes[availableindexes.length-1];
  1703. }
  1704. }
  1705. }
  1706. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  1707.  
  1708. displayInChat("Switched to previous map.","#DA0808","#1EBCC1");
  1709. return "";
  1710. }
  1711. else if (chat_val.substring(1,6)=="start" && chat_val.length == 6){
  1712. Gdocument.getElementById("newbonklobby_editorbutton").click();
  1713. if(recmodebool && ishost){
  1714. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  1715. if(mode == "" && defaultmode!="d"){
  1716. mode = defaultmode;
  1717. }
  1718. if(mode != ""){
  1719. RECIEVE('42[26,"b","'+mode+'"]');
  1720. }
  1721. }
  1722. Gdocument.getElementById("mapeditor_close").click();
  1723. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  1724. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  1725.  
  1726. return "";
  1727. }
  1728.  
  1729. else if (chat_val.substring(1,8)=="startqp" && stopquickplay == 1){
  1730. stopquickplay = 0;
  1731. quicki = 0;
  1732. displayInChat("Enabled quickplay.","#DA0808","#1EBCC1");
  1733. return "";
  1734. }
  1735. else if (chat_val.substring(1,7)=="stopqp" && stopquickplay == 0){
  1736. stopquickplay = 1;
  1737. quicki = 0;
  1738. displayInChat("Disabled quickplay.","#DA0808","#1EBCC1");
  1739. return "";
  1740. }
  1741.  
  1742. else if (chat_val.substring(1,5)=="ban " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  1743. banned.push(chat_val.substring(5).replace(/^\s+|\s+$/g, ''));
  1744. displayInChat("Banned "+chat_val.substring(5).replace(/^\s+|\s+$/g, '')+".","#DA0808","#1EBCC1");
  1745. return "/kick '" + chat_val.substring(5).replace(/^\s+|\s+$/g, '') + "'";
  1746. }
  1747. else if (chat_val.substring(1,6)=="kill " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  1748. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  1749. var keys = Object.keys(playerids);
  1750. var killid = undefined;
  1751. for(var i = 0; i<keys.length; i++){
  1752. if(playerids[keys[i]] == text){
  1753. killid = keys[i];
  1754. }
  1755. }
  1756. if(typeof(killid)!="undefined" && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  1757. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  1758. SEND('42[25,{"a":{"playersLeft":['+killid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  1759. RECIEVE('42[31,{"a":{"playersLeft":['+killid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  1760. }
  1761. return "";
  1762. }
  1763. else if (chat_val.substring(1,10)=="balanceA " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  1764. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  1765. if(!isNaN(parseInt(text))){
  1766. if(parseInt(text)>=-100 && parseInt(text)<=100){
  1767. var keys = Object.keys(playerids);
  1768. for(var i = 0; i<keys.length;i++){
  1769. SEND('42[29,{"sid":'+keys[i]+',"bal":'+text+'}]');
  1770. RECIEVE('42[36,'+keys[i]+','+text+']');
  1771. }
  1772. }
  1773. }
  1774. return "";
  1775.  
  1776. }
  1777. else if (chat_val.substring(1,7)=="moveA " && chat_val.replace(/^\s+|\s+$/g, '').length>=8){
  1778. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '');
  1779. var keys = Object.keys(playerids);
  1780. if(text == "f"){
  1781. for(var i = 0; i<keys.length;i++){
  1782. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":1}]')
  1783. }
  1784. }
  1785. else if(text == "b"){
  1786. for(var i = 0; i<keys.length;i++){
  1787. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":3}]')
  1788. }
  1789. }
  1790. else if(text == "g"){
  1791. for(var i = 0; i<keys.length;i++){
  1792. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":4}]')
  1793. }
  1794. }
  1795. else if(text == "r"){
  1796. for(var i = 0; i<keys.length;i++){
  1797. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":2}]')
  1798. }
  1799. }
  1800. else if(text == "y"){
  1801. for(var i = 0; i<keys.length;i++){
  1802. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":5}]')
  1803. }
  1804. }
  1805. else if(text == "s"){
  1806. for(var i = 0; i<keys.length;i++){
  1807. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":0}]')
  1808. }
  1809. }
  1810. return "";
  1811. }
  1812. else if (chat_val.substring(1,8)=="rounds " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  1813. var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '');
  1814. if(!isNaN(parseInt(text))){
  1815. text = parseInt(text).toString();
  1816. SEND('42[21,{"w":'+text+'}]');
  1817. RECIEVE('42[27,'+text+']');
  1818. }
  1819. return "";
  1820.  
  1821. }
  1822. else if (chat_val.substring(1,6)=="mode " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  1823. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  1824. var mode = "";
  1825. if(text == "arrows"){
  1826. mode = "ar";
  1827. displayInChat("Changed mode to arrows.","#DA0808","#1EBCC1");
  1828. }
  1829. else if(text == "death arrows"){
  1830. mode = "ard";
  1831. displayInChat("Changed mode to death arrows.","#DA0808","#1EBCC1");
  1832. }
  1833. else if(text == "grapple"){
  1834. mode = "sp";
  1835. displayInChat("Changed mode to grapple.","#DA0808","#1EBCC1");
  1836. }
  1837. else if(text == "classic"){
  1838. mode = "b";
  1839. displayInChat("Changed mode to classic.","#DA0808","#1EBCC1");
  1840.  
  1841. }
  1842. else{
  1843. displayInChat("Mode options:","#DA0808","#1EBCC1");
  1844. displayInChat("classic","#DA0808","#1EBCC1");
  1845. displayInChat("arrows","#DA0808","#1EBCC1");
  1846. displayInChat("death arrows","#DA0808","#1EBCC1");
  1847. displayInChat("grapple","#DA0808","#1EBCC1");
  1848. }
  1849. if(mode != ""){
  1850. SEND('42[20,{"ga":"b","mo":"'+mode+'"}]');
  1851. RECIEVE('42[26,"b","'+mode+'"]');
  1852. }
  1853. return "";
  1854.  
  1855. }
  1856. else if (chat_val.substring(1,13)=="defaultmode " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  1857. var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '');
  1858. if(text == "default"){
  1859. defaultmode = "";
  1860. displayInChat("Changed default mode to default.","#DA0808","#1EBCC1");
  1861. }
  1862. else if(text == "arrows"){
  1863. defaultmode = "ar";
  1864. displayInChat("Changed default mode to arrows.","#DA0808","#1EBCC1");
  1865. }
  1866. else if(text == "death arrows"){
  1867. defaultmode = "ard";
  1868. displayInChat("Changed default mode to death arrows.","#DA0808","#1EBCC1");
  1869. }
  1870. else if(text == "grapple"){
  1871. defaultmode = "sp";
  1872. displayInChat("Changed default mode to grapple.","#DA0808","#1EBCC1");
  1873. }
  1874. else if(text == "classic"){
  1875. defaultmode = "b";
  1876. displayInChat("Changed default mode to classic.","#DA0808","#1EBCC1");
  1877.  
  1878. }
  1879. else{
  1880. displayInChat("Default mode options:","#DA0808","#1EBCC1");
  1881. displayInChat("default","#DA0808","#1EBCC1");
  1882. displayInChat("classic","#DA0808","#1EBCC1");
  1883. displayInChat("arrows","#DA0808","#1EBCC1");
  1884. displayInChat("death arrows","#DA0808","#1EBCC1");
  1885. displayInChat("grapple","#DA0808","#1EBCC1");
  1886. }
  1887. return "";
  1888.  
  1889. }
  1890. else if (chat_val.substring(1,8)=="recmode"){
  1891. if(recmodebool == true){
  1892. recmodebool = false;
  1893. displayInChat("Recmode is now off.","#DA0808","#1EBCC1");
  1894.  
  1895. }
  1896. else{
  1897. recmodebool = true;
  1898. displayInChat("Recmode is now on.","#DA0808","#1EBCC1");
  1899.  
  1900. }
  1901.  
  1902. return "";
  1903.  
  1904. }
  1905. else if (chat_val.substring(1,8)=="shuffle"){
  1906. if(shuffle == true){
  1907. shuffle = false;
  1908. displayInChat("Shuffle is now off.","#DA0808","#1EBCC1");
  1909.  
  1910. }
  1911. else{
  1912. shuffle = true;
  1913. displayInChat("Shuffle is now on.","#DA0808","#1EBCC1");
  1914.  
  1915. }
  1916.  
  1917. return "";
  1918.  
  1919. }
  1920. else if(sandboxon){
  1921. if (chat_val.substring(1,11)=="addplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  1922. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  1923. if(!isNaN(parseInt(text))){
  1924. var text2 = parseInt(text);
  1925. if(text2>0){
  1926. for(var i = 0;i<text2;i++){
  1927. RECIEVE('42[4,'+sandboxid+',"0123456789abcdef","'+sandboxid.toString()+'",true,0,1,{"layers":[],"bc":'+Math.floor(Math.random() * 16777215).toString()+'}]');
  1928. sandboxplayerids[sandboxid] = sandboxid.toString();
  1929. sandboxid+=1;
  1930. }
  1931.  
  1932. }
  1933. }
  1934. return "";
  1935.  
  1936. }
  1937. else if (chat_val.substring(1,11)=="delplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  1938. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  1939. if(!isNaN(parseInt(text))){
  1940. var text2 = parseInt(text);
  1941. if(text2>0){
  1942. if(Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden"){
  1943. var jsonkeys = Object.keys(sandboxplayerids).reverse();
  1944. for(var i = 0;i<text2 && i<jsonkeys.length;i++){
  1945. RECIEVE('42[5,'+jsonkeys[i]+',0]');
  1946. delete sandboxplayerids[jsonkeys[i]];
  1947. }
  1948. }
  1949. else{
  1950. displayInChat("Cannot delete players while ingame.","#DA0808","#1EBCC1");
  1951. }
  1952.  
  1953. }
  1954. }
  1955. return "";
  1956. }
  1957. else if (chat_val.substring(1,7)=="copyme"){
  1958. if(sandboxcopyme == true){
  1959. displayInChat("Copyme is now off.","#DA0808","#1EBCC1");
  1960. sandboxcopyme = false;
  1961. }
  1962. else{
  1963. displayInChat("Copyme is now on.","#DA0808","#1EBCC1");
  1964. sandboxcopyme = true;
  1965. }
  1966.  
  1967. return "";
  1968. }
  1969. }
  1970. }
  1971. return chat_val;
  1972. };
  1973.  
  1974. scope.flag_manage = function(t){
  1975. var text = t;
  1976.  
  1977. if(rcaps_flag == true){
  1978. text = text.split('');
  1979. for(var i = 0; i<text.length;i++){
  1980. if(Math.floor(Math.random()*2)){
  1981. text[i] = text[i].toUpperCase();
  1982. }
  1983. else{
  1984. text[i] = text[i].toLowerCase();
  1985. }
  1986. }
  1987. text = text.join('');
  1988. }
  1989. if(space_flag == true){
  1990. text = text.split('').join(' ')
  1991. }
  1992. if(number_flag == true){
  1993. text = text.replace(/[t|T][Oo]+/g,"2");
  1994. text = text.replace(/[f|F][o|O][r|R]/g,"4");
  1995. text = text.replace(/[a|A][t|T][e|E]/g,"8");
  1996. text = text.replace(/[e|E]/g,"3");
  1997. text = text.replace(/[a|A]/g,"4");
  1998. text = text.replace(/[o|O]/g,"0");
  1999. text = text.replace(/[s|S]/g,"5");
  2000. text = text.replace(/[i|I|l|L]/g,"1");
  2001. }
  2002. return text;
  2003. };
  2004. Gdocument.getElementById("newbonklobby_chat_input").onkeydown = function(e){
  2005. if(e.keyCode==13){
  2006.  
  2007. var chat_val = Gdocument.getElementById("newbonklobby_chat_input").value;
  2008.  
  2009. if (chat_val!="" && chat_val[0]=="/"){
  2010.  
  2011. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  2012. chat(commandhandle(chat_val));
  2013. }
  2014. else{
  2015. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  2016. chat(flag_manage(chat_val));
  2017. }
  2018.  
  2019. }
  2020. };
  2021. Gdocument.getElementById("ingamechatinputtext").onkeydown = function(e){
  2022. if(e.keyCode==13){
  2023.  
  2024. var chat_val = Gdocument.getElementById("ingamechatinputtext").value;
  2025.  
  2026. if (chat_val!="" && chat_val[0]=="/"){
  2027.  
  2028. Gdocument.getElementById("ingamechatinputtext").value = "";
  2029. chat(commandhandle(chat_val));
  2030. }
  2031. else{
  2032. Gdocument.getElementById("ingamechatinputtext").value = "";
  2033. chat(flag_manage(chat_val));
  2034. }
  2035. }
  2036. };
  2037. scope.Last_message = "";
  2038. scope.Laster_message = "";
  2039. scope.new_message = false;
  2040. scope.changed_chat = false;
  2041. scope.interval = setInterval(timeout123,100);
  2042.  
  2043. scope.hotkeys = function(e){
  2044. if(e.repeat){return;}
  2045. var keycode = e.code;
  2046. if(e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  2047. if(ishost){
  2048. if(keycode == "KeyE"){
  2049. if(Gdocument.getElementById("newbonklobby").style["display"] == "block"){
  2050. Gdocument.getElementById("newbonklobby_editorbutton").click();
  2051. }
  2052. else if(Gdocument.getElementById("mapeditorcontainer").style["display"] == "block"){
  2053. Gdocument.getElementById("mapeditor_close").click();
  2054. }
  2055. e.preventDefault();
  2056.  
  2057. }
  2058. else if(keycode == "KeyT"){
  2059. Gdocument.getElementById("newbonklobby_teamsbutton").click();
  2060. e.preventDefault();
  2061. }
  2062. else if(keycode == "KeyM"){
  2063. Gdocument.getElementById("newbonklobby_modebutton").click();
  2064. e.preventDefault();
  2065. }
  2066. else if(keycode == "KeyK"){
  2067. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  2068. Gdocument.getElementById("pretty_top_exit").click();
  2069. }
  2070. e.preventDefault();
  2071. }
  2072. else if(keycode == "KeyS"){
  2073. Gdocument.getElementById("newbonklobby_editorbutton").click();
  2074. if(recmodebool && ishost){
  2075. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  2076. if(mode == "" && defaultmode!="d"){
  2077. mode = defaultmode;
  2078. }
  2079. if(mode != ""){
  2080. RECIEVE('42[26,"b","'+mode+'"]');
  2081. }
  2082. }
  2083. Gdocument.getElementById("mapeditor_close").click();
  2084. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  2085. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  2086. e.preventDefault();
  2087. }
  2088. else if(keycode == "KeyD"){
  2089. if(stopquickplay == 0){
  2090. if(shuffle){
  2091. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  2092. var available = [];
  2093. var availableindexes = [];
  2094. var notempty = false;
  2095. for(var i = 0; i<e2.length;i++){
  2096. var a = false;
  2097. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  2098. available.push(a);
  2099. if(a){
  2100. availableindexes.push(i);
  2101. notempty = true;
  2102. }
  2103. }
  2104. if(notempty){
  2105.  
  2106. if(availableindexes.length!=1){
  2107. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  2108. }
  2109. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  2110. }
  2111. }
  2112. else{
  2113. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  2114. var available = [];
  2115. var availableindexes = [];
  2116. var notempty = false;
  2117. for(var i = 0; i<e2.length;i++){
  2118. var a = false;
  2119. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  2120. available.push(a);
  2121. if(a){
  2122. availableindexes.push(i);
  2123. notempty = true;
  2124. }
  2125. }
  2126. if(notempty){
  2127. var above = [];
  2128. for(var i = 0;i<availableindexes.length;i++){
  2129. if(availableindexes[i]>quicki){
  2130. above.push(availableindexes[i]);
  2131. }
  2132. }
  2133. if(above.length>0){
  2134. quicki = above[0];
  2135. }
  2136. else{
  2137. quicki = availableindexes[0];
  2138. }
  2139. }
  2140. }
  2141. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  2142. }
  2143. e.preventDefault();
  2144. }
  2145. else if(keycode == "KeyA"){
  2146. if(stopquickplay == 0){
  2147. if(shuffle){
  2148. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  2149. var available = [];
  2150. var availableindexes = [];
  2151. var notempty = false;
  2152. for(var i = 0; i<e2.length;i++){
  2153. var a = false;
  2154. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  2155. available.push(a);
  2156. if(a){
  2157. availableindexes.push(i);
  2158. notempty = true;
  2159. }
  2160. }
  2161. if(notempty){
  2162.  
  2163. if(availableindexes.length!=1){
  2164. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  2165. }
  2166. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  2167. }
  2168. }
  2169. else{
  2170. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  2171. var available = [];
  2172. var availableindexes = [];
  2173. var notempty = false;
  2174. for(var i = 0; i<e2.length;i++){
  2175. var a = false;
  2176. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  2177. available.push(a);
  2178. if(a){
  2179. availableindexes.push(i);
  2180. notempty = true;
  2181. }
  2182. }
  2183. if(notempty){
  2184. var above = [];
  2185. for(var i = 0;i<availableindexes.length;i++){
  2186. if(availableindexes[i]<quicki){
  2187. above.push(availableindexes[i]);
  2188. }
  2189. }
  2190. if(above.length>0){
  2191. quicki = above[above.length-1];
  2192. }
  2193. else{
  2194. quicki = availableindexes[availableindexes.length-1];
  2195. }
  2196. }
  2197. }
  2198. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  2199. }
  2200. e.preventDefault();
  2201. }
  2202. else if(keycode == "KeyQ"){
  2203. if(stopquickplay == 1){
  2204. stopquickplay = 0;
  2205. quicki = 0;
  2206. displayInChat("Enabled quickplay.","#DA0808","#1EBCC1");
  2207. }
  2208. else{
  2209. stopquickplay = 1;
  2210. quicki = 0;
  2211. displayInChat("Disabled quickplay.","#DA0808","#1EBCC1");
  2212. }
  2213. e.preventDefault();
  2214. }
  2215. else if(keycode == "KeyR"){
  2216. if(recmodebool == true){
  2217. recmodebool = false;
  2218. displayInChat("Recmode is now off.","#DA0808","#1EBCC1");
  2219.  
  2220. }
  2221. else{
  2222. recmodebool = true;
  2223. displayInChat("Recmode is now on.","#DA0808","#1EBCC1");
  2224.  
  2225. }
  2226. }
  2227. else if(keycode == "KeyF"){
  2228. if(freejoin == false){
  2229. freejoin = true;
  2230. displayInChat("Freejoin is now on.","#DA0808","#1EBCC1");
  2231.  
  2232. }
  2233. else{
  2234. freejoin = false;
  2235. displayInChat("Freejoin is now off.","#DA0808","#1EBCC1");
  2236. }
  2237. e.preventDefault();
  2238. }
  2239. }
  2240. else{
  2241. if(keycode == "KeyE"){
  2242. e.preventDefault();
  2243. }
  2244. else if(keycode == "KeyT"){
  2245. e.preventDefault();
  2246. }
  2247. else if(keycode == "KeyM"){
  2248. e.preventDefault();
  2249. }
  2250. else if(keycode == "KeyK"){
  2251. e.preventDefault();
  2252. }
  2253. else if(keycode == "KeyS"){
  2254. e.preventDefault();
  2255. }
  2256. else if(keycode == "KeyD"){
  2257. e.preventDefault();
  2258. }
  2259. else if(keycode == "KeyA"){
  2260. e.preventDefault();
  2261. }
  2262. else if(keycode == "KeyQ"){
  2263. e.preventDefault();
  2264. }
  2265. else if(keycode == "KeyF"){
  2266. e.preventDefault();
  2267. }
  2268. else if(keycode == "KeyR"){
  2269. e.preventDefault();
  2270. }
  2271.  
  2272. }
  2273. if(keycode == "KeyL"){
  2274. lobby();
  2275. e.preventDefault();
  2276. }
  2277. if(keycode == "KeyC"){
  2278. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  2279. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]=="0px"){
  2280. Gdocument.getElementById("ingamechatcontent").style["max-height"]="250px";
  2281. }
  2282. else{
  2283. Gdocument.getElementById("ingamechatcontent").style["max-height"]="0px";
  2284. }
  2285. }
  2286. e.preventDefault();
  2287. }
  2288. if(keycode == "KeyI"){
  2289. if(Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"] == "none"){
  2290. debuggeropen = true;
  2291. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="block";
  2292. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="none";
  2293. Gdocument.getElementById("ingamechatinputtext").style["display"] = "none";
  2294. }
  2295. else{
  2296. debuggeropen = false;
  2297. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="none";
  2298. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  2299. Gdocument.getElementById("ingamechatinputtext").style["display"] = "";
  2300. }
  2301. e.preventDefault();
  2302. }
  2303. }
  2304. if(!e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  2305. if(keycode == "Slash"){
  2306. 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"]==""){
  2307. Gdocument.getElementById("newbonklobby_chat_input").value = "/";
  2308. if(Gdocument.getElementById("newbonklobby_chat_input").style["pointer-events"] == "none"){
  2309. fire("keydown",{keyCode:13});
  2310. }
  2311. else{
  2312. Gdocument.getElementById("newbonklobby_chat_input").focus();
  2313. }
  2314. e.preventDefault();
  2315.  
  2316. }
  2317. else if(Gdocument.getElementById("ingamechatinputtext").style["visibility"]=="visible" && Gdocument.getElementById("ingamechatinputtext").style["display"]=="" && Gdocument.getElementById("mapeditorcontainer").style["display"]!="block" && Gdocument.getElementById("ingamechatinputtext").value == ""){
  2318. Gdocument.getElementById("ingamechatinputtext").value = "/";
  2319. if(!Gdocument.getElementById("ingamechatinputtext").classList.value.includes("ingamechatinputtextbg")){
  2320. fire("keydown",{keyCode:13});
  2321. }
  2322. else{
  2323. Gdocument.getElementById("ingamechatinputtext").focus();
  2324. }
  2325. e.preventDefault();
  2326.  
  2327. }
  2328. }
  2329. }
  2330. };
  2331.  
  2332. Gdocument.onkeydown = hotkeys;
  2333.  
  2334. Gwindow.addEventListener('resize',function(e){
  2335. debuggermenu.style["width"] = Gdocument.getElementById("bonkiocontainer").style["width"];
  2336. debuggermenu.style["height"] = Gdocument.getElementById("bonkiocontainer").style["height"];
  2337. scope.width = parseInt(Gdocument.getElementById("bonkiocontainer").style["width"])-20;
  2338. scope.height = parseInt(Gdocument.getElementById("bonkiocontainer").style["height"])-210;
  2339. logmenu.style["width"] = width.toString()+"px";
  2340. logmenu.style["height"] = height.toString()+"px";
  2341. logmenutopleft.style["width"] = (width/2).toString()+"px";
  2342. logmenutopright.style["width"] = (width/2).toString()+"px";
  2343. logmenutopright.style["left"] = (width/2).toString()+"px";
  2344. debuggerinput.style["width"] = width.toString()+"px";
  2345. debuggerinput.style["top"] = (height+90).toString()+"px";
  2346. debuggersendrecieve.style["top"] = (height+120).toString()+"px";
  2347. debuggerpausebutton.style["top"] = (height+150).toString()+"px";
  2348. debuggereval.style["width"] = (width-150).toString()+"px";
  2349. debuggereval.style["top"] = (height+120).toString()+"px";},true);
  2350.  
  2351.  
  2352. function timeout123() {
  2353. updateWssLog();
  2354. if(originalmanualscroll == null){
  2355. originalmanualscroll = Gdocument.getElementById("maploadwindowmapscontainer").onscroll;
  2356. }
  2357. if(Gdocument.getElementById("maploadwindowmapscontainer").onscroll != null){
  2358. if(Gdocument.getElementById("maploadwindowmapscontainer").onscroll.toString() == originalmanualscroll.toString()){
  2359. Gdocument.getElementById("maploadwindowmapscontainer").onscroll = function(...arguments) {
  2360. if(Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS"){
  2361. return;
  2362. }
  2363. return originalmanualscroll.call(this,...arguments);
  2364. }
  2365. }
  2366. }
  2367. if(ishost && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS"){
  2368. clearmaprequests.style["display"] = "block";
  2369. refreshmaprequests.style["display"] = "block";
  2370. }
  2371. else{
  2372. clearmaprequests.style["display"] = "none";
  2373. refreshmaprequests.style["display"] = "none";
  2374. }
  2375. if(Gdocument.getElementById("gamerenderer").style["visibility"]=="hidden"){
  2376. Gdocument.getElementById("ingamechatcontent").style["max-height"]="250px";
  2377. }
  2378. if(Gdocument.getElementById("maploadwindowmapscontainer").children.length>0 && maponclick == 0){
  2379. maponclick = Gdocument.getElementById("maploadwindowmapscontainer").children[0].onclick;
  2380. }
  2381. if(Gdocument.getElementById("sm_connectingContainer").style["visibility"] == "hidden"){
  2382. var chatbox = Gdocument.getElementById("newbonklobby_chat_content");
  2383. while (chatbox.firstChild) {
  2384. chatbox.removeChild(chatbox.firstChild);
  2385. }
  2386. rcaps_flag = false;
  2387. space_flag = false;
  2388. number_flag = false;
  2389. echo_list = [];
  2390. scroll = false;
  2391. stopquickplay = 1;
  2392. checkboxhidden = false;
  2393. freejoin = false;
  2394. shuffle = false;
  2395. defaultmode = "";
  2396. recmodebool = false;
  2397. playerids = {};
  2398. ishost = false;
  2399. sandboxplayerids = {};
  2400. sandboxcopyme = false;
  2401. sandboxon = false;
  2402. sandboxid = 1;
  2403. if(chatlog[chatlog.length-1]!="ROOM END"){
  2404. chatlog.push("ROOM END");
  2405. }
  2406. }
  2407. else{
  2408. if(chatlog[chatlog.length-1]=="ROOM END"){
  2409. chatlog.push("ROOM START");
  2410. }
  2411. }
  2412.  
  2413. if(Gdocument.getElementById("newbonklobby").style["display"]=="block"){
  2414. Gdocument.getElementById("ingamechatinputtext").style["visibility"]="hidden";
  2415. }
  2416. else{
  2417. Gdocument.getElementById("ingamechatinputtext").style["visibility"]="visible";
  2418.  
  2419. }
  2420. mode = Gdocument.getElementById("newbonklobby_modetext").textContent;
  2421. var userlist = Gdocument.getElementsByClassName("newbonklobby_playerentry_name");
  2422. users = [];
  2423. for(var i = 0;i<userlist.length;i++){
  2424. users.push(userlist[i].textContent);
  2425. }
  2426. if(Gdocument.getElementsByClassName('newbonklobby_settings_button brownButton brownButton_classic buttonShadow brownButtonDisabled').length == 0){
  2427. ishost = true;
  2428. }
  2429. else{
  2430. ishost = false;
  2431. }
  2432.  
  2433. if(Gdocument.getElementById("pretty_top_name")!=null){
  2434. username = Gdocument.getElementById("pretty_top_name").textContent;
  2435. }
  2436. try{
  2437. Last_message = lastmessage()
  2438. } catch{
  2439. Last_message = "";
  2440. }
  2441. if (Laster_message != Last_message){
  2442. Laster_message = Last_message;
  2443. if(changed_chat==false){
  2444. new_message = true;
  2445. }
  2446. else{
  2447. changed_chat = false;
  2448. }
  2449. }
  2450. if(new_message){
  2451. chatlog.push(Last_message);
  2452. if(freejoin && Last_message.startsWith("* ") && Last_message.endsWith(" has joined the game") && ishost){
  2453.  
  2454. var userjoined = Last_message.substring(2,Last_message.length-20);
  2455.  
  2456. if(Gdocument.getElementById("newbonklobby").style["display"] != "block"){
  2457. mess2 = Gdocument.getElementById("ingamechatinputtext").value;
  2458. Gdocument.getElementById("ingamechatinputtext").value = "";
  2459. Gdocument.getElementById("newbonklobby_editorbutton").click();
  2460. Gdocument.getElementById("mapeditor_close").click();
  2461. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  2462. Gdocument.getElementById("ingamechatinputtext").value = mess2;
  2463.  
  2464. }
  2465. var playing = Gdocument.getElementsByClassName("newbonklobby_playerentry newbonklobby_playerentry_half");
  2466. var inplaying = false;
  2467. for(var i = 0;i<playing.length;i++){
  2468. if(userjoined == playing[i].children[1].textContent){
  2469. inplaying = true;
  2470. break;
  2471. }
  2472. }
  2473.  
  2474. if(playing.length<=2 && inplaying){
  2475. Gdocument.getElementById("newbonklobby_editorbutton").click();
  2476. Gdocument.getElementById("mapeditor_close").click();
  2477. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  2478. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  2479. if(transitioning == true){
  2480. canceled = true;
  2481. }
  2482. }
  2483.  
  2484. }
  2485. var lm = "";
  2486. try{
  2487. lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  2488. if(typeof(lm[0].parentElement.style["parsed"]) == 'undefined'){
  2489. if (lm[0].className == "newbonklobby_chat_msg_colorbox"){
  2490. lm[2].innerHTML = urlify(lm[2].innerHTML);
  2491. Laster_message = lastmessage();
  2492. lm[0].parentElement.style["parsed"] = true;
  2493. }
  2494. if (lm[0].className == "newbonklobby_chat_status"){
  2495. lm[0].innerHTML = urlify(lm[0].innerHTML);
  2496. Laster_message = lastmessage();
  2497. lm[0].parentElement.style["parsed"] = true;
  2498. }
  2499. }
  2500. }
  2501. catch{
  2502. lm = "";
  2503. }
  2504.  
  2505. if(Last_message.indexOf("@"+username)!=-1 && npermissions == 1){
  2506. if(Notification.requestPermission()){
  2507. var n = new Notification(Last_message);
  2508. }
  2509. }
  2510.  
  2511. try{
  2512. lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  2513. if(typeof(lm[0].parentElement.style["parsed"])=='undefined'){
  2514. if(lm[0].className == "ingamechatname"){
  2515. lm[1].innerHTML = urlify(lm[1].innerHTML);
  2516. Laster_message = lastmessage();
  2517. lm[0].parentElement.style["parsed"] = true;
  2518. }
  2519. if(lm[0].className == ""){
  2520. lm[0].innerHTML = urlify(lm[0].innerHTML);
  2521. Laster_message = lastmessage();
  2522. lm[0].parentElement.style["parsed"] = true;
  2523. }
  2524. }
  2525. }
  2526. catch{
  2527. lm = "";
  2528. }
  2529. for(i=0;i<echo_list.length;i++){
  2530. if(Last_message.substring(0,echo_list[i].length+2) == echo_list[i]+": "){
  2531. message = Last_message.substring(echo_list[i].length+2);
  2532. chat(flag_manage(message));
  2533. }
  2534. }
  2535.  
  2536. }
  2537. if (ishost==true && new_message){
  2538. for(i=0;i<banned.length;i++){
  2539. if(Last_message.startsWith("* "+banned[i]+" has joined the game")){
  2540. chat("/kick '"+banned[i]+"'");
  2541. }
  2542. }
  2543. }
  2544. if(ishost && stopquickplay == 0){
  2545. if(checkboxhidden){
  2546. checkboxhidden = false;
  2547. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  2548. for(var i = 0; i<classes.length;i++){
  2549. classes[i].style["display"] = "block";
  2550. classes[i].className = "quickplaycheckbox quickplaychecked";
  2551. }
  2552. Gdocument.getElementById('clearallcheckboxes').style["display"] = "block";
  2553.  
  2554. }
  2555. if(Gdocument.getElementById("ingamewinner").style["visibility"]=="inherit" && stopquickplay == 0 && dontswitch == false){
  2556. if(shuffle){
  2557. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  2558. var available = [];
  2559. var availableindexes = [];
  2560. var notempty = false;
  2561. for(var i = 0; i<e.length;i++){
  2562. var a = false;
  2563. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  2564. available.push(a);
  2565. if(a){
  2566. availableindexes.push(i);
  2567. notempty = true;
  2568. }
  2569. }
  2570. if(notempty){
  2571.  
  2572. if(availableindexes.length!=1){
  2573. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  2574. }
  2575. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  2576. }
  2577. }
  2578. else{
  2579. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  2580. var available = [];
  2581. var availableindexes = [];
  2582. var notempty = false;
  2583. for(var i = 0; i<e.length;i++){
  2584. var a = false;
  2585. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  2586. available.push(a);
  2587. if(a){
  2588. availableindexes.push(i);
  2589. notempty = true;
  2590. }
  2591. }
  2592. if(notempty){
  2593. var above = [];
  2594. for(var i = 0;i<availableindexes.length;i++){
  2595. if(availableindexes[i]>quicki){
  2596. above.push(availableindexes[i]);
  2597. }
  2598. }
  2599. if(above.length>0){
  2600. quicki = above[0];
  2601. }
  2602. else{
  2603. quicki = availableindexes[0];
  2604. }
  2605. }
  2606. }
  2607. transitioning = true;
  2608. map(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  2609.  
  2610. dontswitch = true;
  2611. setTimeout(function(){Gdocument.getElementById("ingamewinner").style["visibility"]="hidden"; dontswitch = false;},timedelay);
  2612.  
  2613. }
  2614. }
  2615. else{
  2616. if(!checkboxhidden){
  2617. checkboxhidden = true;
  2618. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  2619. for(var i = 0; i<classes.length;i++){
  2620. classes[i].style["display"] = "none";
  2621. classes[i].className = "quickplaycheckbox quickplayunchecked";
  2622. }
  2623. Gdocument.getElementById('clearallcheckboxes').style["display"] = "none";
  2624. }
  2625. }
  2626. new_message = false;
  2627. };
  2628. });

QingJ © 2025

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