Bonk Commands

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

当前为 2022-10-18 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Bonk Commands
  3. // @namespace https://gf.qytechs.cn/en/scripts/451341-bonk-commands
  4. // @version 6.2
  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.  
  13. function BonkCommandsScriptInjector(f){
  14. if(window.location == window.parent.location){
  15. if(document.readyState == "complete"){f();}
  16. else{document.addEventListener('readystatechange',function(){setTimeout(f,1500);});}
  17. }
  18. }
  19.  
  20. BonkCommandsScriptInjector(function(){
  21. var scope = window;
  22.  
  23. scope.Gwindow = document.getElementById("maingameframe").contentWindow;
  24. scope.Gdocument = document.getElementById("maingameframe").contentDocument;
  25. Gwindow.Gwindow = window;
  26. Gwindow.Gdocument = document;
  27.  
  28. scope.link2pastebin = "https://pastebin.com/2b8XqqYu";
  29. scope.link2greasyfork = "https://gf.qytechs.cn/en/scripts/451341-bonk-commands";
  30.  
  31. if(typeof(scope.injectedBonkCommandsScript)=='undefined'){
  32. scope.injectedBonkCommandsScript = true;
  33. }
  34. else{
  35. for (var i = 0; i < 100000; i++){
  36. clearInterval(i);
  37. }
  38. }
  39. scope.GENERATE_COPRIME_NUMBER = function(mini = 0,maxi = 0,coprimewith = 0,choices = []){
  40. if(choices.length == 0){
  41. for(var i = mini;i<maxi+1;i++){
  42. choices.push(i);
  43. }
  44. }
  45. firstTry = choices[Math.floor(Math.random()*choices.length)];
  46. for(var i = 2; i<firstTry+1;i++){
  47. if(firstTry%i == 0 && coprimewith%i == 0){
  48. choices.splice(choices.indexOf(firstTry),1);
  49. if(choices.length == 0){
  50. return 0;
  51. }
  52. return GENERATE_COPRIME_NUMBER(mini,maxi,coprimewith,choices);
  53. }
  54. }
  55. return firstTry;
  56. };
  57. scope.GENERATE_PRIME_NUMBER = function(mini = 0,maxi = 0,choices = []){
  58. if(choices.length == 0){
  59. for(var i = mini;i<maxi+1;i++){
  60. choices.push(i);
  61. }
  62. }
  63. firstTry = choices[Math.floor(Math.random()*choices.length)];
  64. for(var i = 2; i<Math.floor(Math.sqrt(firstTry)+1);i++){
  65. if(i!=firstTry){
  66. if(firstTry%i == 0){
  67. choices.splice(choices.indexOf(firstTry),1);
  68. if(choices.length == 0){
  69. return 0;
  70. }
  71. return GENERATE_PRIME_NUMBER(mini,maxi,choices);
  72. }
  73. }
  74. }
  75. return firstTry;
  76. };
  77.  
  78. scope.GENERATE_KEYS = function(){
  79. interval = [];
  80. for(var i = 100;i<301;i++){
  81. interval.push(i);
  82. }
  83. random_prime = [GENERATE_PRIME_NUMBER(0,0,choices = interval),0];
  84. interval.splice(interval.indexOf(random_prime[0]),1);
  85. random_prime[1] = GENERATE_PRIME_NUMBER(0,0,choices = interval);
  86.  
  87. n = random_prime[0]*random_prime[1];
  88. n2 = (random_prime[0]-1)*(random_prime[1]-1);
  89.  
  90. e = GENERATE_COPRIME_NUMBER(2,n2-1,n2);
  91. d = 0;
  92. redo = true;
  93. for(var i = 0;i<1000000;i++){
  94. if((e*i-1)%n2 == 0 && i!=e){
  95. d = i;
  96. redo = false;
  97. break;
  98. }
  99. }
  100. if(redo){
  101. return GENERATE_KEYS();
  102. }
  103. else{
  104. return [[n,e],[n,d]];
  105. }
  106.  
  107. };
  108. scope.CRYPT_NUMBER = function(key, data){
  109.  
  110. result = 1;
  111.  
  112. for(var i = 0;i<key[1];i++){
  113. result*=data;
  114. result = result%key[0];
  115. }
  116. return result%key[0];
  117.  
  118. };
  119.  
  120. scope.CRYPT_MESSAGE = function(key,data){
  121. var resulttext = [];
  122. for(var i = 0;i<data.length;i++){
  123. resulttext.push(CRYPT_NUMBER(key,data[i]));
  124. }
  125. return resulttext;
  126.  
  127. };
  128.  
  129. if(typeof(scope.originalSend)=='undefined'){scope.originalSend = Gwindow.WebSocket.prototype.send;}
  130. if(typeof(scope.bonkwss)=='undefined'){scope.bonkwss = 0;}
  131. if(typeof(scope.chatlog)=='undefined'){scope.chatlog = ["ROOM START"];}
  132. if(typeof(scope.sandboxon)=='undefined'){scope.sandboxon = false;}
  133. if(typeof(scope.sandboxid)=='undefined'){scope.sandboxid = 1;}
  134. if(typeof(scope.playerids)=='undefined'){scope.playerids = {};}
  135. if(typeof(scope.pingids)=='undefined'){scope.pingids = {};}
  136. if(typeof(scope.sandboxplayerids)=='undefined'){scope.sandboxplayerids = {};}
  137. if(typeof(scope.originalLobbyChat)=='undefined'){scope.originalLobbyChat = Gdocument.getElementById("newbonklobby_chat_content").appendChild;}
  138. if(typeof(scope.originalIngameChat)=='undefined'){scope.originalIngameChat = Gdocument.getElementById("ingamechatcontent").appendChild;}
  139. 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];}
  140. function sandboxonclick(){
  141. Gdocument.getElementById("roomlistcreatewindowmaxplayers").value = 1;
  142. Gdocument.getElementById("roomlistcreatewindowunlistedcheckbox").checked = true;
  143. Gdocument.getElementById("roomlistcreatecreatebutton").click();
  144. sandboxon = true;
  145. }
  146. if(Gdocument.getElementById("classic_mid_sandbox")==null){
  147. Gdocument.getElementById("roomlistrefreshbutton").click();
  148. scope.sandboxbutton = Gdocument.createElement("div");
  149. sandboxbutton.id = "classic_mid_sandbox";
  150. sandboxbutton.classList.value = "brownButton brownButton_classic classic_mid_buttons";
  151. sandboxbutton.textContent = "SANDBOX";
  152. sandboxbutton.addEventListener("click",sandboxonclick);
  153. Gdocument.getElementById("classic_mid").insertBefore(sandboxbutton,Gdocument.getElementById("classic_mid_news"));
  154.  
  155. }
  156. Gdocument.getElementById("newbonklobby_chat_content").appendChild = function(args){
  157. if(beenKickedTimeStamp+100>Date.now() && args.children.length>0){
  158. if(args.children[0].textContent.endsWith(" has left the game ") && args.children[0].textContent.startsWith("* ")){
  159. args.children[0].textContent = args.children[0].textContent.substring(0,args.children[0].textContent.length-19)+" has been kicked from the game ";
  160. }
  161. }
  162. originalLobbyChat.call(this,args);
  163. };
  164. Gdocument.getElementById("ingamechatcontent").appendChild = function(args){
  165. if(beenKickedTimeStamp+100>Date.now() && args.children.length>0){
  166. if(args.children[0].textContent.endsWith(" has left the game.") && args.children[0].textContent.startsWith("* ")){
  167. args.children[0].textContent = args.children[0].textContent.substring(0,args.children[0].textContent.length-19)+" has been kicked from the game.";
  168. }
  169. }
  170. originalIngameChat.call(this,args);
  171. };
  172. Gwindow.WebSocket.prototype.send = function(args) {
  173. if(this.url.includes(".bonk.io/socket.io/?EIO=3&transport=websocket&sid=")){
  174. bonkwss = this;
  175. if(args.startsWith('42[26,')){
  176. if(sandboxon){
  177. var jsonargs = JSON.parse(args.substring(2))[1];
  178. if(typeof(sandboxplayerids[jsonargs["targetID"]])!='undefined'){
  179. RECIEVE('42[18,'+jsonargs["targetID"]+','+jsonargs["targetTeam"]+']');
  180.  
  181. }
  182. }
  183. }
  184. if(args.startsWith('42[4,')){
  185. var jsonargs = JSON.parse(args.substring(2));
  186. if(sandboxcopyme && typeof(jsonargs[1]["type"])=="undefined"){
  187. var jsonkeys = Object.keys(sandboxplayerids);
  188. for(var i = 0; i<jsonkeys.length;i++){
  189. RECIEVE('42[7,'+jsonkeys[i].toString()+','+JSON.stringify(jsonargs[1])+']');
  190. }
  191. }
  192. args = "42"+JSON.stringify(jsonargs);
  193. }
  194.  
  195. if(args.startsWith('42[5,')){
  196. var jsonargs = JSON.parse(args.substring(2));
  197.  
  198. if(stopquickplay!=1){
  199. jsonargs[1]["gs"]["wl"] = 999;
  200. }
  201. if(recmodebool){
  202. Gdocument.getElementById("newbonklobby_editorbutton").click();
  203. var newmode = Gdocument.getElementById("mapeditor_modeselect").value;
  204. Gdocument.getElementById("mapeditor_close").click();
  205.  
  206. if(newmode!=""){
  207. RECIEVE('42[26,"b","'+newmode+'"]');
  208. }
  209. else{
  210. if(defaultmode != ""){
  211. RECIEVE('42[26,"b","'+defaultmode+'"]');
  212. }
  213. }
  214. }
  215. args = "42"+JSON.stringify(jsonargs);
  216. }
  217.  
  218. }
  219. if(this.url.includes(".bonk.io/socket.io/?EIO=3&transport=websocket&sid=") && !this.injected){
  220. this.injected = true;
  221.  
  222. var originalRecieve = this.onmessage;
  223. this.onmessage = function(args){
  224. if(args.data.startsWith('42[24,')){
  225. beenKickedTimeStamp = Date.now();
  226. }
  227. if(args.data.startsWith('42[1,')){
  228. var jsonargs = JSON.parse(args.data.substring(2));
  229. SEND('42[1,{"id":'+jsonargs[2]+'}]');
  230. pingids = jsonargs[1];
  231. }
  232. if(args.data.startsWith('42[3,')){
  233. var jsonargs = JSON.parse(args.data.substring(2));
  234. for(var i = 0; i<jsonargs[3].length;i++){
  235. if(jsonargs[3][i]!=null){
  236. playerids[i.toString()] = jsonargs[3][i]["userName"];
  237. }
  238. }
  239. }
  240. if(args.data.startsWith('42[7,')){
  241. var jsonargs = JSON.parse(args.data.substring(2));
  242. var idofpacket = jsonargs[1];
  243. jsonargs = jsonargs[2];
  244. if(typeof(jsonargs["type"]) != "undefined"){
  245. if(jsonargs["type"]=="private chat" && jsonargs["to"] == username){
  246. from = jsonargs["from"];
  247. if(Object.keys(playerids).includes(idofpacket.toString())){
  248. from = playerids[idofpacket];
  249. }
  250. if(!ignorepmlist.includes(from)){
  251. if(typeof(jsonargs["message"])=="object" && typeof(jsonargs["password"]) == "object"){
  252. if(public_key[0]==jsonargs["public key"][0] && public_key[1]==jsonargs["public key"][1]){
  253. if(jsonargs["password"].length<=25){
  254. var password = CRYPT_MESSAGE(private_key,jsonargs["password"]);
  255. var decodedtext = jsonargs["message"].slice(0,400);
  256. var encodedtext = "";
  257. for(var i=0;i<decodedtext.length;i++){
  258. if(password[i%password.length]<1000){
  259. encodedtext+=String.fromCharCode(password[i%password.length]^decodedtext[i]);
  260. }
  261. }
  262. 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);';
  263. displayInChat('> '+'<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+from+'</a>'+': ',"#DA0808","#1EBCC1",{sanitize:false},encodedtext);
  264.  
  265. Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true;
  266. Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true;
  267. Laster_message = lastmessage();
  268. }
  269. }
  270. else{
  271. SEND("42"+JSON.stringify([4,{"type":"public key correction","from":username,"to":private_chat_public_key[0],"public key":public_key}]));
  272. }
  273. }
  274. }
  275. }
  276. if(jsonargs["type"]=="request public key" && jsonargs["to"] == username){
  277. SEND("42"+JSON.stringify([4,{"type":"public key","from":username,"public key":public_key}]));
  278. }
  279. if(jsonargs["type"]=="private chat users" && pmuserstimestamp+1500>Date.now()){
  280. if(typeof(jsonargs["from"])!='undefined'){
  281. from = jsonargs["from"];
  282. if(Object.keys(playerids).includes(idofpacket.toString())){
  283. from = playerids[idofpacket];
  284. }
  285. if(!pmusers.includes(from) && username == jsonargs["to"]){
  286. pmusers.push(from);
  287. }
  288. }
  289. }
  290. if(jsonargs["type"]=="request private chat users"){
  291. if(typeof(jsonargs["from"])!='undefined'){
  292. from = jsonargs["from"];
  293. if(Object.keys(playerids).includes(idofpacket.toString())){
  294. from = playerids[idofpacket];
  295. }
  296. SEND("42"+JSON.stringify([4,{"type":"private chat users","from":username,"to":from}]));
  297. }
  298. }
  299. if(jsonargs["type"]=="public key" && request_public_key_time_stamp+1500>Date.now()){
  300. from = jsonargs["from"];
  301. if(Object.keys(playerids).includes(idofpacket.toString())){
  302. from = playerids[idofpacket];
  303. }
  304. if(from == private_chat){
  305. private_chat_public_key = [private_chat,jsonargs["public key"]];
  306. displayInChat("Private chatting with "+private_chat+".","#DA0808","#1EBCC1");
  307. }
  308.  
  309. }
  310. if(jsonargs["type"]=="public key correction" && private_chat_public_key[0] == private_chat){
  311. from = jsonargs["from"];
  312. if(Object.keys(playerids).includes(idofpacket.toString())){
  313. from = playerids[idofpacket];
  314. }
  315. if(from == private_chat){
  316. private_chat_public_key = [private_chat,jsonargs["public key"]];
  317. var text = pmlastmessage;
  318. var password = [];
  319. for(var i = 0;i<10;i++){
  320. password.push(Math.floor(Math.random()*100+50));
  321. }
  322. var text2 = [];
  323. for(var i = 0;i<text.length ;i++){
  324. text2.push(password[i%password.length]^text.slice(0,400).charCodeAt(i));
  325. }
  326. 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)}]));
  327. }
  328. }
  329.  
  330. }
  331. }
  332.  
  333. if(args.data.startsWith('42[4,')){
  334. var jsonargs = JSON.parse(args.data.substring(2));
  335. playerids[jsonargs[1]] = jsonargs[3];
  336.  
  337. }
  338. if(args.data.startsWith('42[5,')){
  339. var jsonargs = JSON.parse(args.data.substring(2));
  340. if(typeof(playerids[jsonargs[1]])!='undefined'){
  341. delete playerids[jsonargs[1]];
  342. }
  343. }
  344. return originalRecieve.call(this,args);
  345. };
  346.  
  347. var originalClose = this.onclose;
  348. this.onclose = function () {
  349. window.bonkwss = 0;
  350. return originalClose.call(this);
  351. }
  352.  
  353. }
  354. return originalSend.call(this,args);
  355. };
  356.  
  357. scope.SEND = function(args){
  358. if(bonkwss!=0){
  359. bonkwss.send(args);
  360. }
  361. };
  362. scope.RECIEVE = function(args){
  363. if(bonkwss!=0){
  364. bonkwss.onmessage({data:args});
  365. }
  366. };
  367. Gdocument.getElementById("ingamechatcontent").style["pointer-events"]="all";
  368. Gdocument.getElementById("ingamechatcontent").style["max-height"]="250px";
  369. Gdocument.getElementById("ingamechatcontent").style["height"]="128px";
  370. Gdocument.getElementById("ingamechatbox").style["height"]="250px";
  371.  
  372. document.getElementById('adboxverticalCurse').style["display"] = "none";
  373. document.getElementById('adboxverticalleftCurse').style["display"] = "none";
  374.  
  375.  
  376. scope.dontswitch = false;
  377. scope.username = 0;
  378. scope.timedelay = 1400;
  379. scope.ishost = false;
  380. scope.quicki=0;
  381. scope.defaultmode = "d";
  382. scope.recmodebool = false;
  383. scope.freejoin = false;
  384. scope.beenKickedTimeStamp = 0;
  385. scope.stopquickplay = 1;
  386. scope.canceled = false;
  387. scope.banned = [];
  388. scope.transitioning = false;
  389. scope.message = "";
  390. scope.mode = "";
  391. scope.private_chat = "";
  392. scope.private_chat_public_key = ["",[0,0]];
  393. scope.users = [];
  394. scope.pmusers = [];
  395. scope.pmlastmessage = "";
  396. scope.pmuserstimestamp = 0;
  397. scope.ignorepmlist = [];
  398. scope.scroll = false;
  399. scope.elem = Gdocument.getElementById("maploadwindowmapscontainer");
  400. scope.npermissions = 1;
  401. scope.space_flag = false;
  402. scope.rcaps_flag = false;
  403. scope.number_flag = false;
  404. scope.request_public_key_time_stamp = 0;
  405. scope.sandboxcopyme = false;
  406. scope.help = ["All the commands are:","/help","/?","/advhelp [command]","/space","/rcaps","/number","/chatw [username]","/msg [text]","/ignorepm [username]","/pmusers","/eval [code]","/lobby","/team [letter]","/scroll","/hidechat","/showchat","/notify","/stopnotify","Host commands are:","/startqp","/stopqp","/next","/previous","/freejoin","/start","/balanceA [number]","/moveA [letter]","/rounds [number]","/ban [username]","Sandbox commands are:","/addplayer [number]","/delplayer [number]","/copyme","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"];
  407.  
  408. scope.adv_help = {"help":"Shows all command names.",
  409. "?":"Shows all command names.",
  410. "advhelp":"Shows a command in detail.",
  411. "space":"Toggles space. When space is on, whatever you type will be spaced apart.",
  412. "rcaps":"Toggles rcaps. When rcaps is on, each letter will randomly get capitalized.",
  413. "number":"Toggles number. When number is on, 'a' becomes 4, 'e' becomes 3, 's' becomes 5, 'o' becomes 0, 'l' and 'i' become 1.",
  414. "chatw":"It private chats with username. Type /msg to message that username.",
  415. "msg":"Messages with what username you are chatting with. Type /chatw to chat with a username.",
  416. "ignorepm":"Ignores the username's private chat messages. To unignore, type /ignorepm [username].",
  417. "pmusers":"Dispays who you can private chat with.",
  418. "eval":"Evaluates code. Only use this if you are experienced in javascript.",
  419. "lobby":"Makes lobby visible when you are ingame. Type /lobby again to close lobby.",
  420. "team":"Joins a specific team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  421. "scroll":"Toggles a scrollbar in ingame chat.",
  422. "hidechat":"Hides ingame chat. Type /showchat to show it again.",
  423. "showchat":"Shows ingame chat. /hidechat hides the chat.",
  424. "notify":"You will be notified if a person types @MYUSERNAME",
  425. "stopnotify":"You will not be notified if a person types @MYUSERNAME",
  426. "startqp":"Starts cycling maps in your map menu.",
  427. "stopqp":"Stops cycling maps in your map menu.",
  428. "next":"Skips the map. Usable only with /startqp.",
  429. "previous":"Goes to previous map. Usable only with /startqp.",
  430. "freejoin":"Toggles freejoin. If freejoin is on, starts the game instantly if there are 1 or less players currently playing.",
  431. "start":"Starts game instantly.",
  432. "balanceA":"Balances everyone with balance number.",
  433. "moveA":"Sets everyones team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  434. "rounds":"Sets rounds to win.",
  435. "ban":"Bans username from lobby. If they rejoin, it automatically bans.",
  436. "addplayer":"In sandbox, it adds players.",
  437. "delplayer":"In sandbox, it deletes players.",
  438. "copyme":"In sandbox, it makes each player copy your movements.",
  439. "Alt L":"Makes lobby visible when you are ingame. Press Alt L again to close lobby.",
  440. "Alt C":"Hides ingame chat. Press Alt C again to show ingame chat.",
  441. "Alt S":"Starts game instantly.",
  442. "Alt T":"Toggles teams.",
  443. "Alt E":"Toggles editor.",
  444. "Alt K":"Exits ingame and returns to lobby.",
  445. "Alt M":"Switches modes.",
  446. "Alt Q":"Toggles quickplay.",
  447. "Alt A":"Skips the map if quickplay is on.",
  448. "Alt D":"Goes to previous map if quickplay is on.",
  449. "Alt F":"Toggles freejoin. If freejoin is on, starts the game instantly if there are 1 or less players currently playing"
  450. };
  451.  
  452. elem.onclick=function(e){
  453. if(stopquickplay==0 && ishost == true && e.isTrusted == true){
  454. quicki = (Array.from(e.target.parentElement.parentNode.children).indexOf(e.target.parentNode)-1)%(Gdocument.getElementById("maploadwindowmapscontainer").children.length);
  455. }
  456. };
  457. scope.urlify = function(text) {
  458. return text.replace(/(?:https?:\/\/)?(?:[A-Za-z0-9-ßàÁâãóôþüúðæåïçèõöÿýòäœêëìíøùîûñé]+)(?:\.[A-Za-z0-9-ßàÁâãóôþüúðæåïçèõöÿýòäœêëìíøùîûñé]+)+(?:\/(?:[A-Za-z0-9-._~:/?#\[\]@!$&'()*+,;=]|%[0-9a-fA-F]{2})*)?(?:\?(?:[^=]+=[^&](?:&[^=]+=[^&])*)?)?/g, function(url) {
  459. return '<a href="' + url + '" target="_blank" style = "color:orange">' + url + '</a>';
  460. })
  461. };
  462.  
  463. scope.fire = function(type,options,d = Gdocument){
  464. var event=new CustomEvent(type);
  465. for(var p in options){
  466. event[p]=options[p];
  467. }
  468. d.dispatchEvent(event);
  469. };
  470.  
  471. scope.chat = function(message){
  472. mess = Gdocument.getElementById("newbonklobby_chat_input").value;
  473. mess2 = Gdocument.getElementById("ingamechatinputtext").value;
  474. Gdocument.getElementById("newbonklobby_chat_input").value = message;
  475. Gdocument.getElementById("ingamechatinputtext").value = message;
  476. fire("keydown",{keyCode:13});
  477. fire("keydown",{keyCode:13});
  478. Gdocument.getElementById("newbonklobby_chat_input").value = mess;
  479. Gdocument.getElementById("ingamechatinputtext").value = mess2;
  480. };
  481. scope.displayInChat = function(message, LobbyColor, InGameColor, options, message2) {
  482. options = options ?? {};
  483. message2 = message2 ?? "";
  484. LobbyColor = LobbyColor ?? "#8800FF";
  485. InGameColor = InGameColor ?? "#AA88FF";
  486. let A = Gdocument.createElement("div");
  487. let B = Gdocument.createElement("span");
  488. B.className = "newbonklobby_chat_status";
  489. B.style.color = LobbyColor;
  490. A.appendChild(B);
  491. B.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  492. B.innerHTML+=urlify(message2.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;'));
  493. let C = Gdocument.createElement("div");
  494. let D = Gdocument.createElement("span");
  495. D.style.color = InGameColor;
  496. C.appendChild(D);
  497. D.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  498. D.innerHTML+=urlify(message2.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;'));
  499.  
  500. let a = false;
  501. if(Gdocument.getElementById("newbonklobby_chat_content").scrollHeight - Gdocument.getElementById("newbonklobby_chat_content").scrollTop > Gdocument.getElementById("newbonklobby_chat_content").clientHeight - 1) {
  502. a = true;
  503. }
  504. Gdocument.getElementById("newbonklobby_chat_content").appendChild(A);
  505. Gdocument.getElementById("ingamechatcontent").appendChild(C);
  506. if (a) { Gdocument.getElementById("newbonklobby_chat_content").scrollTop = Number.MAX_SAFE_INTEGER;};
  507. Gdocument.getElementById("ingamechatcontent").scrollTop = Number.MAX_SAFE_INTEGER;
  508. chat("");
  509. };
  510.  
  511. scope.lobby = function(){
  512. if (Gdocument.getElementById("newbonklobby").style["display"]=="none"){
  513.  
  514. Gdocument.getElementById("newbonklobby_editorbutton").click();
  515. Gdocument.getElementById("mapeditor_close").click();
  516. if(Gdocument.getElementsByClassName("newbonklobby_playerentry").length>0){
  517. Gdocument.getElementById("newbonklobby").style["z-index"]=1;
  518. Gdocument.getElementById("maploadwindowcontainer").style["z-index"]=1;
  519. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=1;
  520. Gdocument.getElementById("pretty_top").style["z-index"]=2;
  521. Gdocument.getElementById("settingsContainer").style["z-index"]=2;
  522. Gdocument.getElementById("leaveconfirmwindow").style["z-index"]=2;
  523. Gdocument.getElementById("hostleaveconfirmwindow").style["z-index"]=2;
  524. }
  525. else{
  526. Gdocument.getElementById("newbonklobby").style["opacity"]=0;
  527. Gdocument.getElementById("newbonklobby").style["display"]="none";
  528. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
  529. }
  530.  
  531. }
  532. else if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  533. Gdocument.getElementById("newbonklobby").style["opacity"]=0;
  534. Gdocument.getElementById("newbonklobby").style["display"]="none";
  535. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
  536. }
  537. };
  538.  
  539. scope.lastmessage = function(){
  540. if(Gdocument.getElementById("newbonklobby_chat_content").children.length!=0){
  541. var lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  542. var lm2 = "";
  543. for(var i = 0; i<lm.length;i++){
  544. lm2+=" "+lm[i].textContent.trim();
  545. }
  546. lm2 = lm2.trim();
  547. if(lm2.startsWith("*")){
  548. return lm2;
  549. }
  550. }
  551. if(Gdocument.getElementById("ingamechatcontent").children.length!=0){
  552. var lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  553. var lm2 = "";
  554. for(var i = 0; i<lm.length;i++){
  555. lm2+=" "+lm[i].textContent.trim();
  556. }
  557. return lm2.trim();
  558. }
  559. return "";
  560.  
  561. };
  562. scope.map = function(e){
  563. if(e<0){
  564. displayInChat("There is no previous map.","#DA0808","#1EBCC1");
  565. quicki = 0;
  566. return;
  567. }
  568. if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
  569. displayInChat("Click the maps button.","#DA0808","#1EBCC1");
  570. return;
  571. }
  572.  
  573. setTimeout(function(){if(!canceled){
  574. Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
  575. Gdocument.getElementById("newbonklobby_editorbutton").click();
  576. Gdocument.getElementById("mapeditor_close").click();
  577. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  578. Gdocument.getElementById("mapeditor_midbox_testbutton").click();}
  579. canceled = false;
  580. transitioning = false;
  581. },timedelay);
  582.  
  583. };
  584.  
  585. scope.gotonextmap = function(e){
  586. if(e<0){
  587. displayInChat("There is no previous map.","#DA0808","#1EBCC1");
  588. quicki = 0;
  589. return;
  590. }
  591. if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
  592. displayInChat("Click the maps button.","#DA0808","#1EBCC1");
  593. return;
  594. }
  595. Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
  596. Gdocument.getElementById("newbonklobby_editorbutton").click();
  597. Gdocument.getElementById("mapeditor_close").click();
  598. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  599. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  600. Gdocument.getElementById("newbonklobby").style["visibility"] = "visible";
  601. };
  602. scope.commandhandle = function(chat_val){
  603.  
  604. if (chat_val.substring(1,6)=="space"){
  605. if(space_flag == true){
  606. displayInChat("Space is now off.","#DA0808","#1EBCC1");
  607. space_flag = false;
  608. }
  609. else{
  610. displayInChat("Space is now on.","#DA0808","#1EBCC1");
  611. space_flag = true;
  612. }
  613. return "";
  614. }
  615. else if (chat_val.substring(1,6)=="rcaps"){
  616. if(rcaps_flag == true){
  617. displayInChat("Rcaps is now off.","#DA0808","#1EBCC1");
  618. rcaps_flag = false;
  619. }
  620. else{
  621. displayInChat("Rcaps is now on.","#DA0808","#1EBCC1");
  622. rcaps_flag = true;
  623. }
  624.  
  625. return "";
  626. }
  627. else if (chat_val.substring(1,7)=="number"){
  628. if(number_flag == true){
  629. displayInChat("Number is now off.","#DA0808","#1EBCC1");
  630. number_flag = false;
  631. }
  632. else{
  633. displayInChat("Number is now on.","#DA0808","#1EBCC1");
  634. number_flag = true;
  635. }
  636.  
  637. return "";
  638. }
  639. else if (chat_val.substring(1,6)=="eval " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  640. var ev = "";
  641. try{
  642. ev = eval(chat_val.substring(6).replace(/^\s+|\s+$/g, ''));
  643. }
  644. catch(e){
  645. displayInChat(e.message,"#DA0808","#1EBCC1");
  646. }
  647. try{
  648. displayInChat(ev.toString(),"#DA0808","#1EBCC1");
  649. }
  650. catch{
  651. }
  652.  
  653. return "";
  654.  
  655. }
  656.  
  657. else if (chat_val.substring(1,9)=="hidechat"){
  658. Gdocument.getElementById("ingamechatcontent").style["max-height"]="0px";
  659. return "";
  660. }
  661. else if (chat_val.substring(1,9)=="showchat"){
  662. Gdocument.getElementById("ingamechatcontent").style["max-height"]="250px";
  663. return "";
  664. }
  665.  
  666. else if (chat_val.substring(1,7)=="scroll"){
  667. if(scroll==false){
  668. scroll = true;
  669. Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="scroll";
  670. Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
  671. }
  672. else if(scroll==true){
  673. scroll = false;
  674. Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="hidden";
  675. Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
  676. }
  677.  
  678. return "";
  679. }
  680.  
  681. else if (chat_val.substring(1,7)=="chatw "){
  682. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '');
  683.  
  684. if(username == text){
  685. displayInChat("You cannot private chat with yourself.","#DA0808","#1EBCC1");
  686. return "";
  687. }
  688. private_chat = text;
  689.  
  690. SEND("42"+JSON.stringify([4,{"type":"request public key","from":username,"to":private_chat}]));
  691. request_public_key_time_stamp = Date.now();
  692. 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);
  693. return "";
  694. }
  695.  
  696. else if (chat_val.substring(1,5)=="msg " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  697. if(private_chat_public_key[1][0] != 0 && private_chat_public_key[1][1] != 0 && private_chat_public_key[0] == private_chat){
  698. var text = chat_val.substring(5).replace(/^\s+|\s+$/g, '');
  699. var password = [];
  700. for(var i = 0;i<10;i++){
  701. password.push(Math.floor(Math.random()*100+50));
  702. }
  703. var text2 = [];
  704. for(var i = 0;i<text.slice(0,400).length ;i++){
  705. text2.push(password[i%password.length]^text.slice(0,400).charCodeAt(i));
  706. }
  707. pmlastmessage = text.slice(0,400);
  708. 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)}]));
  709. displayInChat("> "+username+": "+text,"#DA0808","#1EBCC1");
  710.  
  711. }
  712. return "";
  713. }
  714. else if (chat_val.substring(1,10)=="ignorepm " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  715. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  716. if(ignorepmlist.includes(text)){
  717. var index = ignorepmlist.indexOf(text);
  718. ignorepmlist.splice(index,1);
  719. displayInChat("You are not ignoring private messages from "+text+".","#DA0808","#1EBCC1");
  720.  
  721. }
  722. else{
  723. ignorepmlist.push(text);
  724. displayInChat("You are now ignoring private messages from "+text+".","#DA0808","#1EBCC1");
  725. }
  726. return "";
  727. }
  728. else if (chat_val.substring(1,8)=="pmusers"){
  729. pmusers = [];
  730. SEND("42"+JSON.stringify([4,{"type":"request private chat users","from":username}]));
  731. pmuserstimestamp = Date.now();
  732. setTimeout(function(){if(pmusers.length == 0){displayInChat("You cannot private chat with anyone.","#DA0808","#1EBCC1");
  733. }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);
  734. return "";
  735. }
  736. else if (chat_val.substring(1,6)=="lobby"){
  737. lobby();
  738. return "";
  739. }
  740. else if (chat_val.substring(1,6)=="team " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  741. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  742. if(text == "r"){Gdocument.getElementById("newbonklobby_redbutton").click();}
  743. else if(text == "g"){Gdocument.getElementById("newbonklobby_greenbutton").click();}
  744. else if(text == "y"){Gdocument.getElementById("newbonklobby_yellowbutton").click();}
  745. else if(text == "b"){Gdocument.getElementById("newbonklobby_bluebutton").click();}
  746. else if(text == "s"){Gdocument.getElementById("newbonklobby_specbutton").click();}
  747. else if(text == "f"){Gdocument.getElementById("newbonklobby_ffabutton").click();}
  748. return "";
  749. }
  750. else if (chat_val.substring(1,7)=="notify"){
  751.  
  752. npermissions = 1;
  753. return "";
  754. }
  755. else if (chat_val.substring(1,11)=="stopnotify"){
  756.  
  757. npermissions = 0;
  758. return "";
  759. }
  760. else if (chat_val.substring(1,5)=="help" || chat_val.substring(1,2)=="?"){
  761. for(var i = 0;i<help.length;i++){
  762. displayInChat(help[i],"#DA0808","#1EBCC1");
  763.  
  764. }
  765. return "";
  766. }
  767. else if (chat_val.substring(1,9)=="advhelp " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  768. var text = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  769. if(typeof(adv_help[text])!='undefined'){
  770. displayInChat(adv_help[text],"#DA0808","#1EBCC1");
  771. }
  772. return "";
  773. }
  774. else if(ishost){
  775.  
  776. if (chat_val.substring(1,5)=="next" && stopquickplay == 0){
  777. quicki++;
  778. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  779. displayInChat("Switched to next map.","#DA0808","#1EBCC1");
  780. return "";
  781.  
  782. }
  783. else if (chat_val.substring(1,9)=="freejoin"){
  784. if(freejoin == false){
  785. freejoin = true;
  786. displayInChat("Freejoin is now on.","#DA0808","#1EBCC1");
  787.  
  788. }
  789. else{
  790. freejoin = false;
  791. displayInChat("Freejoin is now off.","#DA0808","#1EBCC1");
  792. }
  793.  
  794. return "";
  795.  
  796. }
  797.  
  798. else if (chat_val.substring(1,9)=="previous" && stopquickplay == 0){
  799. quicki--;
  800. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  801.  
  802. displayInChat("Switched to previous map.","#DA0808","#1EBCC1");
  803. return "";
  804. }
  805. else if (chat_val.substring(1,6)=="start" && chat_val.length == 6){
  806. Gdocument.getElementById("newbonklobby_editorbutton").click();
  807. Gdocument.getElementById("mapeditor_close").click();
  808. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  809. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  810.  
  811. return "";
  812. }
  813.  
  814. else if (chat_val.substring(1,8)=="startqp" && stopquickplay == 1){
  815. stopquickplay = 0;
  816. quicki = 0;
  817. displayInChat("Enabled quickplay.","#DA0808","#1EBCC1");
  818. return "";
  819. }
  820. else if (chat_val.substring(1,7)=="stopqp" && stopquickplay == 0){
  821. stopquickplay = 1;
  822. quicki = 0;
  823. displayInChat("Disabled quickplay.","#DA0808","#1EBCC1");
  824. return "";
  825. }
  826.  
  827. else if (chat_val.substring(1,5)=="ban " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  828. banned.push(chat_val.substring(5).replace(/^\s+|\s+$/g, ''));
  829. displayInChat("Banned "+chat_val.substring(5).replace(/^\s+|\s+$/g, '')+".","#DA0808","#1EBCC1");
  830. return "/kick '" + chat_val.substring(5).replace(/^\s+|\s+$/g, '') + "'";
  831. }
  832. else if (chat_val.substring(1,10)=="balanceA " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  833. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  834. if(!isNaN(parseInt(text))){
  835. if(parseInt(text)>=-100 && parseInt(text)<=100){
  836. var keys = Object.keys(playerids);
  837. for(var i = 0; i<keys.length;i++){
  838. SEND('42[29,{"sid":'+keys[i]+',"bal":'+text+'}]');
  839. RECIEVE('42[36,'+keys[i]+','+text+']');
  840. }
  841. }
  842. }
  843. return "";
  844.  
  845. }
  846. else if (chat_val.substring(1,7)=="moveA " && chat_val.replace(/^\s+|\s+$/g, '').length>=8){
  847. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '');
  848. var keys = Object.keys(playerids);
  849. if(text == "f"){
  850. for(var i = 0; i<keys.length;i++){
  851. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":1}]')
  852. }
  853. }
  854. else if(text == "b"){
  855. for(var i = 0; i<keys.length;i++){
  856. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":3}]')
  857. }
  858. }
  859. else if(text == "g"){
  860. for(var i = 0; i<keys.length;i++){
  861. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":4}]')
  862. }
  863. }
  864. else if(text == "r"){
  865. for(var i = 0; i<keys.length;i++){
  866. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":2}]')
  867. }
  868. }
  869. else if(text == "y"){
  870. for(var i = 0; i<keys.length;i++){
  871. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":5}]')
  872. }
  873. }
  874. else if(text == "s"){
  875. for(var i = 0; i<keys.length;i++){
  876. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":0}]')
  877. }
  878. }
  879. return "";
  880. }
  881. else if (chat_val.substring(1,8)=="rounds " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  882. var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '');
  883. if(!isNaN(parseInt(text))){
  884. text = parseInt(text).toString();
  885. SEND('42[21,{"w":'+text+'}]');
  886. RECIEVE('42[27,'+text+']');
  887. }
  888. return "";
  889.  
  890. }
  891. else if (chat_val.substring(1,13)=="defaultmode " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  892. var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '');
  893. if(text == "default"){
  894. defaultmode = "";
  895. displayInChat("Changed default mode to default.","#DA0808","#1EBCC1");
  896. }
  897. else if(text == "arrows"){
  898. defaultmode = "ar";
  899. displayInChat("Changed default mode to arrows.","#DA0808","#1EBCC1");
  900. }
  901. else if(text == "death arrows"){
  902. defaultmode = "ard";
  903. displayInChat("Changed default mode to death arrows.","#DA0808","#1EBCC1");
  904. }
  905. else if(text == "grapple"){
  906. defaultmode = "sp";
  907. displayInChat("Changed default mode to grapple.","#DA0808","#1EBCC1");
  908. }
  909. else if(text == "classic"){
  910. defaultmode = "b";
  911. displayInChat("Changed default mode to classic.","#DA0808","#1EBCC1");
  912.  
  913. }
  914. else{
  915. displayInChat("Default mode options:","#DA0808","#1EBCC1");
  916. displayInChat("default","#DA0808","#1EBCC1");
  917. displayInChat("classic","#DA0808","#1EBCC1");
  918. displayInChat("arrows","#DA0808","#1EBCC1");
  919. displayInChat("death arrows","#DA0808","#1EBCC1");
  920. displayInChat("grapple","#DA0808","#1EBCC1");
  921. }
  922. return "";
  923.  
  924. }
  925. else if (chat_val.substring(1,8)=="recmode"){
  926. if(recmodebool == true){
  927. recmodebool = false;
  928. displayInChat("Recmode is now off.","#DA0808","#1EBCC1");
  929.  
  930. }
  931. else{
  932. recmodebool = true;
  933. displayInChat("Recmode is now on.","#DA0808","#1EBCC1");
  934.  
  935. }
  936.  
  937. return "";
  938.  
  939. }
  940. else if(sandboxon){
  941. if (chat_val.substring(1,11)=="addplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  942. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  943. if(!isNaN(parseInt(text))){
  944. var text2 = parseInt(text);
  945. if(text2>0){
  946. for(var i = 0;i<text2;i++){
  947. RECIEVE('42[4,'+sandboxid+',"0123456789abcdef","'+sandboxid.toString()+'",true,0,1,{"layers":[],"bc":'+Math.floor(Math.random() * 16777215).toString()+'}]');
  948. sandboxplayerids[sandboxid] = sandboxid.toString();
  949. sandboxid+=1;
  950. }
  951.  
  952. }
  953. }
  954. return "";
  955.  
  956. }
  957. else if (chat_val.substring(1,11)=="delplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  958. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  959. if(!isNaN(parseInt(text))){
  960. var text2 = parseInt(text);
  961. if(text2>0){
  962. if(Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden"){
  963. var jsonkeys = Object.keys(sandboxplayerids).reverse();
  964. for(var i = 0;i<text2 && i<jsonkeys.length;i++){
  965. RECIEVE('42[5,'+jsonkeys[i]+',0]');
  966. delete sandboxplayerids[jsonkeys[i]];
  967. }
  968. }
  969. else{
  970. displayInChat("Cannot delete players while ingame.","#DA0808","#1EBCC1");
  971. }
  972.  
  973. }
  974. }
  975. return "";
  976. }
  977. else if (chat_val.substring(1,7)=="copyme"){
  978. if(sandboxcopyme == true){
  979. displayInChat("Copyme is now off.","#DA0808","#1EBCC1");
  980. sandboxcopyme = false;
  981. }
  982. else{
  983. displayInChat("Copyme is now on.","#DA0808","#1EBCC1");
  984. sandboxcopyme = true;
  985. }
  986.  
  987. return "";
  988. }
  989. }
  990. }
  991. return chat_val;
  992. };
  993.  
  994. scope.flag_manage = function(t){
  995. var text = t;
  996.  
  997. if(rcaps_flag == true){
  998. text = text.split('');
  999. for(var i = 0; i<text.length;i++){
  1000. if(Math.floor(Math.random()*2)){
  1001. text[i] = text[i].toUpperCase();
  1002. }
  1003. else{
  1004. text[i] = text[i].toLowerCase();
  1005. }
  1006. }
  1007. text = text.join('');
  1008. }
  1009. if(space_flag == true){
  1010. text = text.split('').join(' ')
  1011. }
  1012. if(number_flag == true){
  1013. text = text.replace(/[t|T][Oo]+/g,"2");
  1014. text = text.replace(/[f|F][o|O][r|R]/g,"4");
  1015. text = text.replace(/[a|A][t|T][e|E]/g,"8");
  1016. text = text.replace(/[e|E]/g,"3");
  1017. text = text.replace(/[a|A]/g,"4");
  1018. text = text.replace(/[o|O]/g,"0");
  1019. text = text.replace(/[s|S]/g,"5");
  1020. text = text.replace(/[i|I|l|L]/g,"1");
  1021. }
  1022. return text;
  1023. };
  1024. Gdocument.getElementById("newbonklobby_chat_input").onkeydown = function(e){
  1025. if(e.keyCode==13){
  1026.  
  1027. var chat_val = Gdocument.getElementById("newbonklobby_chat_input").value;
  1028.  
  1029. if (chat_val!="" && chat_val[0]=="/"){
  1030.  
  1031. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  1032. chat(commandhandle(chat_val));
  1033. }
  1034. else{
  1035. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  1036. chat(flag_manage(chat_val));
  1037. }
  1038.  
  1039. }
  1040. };
  1041. Gdocument.getElementById("ingamechatinputtext").onkeydown = function(e){
  1042. if(e.keyCode==13){
  1043.  
  1044. var chat_val = Gdocument.getElementById("ingamechatinputtext").value;
  1045.  
  1046. if (chat_val!="" && chat_val[0]=="/"){
  1047.  
  1048. Gdocument.getElementById("ingamechatinputtext").value = "";
  1049. chat(commandhandle(chat_val));
  1050. }
  1051. else{
  1052. Gdocument.getElementById("ingamechatinputtext").value = "";
  1053. chat(flag_manage(chat_val));
  1054. }
  1055. }
  1056. };
  1057. scope.Last_message = "";
  1058. scope.Laster_message = "";
  1059. scope.new_message = false;
  1060. scope.changed_chat = false;
  1061. scope.interval = setInterval(timeout123,100);
  1062.  
  1063. scope.hotkeys = function(e){
  1064. if(e.repeat){return;}
  1065. var keycode = e.which || e.keyCode;
  1066. if(e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  1067. if(ishost){
  1068. if(keycode == 69){
  1069. if(Gdocument.getElementById("newbonklobby").style["display"] == "block"){
  1070. Gdocument.getElementById("newbonklobby_editorbutton").click();
  1071. }
  1072. else if(Gdocument.getElementById("mapeditorcontainer").style["display"] == "block"){
  1073. Gdocument.getElementById("mapeditor_close").click();
  1074. }
  1075. e.preventDefault();
  1076.  
  1077. }
  1078. else if(keycode == 84){
  1079. Gdocument.getElementById("newbonklobby_teamsbutton").click();
  1080. e.preventDefault();
  1081. }
  1082. else if(keycode == 77){
  1083. Gdocument.getElementById("newbonklobby_modebutton").click();
  1084. e.preventDefault();
  1085. }
  1086. else if(keycode == 75){
  1087. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  1088. Gdocument.getElementById("pretty_top_exit").click();
  1089. }
  1090. e.preventDefault();
  1091. }
  1092. else if(keycode == 83){
  1093. Gdocument.getElementById("newbonklobby_editorbutton").click();
  1094. Gdocument.getElementById("mapeditor_close").click();
  1095. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  1096. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  1097. e.preventDefault();
  1098. }
  1099. else if(keycode == 68){
  1100. if(stopquickplay == 0){
  1101. quicki++;
  1102. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  1103. }
  1104. e.preventDefault();
  1105. }
  1106. else if(keycode == 65){
  1107. if(stopquickplay == 0){
  1108. quicki--;
  1109. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  1110. }
  1111. e.preventDefault();
  1112. }
  1113. else if(keycode == 81){
  1114. if(stopquickplay == 1){
  1115. stopquickplay = 0;
  1116. quicki = 0;
  1117. displayInChat("Enabled quickplay.","#DA0808","#1EBCC1");
  1118. }
  1119. else{
  1120. stopquickplay = 1;
  1121. quicki = 0;
  1122. displayInChat("Disabled quickplay.","#DA0808","#1EBCC1");
  1123. }
  1124. e.preventDefault();
  1125. }
  1126. else if(keycode == 70){
  1127. if(freejoin == false){
  1128. freejoin = true;
  1129. displayInChat("Freejoin is now on.","#DA0808","#1EBCC1");
  1130.  
  1131. }
  1132. else{
  1133. freejoin = false;
  1134. displayInChat("Freejoin is now off.","#DA0808","#1EBCC1");
  1135. }
  1136. e.preventDefault();
  1137. }
  1138. }
  1139. else{
  1140. if(keycode == 69){
  1141. e.preventDefault();
  1142. }
  1143. else if(keycode == 84){
  1144. e.preventDefault();
  1145. }
  1146. else if(keycode == 77){
  1147. e.preventDefault();
  1148. }
  1149. else if(keycode == 75){
  1150. e.preventDefault();
  1151. }
  1152. else if(keycode == 83){
  1153. e.preventDefault();
  1154. }
  1155. else if(keycode == 68){
  1156. e.preventDefault();
  1157. }
  1158. else if(keycode == 65){
  1159. e.preventDefault();
  1160. }
  1161. else if(keycode == 81){
  1162. e.preventDefault();
  1163. }
  1164. else if(keycode == 70){
  1165. e.preventDefault();
  1166. }
  1167. }
  1168. if(keycode == 76){
  1169. lobby();
  1170. e.preventDefault();
  1171. }
  1172. if(keycode == 67){
  1173. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  1174. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]=="0px"){
  1175. Gdocument.getElementById("ingamechatcontent").style["max-height"]="250px";
  1176. }
  1177. else{
  1178. Gdocument.getElementById("ingamechatcontent").style["max-height"]="0px";
  1179. }
  1180. }
  1181. e.preventDefault();
  1182. }
  1183. }
  1184. };
  1185.  
  1186. Gdocument.onkeydown = hotkeys;
  1187.  
  1188. function timeout123() {
  1189. if(Gdocument.getElementById("gamerenderer").style["visibility"]=="hidden"){
  1190. Gdocument.getElementById("ingamechatcontent").style["max-height"]="250px";
  1191. }
  1192. if(Gdocument.getElementById("sm_connectingContainer").style["visibility"] == "hidden"){
  1193. var chatbox = Gdocument.getElementById("newbonklobby_chat_content");
  1194. while (chatbox.firstChild) {
  1195. chatbox.removeChild(chatbox.firstChild);
  1196. }
  1197. rcaps_flag = false;
  1198. space_flag = false;
  1199. number_flag = false;
  1200. scroll = false;
  1201. stopquickplay = 1;
  1202. freejoin = false;
  1203. defaultmode = "";
  1204. recmodebool = false;
  1205. playerids = {};
  1206. pingids = {};
  1207. ishost = false;
  1208. sandboxplayerids = {};
  1209. sandboxcopyme = false;
  1210. sandboxon = false;
  1211. sandboxid = 1;
  1212. if(chatlog[chatlog.length-1]!="ROOM END"){
  1213. chatlog.push("ROOM END");
  1214. }
  1215. }
  1216. else{
  1217. if(chatlog[chatlog.length-1]=="ROOM END"){
  1218. chatlog.push("ROOM START");
  1219. }
  1220. var pingidkey = Object.keys(pingids);
  1221. var playeridkey = Object.keys(playerids);
  1222. for(var i = 0; i<pingidkey.length;i++){
  1223. if(!playeridkey.includes(pingidkey[i])){
  1224. var pingtext = Gdocument.getElementsByClassName("newbonklobby_playerentry_pingtext");
  1225. var found = [];
  1226. if(Gdocument.getElementById("newbonklobby").style["display"] != "block"){
  1227. mess2 = Gdocument.getElementById("ingamechatinputtext").value;
  1228. Gdocument.getElementById("ingamechatinputtext").value = "";
  1229. Gdocument.getElementById("newbonklobby_editorbutton").click();
  1230. Gdocument.getElementById("mapeditor_close").click();
  1231. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  1232. Gdocument.getElementById("ingamechatinputtext").value = mess2;
  1233.  
  1234. }
  1235. for(var e=0; e<pingtext.length;e++){
  1236. if(pingtext[e].textContent == pingids[pingidkey[i]].toString()+"ms"){
  1237. found.push(pingtext[e].parentElement);
  1238. }
  1239. }
  1240. if(found.length == 1){
  1241. playerids[pingidkey[i]] = found[0].children[1].textContent;
  1242. break;
  1243. }
  1244. }
  1245. }
  1246. pingids = {};
  1247. }
  1248. if(Gdocument.getElementById("ingametextwarning_afk").style["display"]=="table"){
  1249. Gdocument.getElementById("pretty_top_settings").click();
  1250. key2 = Gdocument.getElementById("redefineControls_table").children[0].children[5].children[1].innerHTML.charCodeAt(0);
  1251. Gdocument.getElementById("settings_close").click();
  1252.  
  1253. if(key2>0){
  1254. fire("keydown",{keyCode:key2},Gwindow);
  1255. setTimeout(function(){fire("keyup",{keyCode:key2},Gwindow)},100);
  1256. }
  1257.  
  1258. }
  1259.  
  1260. if(Gdocument.getElementById("newbonklobby").style["display"]=="block"){
  1261. Gdocument.getElementById("ingamechatinputtext").style["visibility"]="hidden";
  1262. }
  1263. else{
  1264. Gdocument.getElementById("ingamechatinputtext").style["visibility"]="visible";
  1265.  
  1266. }
  1267. mode = Gdocument.getElementById("newbonklobby_modetext").textContent;
  1268. var userlist = Gdocument.getElementsByClassName("newbonklobby_playerentry_name");
  1269. users = [];
  1270. for(var i = 0;i<userlist.length;i++){
  1271. users.push(userlist[i].textContent);
  1272. }
  1273. if(Gdocument.getElementsByClassName('newbonklobby_settings_button brownButton brownButton_classic buttonShadow brownButtonDisabled').length == 0){
  1274. ishost = true;
  1275. }
  1276. else{
  1277. ishost = false;
  1278. }
  1279.  
  1280. if(Gdocument.getElementById("pretty_top_name")!=null){
  1281. username = Gdocument.getElementById("pretty_top_name").textContent;
  1282. }
  1283. try{
  1284. Last_message = lastmessage()
  1285. } catch{
  1286. Last_message = "";
  1287. }
  1288. if (Laster_message != Last_message){
  1289. Laster_message = Last_message;
  1290. if(changed_chat==false){
  1291. new_message = true;
  1292. }
  1293. else{
  1294. changed_chat = false;
  1295. }
  1296. }
  1297. if(new_message){
  1298. chatlog.push(Last_message);
  1299. if(freejoin && Last_message.startsWith("* ") && Last_message.endsWith(" has joined the game") && ishost){
  1300.  
  1301. var userjoined = Last_message.substring(2,Last_message.length-20);
  1302.  
  1303. if(Gdocument.getElementById("newbonklobby").style["display"] != "block"){
  1304. mess2 = Gdocument.getElementById("ingamechatinputtext").value;
  1305. Gdocument.getElementById("ingamechatinputtext").value = "";
  1306. Gdocument.getElementById("newbonklobby_editorbutton").click();
  1307. Gdocument.getElementById("mapeditor_close").click();
  1308. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  1309. Gdocument.getElementById("ingamechatinputtext").value = mess2;
  1310.  
  1311. }
  1312. var playing = Gdocument.getElementsByClassName("newbonklobby_playerentry newbonklobby_playerentry_half");
  1313. var inplaying = false;
  1314. for(var i = 0;i<playing.length;i++){
  1315. if(userjoined == playing[i].children[1].textContent){
  1316. inplaying = true;
  1317. break;
  1318. }
  1319. }
  1320.  
  1321. if(playing.length<=2 && inplaying){
  1322. Gdocument.getElementById("newbonklobby_editorbutton").click();
  1323. Gdocument.getElementById("mapeditor_close").click();
  1324. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  1325. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  1326. if(transitioning == true){
  1327. canceled = true;
  1328. }
  1329. }
  1330.  
  1331. }
  1332. var lm = "";
  1333. try{
  1334. lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  1335. if(typeof(lm[0].parentElement.style["parsed"]) == 'undefined'){
  1336. if (lm[0].className == "newbonklobby_chat_msg_colorbox"){
  1337. lm[2].innerHTML = urlify(lm[2].innerHTML);
  1338. Laster_message = lastmessage();
  1339. lm[0].parentElement.style["parsed"] = true;
  1340. }
  1341. if (lm[0].className == "newbonklobby_chat_status"){
  1342. lm[0].innerHTML = urlify(lm[0].innerHTML);
  1343. Laster_message = lastmessage();
  1344. lm[0].parentElement.style["parsed"] = true;
  1345. }
  1346. }
  1347. }
  1348. catch{
  1349. lm = "";
  1350. }
  1351.  
  1352. if(Last_message.indexOf("@"+username)!=-1 && npermissions == 1){
  1353. var n = new Notification(Last_message);
  1354. }
  1355.  
  1356. try{
  1357. lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  1358. if(typeof(lm[0].parentElement.style["parsed"])=='undefined'){
  1359. if(lm[0].className == "ingamechatname"){
  1360. lm[1].innerHTML = urlify(lm[1].innerHTML);
  1361. Laster_message = lastmessage();
  1362. lm[0].parentElement.style["parsed"] = true;
  1363. }
  1364. if(lm[0].className == ""){
  1365. lm[0].innerHTML = urlify(lm[0].innerHTML);
  1366. Laster_message = lastmessage();
  1367. lm[0].parentElement.style["parsed"] = true;
  1368. }
  1369. }
  1370. }
  1371. catch{
  1372. lm = "";
  1373. }
  1374.  
  1375. }
  1376. if (ishost==true && new_message){
  1377. for(i=0;i<banned.length;i++){
  1378. if(Last_message == "* "+banned[i]+" has joined the game "){
  1379. chat("/kick '"+banned[i]+"'");
  1380. }
  1381. }
  1382. }
  1383. if(ishost == true && stopquickplay == 0){
  1384.  
  1385. if(Gdocument.getElementById("ingamewinner").style["visibility"]=="inherit" && stopquickplay == 0 && dontswitch == false){
  1386. quicki++;
  1387. transitioning = true;
  1388. map(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  1389.  
  1390. dontswitch = true;
  1391. setTimeout(function(){Gdocument.getElementById("ingamewinner").style["visibility"]="hidden"; dontswitch = false;},timedelay);
  1392.  
  1393. }
  1394. }
  1395. new_message = false;
  1396. };
  1397. });

QingJ © 2025

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