Bonk Commands

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

目前为 2022-09-17 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Bonk Commands
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.5
  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. // @license MIT
  8. // @match https://bonk.io/gameframe-release.html
  9. // @run-at document-end
  10. // @grant none
  11. // ==/UserScript==
  12. setTimeout(function(){
  13. var link2pastebin = "https://pastebin.com/2b8XqqYu";
  14. var link2greasyfork = "https://greasyfork.org/en/scripts/451341-bonk-commands";
  15.  
  16. var Gdocument = document.getElementById("maingameframe").contentDocument;
  17. var Gwindow = document.getElementById("maingameframe").contentWindow;
  18.  
  19. if(typeof(originalSend)=='undefined'){var originalSend = Gwindow.WebSocket.prototype.send;}
  20. if(typeof(bonkwss)=='undefined'){var bonkwss = 0;}
  21. Gwindow.WebSocket.prototype.send = function(args) {
  22. if(this.url.includes(".bonk.io/socket.io/?EIO=3&transport=websocket&sid=")){bonkwss = this;}
  23. if(this.url.includes(".bonk.io/socket.io/?EIO=3&transport=websocket&sid=") && !this.injected){
  24. this.injected = true;
  25. var originalRecieve = this.onmessage;
  26. this.onmessage = function(args){
  27. if(args.data.startsWith('42[7')){
  28. var jsonargs = JSON.parse(args.data.substring(2))[2];
  29. if(typeof(jsonargs["type"]) != "undefined"){
  30. if(jsonargs["type"]=="private chat" && (jsonargs["to"] == username)){
  31. if(typeof(jsonargs["message"])=="object" && typeof(jsonargs["password"]) == "object"){
  32. var password = CRYPT_MESSAGE(private_key,jsonargs["password"]);
  33. var decodedtext = jsonargs["message"].slice(0,400);
  34. var encodedtext = "";
  35. for(var i=0;i<decodedtext.length;i++){
  36. if(password[i%password.length]<1000){
  37. encodedtext+=String.fromCharCode(password[i%password.length]^decodedtext[i]);
  38. }
  39. }
  40. displayInChat("> "+jsonargs["from"]+": "+encodedtext,"#DA0808","#1EBCC1");
  41. }
  42. }
  43. if(jsonargs["type"]=="request public key" && jsonargs["to"] == username){
  44. SEND("42"+JSON.stringify([4,{"type":"public key","from":username,"public key":public_key}]));
  45. }
  46. if(jsonargs["type"]=="public key" && jsonargs["from"] == private_chat && request_public_key_time_stamp+1500>Date.now()){
  47. private_chat_public_key = [private_chat,jsonargs["public key"]];
  48. displayInChat("Private chatting with "+private_chat+".","#DA0808","#1EBCC1");
  49.  
  50. }
  51.  
  52. }
  53. }
  54. return originalRecieve.call(this,args);
  55. };
  56. var originalClose = this.onclose;
  57. this.onclose = function () {
  58. window.bonkwss = 0;
  59. return originalClose.call(this);
  60. }
  61. }
  62. if(args.startsWith('42[4,')){
  63. var jsonargs = JSON.parse(args.substring(2))[1];
  64. if(typeof(jsonargs["type"]) != "undefined"){
  65. }
  66. }
  67. if(stopquickplay!=1){
  68. args = args.replace('"wl":3','"wl":999');
  69. }
  70. return originalSend.call(this,args);
  71. };
  72.  
  73.  
  74.  
  75. function SEND(args){
  76. if(bonkwss!=0){
  77. bonkwss.send(args);
  78. }
  79. }
  80.  
  81. Gdocument.getElementById("ingamechatcontent").style["pointer-events"]="all";
  82. Gdocument.getElementById("ingamechatcontent").style["max-height"]="250px";
  83. Gdocument.getElementById("ingamechatcontent").style["height"]="128px";
  84. Gdocument.getElementById("ingamechatbox").style["height"]="250px";
  85.  
  86. setTimeout(function(){document.getElementById('adboxverticalCurse').style["display"] = "none";
  87. document.getElementById('adboxverticalleftCurse').style["display"] = "none";},3000);
  88.  
  89.  
  90. function GENERATE_PRIME_NUMBER(mini = 0,maxi = 0,choices = []){
  91. if(choices.length == 0){
  92. for(var i = mini;i<maxi+1;i++){
  93. choices.push(i);
  94. }
  95. }
  96. firstTry = choices[Math.floor(Math.random()*choices.length)];
  97. for(var i = 2; i<Math.floor(Math.sqrt(firstTry)+1);i++){
  98. if(i!=firstTry){
  99. if(firstTry%i == 0){
  100. choices.splice(choices.indexOf(firstTry),1);
  101. if(choices.length == 0){
  102. return 0;
  103. }
  104. return GENERATE_PRIME_NUMBER(mini,maxi,choices);
  105. }
  106. }
  107. }
  108. return firstTry;
  109. }
  110. function GENERATE_KEYS(){
  111. interval = [];
  112. for(var i = 100;i<301;i++){
  113. interval.push(i);
  114. }
  115. random_prime = [GENERATE_PRIME_NUMBER(0,0,choices = interval),0];
  116. interval.splice(interval.indexOf(random_prime[0]),1);
  117. random_prime[1] = GENERATE_PRIME_NUMBER(0,0,choices = interval);
  118.  
  119. n = random_prime[0]*random_prime[1];
  120. n2 = (random_prime[0]-1)*(random_prime[1]-1);
  121.  
  122.  
  123. e = GENERATE_PRIME_NUMBER(2,n2-1);
  124. d = 0;
  125. redo = true;
  126. for(var i = 0;i<1000000;i++){
  127. if((e*i-1)%n2 == 0 && i!=e){
  128. d = i;
  129. redo = false;
  130. break;
  131. }
  132. }
  133. if(redo){
  134. return GENERATE_KEYS();
  135. }
  136. else{
  137. return [[n,e],[n,d]];
  138. }
  139.  
  140. }
  141. function CRYPT_NUMBER(key, data){
  142.  
  143. result = 1;
  144. for(var i = 0;i<key[1];i++){
  145. result*=data;
  146. result = result%key[0];
  147. }
  148. return result%key[0];
  149.  
  150. }
  151.  
  152. function CRYPT_MESSAGE(key,data){
  153. var resulttext = [];
  154. for(var i = 0;i<data.length;i++){
  155. resulttext.push(CRYPT_NUMBER(key,data[i]));
  156. }
  157. return resulttext;
  158.  
  159. }
  160.  
  161.  
  162. var dontswitch = false;
  163. var username = 0;
  164. var timedelay = 1400;
  165. var ishost = false;
  166. var quicki=0;
  167. var freejoin = false;
  168. var stopquickplay = 1;
  169. var canceled = false;
  170. var banned = [];
  171. var transitioning = false;
  172. var echo_list = [];
  173. var message = "";
  174. var mode = "";
  175. var private_chat = "";
  176. var private_chat_public_key = ["",[0,0]];
  177. var users = [];
  178. var scroll = false;
  179. var elem = Gdocument.getElementById("maploadwindowmapscontainer");
  180. var npermissions = 1;
  181. var space_flag = false;
  182. var rcaps_flag = false;
  183. var number_flag = false;
  184. var private_chat_keys = GENERATE_KEYS();
  185. var private_key = private_chat_keys[0];
  186. var public_key = private_chat_keys[1];
  187. var request_public_key_time_stamp = 0;
  188. elem.onclick=function(e){
  189. if(stopquickplay==0 && ishost == true && e.isTrusted == true){
  190. quicki = (Array.from(e.target.parentElement.parentNode.children).indexOf(e.target.parentNode)-1)%(Gdocument.getElementById("maploadwindowmapscontainer").children.length);
  191. }
  192. };
  193. function urlify(text) {
  194. return text.replace(/(?:https?:\/\/)?(?:[A-Za-z0-9-ßàÁâãóôþüúðæåïçèõöÿýòäœêëìíøùîûñé]+)(?:\.[A-Za-z0-9-ßàÁâãóôþüúðæåïçèõöÿýòäœêëìíøùîûñé]+)+(?:\/(?:[A-Za-z0-9-._~:/?#\[\]@!$&'()*+,;=]|%[0-9a-fA-F]{2})*)?(?:\?(?:[^=]+=[^&](?:&[^=]+=[^&])*)?)?/g, function(url) {
  195. return '<a href="' + url + '" target="_blank" style = "color:orange">' + url + '</a>';
  196. })
  197. }
  198.  
  199.  
  200. function fire(type,options,d = Gdocument){
  201. var event=new CustomEvent(type);
  202. for(var p in options){
  203. event[p]=options[p];
  204. }
  205. d.dispatchEvent(event);
  206. }
  207.  
  208.  
  209. function chat(message){
  210. mess = Gdocument.getElementById("newbonklobby_chat_input").value;
  211. mess2 = Gdocument.getElementById("ingamechatinputtext").value;
  212. Gdocument.getElementById("newbonklobby_chat_input").value = message;
  213. Gdocument.getElementById("ingamechatinputtext").value = message;
  214. fire("keydown",{keyCode:13});
  215. fire("keydown",{keyCode:13});
  216. Gdocument.getElementById("newbonklobby_chat_input").value = mess;
  217. Gdocument.getElementById("ingamechatinputtext").value = mess2;
  218. }
  219. function displayInChat(message, LobbyColor, InGameColor, options) {
  220. options = options ?? {};
  221. LobbyColor = LobbyColor ?? "#8800FF";
  222. InGameColor = InGameColor ?? "#AA88FF";
  223. let A = Gdocument.createElement("div");
  224. let B = Gdocument.createElement("span");
  225. B.className = "newbonklobby_chat_status";
  226. B.style.color = LobbyColor;
  227. A.appendChild(B);
  228. B.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  229. let C = Gdocument.createElement("div");
  230. let D = Gdocument.createElement("span");
  231. D.style.color = InGameColor;
  232. C.appendChild(D);
  233. D.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  234. let a = false;
  235. if(Gdocument.getElementById("newbonklobby_chat_content").scrollHeight - Gdocument.getElementById("newbonklobby_chat_content").scrollTop > Gdocument.getElementById("newbonklobby_chat_content").clientHeight - 1) {
  236. a = true;
  237. }
  238. Gdocument.getElementById("newbonklobby_chat_content").appendChild(A);
  239. Gdocument.getElementById("ingamechatcontent").appendChild(C);
  240. if (a) { Gdocument.getElementById("newbonklobby_chat_content").scrollTop = Number.MAX_SAFE_INTEGER;};
  241. Gdocument.getElementById("ingamechatcontent").scrollTop = Number.MAX_SAFE_INTEGER;
  242. }
  243.  
  244.  
  245. function lobby(){
  246. if (Gdocument.getElementById("newbonklobby").style["display"]=="none"){
  247. Gdocument.getElementById("mapeditorcontainer").click();
  248. Gdocument.getElementById("mapeditor_close").click();
  249. if(Gdocument.getElementsByClassName("newbonklobby_playerentry").length>0){
  250. Gdocument.getElementById("newbonklobby").style["opacity"]=1;
  251. Gdocument.getElementById("newbonklobby").style["display"]="block";
  252. Gdocument.getElementById("newbonklobby").style["z-index"]=1;
  253. Gdocument.getElementById("maploadwindowcontainer").style["z-index"]=1;
  254. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=1;
  255. Gdocument.getElementById("pretty_top").style["z-index"]=2;
  256. Gdocument.getElementById("settingsContainer").style["z-index"]=2;
  257. Gdocument.getElementById("leaveconfirmwindow").style["z-index"]=2;
  258. Gdocument.getElementById("hostleaveconfirmwindow").style["z-index"]=2;
  259. }
  260. else{
  261. Gdocument.getElementById("newbonklobby").style["opacity"]=0;
  262. Gdocument.getElementById("newbonklobby").style["display"]="none";
  263. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
  264. }
  265. }
  266. else if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  267. Gdocument.getElementById("newbonklobby").style["opacity"]=0;
  268. Gdocument.getElementById("newbonklobby").style["display"]="none";
  269. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
  270. }
  271. }
  272.  
  273. function lastmessage(){
  274. if(Gdocument.getElementById("newbonklobby_chat_content").children.length!=0){
  275. var lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  276. var lm2 = "";
  277. for(var i = 0; i<lm.length;i++){
  278. lm2+=" "+lm[i].textContent.trim();
  279. }
  280. lm2 = lm2.trim();
  281. if(lm2.startsWith("*")){
  282. return lm2;
  283. }
  284. }
  285. if(Gdocument.getElementById("ingamechatcontent").children.length!=0){
  286. var lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  287. var lm2 = "";
  288. for(var i = 0; i<lm.length;i++){
  289. lm2+=" "+lm[i].textContent.trim();
  290. }
  291. return lm2.trim();
  292. }
  293. return "";
  294.  
  295. }
  296. function map(e){
  297. if(e<0){
  298. displayInChat("There is no previous map.","#DA0808","#1EBCC1");
  299. quicki = 0;
  300. return;
  301. }
  302. if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
  303. displayInChat("Click the maps button.","#DA0808","#1EBCC1");
  304. return;
  305. }
  306. setTimeout(function(){if(!canceled){
  307. Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
  308. Gdocument.getElementById("newbonklobby_editorbutton").click();
  309. Gdocument.getElementById("mapeditor_close").click();
  310. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  311. Gdocument.getElementById("mapeditor_midbox_testbutton").click();}
  312. canceled = false;
  313. transitioning = false;
  314. },timedelay);
  315. }
  316.  
  317. function gotonextmap(e){
  318. if(e<0){
  319. displayInChat("There is no previous map.","#DA0808","#1EBCC1");
  320. quicki = 0;
  321. return;
  322. }
  323. if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
  324. displayInChat("Click the maps button.","#DA0808","#1EBCC1");
  325. return;
  326. }
  327. Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
  328. Gdocument.getElementById("newbonklobby_editorbutton").click();
  329. Gdocument.getElementById("mapeditor_close").click();
  330. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  331. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  332. Gdocument.getElementById("newbonklobby").style["visibility"] = "visible";
  333.  
  334. }
  335. function commandhandle(chat_val){
  336. if (chat_val.substring(1,6)=="echo " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  337. if (chat_val.substring(6).replace(/^\s+|\s+$/g, '')==username){
  338. displayInChat("You cannot echo yourself.","#DA0808","#1EBCC1");
  339. return "";
  340. }
  341. else if (echo_list.indexOf(chat_val.substring(6).replace(/^\s+|\s+$/g, ''))===-1) {
  342. echo_list.push(chat_val.substring(6).replace(/^\s+|\s+$/g, ''));
  343. displayInChat(chat_val.substring(6).replace(/^\s+|\s+$/g, '') + " is being echoed.","#DA0808","#1EBCC1");
  344. return "";
  345. }
  346. else{
  347. displayInChat(chat_val.substring(6).replace(/^\s+|\s+$/g, '') + " is already being echoed.","#DA0808","#1EBCC1");
  348. return "";
  349. }
  350. }
  351. else if (chat_val.substring(1,8)=="remove " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  352. if (echo_list.indexOf(chat_val.substring(7).replace(/^\s+|\s+$/g, ''))!==-1){
  353. echo_list.splice(echo_list.indexOf(chat_val.substring(7).replace(/^\s+|\s+$/g, '')),1);
  354. displayInChat(chat_val.substring(7).replace(/^\s+|\s+$/g, '')+" is not being echoed.","#DA0808","#1EBCC1");
  355. return "";
  356. }
  357. else{
  358. displayInChat("You cannot remove someone that you didn't echo.","#DA0808","#1EBCC1");
  359. return "";
  360. }
  361. }
  362. else if (chat_val.substring(1,10)=="clearecho"){
  363. echo_list = [];
  364. displayInChat("Cleared the echo list.","#DA0808","#1EBCC1");
  365. return "";
  366. }
  367. else if (chat_val.substring(1,6)=="space"){
  368. if(space_flag == true){
  369. displayInChat("Space is now off.","#DA0808","#1EBCC1");
  370. space_flag = false;
  371. }
  372. else{
  373. displayInChat("Space is now on.","#DA0808","#1EBCC1");
  374. space_flag = true;
  375. }
  376. return "";
  377. }
  378. else if (chat_val.substring(1,6)=="rcaps"){
  379. if(rcaps_flag == true){
  380. displayInChat("Rcaps is now off.","#DA0808","#1EBCC1");
  381. rcaps_flag = false;
  382. }
  383. else{
  384. displayInChat("Rcaps is now on.","#DA0808","#1EBCC1");
  385. rcaps_flag = true;
  386. }
  387. return "";
  388. }
  389. else if (chat_val.substring(1,7)=="number"){
  390. if(number_flag == true){
  391. displayInChat("Number is now off.","#DA0808","#1EBCC1");
  392. number_flag = false;
  393. }
  394. else{
  395. displayInChat("Number is now on.","#DA0808","#1EBCC1");
  396. number_flag = true;
  397. }
  398. return "";
  399. }
  400. else if (chat_val.substring(1,12)=="requestfake" && chat_val.replace(/^\s+|\s+$/g, '').length>=13){
  401. var mess = chat_val.substring(13).replace(/^\s+|\s+$/g, '');
  402. var result;
  403. var key;
  404. try{
  405. result = JSON.parse("{"+mess.replaceAll(",",":")+"}");
  406. if(Object.keys(result).length!=1){
  407. throw "";
  408. }
  409. else{
  410. key = Object.keys(result)[0];
  411. }
  412. SEND('42'+JSON.stringify([27,{"m":"","mapname":key.replaceAll(":",","),"mapauthor":result[key].replaceAll(":",",")}]));
  413. return "";
  414. }
  415. catch{
  416. displayInChat('Format: /requestfake "mapname", "mapauthor"',"#DA0808","#1EBCC1");
  417. return "";
  418. }
  419. return "";
  420. }
  421. else if (chat_val.substring(1,6)=="eval " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  422. var ev = "";
  423. try{
  424. ev = eval(chat_val.substring(6).replace(/^\s+|\s+$/g, ''));
  425. }
  426. catch(e){
  427. displayInChat(e.message,"#DA0808","#1EBCC1");
  428. }
  429. try{
  430. displayInChat(ev.toString(),"#DA0808","#1EBCC1");
  431. }
  432. catch{
  433. }
  434. return "";
  435. }
  436. else if (chat_val.substring(1,9)=="hidechat"){
  437. Gdocument.getElementById("ingamechatcontent").style["max-height"]="0px";
  438. return "";
  439. }
  440. else if (chat_val.substring(1,9)=="showchat"){
  441. Gdocument.getElementById("ingamechatcontent").style["max-height"]="250px";
  442. return "";
  443. }
  444. else if (chat_val.substring(1,7)=="scroll"){
  445. if(scroll==false){
  446. scroll = true;
  447. Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="scroll";
  448. Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
  449. }
  450. else if(scroll==true){
  451. scroll = false;
  452. Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="hidden";
  453. Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
  454. }
  455. return "";
  456. }
  457.  
  458. else if (chat_val.substring(1,7)=="chatw "){
  459. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '');
  460. if(username == text){
  461. displayInChat("You cannot private chat with yourself.","#DA0808","#1EBCC1");
  462. return "";
  463. }
  464. private_chat = text;
  465. SEND("42"+JSON.stringify([4,{"type":"request public key","from":username,"to":private_chat}]));
  466. request_public_key_time_stamp = Date.now();
  467. 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);
  468. return "";
  469. }
  470. else if (chat_val.substring(1,5)=="msg " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  471. if(private_chat_public_key[1][0] != 0 && private_chat_public_key[1][1] != 0 && private_chat_public_key[0] == private_chat){
  472. var text = chat_val.substring(5).replace(/^\s+|\s+$/g, '');
  473. var password = [];
  474. for(var i = 0;i<5;i++){
  475. password.push(Math.floor(Math.random()*100+50));
  476. }
  477. var text2 = [];
  478. for(var i = 0;i<text.slice(0,400).length ;i++){
  479. text2.push(password[i%password.length]^text.slice(0,400).charCodeAt(i));
  480. }
  481. SEND("42"+JSON.stringify([4,{"type":"private chat","from":username,"to":private_chat,"message":text2,"password":CRYPT_MESSAGE(private_chat_public_key[1],password)}]));
  482. displayInChat("> "+username+": "+text,"#DA0808","#1EBCC1");
  483.  
  484. }
  485. return "";
  486. }
  487. else if (chat_val.substring(1,6)=="lobby"){
  488. lobby();
  489. return "";
  490. }
  491. else if (chat_val.substring(1,6)=="team " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  492. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  493. if(text == "r"){Gdocument.getElementById("newbonklobby_redbutton").click();}
  494. else if(text == "g"){Gdocument.getElementById("newbonklobby_greenbutton").click();}
  495. else if(text == "y"){Gdocument.getElementById("newbonklobby_yellowbutton").click();}
  496. else if(text == "b"){Gdocument.getElementById("newbonklobby_bluebutton").click();}
  497. else if(text == "s"){Gdocument.getElementById("newbonklobby_specbutton").click();}
  498. else if(text == "f"){Gdocument.getElementById("newbonklobby_ffabutton").click();}
  499. return "";
  500. }
  501. else if (chat_val.substring(1,7)=="notify"){
  502. npermissions = 1;
  503. return "";
  504. }
  505. else if (chat_val.substring(1,11)=="stopnotify"){
  506. npermissions = 0;
  507. return "";
  508. }
  509. else if (chat_val.substring(1,5)=="help" || chat_val.substring(1,2)=="?"){
  510. displayInChat("All the commands are:","#DA0808","#1EBCC1");
  511. displayInChat("/help","#DA0808","#1EBCC1");
  512. displayInChat("/?","#DA0808","#1EBCC1");
  513. displayInChat("/space","#DA0808","#1EBCC1");
  514. displayInChat("/rcaps","#DA0808","#1EBCC1");
  515. displayInChat("/number","#DA0808","#1EBCC1");
  516. displayInChat("/echo [username]","#DA0808","#1EBCC1");
  517. displayInChat("/remove [username]","#DA0808","#1EBCC1");
  518. displayInChat("/clearecho","#DA0808","#1EBCC1");
  519. displayInChat("/chatw [username]","#DA0808","#1EBCC1");
  520. displayInChat("/msg [text]","#DA0808","#1EBCC1");
  521. displayInChat("/requestfake \"[mapname]\", \"[mapauthor]\"","#DA0808","#1EBCC1");
  522. displayInChat("/eval [code]","#DA0808","#1EBCC1");
  523. displayInChat("/lobby","#DA0808","#1EBCC1");
  524. displayInChat("/team [letter]","#DA0808","#1EBCC1");
  525. displayInChat("/scroll","#DA0808","#1EBCC1");
  526. displayInChat("/hidechat","#DA0808","#1EBCC1");
  527. displayInChat("/showchat","#DA0808","#1EBCC1");
  528. displayInChat("/notify","#DA0808","#1EBCC1");
  529. displayInChat("/stopnotify","#DA0808","#1EBCC1");
  530. displayInChat("Host commands are:","#DA0808","#1EBCC1");
  531. displayInChat("/startqp","#DA0808","#1EBCC1");
  532. displayInChat("/stopqp","#DA0808","#1EBCC1");
  533. displayInChat("/next","#DA0808","#1EBCC1");
  534. displayInChat("/previous","#DA0808","#1EBCC1");
  535. displayInChat("/start","#DA0808","#1EBCC1");
  536. displayInChat("/balanceA [number]","#DA0808","#1EBCC1");
  537. displayInChat("/ban [username]","#DA0808","#1EBCC1");
  538. return "";
  539. }
  540. else if(ishost){
  541. if (chat_val.substring(1,5)=="next" && stopquickplay == 0){
  542. quicki++;
  543. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  544. displayInChat("Switched to next map.","#DA0808","#1EBCC1");
  545. return "";
  546.  
  547. }
  548. else if (chat_val.substring(1,9)=="freejoin"){
  549. if(freejoin == false){
  550. freejoin = true;
  551. displayInChat("Freejoin is now on.","#DA0808","#1EBCC1");
  552.  
  553. }
  554. else{
  555. freejoin = false;
  556. displayInChat("Freejoin is now off.","#DA0808","#1EBCC1");
  557. }
  558. return "";
  559.  
  560. }
  561. else if (chat_val.substring(1,9)=="previous" && stopquickplay == 0){
  562. quicki--;
  563. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  564. displayInChat("Switched to previous map.","#DA0808","#1EBCC1");
  565. return "";
  566. }
  567. else if (chat_val.substring(1,6)=="start" && chat_val.length == 6){
  568. Gdocument.getElementById("newbonklobby_editorbutton").click();
  569. Gdocument.getElementById("mapeditor_close").click();
  570. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  571. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  572. return "";
  573. }
  574. else if (chat_val.substring(1,8)=="startqp" && stopquickplay == 1){
  575. stopquickplay = 0;
  576. quicki = 0;
  577. displayInChat("Enabled quickplay.","#DA0808","#1EBCC1");
  578. return "";
  579. }
  580. else if (chat_val.substring(1,7)=="stopqp" && stopquickplay == 0){
  581. stopquickplay = 1;
  582. quicki = 0;
  583. displayInChat("Disabled quickplay.","#DA0808","#1EBCC1");
  584. return "";
  585. }
  586.  
  587. else if (chat_val.substring(1,5)=="ban " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  588. banned.push(chat_val.substring(5).replace(/^\s+|\s+$/g, ''));
  589. displayInChat("Banned "+chat_val.substring(5).replace(/^\s+|\s+$/g, '')+".","#DA0808","#1EBCC1");
  590. return "/kick '" + chat_val.substring(5).replace(/^\s+|\s+$/g, '') + "'";
  591. }
  592. else if (chat_val.substring(1,10)=="balanceA " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  593. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  594. if(parseInt(text)!=NaN){
  595. if(Gdocument.getElementById("newbonklobby").style["display"] != "block"){
  596. mess2 = Gdocument.getElementById("ingamechatinputtext").value;
  597. Gdocument.getElementById("ingamechatinputtext").value = "";
  598. Gdocument.getElementById("newbonklobby_editorbutton").click();
  599. Gdocument.getElementById("mapeditor_close").click();
  600. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  601. Gdocument.getElementById("ingamechatinputtext").value = mess2;
  602.  
  603. }
  604. var playing = Gdocument.getElementsByClassName("newbonklobby_playerentry");
  605. for(var i = 0; i<playing.length;i++){
  606. chat("/balance \""+playing[i].children[1].textContent+"\" "+text)
  607. }
  608. }
  609. return "";
  610.  
  611. }
  612. }
  613. return chat_val;
  614. }
  615. function flag_manage(t){
  616. var text = t;
  617. if(rcaps_flag == true){
  618. text = text.split('');
  619. for(var i = 0; i<text.length;i++){
  620. if(Math.floor(Math.random()*2)){
  621. text[i] = text[i].toUpperCase();
  622. }
  623. else{
  624. text[i] = text[i].toLowerCase();
  625. }
  626. }
  627. text = text.join('');
  628. }
  629. if(space_flag == true){
  630. text = text.split('').join(' ')
  631. }
  632. if(number_flag == true){
  633. text = text.replace(/[t|T][Oo]+/g,"2");
  634. text = text.replace(/[f|F][o|O][r|R]/g,"4");
  635. text = text.replace(/[a|A][t|T][e|E]/g,"8");
  636. text = text.replace(/[e|E]/g,"3");
  637. text = text.replace(/[a|A]/g,"4");
  638. text = text.replace(/[o|O]/g,"0");
  639. text = text.replace(/[s|S]/g,"5");
  640. text = text.replace(/[i|I|l|L]/g,"1");
  641. }
  642. return text;
  643. }
  644. (function(){
  645. var newbonklobby_chat_input_old = Gdocument.getElementById("newbonklobby_chat_input").onkeydown ?? (function(){});
  646. Gdocument.getElementById("newbonklobby_chat_input").onkeydown = function(e){
  647. newbonklobby_chat_input_old(e);
  648. if(e.keyCode==13){
  649. var chat_val = Gdocument.getElementById("newbonklobby_chat_input").value;
  650. if (chat_val!="" && chat_val[0]=="/"){
  651. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  652. chat(commandhandle(chat_val));
  653. }
  654. else{
  655. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  656. chat(flag_manage(chat_val));
  657. }
  658. chat_val = Gdocument.getElementById("ingamechatinputtext").value;
  659. if (chat_val!="" && chat_val[0]=="/"){
  660. Gdocument.getElementById("ingamechatinputtext").value = "";
  661. chat(commandhandle(chat_val));
  662. }
  663. else{
  664. Gdocument.getElementById("ingamechatinputtext").value = "";
  665. chat(flag_manage(chat_val));
  666. }
  667. }
  668. }
  669. })();
  670. (function(){
  671. var ingame_chat_input_old = Gdocument.getElementById("ingamechatinputtext").onkeydown ?? (function(){});
  672. Gdocument.getElementById("ingamechatinputtext").onkeydown = function(e){
  673. ingame_chat_input_old(e);
  674. if(e.keyCode==13){
  675. var chat_val = Gdocument.getElementById("newbonklobby_chat_input").value;
  676. if (chat_val!="" && chat_val[0]=="/"){
  677. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  678. chat(commandhandle(chat_val));
  679. }
  680. else{
  681. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  682. chat(flag_manage(chat_val));
  683. }
  684. chat_val = Gdocument.getElementById("ingamechatinputtext").value;
  685. if (chat_val!="" && chat_val[0]=="/"){
  686. Gdocument.getElementById("ingamechatinputtext").value = "";
  687. chat(commandhandle(chat_val));
  688. }
  689. else{
  690. Gdocument.getElementById("ingamechatinputtext").value = "";
  691. chat(flag_manage(chat_val));
  692. }
  693. }
  694. }
  695. })();
  696. Last_message = "";
  697. Laster_message = "";
  698. var new_message = false;
  699. var changed_chat = false;
  700. interval = setInterval(timeout123,100);
  701. function timeout123() {
  702. if(Gdocument.getElementById("mainmenuelements").style["display"] == "block"){
  703. var chatbox = Gdocument.getElementById("newbonklobby_chat_content");
  704. while (chatbox.firstChild) {
  705. chatbox.removeChild(chatbox.firstChild);
  706. }
  707. rcaps_flag = false;
  708. space_flag = false;
  709. number_flag = false;
  710. echo_list = [];
  711. scroll = false;
  712. stopquickplay = 1;
  713. freejoin = false;
  714.  
  715. }
  716. if(Gdocument.getElementById("ingametextwarning_afk").style["display"]=="table"){
  717. Gdocument.getElementById("pretty_top_settings").click();
  718. key2 = Gdocument.getElementById("redefineControls_table").children[0].children[5].children[1].innerHTML.charCodeAt(0);
  719. Gdocument.getElementById("settings_close").click();
  720.  
  721. if(key2>0){
  722. fire("keydown",{keyCode:key2},Gwindow);
  723. setTimeout(function(){fire("keyup",{keyCode:key2},Gwindow)},100);
  724. }
  725. }
  726. if(Gdocument.getElementById("newbonklobby").style["display"]=="block"){
  727. Gdocument.getElementById("ingamechatinputtext").style["visibility"]="hidden";
  728. }
  729. else{
  730. Gdocument.getElementById("ingamechatinputtext").style["visibility"]="visible";
  731.  
  732. }
  733. mode = Gdocument.getElementById("newbonklobby_modetext").textContent;
  734. var userlist = Gdocument.getElementsByClassName("newbonklobby_playerentry_name");
  735. users = [];
  736. for(var i = 0;i<userlist.length;i++){
  737. users.push(userlist[i].textContent);
  738. }
  739. if(Gdocument.getElementsByClassName('newbonklobby_settings_button brownButton brownButton_classic buttonShadow brownButtonDisabled').length == 0){
  740. ishost = true;
  741. }
  742. else if(Gdocument.getElementsByClassName('newbonklobby_settings_button brownButton brownButton_classic buttonShadow brownButtonDisabled').length == 4){
  743. ishost = false;
  744. }
  745. if(Gdocument.getElementById("pretty_top_name")!=null){
  746. username = Gdocument.getElementById("pretty_top_name").textContent;
  747. }
  748. try{
  749. Last_message = lastmessage()
  750. } catch{
  751. Last_message = "";
  752. }
  753. if (Laster_message != Last_message){
  754. Laster_message = Last_message;
  755. if(changed_chat==false){
  756. new_message = true;
  757. }
  758. else{
  759. changed_chat = false;
  760. }
  761. }
  762. if(new_message){
  763. if(freejoin && Last_message.startsWith("* ") && Last_message.endsWith(" has joined the game") && ishost){
  764. var userjoined = Last_message.substring(2,Last_message.length-20);
  765. if(Gdocument.getElementById("newbonklobby").style["display"] != "block"){
  766. mess2 = Gdocument.getElementById("ingamechatinputtext").value;
  767. Gdocument.getElementById("ingamechatinputtext").value = "";
  768. Gdocument.getElementById("newbonklobby_editorbutton").click();
  769. Gdocument.getElementById("mapeditor_close").click();
  770. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  771. Gdocument.getElementById("ingamechatinputtext").value = mess2;
  772.  
  773. }
  774. var playing = Gdocument.getElementsByClassName("newbonklobby_playerentry newbonklobby_playerentry_half");
  775. var inplaying = false;
  776. for(var i = 0;i<playing.length;i++){
  777. if(userjoined == playing[i].children[1].textContent){
  778. inplaying = true;
  779. break;
  780. }
  781. }
  782. if(playing.length<=2 && inplaying){
  783. Gdocument.getElementById("newbonklobby_editorbutton").click();
  784. Gdocument.getElementById("mapeditor_close").click();
  785. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  786. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  787. if(transitioning == true){
  788. canceled = true;
  789. }
  790. }
  791. }
  792. var lm = "";
  793. try{
  794. lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  795. if (lm[0].className == "newbonklobby_chat_msg_colorbox"){
  796. lm[2].innerHTML = urlify(lm[2].innerHTML);
  797. Laster_message = lastmessage();
  798. }
  799. if (lm[0].className == "newbonklobby_chat_status"){
  800. lm[0].innerHTML = urlify(lm[0].innerHTML);
  801. Laster_message = lastmessage();
  802. }
  803. }
  804. catch{
  805. lm = "";
  806. }
  807. if(Last_message.indexOf("@"+username)!=-1 && npermissions == 1){
  808. var n = new Notification(Last_message);
  809. }
  810. try{
  811. lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  812. if(lm[0].className == "ingamechatname"){
  813. lm[1].innerHTML = urlify(lm[1].innerHTML);
  814. Laster_message = lastmessage();
  815. }
  816. if(lm[0].className == ""){
  817. lm[0].innerHTML = urlify(lm[0].innerHTML);
  818. Laster_message = lastmessage();
  819. }
  820. }
  821. catch{
  822. lm = "";
  823. }
  824.  
  825. for(i=0;i<echo_list.length;i++){
  826. if(Last_message.substring(0,echo_list[i].length+2) == echo_list[i]+": "){
  827. message = Last_message.substring(echo_list[i].length+2);
  828. chat(flag_manage(message));
  829. }
  830. }
  831. }
  832. if (ishost==true && new_message){
  833. for(i=0;i<banned.length;i++){
  834. if(Last_message == "* "+banned[i]+" has joined the game "){
  835. chat("/kick '"+banned[i]+"'");
  836. }
  837. }
  838. }
  839. if(ishost == true && stopquickplay == 0){
  840. if(Gdocument.getElementById("ingamewinner").style["visibility"]=="inherit" && stopquickplay == 0 && dontswitch == false){
  841. quicki++;
  842. transitioning = true;
  843. map(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  844. dontswitch = true;
  845. setTimeout(function(){Gdocument.getElementById("ingamewinner").style["visibility"]="hidden"; dontswitch = false;},timedelay);
  846. }
  847. }
  848. new_message = false;
  849. }
  850.  
  851. },5000)