Bonk Commands

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

当前为 2022-09-26 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Bonk Commands
  3. // @namespace http://tampermonkey.net/
  4. // @version 2.0
  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/*
  9. // @run-at document-end
  10. // @grant none
  11. // ==/UserScript==
  12. setTimeout(function(){
  13. var link2pastebin = "https://pastebin.com/2b8XqqYu";
  14. var link2greasyfork = "https://gf.qytechs.cn/en/scripts/451341-bonk-commands";
  15. var Gdocument = document.getElementById("maingameframe").contentDocument;
  16. var Gwindow = document.getElementById("maingameframe").contentWindow;
  17. if(typeof(originalSend)=='undefined'){var originalSend = Gwindow.WebSocket.prototype.send;}
  18. if(typeof(bonkwss)=='undefined'){var bonkwss = 0;}
  19. if(typeof(sandboxon)=='undefined'){var sandboxon = false;}
  20. if(typeof(sandboxid)=='undefined'){var sandboxid = 1;}
  21. if(typeof(playerids)=='undefined'){var playerids = {};}
  22. if(typeof(sandboxplayerids)=='undefined'){var sandboxplayerids = {};}
  23. function sandboxonclick(){
  24. Gdocument.getElementById("roomlistcreatewindowmaxplayers").value = 1;
  25. Gdocument.getElementById("roomlistcreatewindowunlistedcheckbox").checked = true;
  26. Gdocument.getElementById("roomlistcreatecreatebutton").click();
  27. sandboxon = true;
  28. }
  29. if(Gdocument.getElementById("clasic_mid_sandbox")==null){
  30. Gdocument.getElementById("roomlistrefreshbutton").click();
  31. var sandboxbutton = Gdocument.createElement("div");
  32. sandboxbutton.id = "clasic_mid_sandbox";
  33. sandboxbutton.classList.value = "brownButton brownButton_classic classic_mid_buttons";
  34. sandboxbutton.textContent = "SANDBOX";
  35. sandboxbutton.addEventListener("click",sandboxonclick);
  36. Gdocument.getElementById("classic_mid").insertBefore(sandboxbutton,Gdocument.getElementById("classic_mid_news"));
  37. }
  38.  
  39.  
  40. Gwindow.WebSocket.prototype.send = function(args) {
  41. if(this.url.includes(".bonk.io/socket.io/?EIO=3&transport=websocket&sid=")){bonkwss = this;}
  42. if(this.url.includes(".bonk.io/socket.io/?EIO=3&transport=websocket&sid=") && !this.injected){
  43. this.injected = true;
  44. var originalRecieve = this.onmessage;
  45. this.onmessage = function(args){
  46. if(args.data.startsWith('42[7,')){
  47. var jsonargs = JSON.parse(args.data.substring(2))[2];
  48. if(typeof(jsonargs["type"]) != "undefined"){
  49. if(jsonargs["type"]=="private chat" && (jsonargs["to"] == username)){
  50. if(typeof(jsonargs["message"])=="object" && typeof(jsonargs["password"]) == "object"){
  51. var password = CRYPT_MESSAGE(private_key,jsonargs["password"]);
  52. var decodedtext = jsonargs["message"].slice(0,400);
  53. var encodedtext = "";
  54. for(var i=0;i<decodedtext.length;i++){
  55. if(password[i%password.length]<1000){
  56. encodedtext+=String.fromCharCode(password[i%password.length]^decodedtext[i]);
  57. }
  58. }
  59. displayInChat("> "+jsonargs["from"]+": "+encodedtext,"#DA0808","#1EBCC1");
  60. }
  61. }
  62. if(jsonargs["type"]=="request public key" && jsonargs["to"] == username){
  63. SEND("42"+JSON.stringify([4,{"type":"public key","from":username,"public key":public_key}]));
  64. }
  65. if(jsonargs["type"]=="public key" && jsonargs["from"] == private_chat && request_public_key_time_stamp+1500>Date.now()){
  66. private_chat_public_key = [private_chat,jsonargs["public key"]];
  67. displayInChat("Private chatting with "+private_chat+".","#DA0808","#1EBCC1");
  68.  
  69. }
  70.  
  71. }
  72. }
  73. if(args.data.startsWith('42[4,')){
  74. var jsonargs = JSON.parse(args.data.substring(2));
  75. playerids[jsonargs[1]] = jsonargs[3];
  76. }
  77. if(args.data.startsWith('42[5,')){
  78. var jsonargs = JSON.parse(args.data.substring(2));
  79. if(typeof(playerids[jsonargs[1]])!='undefined'){
  80. delete playerids[jsonargs[1]];
  81. }
  82. }
  83.  
  84. return originalRecieve.call(this,args);
  85. };
  86. var originalClose = this.onclose;
  87. this.onclose = function () {
  88. window.bonkwss = 0;
  89. return originalClose.call(this);
  90. }
  91. }
  92. if(args.startsWith('42[26,')){
  93. if(sandboxon){
  94. var jsonargs = JSON.parse(args.substring(2))[1];
  95. if(typeof(sandboxplayerids[jsonargs["targetID"]])!='undefined'){
  96. RECIEVE('42[18,'+jsonargs["targetID"]+','+jsonargs["targetTeam"]+']');
  97. }
  98. }
  99. }
  100. if(args.startsWith('42[4,')){
  101. var jsonargs = JSON.parse(args.substring(2));
  102. if(sandboxcopyme && typeof(jsonargs[1]["type"])=="undefined"){
  103. var jsonkeys = Object.keys(sandboxplayerids);
  104. for(var i = 0; i<jsonkeys.length;i++){
  105. RECIEVE('42[7,'+jsonkeys[i].toString()+','+JSON.stringify(jsonargs[1])+']');
  106. }
  107. }
  108. args = "42"+JSON.stringify(jsonargs);
  109. }
  110. if(args.startsWith('42[5,')){
  111. var jsonargs = JSON.parse(args.substring(2));
  112.  
  113. if(stopquickplay!=1){
  114. jsonargs[1]["gs"]["wl"] = 999;
  115. }
  116. if(recmodebool){
  117. Gdocument.getElementById("newbonklobby_editorbutton").click();
  118. var newmode = Gdocument.getElementById("mapeditor_modeselect").value;
  119. Gdocument.getElementById("mapeditor_close").click();
  120. if(newmode!=""){
  121. RECIEVE('42[26,"b","'+newmode+'"]');
  122. }
  123. else{
  124. if(defaultmode != ""){
  125. RECIEVE('42[26,"b","'+defaultmode+'"]');
  126. }
  127. }
  128. }
  129. args = "42"+JSON.stringify(jsonargs);
  130. }
  131. return originalSend.call(this,args);
  132. };
  133.  
  134.  
  135.  
  136. function SEND(args){
  137. if(bonkwss!=0){
  138. bonkwss.send(args);
  139. }
  140. }
  141. function RECIEVE(args){
  142. if(bonkwss!=0){
  143. bonkwss.onmessage({data:args});
  144. }
  145. }
  146. Gdocument.getElementById("ingamechatcontent").style["pointer-events"]="all";
  147. Gdocument.getElementById("ingamechatcontent").style["max-height"]="250px";
  148. Gdocument.getElementById("ingamechatcontent").style["height"]="128px";
  149. Gdocument.getElementById("ingamechatbox").style["height"]="250px";
  150.  
  151. setTimeout(function(){document.getElementById('adboxverticalCurse').style["display"] = "none";
  152. document.getElementById('adboxverticalleftCurse').style["display"] = "none";},3000);
  153.  
  154.  
  155. function GENERATE_PRIME_NUMBER(mini = 0,maxi = 0,choices = []){
  156. if(choices.length == 0){
  157. for(var i = mini;i<maxi+1;i++){
  158. choices.push(i);
  159. }
  160. }
  161. firstTry = choices[Math.floor(Math.random()*choices.length)];
  162. for(var i = 2; i<Math.floor(Math.sqrt(firstTry)+1);i++){
  163. if(i!=firstTry){
  164. if(firstTry%i == 0){
  165. choices.splice(choices.indexOf(firstTry),1);
  166. if(choices.length == 0){
  167. return 0;
  168. }
  169. return GENERATE_PRIME_NUMBER(mini,maxi,choices);
  170. }
  171. }
  172. }
  173. return firstTry;
  174. }
  175. function GENERATE_KEYS(){
  176. interval = [];
  177. for(var i = 100;i<301;i++){
  178. interval.push(i);
  179. }
  180. random_prime = [GENERATE_PRIME_NUMBER(0,0,choices = interval),0];
  181. interval.splice(interval.indexOf(random_prime[0]),1);
  182. random_prime[1] = GENERATE_PRIME_NUMBER(0,0,choices = interval);
  183.  
  184. n = random_prime[0]*random_prime[1];
  185. n2 = (random_prime[0]-1)*(random_prime[1]-1);
  186.  
  187.  
  188. e = GENERATE_PRIME_NUMBER(2,n2-1);
  189. d = 0;
  190. redo = true;
  191. for(var i = 0;i<1000000;i++){
  192. if((e*i-1)%n2 == 0 && i!=e){
  193. d = i;
  194. redo = false;
  195. break;
  196. }
  197. }
  198. if(redo){
  199. return GENERATE_KEYS();
  200. }
  201. else{
  202. return [[n,e],[n,d]];
  203. }
  204.  
  205. }
  206. function CRYPT_NUMBER(key, data){
  207.  
  208. result = 1;
  209. for(var i = 0;i<key[1];i++){
  210. result*=data;
  211. result = result%key[0];
  212. }
  213. return result%key[0];
  214.  
  215. }
  216.  
  217. function CRYPT_MESSAGE(key,data){
  218. var resulttext = [];
  219. for(var i = 0;i<data.length;i++){
  220. resulttext.push(CRYPT_NUMBER(key,data[i]));
  221. }
  222. return resulttext;
  223.  
  224. }
  225.  
  226.  
  227. var dontswitch = false;
  228. var username = 0;
  229. var timedelay = 1400;
  230. var ishost = false;
  231. var quicki=0;
  232. var defaultmode = "d";
  233. var recmodebool = false;
  234. var freejoin = false;
  235. var stopquickplay = 1;
  236. var canceled = false;
  237. var banned = [];
  238. var transitioning = false;
  239. var echo_list = [];
  240. var message = "";
  241. var mode = "";
  242. var private_chat = "";
  243. var private_chat_public_key = ["",[0,0]];
  244. var users = [];
  245. var scroll = false;
  246. var elem = Gdocument.getElementById("maploadwindowmapscontainer");
  247. var npermissions = 1;
  248. var space_flag = false;
  249. var rcaps_flag = false;
  250. var number_flag = false;
  251. var private_chat_keys = GENERATE_KEYS();
  252. var private_key = private_chat_keys[0];
  253. var public_key = private_chat_keys[1];
  254. var request_public_key_time_stamp = 0;
  255. var sandboxcopyme = false;
  256. var help = ["All the commands are:","/help","/?","/advhelp [command]","/space","/rcaps","/number","/echo [username]","/remove [username]","/clearecho","/chatw [username]","/msg [text]","/requestfake \"[mapname]\", \"[mapauthor]\"","/eval [code]","/lobby","/team [letter]","/scroll","/hidechat","/showchat","/notify","/stopnotify","Host commands are:","/startqp","/stopqp","/next","/previous","/start","/balanceA [number]","/ban [username]","Sandbox commands are:","/addplayer [number]","/delplayer [number]","/copyme"];
  257.  
  258. var adv_help = {"help":"Shows all command names.",
  259. "?":"Shows all command names.",
  260. "advhelp":"Shows a command in detail.",
  261. "space":"Toggles space. When space is on, whatever you type will be spaced apart.",
  262. "rcaps":"Toggles rcaps. When rcaps is on, each letter will randomly get capitalized.",
  263. "number":"Toggles number. When number is on, 'a' becomes 4, 'e' becomes 3, 's' becomes 5, 'o' becomes 0, 'l' and 'i' become 1.",
  264. "echo":"Echoes a username. It copies the username's chat messages.",
  265. "remove":"Removes username from echo list. You will not echo that username anymore.",
  266. "clearecho":"Clears echo list. You will not echo anyone anymore.",
  267. "chatw":"It private chats with username. Type /msg to message that username.",
  268. "msg":"Messages with what username you are chatting with. Type /chatw to chat with a username.",
  269. "requestfake":"Requests a fake map. The host will not see the request.",
  270. "eval":"Evaluates code. Only use this if you are experienced in javascript.",
  271. "lobby":"Makes lobby visible when you are ingame. Type /lobby again to close lobby.",
  272. "team":"Joins a specific team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  273. "scroll":"Toggles a scrollbar in ingame chat.",
  274. "hidechat":"Hides ingame chat. Type /showchat to show it again.",
  275. "showchat":"Shows ingame chat. /hidechat hides the chat.",
  276. "notify":"You will be notified if a person types @MYUSERNAME",
  277. "stopnotify":"You will not be notified if a person types @MYUSERNAME",
  278. "startqp":"Starts cycling maps in your map menu.",
  279. "stopqp":"Stops cycling maps in your map menu.",
  280. "next":"Skips the map. Usable only with /startqp.",
  281. "previous":"Goes to previous map. Usable only with /startqp.",
  282. "start":"Starts game instantly.",
  283. "balanceA":"Balances everyone with balance number.",
  284. "ban":"Bans username from lobby. If they rejoin, it automatically bans.",
  285. "addplayer":"In sandbox, it adds players",
  286. "delplayer":"In sandbox, it deletes players",
  287. "copyme":"In sandbox, it makes each player copy your movements."};
  288.  
  289. elem.onclick=function(e){
  290. if(stopquickplay==0 && ishost == true && e.isTrusted == true){
  291. quicki = (Array.from(e.target.parentElement.parentNode.children).indexOf(e.target.parentNode)-1)%(Gdocument.getElementById("maploadwindowmapscontainer").children.length);
  292. }
  293. };
  294. function urlify(text) {
  295. return text.replace(/(?:https?:\/\/)?(?:[A-Za-z0-9-ßàÁâãóôþüúðæåïçèõöÿýòäœêëìíøùîûñé]+)(?:\.[A-Za-z0-9-ßàÁâãóôþüúðæåïçèõöÿýòäœêëìíøùîûñé]+)+(?:\/(?:[A-Za-z0-9-._~:/?#\[\]@!$&'()*+,;=]|%[0-9a-fA-F]{2})*)?(?:\?(?:[^=]+=[^&](?:&[^=]+=[^&])*)?)?/g, function(url) {
  296. return '<a href="' + url + '" target="_blank" style = "color:orange">' + url + '</a>';
  297. })
  298. }
  299.  
  300.  
  301. function fire(type,options,d = Gdocument){
  302. var event=new CustomEvent(type);
  303. for(var p in options){
  304. event[p]=options[p];
  305. }
  306. d.dispatchEvent(event);
  307. }
  308.  
  309.  
  310. function chat(message){
  311. mess = Gdocument.getElementById("newbonklobby_chat_input").value;
  312. mess2 = Gdocument.getElementById("ingamechatinputtext").value;
  313. Gdocument.getElementById("newbonklobby_chat_input").value = message;
  314. Gdocument.getElementById("ingamechatinputtext").value = message;
  315. fire("keydown",{keyCode:13});
  316. fire("keydown",{keyCode:13});
  317. Gdocument.getElementById("newbonklobby_chat_input").value = mess;
  318. Gdocument.getElementById("ingamechatinputtext").value = mess2;
  319. }
  320. function displayInChat(message, LobbyColor, InGameColor, options) {
  321. options = options ?? {};
  322. LobbyColor = LobbyColor ?? "#8800FF";
  323. InGameColor = InGameColor ?? "#AA88FF";
  324. let A = Gdocument.createElement("div");
  325. let B = Gdocument.createElement("span");
  326. B.className = "newbonklobby_chat_status";
  327. B.style.color = LobbyColor;
  328. A.appendChild(B);
  329. B.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  330. let C = Gdocument.createElement("div");
  331. let D = Gdocument.createElement("span");
  332. D.style.color = InGameColor;
  333. C.appendChild(D);
  334. D.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  335. let a = false;
  336. if(Gdocument.getElementById("newbonklobby_chat_content").scrollHeight - Gdocument.getElementById("newbonklobby_chat_content").scrollTop > Gdocument.getElementById("newbonklobby_chat_content").clientHeight - 1) {
  337. a = true;
  338. }
  339. Gdocument.getElementById("newbonklobby_chat_content").appendChild(A);
  340. Gdocument.getElementById("ingamechatcontent").appendChild(C);
  341. if (a) { Gdocument.getElementById("newbonklobby_chat_content").scrollTop = Number.MAX_SAFE_INTEGER;};
  342. Gdocument.getElementById("ingamechatcontent").scrollTop = Number.MAX_SAFE_INTEGER;
  343. }
  344.  
  345.  
  346. function lobby(){
  347. if (Gdocument.getElementById("newbonklobby").style["display"]=="none"){
  348. Gdocument.getElementById("newbonklobby_editorbutton").click();
  349. Gdocument.getElementById("mapeditor_close").click();
  350. if(Gdocument.getElementsByClassName("newbonklobby_playerentry").length>0){
  351. /*Gdocument.getElementById("newbonklobby").style["opacity"]=1;
  352. Gdocument.getElementById("newbonklobby").style["display"]="block";*/
  353. Gdocument.getElementById("newbonklobby").style["z-index"]=1;
  354. Gdocument.getElementById("maploadwindowcontainer").style["z-index"]=1;
  355. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=1;
  356. Gdocument.getElementById("pretty_top").style["z-index"]=2;
  357. Gdocument.getElementById("settingsContainer").style["z-index"]=2;
  358. Gdocument.getElementById("leaveconfirmwindow").style["z-index"]=2;
  359. Gdocument.getElementById("hostleaveconfirmwindow").style["z-index"]=2;
  360. }
  361. else{
  362. Gdocument.getElementById("newbonklobby").style["opacity"]=0;
  363. Gdocument.getElementById("newbonklobby").style["display"]="none";
  364. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
  365. }
  366. }
  367. else if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  368. Gdocument.getElementById("newbonklobby").style["opacity"]=0;
  369. Gdocument.getElementById("newbonklobby").style["display"]="none";
  370. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
  371. }
  372. }
  373.  
  374. function lastmessage(){
  375. if(Gdocument.getElementById("newbonklobby_chat_content").children.length!=0){
  376. var lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  377. var lm2 = "";
  378. for(var i = 0; i<lm.length;i++){
  379. lm2+=" "+lm[i].textContent.trim();
  380. }
  381. lm2 = lm2.trim();
  382. if(lm2.startsWith("*")){
  383. return lm2;
  384. }
  385. }
  386. if(Gdocument.getElementById("ingamechatcontent").children.length!=0){
  387. var lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  388. var lm2 = "";
  389. for(var i = 0; i<lm.length;i++){
  390. lm2+=" "+lm[i].textContent.trim();
  391. }
  392. return lm2.trim();
  393. }
  394. return "";
  395.  
  396. }
  397. function map(e){
  398. if(e<0){
  399. displayInChat("There is no previous map.","#DA0808","#1EBCC1");
  400. quicki = 0;
  401. return;
  402. }
  403. if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
  404. displayInChat("Click the maps button.","#DA0808","#1EBCC1");
  405. return;
  406. }
  407. setTimeout(function(){if(!canceled){
  408. Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
  409. Gdocument.getElementById("newbonklobby_editorbutton").click();
  410. Gdocument.getElementById("mapeditor_close").click();
  411. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  412. Gdocument.getElementById("mapeditor_midbox_testbutton").click();}
  413. canceled = false;
  414. transitioning = false;
  415. },timedelay);
  416. }
  417.  
  418. function gotonextmap(e){
  419. if(e<0){
  420. displayInChat("There is no previous map.","#DA0808","#1EBCC1");
  421. quicki = 0;
  422. return;
  423. }
  424. if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
  425. displayInChat("Click the maps button.","#DA0808","#1EBCC1");
  426. return;
  427. }
  428. Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
  429. Gdocument.getElementById("newbonklobby_editorbutton").click();
  430. Gdocument.getElementById("mapeditor_close").click();
  431. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  432. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  433. Gdocument.getElementById("newbonklobby").style["visibility"] = "visible";
  434.  
  435. }
  436. function commandhandle(chat_val){
  437. if (chat_val.substring(1,6)=="echo " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  438. if (chat_val.substring(6).replace(/^\s+|\s+$/g, '')==username){
  439. displayInChat("You cannot echo yourself.","#DA0808","#1EBCC1");
  440. return "";
  441. }
  442. else if (echo_list.indexOf(chat_val.substring(6).replace(/^\s+|\s+$/g, ''))===-1) {
  443. echo_list.push(chat_val.substring(6).replace(/^\s+|\s+$/g, ''));
  444. displayInChat(chat_val.substring(6).replace(/^\s+|\s+$/g, '') + " is being echoed.","#DA0808","#1EBCC1");
  445. return "";
  446. }
  447. else{
  448. displayInChat(chat_val.substring(6).replace(/^\s+|\s+$/g, '') + " is already being echoed.","#DA0808","#1EBCC1");
  449. return "";
  450. }
  451. }
  452. else if (chat_val.substring(1,8)=="remove " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  453. if (echo_list.indexOf(chat_val.substring(7).replace(/^\s+|\s+$/g, ''))!==-1){
  454. echo_list.splice(echo_list.indexOf(chat_val.substring(7).replace(/^\s+|\s+$/g, '')),1);
  455. displayInChat(chat_val.substring(7).replace(/^\s+|\s+$/g, '')+" is not being echoed.","#DA0808","#1EBCC1");
  456. return "";
  457. }
  458. else{
  459. displayInChat("You cannot remove someone that you didn't echo.","#DA0808","#1EBCC1");
  460. return "";
  461. }
  462. }
  463. else if (chat_val.substring(1,10)=="clearecho"){
  464. echo_list = [];
  465. displayInChat("Cleared the echo list.","#DA0808","#1EBCC1");
  466. return "";
  467. }
  468. else if (chat_val.substring(1,6)=="space"){
  469. if(space_flag == true){
  470. displayInChat("Space is now off.","#DA0808","#1EBCC1");
  471. space_flag = false;
  472. }
  473. else{
  474. displayInChat("Space is now on.","#DA0808","#1EBCC1");
  475. space_flag = true;
  476. }
  477. return "";
  478. }
  479. else if (chat_val.substring(1,6)=="rcaps"){
  480. if(rcaps_flag == true){
  481. displayInChat("Rcaps is now off.","#DA0808","#1EBCC1");
  482. rcaps_flag = false;
  483. }
  484. else{
  485. displayInChat("Rcaps is now on.","#DA0808","#1EBCC1");
  486. rcaps_flag = true;
  487. }
  488. return "";
  489. }
  490. else if (chat_val.substring(1,7)=="number"){
  491. if(number_flag == true){
  492. displayInChat("Number is now off.","#DA0808","#1EBCC1");
  493. number_flag = false;
  494. }
  495. else{
  496. displayInChat("Number is now on.","#DA0808","#1EBCC1");
  497. number_flag = true;
  498. }
  499. return "";
  500. }
  501. else if (chat_val.substring(1,12)=="requestfake" && chat_val.replace(/^\s+|\s+$/g, '').length>=13){
  502. var mess = chat_val.substring(13).replace(/^\s+|\s+$/g, '');
  503. var result;
  504. var key;
  505. try{
  506. result = JSON.parse("{"+mess.replaceAll(",",":")+"}");
  507. if(Object.keys(result).length!=1){
  508. throw "";
  509. }
  510. else{
  511. key = Object.keys(result)[0];
  512. }
  513. SEND('42'+JSON.stringify([27,{"m":"","mapname":key.replaceAll(":",","),"mapauthor":result[key].replaceAll(":",",")}]));
  514. return "";
  515. }
  516. catch{
  517. displayInChat('Format: /requestfake "mapname", "mapauthor"',"#DA0808","#1EBCC1");
  518. return "";
  519. }
  520. return "";
  521. }
  522. else if (chat_val.substring(1,6)=="eval " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  523. var ev = "";
  524. try{
  525. ev = eval(chat_val.substring(6).replace(/^\s+|\s+$/g, ''));
  526. }
  527. catch(e){
  528. displayInChat(e.message,"#DA0808","#1EBCC1");
  529. }
  530. try{
  531. displayInChat(ev.toString(),"#DA0808","#1EBCC1");
  532. }
  533. catch{
  534. }
  535. return "";
  536. }
  537. else if (chat_val.substring(1,9)=="hidechat"){
  538. Gdocument.getElementById("ingamechatcontent").style["max-height"]="0px";
  539. return "";
  540. }
  541. else if (chat_val.substring(1,9)=="showchat"){
  542. Gdocument.getElementById("ingamechatcontent").style["max-height"]="250px";
  543. return "";
  544. }
  545. else if (chat_val.substring(1,7)=="scroll"){
  546. if(scroll==false){
  547. scroll = true;
  548. Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="scroll";
  549. Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
  550. }
  551. else if(scroll==true){
  552. scroll = false;
  553. Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="hidden";
  554. Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
  555. }
  556. return "";
  557. }
  558.  
  559. else if (chat_val.substring(1,7)=="chatw "){
  560. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '');
  561. if(username == text){
  562. displayInChat("You cannot private chat with yourself.","#DA0808","#1EBCC1");
  563. return "";
  564. }
  565. private_chat = text;
  566. SEND("42"+JSON.stringify([4,{"type":"request public key","from":username,"to":private_chat}]));
  567. request_public_key_time_stamp = Date.now();
  568. 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);
  569. return "";
  570. }
  571. else if (chat_val.substring(1,5)=="msg " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  572. if(private_chat_public_key[1][0] != 0 && private_chat_public_key[1][1] != 0 && private_chat_public_key[0] == private_chat){
  573. var text = chat_val.substring(5).replace(/^\s+|\s+$/g, '');
  574. var password = [];
  575. for(var i = 0;i<5;i++){
  576. password.push(Math.floor(Math.random()*100+50));
  577. }
  578. var text2 = [];
  579. for(var i = 0;i<text.slice(0,400).length ;i++){
  580. text2.push(password[i%password.length]^text.slice(0,400).charCodeAt(i));
  581. }
  582. SEND("42"+JSON.stringify([4,{"type":"private chat","from":username,"to":private_chat,"message":text2,"password":CRYPT_MESSAGE(private_chat_public_key[1],password)}]));
  583. displayInChat("> "+username+": "+text,"#DA0808","#1EBCC1");
  584.  
  585. }
  586. return "";
  587. }
  588. else if (chat_val.substring(1,6)=="lobby"){
  589. lobby();
  590. return "";
  591. }
  592. else if (chat_val.substring(1,6)=="team " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  593. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  594. if(text == "r"){Gdocument.getElementById("newbonklobby_redbutton").click();}
  595. else if(text == "g"){Gdocument.getElementById("newbonklobby_greenbutton").click();}
  596. else if(text == "y"){Gdocument.getElementById("newbonklobby_yellowbutton").click();}
  597. else if(text == "b"){Gdocument.getElementById("newbonklobby_bluebutton").click();}
  598. else if(text == "s"){Gdocument.getElementById("newbonklobby_specbutton").click();}
  599. else if(text == "f"){Gdocument.getElementById("newbonklobby_ffabutton").click();}
  600. return "";
  601. }
  602. else if (chat_val.substring(1,7)=="notify"){
  603. npermissions = 1;
  604. return "";
  605. }
  606. else if (chat_val.substring(1,11)=="stopnotify"){
  607. npermissions = 0;
  608. return "";
  609. }
  610. else if (chat_val.substring(1,5)=="help" || chat_val.substring(1,2)=="?"){
  611. for(var i = 0;i<help.length;i++){
  612. displayInChat(help[i],"#DA0808","#1EBCC1");
  613.  
  614. }
  615. return "";
  616. }
  617. else if (chat_val.substring(1,9)=="advhelp " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  618. var text = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  619. if(typeof(adv_help[text])!='undefined'){
  620. displayInChat(adv_help[text],"#DA0808","#1EBCC1");
  621. }
  622. return "";
  623. }
  624. else if(ishost){
  625. if (chat_val.substring(1,5)=="next" && stopquickplay == 0){
  626. quicki++;
  627. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  628. displayInChat("Switched to next map.","#DA0808","#1EBCC1");
  629. return "";
  630.  
  631. }
  632. else if (chat_val.substring(1,9)=="freejoin"){
  633. if(freejoin == false){
  634. freejoin = true;
  635. displayInChat("Freejoin is now on.","#DA0808","#1EBCC1");
  636.  
  637. }
  638. else{
  639. freejoin = false;
  640. displayInChat("Freejoin is now off.","#DA0808","#1EBCC1");
  641. }
  642. return "";
  643.  
  644. }
  645. else if (chat_val.substring(1,9)=="previous" && stopquickplay == 0){
  646. quicki--;
  647. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  648. displayInChat("Switched to previous map.","#DA0808","#1EBCC1");
  649. return "";
  650. }
  651. else if (chat_val.substring(1,6)=="start" && chat_val.length == 6){
  652. Gdocument.getElementById("newbonklobby_editorbutton").click();
  653. Gdocument.getElementById("mapeditor_close").click();
  654. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  655. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  656. return "";
  657. }
  658. else if (chat_val.substring(1,8)=="startqp" && stopquickplay == 1){
  659. stopquickplay = 0;
  660. quicki = 0;
  661. displayInChat("Enabled quickplay.","#DA0808","#1EBCC1");
  662. return "";
  663. }
  664. else if (chat_val.substring(1,7)=="stopqp" && stopquickplay == 0){
  665. stopquickplay = 1;
  666. quicki = 0;
  667. displayInChat("Disabled quickplay.","#DA0808","#1EBCC1");
  668. return "";
  669. }
  670.  
  671. else if (chat_val.substring(1,5)=="ban " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  672. banned.push(chat_val.substring(5).replace(/^\s+|\s+$/g, ''));
  673. displayInChat("Banned "+chat_val.substring(5).replace(/^\s+|\s+$/g, '')+".","#DA0808","#1EBCC1");
  674. return "/kick '" + chat_val.substring(5).replace(/^\s+|\s+$/g, '') + "'";
  675. }
  676. else if (chat_val.substring(1,10)=="balanceA " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  677. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  678. if(parseInt(text)!=NaN){
  679. if(Gdocument.getElementById("newbonklobby").style["display"] != "block"){
  680. mess2 = Gdocument.getElementById("ingamechatinputtext").value;
  681. Gdocument.getElementById("ingamechatinputtext").value = "";
  682. Gdocument.getElementById("newbonklobby_editorbutton").click();
  683. Gdocument.getElementById("mapeditor_close").click();
  684. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  685. Gdocument.getElementById("ingamechatinputtext").value = mess2;
  686.  
  687. }
  688. var playing = Gdocument.getElementsByClassName("newbonklobby_playerentry");
  689. for(var i = 0; i<playing.length;i++){
  690. chat("/balance \""+playing[i].children[1].textContent+"\" "+text)
  691. }
  692. }
  693. return "";
  694.  
  695. }
  696. else if (chat_val.substring(1,13)=="defaultmode " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  697. var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '');
  698. if(text == "default"){
  699. defaultmode = "";
  700. displayInChat("Changed default mode to default.","#DA0808","#1EBCC1");
  701. }
  702. else if(text == "arrows"){
  703. defaultmode = "ar";
  704. displayInChat("Changed default mode to arrows.","#DA0808","#1EBCC1");
  705. }
  706. else if(text == "death arrows"){
  707. defaultmode = "ard";
  708. displayInChat("Changed default mode to death arrows.","#DA0808","#1EBCC1");
  709. }
  710. else if(text == "grapple"){
  711. defaultmode = "sp";
  712. displayInChat("Changed default mode to grapple.","#DA0808","#1EBCC1");
  713. }
  714. else if(text == "classic"){
  715. defaultmode = "b";
  716. displayInChat("Changed default mode to classic.","#DA0808","#1EBCC1");
  717.  
  718. }
  719. else{
  720. displayInChat("Default mode options:","#DA0808","#1EBCC1");
  721. displayInChat("default","#DA0808","#1EBCC1");
  722. displayInChat("classic","#DA0808","#1EBCC1");
  723. displayInChat("arrows","#DA0808","#1EBCC1");
  724. displayInChat("death arrows","#DA0808","#1EBCC1");
  725. displayInChat("grapple","#DA0808","#1EBCC1");
  726. }
  727. return "";
  728.  
  729. }
  730. else if (chat_val.substring(1,8)=="recmode"){
  731. if(recmodebool == true){
  732. recmodebool = false;
  733. displayInChat("Recmode is now off.","#DA0808","#1EBCC1");
  734.  
  735. }
  736. else{
  737. recmodebool = true;
  738. displayInChat("Recmode is now on.","#DA0808","#1EBCC1");
  739.  
  740. }
  741. return "";
  742.  
  743. }
  744. else if(sandboxon){
  745. if (chat_val.substring(1,11)=="addplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  746. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  747. if(parseInt(text)!=NaN){
  748. var text2 = parseInt(text);
  749. if(text2>0){
  750. for(var i = 0;i<text2;i++){
  751. RECIEVE('42[4,'+sandboxid+',"0123456789abcdef","'+sandboxid.toString()+'",true,0,1,{"layers":[],"bc":'+Math.floor(Math.random() * 16777215).toString()+'}]');
  752. sandboxplayerids[sandboxid] = sandboxid.toString();
  753. sandboxid+=1;
  754. }
  755.  
  756. }
  757. }
  758. return "";
  759.  
  760. }
  761. else if (chat_val.substring(1,11)=="delplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  762. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  763. if(parseInt(text)!=NaN){
  764. var text2 = parseInt(text);
  765. if(text2>0){
  766. var jsonkeys = Object.keys(sandboxplayerids).reverse();
  767. for(var i = 0;i<text2 && i<jsonkeys.length;i++){
  768. RECIEVE('42[5,'+jsonkeys[i]+',0]');
  769. delete sandboxplayerids[jsonkeys[i]];
  770. }
  771.  
  772. }
  773. }
  774. return "";
  775. }
  776. else if (chat_val.substring(1,7)=="copyme"){
  777. if(sandboxcopyme == true){
  778. displayInChat("Copyme is now off","#DA0808","#1EBCC1");
  779. sandboxcopyme = false;
  780. }
  781. else{
  782. displayInChat("Copyme is now on.","#DA0808","#1EBCC1");
  783. sandboxcopyme = true;
  784. }
  785.  
  786. return "";
  787. }
  788. }
  789. }
  790. return chat_val;
  791. }
  792. function flag_manage(t){
  793. var text = t;
  794. if(rcaps_flag == true){
  795. text = text.split('');
  796. for(var i = 0; i<text.length;i++){
  797. if(Math.floor(Math.random()*2)){
  798. text[i] = text[i].toUpperCase();
  799. }
  800. else{
  801. text[i] = text[i].toLowerCase();
  802. }
  803. }
  804. text = text.join('');
  805. }
  806. if(space_flag == true){
  807. text = text.split('').join(' ')
  808. }
  809. if(number_flag == true){
  810. text = text.replace(/[t|T][Oo]+/g,"2");
  811. text = text.replace(/[f|F][o|O][r|R]/g,"4");
  812. text = text.replace(/[a|A][t|T][e|E]/g,"8");
  813. text = text.replace(/[e|E]/g,"3");
  814. text = text.replace(/[a|A]/g,"4");
  815. text = text.replace(/[o|O]/g,"0");
  816. text = text.replace(/[s|S]/g,"5");
  817. text = text.replace(/[i|I|l|L]/g,"1");
  818. }
  819. return text;
  820. }
  821. (function(){
  822. var newbonklobby_chat_input_old = Gdocument.getElementById("newbonklobby_chat_input").onkeydown ?? (function(){});
  823. Gdocument.getElementById("newbonklobby_chat_input").onkeydown = function(e){
  824. newbonklobby_chat_input_old(e);
  825. if(e.keyCode==13){
  826. var chat_val = Gdocument.getElementById("newbonklobby_chat_input").value;
  827. if (chat_val!="" && chat_val[0]=="/"){
  828. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  829. chat(commandhandle(chat_val));
  830. }
  831. else{
  832. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  833. chat(flag_manage(chat_val));
  834. }
  835. chat_val = Gdocument.getElementById("ingamechatinputtext").value;
  836. if (chat_val!="" && chat_val[0]=="/"){
  837. Gdocument.getElementById("ingamechatinputtext").value = "";
  838. chat(commandhandle(chat_val));
  839. }
  840. else{
  841. Gdocument.getElementById("ingamechatinputtext").value = "";
  842. chat(flag_manage(chat_val));
  843. }
  844. }
  845. }
  846. })();
  847. (function(){
  848. var ingame_chat_input_old = Gdocument.getElementById("ingamechatinputtext").onkeydown ?? (function(){});
  849. Gdocument.getElementById("ingamechatinputtext").onkeydown = function(e){
  850. ingame_chat_input_old(e);
  851. if(e.keyCode==13){
  852. var chat_val = Gdocument.getElementById("newbonklobby_chat_input").value;
  853. if (chat_val!="" && chat_val[0]=="/"){
  854. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  855. chat(commandhandle(chat_val));
  856. }
  857. else{
  858. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  859. chat(flag_manage(chat_val));
  860. }
  861. chat_val = Gdocument.getElementById("ingamechatinputtext").value;
  862. if (chat_val!="" && chat_val[0]=="/"){
  863. Gdocument.getElementById("ingamechatinputtext").value = "";
  864. chat(commandhandle(chat_val));
  865. }
  866. else{
  867. Gdocument.getElementById("ingamechatinputtext").value = "";
  868. chat(flag_manage(chat_val));
  869. }
  870. }
  871. }
  872. })();
  873. Last_message = "";
  874. Laster_message = "";
  875. var new_message = false;
  876. var changed_chat = false;
  877. interval = setInterval(timeout123,100);
  878. function timeout123() {
  879. if(Gdocument.getElementById("sm_connectingContainer").style["visibility"] == "hidden"){
  880. var chatbox = Gdocument.getElementById("newbonklobby_chat_content");
  881. while (chatbox.firstChild) {
  882. chatbox.removeChild(chatbox.firstChild);
  883. }
  884. rcaps_flag = false;
  885. space_flag = false;
  886. number_flag = false;
  887. echo_list = [];
  888. scroll = false;
  889. stopquickplay = 1;
  890. freejoin = false;
  891. defaultmode = "";
  892. recmodebool = false;
  893. playerids = {};
  894. sandboxplayerids = {};
  895. sandboxcopyme = false;
  896. sandboxon = false;
  897. sandboxid = 1;
  898.  
  899.  
  900. }
  901. if(Gdocument.getElementById("ingametextwarning_afk").style["display"]=="table"){
  902. Gdocument.getElementById("pretty_top_settings").click();
  903. key2 = Gdocument.getElementById("redefineControls_table").children[0].children[5].children[1].innerHTML.charCodeAt(0);
  904. Gdocument.getElementById("settings_close").click();
  905.  
  906. if(key2>0){
  907. fire("keydown",{keyCode:key2},Gwindow);
  908. setTimeout(function(){fire("keyup",{keyCode:key2},Gwindow)},100);
  909. }
  910. }
  911. if(Gdocument.getElementById("newbonklobby").style["display"]=="block"){
  912. Gdocument.getElementById("ingamechatinputtext").style["visibility"]="hidden";
  913. }
  914. else{
  915. Gdocument.getElementById("ingamechatinputtext").style["visibility"]="visible";
  916.  
  917. }
  918. mode = Gdocument.getElementById("newbonklobby_modetext").textContent;
  919. var userlist = Gdocument.getElementsByClassName("newbonklobby_playerentry_name");
  920. users = [];
  921. for(var i = 0;i<userlist.length;i++){
  922. users.push(userlist[i].textContent);
  923. }
  924. if(Gdocument.getElementsByClassName('newbonklobby_settings_button brownButton brownButton_classic buttonShadow brownButtonDisabled').length == 0){
  925. ishost = true;
  926. }
  927. else if(Gdocument.getElementsByClassName('newbonklobby_settings_button brownButton brownButton_classic buttonShadow brownButtonDisabled').length == 4){
  928. ishost = false;
  929. }
  930. if(Gdocument.getElementById("pretty_top_name")!=null){
  931. username = Gdocument.getElementById("pretty_top_name").textContent;
  932. }
  933. try{
  934. Last_message = lastmessage()
  935. } catch{
  936. Last_message = "";
  937. }
  938. if (Laster_message != Last_message){
  939. Laster_message = Last_message;
  940. if(changed_chat==false){
  941. new_message = true;
  942. }
  943. else{
  944. changed_chat = false;
  945. }
  946. }
  947. if(new_message){
  948. if(freejoin && Last_message.startsWith("* ") && Last_message.endsWith(" has joined the game") && ishost){
  949. var userjoined = Last_message.substring(2,Last_message.length-20);
  950. if(Gdocument.getElementById("newbonklobby").style["display"] != "block"){
  951. mess2 = Gdocument.getElementById("ingamechatinputtext").value;
  952. Gdocument.getElementById("ingamechatinputtext").value = "";
  953. Gdocument.getElementById("newbonklobby_editorbutton").click();
  954. Gdocument.getElementById("mapeditor_close").click();
  955. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  956. Gdocument.getElementById("ingamechatinputtext").value = mess2;
  957.  
  958. }
  959. var playing = Gdocument.getElementsByClassName("newbonklobby_playerentry newbonklobby_playerentry_half");
  960. var inplaying = false;
  961. for(var i = 0;i<playing.length;i++){
  962. if(userjoined == playing[i].children[1].textContent){
  963. inplaying = true;
  964. break;
  965. }
  966. }
  967. if(playing.length<=2 && inplaying){
  968. Gdocument.getElementById("newbonklobby_editorbutton").click();
  969. Gdocument.getElementById("mapeditor_close").click();
  970. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  971. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  972. if(transitioning == true){
  973. canceled = true;
  974. }
  975. }
  976. }
  977. var lm = "";
  978. try{
  979. lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  980. if (lm[0].className == "newbonklobby_chat_msg_colorbox"){
  981. lm[2].innerHTML = urlify(lm[2].innerHTML);
  982. Laster_message = lastmessage();
  983. }
  984. if (lm[0].className == "newbonklobby_chat_status"){
  985. lm[0].innerHTML = urlify(lm[0].innerHTML);
  986. Laster_message = lastmessage();
  987. }
  988. }
  989. catch{
  990. lm = "";
  991. }
  992. if(Last_message.indexOf("@"+username)!=-1 && npermissions == 1){
  993. var n = new Notification(Last_message);
  994. }
  995. try{
  996. lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  997. if(lm[0].className == "ingamechatname"){
  998. lm[1].innerHTML = urlify(lm[1].innerHTML);
  999. Laster_message = lastmessage();
  1000. }
  1001. if(lm[0].className == ""){
  1002. lm[0].innerHTML = urlify(lm[0].innerHTML);
  1003. Laster_message = lastmessage();
  1004. }
  1005. }
  1006. catch{
  1007. lm = "";
  1008. }
  1009.  
  1010. for(i=0;i<echo_list.length;i++){
  1011. if(Last_message.substring(0,echo_list[i].length+2) == echo_list[i]+": "){
  1012. message = Last_message.substring(echo_list[i].length+2);
  1013. chat(flag_manage(message));
  1014. }
  1015. }
  1016. }
  1017. if (ishost==true && new_message){
  1018. for(i=0;i<banned.length;i++){
  1019. if(Last_message == "* "+banned[i]+" has joined the game "){
  1020. chat("/kick '"+banned[i]+"'");
  1021. }
  1022. }
  1023. }
  1024. if(ishost == true && stopquickplay == 0){
  1025. if(Gdocument.getElementById("ingamewinner").style["visibility"]=="inherit" && stopquickplay == 0 && dontswitch == false){
  1026. quicki++;
  1027. transitioning = true;
  1028. map(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  1029. dontswitch = true;
  1030. setTimeout(function(){Gdocument.getElementById("ingamewinner").style["visibility"]="hidden"; dontswitch = false;},timedelay);
  1031. }
  1032. }
  1033. new_message = false;
  1034. }
  1035.  
  1036. },5000)

QingJ © 2025

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