Bonk Commands

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

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

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

QingJ © 2025

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