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.3
  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.echo_list = [];
  390. scope.message = "";
  391. scope.mode = "";
  392. scope.private_chat = "";
  393. scope.private_chat_public_key = ["",[0,0]];
  394. scope.users = [];
  395. scope.pmusers = [];
  396. scope.pmlastmessage = "";
  397. scope.pmuserstimestamp = 0;
  398. scope.ignorepmlist = [];
  399. scope.scroll = false;
  400. scope.elem = Gdocument.getElementById("maploadwindowmapscontainer");
  401. scope.npermissions = 1;
  402. scope.space_flag = false;
  403. scope.rcaps_flag = false;
  404. scope.number_flag = false;
  405. scope.request_public_key_time_stamp = 0;
  406. scope.sandboxcopyme = false;
  407. scope.help = ["All the commands are:","/help","/?","/advhelp [command]","/space","/rcaps","/number","/echo [username]","/clearecho","/remove [username]","/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"];
  408.  
  409. scope.adv_help = {"help":"Shows all command names.",
  410. "?":"Shows all command names.",
  411. "advhelp":"Shows a command in detail.",
  412. "space":"Toggles space. When space is on, whatever you type will be spaced apart.",
  413. "rcaps":"Toggles rcaps. When rcaps is on, each letter will randomly get capitalized.",
  414. "number":"Toggles number. When number is on, 'a' becomes 4, 'e' becomes 3, 's' becomes 5, 'o' becomes 0, 'l' and 'i' become 1.",
  415. "echo":"Echoes a username. It copies the username's chat messages.",
  416. "remove":"Removes username from echo list. You will not echo that username anymore.",
  417. "clearecho":"Clears echo list. You will not echo anyone anymore.",
  418. "chatw":"It private chats with username. Type /msg to message that username.",
  419. "msg":"Messages with what username you are chatting with. Type /chatw to chat with a username.",
  420. "ignorepm":"Ignores the username's private chat messages. To unignore, type /ignorepm [username].",
  421. "pmusers":"Dispays who you can private chat with.",
  422. "eval":"Evaluates code. Only use this if you are experienced in javascript.",
  423. "lobby":"Makes lobby visible when you are ingame. Type /lobby again to close lobby.",
  424. "team":"Joins a specific team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  425. "scroll":"Toggles a scrollbar in ingame chat.",
  426. "hidechat":"Hides ingame chat. Type /showchat to show it again.",
  427. "showchat":"Shows ingame chat. /hidechat hides the chat.",
  428. "notify":"You will be notified if a person types @MYUSERNAME",
  429. "stopnotify":"You will not be notified if a person types @MYUSERNAME",
  430. "startqp":"Starts cycling maps in your map menu.",
  431. "stopqp":"Stops cycling maps in your map menu.",
  432. "next":"Skips the map. Usable only with /startqp.",
  433. "previous":"Goes to previous map. Usable only with /startqp.",
  434. "freejoin":"Toggles freejoin. If freejoin is on, starts the game instantly if there are 1 or less players currently playing.",
  435. "start":"Starts game instantly.",
  436. "balanceA":"Balances everyone with balance number.",
  437. "moveA":"Sets everyones team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  438. "rounds":"Sets rounds to win.",
  439. "ban":"Bans username from lobby. If they rejoin, it automatically bans.",
  440. "addplayer":"In sandbox, it adds players.",
  441. "delplayer":"In sandbox, it deletes players.",
  442. "copyme":"In sandbox, it makes each player copy your movements.",
  443. "Alt L":"Makes lobby visible when you are ingame. Press Alt L again to close lobby.",
  444. "Alt C":"Hides ingame chat. Press Alt C again to show ingame chat.",
  445. "Alt S":"Starts game instantly.",
  446. "Alt T":"Toggles teams.",
  447. "Alt E":"Toggles editor.",
  448. "Alt K":"Exits ingame and returns to lobby.",
  449. "Alt M":"Switches modes.",
  450. "Alt Q":"Toggles quickplay.",
  451. "Alt A":"Skips the map if quickplay is on.",
  452. "Alt D":"Goes to previous map if quickplay is on.",
  453. "Alt F":"Toggles freejoin. If freejoin is on, starts the game instantly if there are 1 or less players currently playing"
  454. };
  455.  
  456. elem.onclick=function(e){
  457. if(stopquickplay==0 && ishost == true && e.isTrusted == true){
  458. quicki = (Array.from(e.target.parentElement.parentNode.children).indexOf(e.target.parentNode)-1)%(Gdocument.getElementById("maploadwindowmapscontainer").children.length);
  459. }
  460. };
  461. scope.urlify = function(text) {
  462. return text.replace(/(?:https?:\/\/)?(?:[A-Za-z0-9-ßàÁâãóôþüúðæåïçèõöÿýòäœêëìíøùîûñé]+)(?:\.[A-Za-z0-9-ßàÁâãóôþüúðæåïçèõöÿýòäœêëìíøùîûñé]+)+(?:\/(?:[A-Za-z0-9-._~:/?#\[\]@!$&'()*+,;=]|%[0-9a-fA-F]{2})*)?(?:\?(?:[^=]+=[^&](?:&[^=]+=[^&])*)?)?/g, function(url) {
  463. return '<a href="' + url + '" target="_blank" style = "color:orange">' + url + '</a>';
  464. })
  465. };
  466.  
  467. scope.fire = function(type,options,d = Gdocument){
  468. var event=new CustomEvent(type);
  469. for(var p in options){
  470. event[p]=options[p];
  471. }
  472. d.dispatchEvent(event);
  473. };
  474.  
  475. scope.chat = function(message){
  476. mess = Gdocument.getElementById("newbonklobby_chat_input").value;
  477. mess2 = Gdocument.getElementById("ingamechatinputtext").value;
  478. Gdocument.getElementById("newbonklobby_chat_input").value = message;
  479. Gdocument.getElementById("ingamechatinputtext").value = message;
  480. fire("keydown",{keyCode:13});
  481. fire("keydown",{keyCode:13});
  482. Gdocument.getElementById("newbonklobby_chat_input").value = mess;
  483. Gdocument.getElementById("ingamechatinputtext").value = mess2;
  484. };
  485. scope.displayInChat = function(message, LobbyColor, InGameColor, options, message2) {
  486. options = options ?? {};
  487. message2 = message2 ?? "";
  488. LobbyColor = LobbyColor ?? "#8800FF";
  489. InGameColor = InGameColor ?? "#AA88FF";
  490. let A = Gdocument.createElement("div");
  491. let B = Gdocument.createElement("span");
  492. B.className = "newbonklobby_chat_status";
  493. B.style.color = LobbyColor;
  494. A.appendChild(B);
  495. B.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  496. B.innerHTML+=urlify(message2.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;'));
  497. let C = Gdocument.createElement("div");
  498. let D = Gdocument.createElement("span");
  499. D.style.color = InGameColor;
  500. C.appendChild(D);
  501. D.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  502. D.innerHTML+=urlify(message2.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;'));
  503.  
  504. let a = false;
  505. if(Gdocument.getElementById("newbonklobby_chat_content").scrollHeight - Gdocument.getElementById("newbonklobby_chat_content").scrollTop > Gdocument.getElementById("newbonklobby_chat_content").clientHeight - 1) {
  506. a = true;
  507. }
  508. Gdocument.getElementById("newbonklobby_chat_content").appendChild(A);
  509. Gdocument.getElementById("ingamechatcontent").appendChild(C);
  510. if (a) { Gdocument.getElementById("newbonklobby_chat_content").scrollTop = Number.MAX_SAFE_INTEGER;};
  511. Gdocument.getElementById("ingamechatcontent").scrollTop = Number.MAX_SAFE_INTEGER;
  512. chat("");
  513. };
  514.  
  515. scope.lobby = function(){
  516. if (Gdocument.getElementById("newbonklobby").style["display"]=="none"){
  517.  
  518. Gdocument.getElementById("newbonklobby_editorbutton").click();
  519. Gdocument.getElementById("mapeditor_close").click();
  520. if(Gdocument.getElementsByClassName("newbonklobby_playerentry").length>0){
  521. Gdocument.getElementById("newbonklobby").style["z-index"]=1;
  522. Gdocument.getElementById("maploadwindowcontainer").style["z-index"]=1;
  523. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=1;
  524. Gdocument.getElementById("pretty_top").style["z-index"]=2;
  525. Gdocument.getElementById("settingsContainer").style["z-index"]=2;
  526. Gdocument.getElementById("leaveconfirmwindow").style["z-index"]=2;
  527. Gdocument.getElementById("hostleaveconfirmwindow").style["z-index"]=2;
  528. }
  529. else{
  530. Gdocument.getElementById("newbonklobby").style["opacity"]=0;
  531. Gdocument.getElementById("newbonklobby").style["display"]="none";
  532. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
  533. }
  534.  
  535. }
  536. else if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  537. Gdocument.getElementById("newbonklobby").style["opacity"]=0;
  538. Gdocument.getElementById("newbonklobby").style["display"]="none";
  539. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
  540. }
  541. };
  542.  
  543. scope.lastmessage = function(){
  544. if(Gdocument.getElementById("newbonklobby_chat_content").children.length!=0){
  545. var lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  546. var lm2 = "";
  547. for(var i = 0; i<lm.length;i++){
  548. lm2+=" "+lm[i].textContent.trim();
  549. }
  550. lm2 = lm2.trim();
  551. if(lm2.startsWith("*")){
  552. return lm2;
  553. }
  554. }
  555. if(Gdocument.getElementById("ingamechatcontent").children.length!=0){
  556. var lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  557. var lm2 = "";
  558. for(var i = 0; i<lm.length;i++){
  559. lm2+=" "+lm[i].textContent.trim();
  560. }
  561. return lm2.trim();
  562. }
  563. return "";
  564.  
  565. };
  566. scope.map = function(e){
  567. if(e<0){
  568. displayInChat("There is no previous map.","#DA0808","#1EBCC1");
  569. quicki = 0;
  570. return;
  571. }
  572. if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
  573. displayInChat("Click the maps button.","#DA0808","#1EBCC1");
  574. return;
  575. }
  576.  
  577. setTimeout(function(){if(!canceled){
  578. Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
  579. Gdocument.getElementById("newbonklobby_editorbutton").click();
  580. Gdocument.getElementById("mapeditor_close").click();
  581. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  582. Gdocument.getElementById("mapeditor_midbox_testbutton").click();}
  583. canceled = false;
  584. transitioning = false;
  585. },timedelay);
  586.  
  587. };
  588.  
  589. scope.gotonextmap = function(e){
  590. if(e<0){
  591. displayInChat("There is no previous map.","#DA0808","#1EBCC1");
  592. quicki = 0;
  593. return;
  594. }
  595. if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
  596. displayInChat("Click the maps button.","#DA0808","#1EBCC1");
  597. return;
  598. }
  599. Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
  600. Gdocument.getElementById("newbonklobby_editorbutton").click();
  601. Gdocument.getElementById("mapeditor_close").click();
  602. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  603. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  604. Gdocument.getElementById("newbonklobby").style["visibility"] = "visible";
  605. };
  606. scope.commandhandle = function(chat_val){
  607. if (chat_val.substring(1,6)=="echo " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  608. if (chat_val.substring(6).replace(/^\s+|\s+$/g, '')==username){
  609. displayInChat("You cannot echo yourself.","#DA0808","#1EBCC1");
  610. return "";
  611. }
  612. else if (echo_list.indexOf(chat_val.substring(6).replace(/^\s+|\s+$/g, ''))===-1) {
  613.  
  614. echo_list.push(chat_val.substring(6).replace(/^\s+|\s+$/g, ''));
  615. displayInChat(chat_val.substring(6).replace(/^\s+|\s+$/g, '') + " is being echoed.","#DA0808","#1EBCC1");
  616. return "";
  617. }
  618. else{
  619. displayInChat(chat_val.substring(6).replace(/^\s+|\s+$/g, '') + " is already being echoed.","#DA0808","#1EBCC1");
  620. return "";
  621. }
  622. }
  623. else if (chat_val.substring(1,8)=="remove " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  624. if (echo_list.indexOf(chat_val.substring(7).replace(/^\s+|\s+$/g, ''))!==-1){
  625. echo_list.splice(echo_list.indexOf(chat_val.substring(7).replace(/^\s+|\s+$/g, '')),1);
  626. displayInChat(chat_val.substring(7).replace(/^\s+|\s+$/g, '')+" is not being echoed.","#DA0808","#1EBCC1");
  627. return "";
  628. }
  629. else{
  630. displayInChat("You cannot remove someone that you didn't echo.","#DA0808","#1EBCC1");
  631. return "";
  632. }
  633.  
  634. }
  635. else if (chat_val.substring(1,10)=="clearecho"){
  636. echo_list = [];
  637. displayInChat("Cleared the echo list.","#DA0808","#1EBCC1");
  638. return "";
  639. }
  640. else if (chat_val.substring(1,6)=="space"){
  641. if(space_flag == true){
  642. displayInChat("Space is now off.","#DA0808","#1EBCC1");
  643. space_flag = false;
  644. }
  645. else{
  646. displayInChat("Space is now on.","#DA0808","#1EBCC1");
  647. space_flag = true;
  648. }
  649. return "";
  650. }
  651. else if (chat_val.substring(1,6)=="rcaps"){
  652. if(rcaps_flag == true){
  653. displayInChat("Rcaps is now off.","#DA0808","#1EBCC1");
  654. rcaps_flag = false;
  655. }
  656. else{
  657. displayInChat("Rcaps is now on.","#DA0808","#1EBCC1");
  658. rcaps_flag = true;
  659. }
  660.  
  661. return "";
  662. }
  663. else if (chat_val.substring(1,7)=="number"){
  664. if(number_flag == true){
  665. displayInChat("Number is now off.","#DA0808","#1EBCC1");
  666. number_flag = false;
  667. }
  668. else{
  669. displayInChat("Number is now on.","#DA0808","#1EBCC1");
  670. number_flag = true;
  671. }
  672.  
  673. return "";
  674. }
  675. else if (chat_val.substring(1,6)=="eval " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  676. var ev = "";
  677. try{
  678. ev = eval(chat_val.substring(6).replace(/^\s+|\s+$/g, ''));
  679. }
  680. catch(e){
  681. displayInChat(e.message,"#DA0808","#1EBCC1");
  682. }
  683. try{
  684. displayInChat(ev.toString(),"#DA0808","#1EBCC1");
  685. }
  686. catch{
  687. }
  688.  
  689. return "";
  690.  
  691. }
  692.  
  693. else if (chat_val.substring(1,9)=="hidechat"){
  694. Gdocument.getElementById("ingamechatcontent").style["max-height"]="0px";
  695. return "";
  696. }
  697. else if (chat_val.substring(1,9)=="showchat"){
  698. Gdocument.getElementById("ingamechatcontent").style["max-height"]="250px";
  699. return "";
  700. }
  701.  
  702. else if (chat_val.substring(1,7)=="scroll"){
  703. if(scroll==false){
  704. scroll = true;
  705. Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="scroll";
  706. Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
  707. }
  708. else if(scroll==true){
  709. scroll = false;
  710. Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="hidden";
  711. Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
  712. }
  713.  
  714. return "";
  715. }
  716.  
  717. else if (chat_val.substring(1,7)=="chatw "){
  718. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '');
  719.  
  720. if(username == text){
  721. displayInChat("You cannot private chat with yourself.","#DA0808","#1EBCC1");
  722. return "";
  723. }
  724. private_chat = text;
  725.  
  726. SEND("42"+JSON.stringify([4,{"type":"request public key","from":username,"to":private_chat}]));
  727. request_public_key_time_stamp = Date.now();
  728. 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);
  729. return "";
  730. }
  731.  
  732. else if (chat_val.substring(1,5)=="msg " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  733. if(private_chat_public_key[1][0] != 0 && private_chat_public_key[1][1] != 0 && private_chat_public_key[0] == private_chat){
  734. var text = chat_val.substring(5).replace(/^\s+|\s+$/g, '');
  735. var password = [];
  736. for(var i = 0;i<10;i++){
  737. password.push(Math.floor(Math.random()*100+50));
  738. }
  739. var text2 = [];
  740. for(var i = 0;i<text.slice(0,400).length ;i++){
  741. text2.push(password[i%password.length]^text.slice(0,400).charCodeAt(i));
  742. }
  743. pmlastmessage = text.slice(0,400);
  744. 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)}]));
  745. displayInChat("> "+username+": "+text,"#DA0808","#1EBCC1");
  746.  
  747. }
  748. return "";
  749. }
  750. else if (chat_val.substring(1,10)=="ignorepm " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  751. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  752. if(ignorepmlist.includes(text)){
  753. var index = ignorepmlist.indexOf(text);
  754. ignorepmlist.splice(index,1);
  755. displayInChat("You are not ignoring private messages from "+text+".","#DA0808","#1EBCC1");
  756.  
  757. }
  758. else{
  759. ignorepmlist.push(text);
  760. displayInChat("You are now ignoring private messages from "+text+".","#DA0808","#1EBCC1");
  761. }
  762. return "";
  763. }
  764. else if (chat_val.substring(1,8)=="pmusers"){
  765. pmusers = [];
  766. SEND("42"+JSON.stringify([4,{"type":"request private chat users","from":username}]));
  767. pmuserstimestamp = Date.now();
  768. setTimeout(function(){if(pmusers.length == 0){displayInChat("You cannot private chat with anyone.","#DA0808","#1EBCC1");
  769. }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);
  770. return "";
  771. }
  772. else if (chat_val.substring(1,6)=="lobby"){
  773. lobby();
  774. return "";
  775. }
  776. else if (chat_val.substring(1,6)=="team " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  777. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  778. if(text == "r"){Gdocument.getElementById("newbonklobby_redbutton").click();}
  779. else if(text == "g"){Gdocument.getElementById("newbonklobby_greenbutton").click();}
  780. else if(text == "y"){Gdocument.getElementById("newbonklobby_yellowbutton").click();}
  781. else if(text == "b"){Gdocument.getElementById("newbonklobby_bluebutton").click();}
  782. else if(text == "s"){Gdocument.getElementById("newbonklobby_specbutton").click();}
  783. else if(text == "f"){Gdocument.getElementById("newbonklobby_ffabutton").click();}
  784. return "";
  785. }
  786. else if (chat_val.substring(1,7)=="notify"){
  787.  
  788. npermissions = 1;
  789. return "";
  790. }
  791. else if (chat_val.substring(1,11)=="stopnotify"){
  792.  
  793. npermissions = 0;
  794. return "";
  795. }
  796. else if (chat_val.substring(1,5)=="help" || chat_val.substring(1,2)=="?"){
  797. for(var i = 0;i<help.length;i++){
  798. displayInChat(help[i],"#DA0808","#1EBCC1");
  799.  
  800. }
  801. return "";
  802. }
  803. else if (chat_val.substring(1,9)=="advhelp " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  804. var text = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  805. if(typeof(adv_help[text])!='undefined'){
  806. displayInChat(adv_help[text],"#DA0808","#1EBCC1");
  807. }
  808. return "";
  809. }
  810. else if(ishost){
  811.  
  812. if (chat_val.substring(1,5)=="next" && stopquickplay == 0){
  813. quicki++;
  814. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  815. displayInChat("Switched to next map.","#DA0808","#1EBCC1");
  816. return "";
  817.  
  818. }
  819. else if (chat_val.substring(1,9)=="freejoin"){
  820. if(freejoin == false){
  821. freejoin = true;
  822. displayInChat("Freejoin is now on.","#DA0808","#1EBCC1");
  823.  
  824. }
  825. else{
  826. freejoin = false;
  827. displayInChat("Freejoin is now off.","#DA0808","#1EBCC1");
  828. }
  829.  
  830. return "";
  831.  
  832. }
  833.  
  834. else if (chat_val.substring(1,9)=="previous" && stopquickplay == 0){
  835. quicki--;
  836. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  837.  
  838. displayInChat("Switched to previous map.","#DA0808","#1EBCC1");
  839. return "";
  840. }
  841. else if (chat_val.substring(1,6)=="start" && chat_val.length == 6){
  842. Gdocument.getElementById("newbonklobby_editorbutton").click();
  843. Gdocument.getElementById("mapeditor_close").click();
  844. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  845. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  846.  
  847. return "";
  848. }
  849.  
  850. else if (chat_val.substring(1,8)=="startqp" && stopquickplay == 1){
  851. stopquickplay = 0;
  852. quicki = 0;
  853. displayInChat("Enabled quickplay.","#DA0808","#1EBCC1");
  854. return "";
  855. }
  856. else if (chat_val.substring(1,7)=="stopqp" && stopquickplay == 0){
  857. stopquickplay = 1;
  858. quicki = 0;
  859. displayInChat("Disabled quickplay.","#DA0808","#1EBCC1");
  860. return "";
  861. }
  862.  
  863. else if (chat_val.substring(1,5)=="ban " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  864. banned.push(chat_val.substring(5).replace(/^\s+|\s+$/g, ''));
  865. displayInChat("Banned "+chat_val.substring(5).replace(/^\s+|\s+$/g, '')+".","#DA0808","#1EBCC1");
  866. return "/kick '" + chat_val.substring(5).replace(/^\s+|\s+$/g, '') + "'";
  867. }
  868. else if (chat_val.substring(1,10)=="balanceA " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  869. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  870. if(!isNaN(parseInt(text))){
  871. if(parseInt(text)>=-100 && parseInt(text)<=100){
  872. var keys = Object.keys(playerids);
  873. for(var i = 0; i<keys.length;i++){
  874. SEND('42[29,{"sid":'+keys[i]+',"bal":'+text+'}]');
  875. RECIEVE('42[36,'+keys[i]+','+text+']');
  876. }
  877. }
  878. }
  879. return "";
  880.  
  881. }
  882. else if (chat_val.substring(1,7)=="moveA " && chat_val.replace(/^\s+|\s+$/g, '').length>=8){
  883. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '');
  884. var keys = Object.keys(playerids);
  885. if(text == "f"){
  886. for(var i = 0; i<keys.length;i++){
  887. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":1}]')
  888. }
  889. }
  890. else if(text == "b"){
  891. for(var i = 0; i<keys.length;i++){
  892. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":3}]')
  893. }
  894. }
  895. else if(text == "g"){
  896. for(var i = 0; i<keys.length;i++){
  897. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":4}]')
  898. }
  899. }
  900. else if(text == "r"){
  901. for(var i = 0; i<keys.length;i++){
  902. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":2}]')
  903. }
  904. }
  905. else if(text == "y"){
  906. for(var i = 0; i<keys.length;i++){
  907. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":5}]')
  908. }
  909. }
  910. else if(text == "s"){
  911. for(var i = 0; i<keys.length;i++){
  912. SEND('42[26,{"targetID":'+keys[i]+',"targetTeam":0}]')
  913. }
  914. }
  915. return "";
  916. }
  917. else if (chat_val.substring(1,8)=="rounds " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  918. var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '');
  919. if(!isNaN(parseInt(text))){
  920. text = parseInt(text).toString();
  921. SEND('42[21,{"w":'+text+'}]');
  922. RECIEVE('42[27,'+text+']');
  923. }
  924. return "";
  925.  
  926. }
  927. else if (chat_val.substring(1,13)=="defaultmode " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  928. var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '');
  929. if(text == "default"){
  930. defaultmode = "";
  931. displayInChat("Changed default mode to default.","#DA0808","#1EBCC1");
  932. }
  933. else if(text == "arrows"){
  934. defaultmode = "ar";
  935. displayInChat("Changed default mode to arrows.","#DA0808","#1EBCC1");
  936. }
  937. else if(text == "death arrows"){
  938. defaultmode = "ard";
  939. displayInChat("Changed default mode to death arrows.","#DA0808","#1EBCC1");
  940. }
  941. else if(text == "grapple"){
  942. defaultmode = "sp";
  943. displayInChat("Changed default mode to grapple.","#DA0808","#1EBCC1");
  944. }
  945. else if(text == "classic"){
  946. defaultmode = "b";
  947. displayInChat("Changed default mode to classic.","#DA0808","#1EBCC1");
  948.  
  949. }
  950. else{
  951. displayInChat("Default mode options:","#DA0808","#1EBCC1");
  952. displayInChat("default","#DA0808","#1EBCC1");
  953. displayInChat("classic","#DA0808","#1EBCC1");
  954. displayInChat("arrows","#DA0808","#1EBCC1");
  955. displayInChat("death arrows","#DA0808","#1EBCC1");
  956. displayInChat("grapple","#DA0808","#1EBCC1");
  957. }
  958. return "";
  959.  
  960. }
  961. else if (chat_val.substring(1,8)=="recmode"){
  962. if(recmodebool == true){
  963. recmodebool = false;
  964. displayInChat("Recmode is now off.","#DA0808","#1EBCC1");
  965.  
  966. }
  967. else{
  968. recmodebool = true;
  969. displayInChat("Recmode is now on.","#DA0808","#1EBCC1");
  970.  
  971. }
  972.  
  973. return "";
  974.  
  975. }
  976. else if(sandboxon){
  977. if (chat_val.substring(1,11)=="addplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  978. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  979. if(!isNaN(parseInt(text))){
  980. var text2 = parseInt(text);
  981. if(text2>0){
  982. for(var i = 0;i<text2;i++){
  983. RECIEVE('42[4,'+sandboxid+',"0123456789abcdef","'+sandboxid.toString()+'",true,0,1,{"layers":[],"bc":'+Math.floor(Math.random() * 16777215).toString()+'}]');
  984. sandboxplayerids[sandboxid] = sandboxid.toString();
  985. sandboxid+=1;
  986. }
  987.  
  988. }
  989. }
  990. return "";
  991.  
  992. }
  993. else if (chat_val.substring(1,11)=="delplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  994. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  995. if(!isNaN(parseInt(text))){
  996. var text2 = parseInt(text);
  997. if(text2>0){
  998. if(Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden"){
  999. var jsonkeys = Object.keys(sandboxplayerids).reverse();
  1000. for(var i = 0;i<text2 && i<jsonkeys.length;i++){
  1001. RECIEVE('42[5,'+jsonkeys[i]+',0]');
  1002. delete sandboxplayerids[jsonkeys[i]];
  1003. }
  1004. }
  1005. else{
  1006. displayInChat("Cannot delete players while ingame.","#DA0808","#1EBCC1");
  1007. }
  1008.  
  1009. }
  1010. }
  1011. return "";
  1012. }
  1013. else if (chat_val.substring(1,7)=="copyme"){
  1014. if(sandboxcopyme == true){
  1015. displayInChat("Copyme is now off.","#DA0808","#1EBCC1");
  1016. sandboxcopyme = false;
  1017. }
  1018. else{
  1019. displayInChat("Copyme is now on.","#DA0808","#1EBCC1");
  1020. sandboxcopyme = true;
  1021. }
  1022.  
  1023. return "";
  1024. }
  1025. }
  1026. }
  1027. return chat_val;
  1028. };
  1029.  
  1030. scope.flag_manage = function(t){
  1031. var text = t;
  1032.  
  1033. if(rcaps_flag == true){
  1034. text = text.split('');
  1035. for(var i = 0; i<text.length;i++){
  1036. if(Math.floor(Math.random()*2)){
  1037. text[i] = text[i].toUpperCase();
  1038. }
  1039. else{
  1040. text[i] = text[i].toLowerCase();
  1041. }
  1042. }
  1043. text = text.join('');
  1044. }
  1045. if(space_flag == true){
  1046. text = text.split('').join(' ')
  1047. }
  1048. if(number_flag == true){
  1049. text = text.replace(/[t|T][Oo]+/g,"2");
  1050. text = text.replace(/[f|F][o|O][r|R]/g,"4");
  1051. text = text.replace(/[a|A][t|T][e|E]/g,"8");
  1052. text = text.replace(/[e|E]/g,"3");
  1053. text = text.replace(/[a|A]/g,"4");
  1054. text = text.replace(/[o|O]/g,"0");
  1055. text = text.replace(/[s|S]/g,"5");
  1056. text = text.replace(/[i|I|l|L]/g,"1");
  1057. }
  1058. return text;
  1059. };
  1060. Gdocument.getElementById("newbonklobby_chat_input").onkeydown = function(e){
  1061. if(e.keyCode==13){
  1062.  
  1063. var chat_val = Gdocument.getElementById("newbonklobby_chat_input").value;
  1064.  
  1065. if (chat_val!="" && chat_val[0]=="/"){
  1066.  
  1067. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  1068. chat(commandhandle(chat_val));
  1069. }
  1070. else{
  1071. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  1072. chat(flag_manage(chat_val));
  1073. }
  1074.  
  1075. }
  1076. };
  1077. Gdocument.getElementById("ingamechatinputtext").onkeydown = function(e){
  1078. if(e.keyCode==13){
  1079.  
  1080. var chat_val = Gdocument.getElementById("ingamechatinputtext").value;
  1081.  
  1082. if (chat_val!="" && chat_val[0]=="/"){
  1083.  
  1084. Gdocument.getElementById("ingamechatinputtext").value = "";
  1085. chat(commandhandle(chat_val));
  1086. }
  1087. else{
  1088. Gdocument.getElementById("ingamechatinputtext").value = "";
  1089. chat(flag_manage(chat_val));
  1090. }
  1091. }
  1092. };
  1093. scope.Last_message = "";
  1094. scope.Laster_message = "";
  1095. scope.new_message = false;
  1096. scope.changed_chat = false;
  1097. scope.interval = setInterval(timeout123,100);
  1098.  
  1099. scope.hotkeys = function(e){
  1100. if(e.repeat){return;}
  1101. var keycode = e.which || e.keyCode;
  1102. if(e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  1103. if(ishost){
  1104. if(keycode == 69){
  1105. if(Gdocument.getElementById("newbonklobby").style["display"] == "block"){
  1106. Gdocument.getElementById("newbonklobby_editorbutton").click();
  1107. }
  1108. else if(Gdocument.getElementById("mapeditorcontainer").style["display"] == "block"){
  1109. Gdocument.getElementById("mapeditor_close").click();
  1110. }
  1111. e.preventDefault();
  1112.  
  1113. }
  1114. else if(keycode == 84){
  1115. Gdocument.getElementById("newbonklobby_teamsbutton").click();
  1116. e.preventDefault();
  1117. }
  1118. else if(keycode == 77){
  1119. Gdocument.getElementById("newbonklobby_modebutton").click();
  1120. e.preventDefault();
  1121. }
  1122. else if(keycode == 75){
  1123. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  1124. Gdocument.getElementById("pretty_top_exit").click();
  1125. }
  1126. e.preventDefault();
  1127. }
  1128. else if(keycode == 83){
  1129. Gdocument.getElementById("newbonklobby_editorbutton").click();
  1130. Gdocument.getElementById("mapeditor_close").click();
  1131. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  1132. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  1133. e.preventDefault();
  1134. }
  1135. else if(keycode == 68){
  1136. if(stopquickplay == 0){
  1137. quicki++;
  1138. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  1139. }
  1140. e.preventDefault();
  1141. }
  1142. else if(keycode == 65){
  1143. if(stopquickplay == 0){
  1144. quicki--;
  1145. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  1146. }
  1147. e.preventDefault();
  1148. }
  1149. else if(keycode == 81){
  1150. if(stopquickplay == 1){
  1151. stopquickplay = 0;
  1152. quicki = 0;
  1153. displayInChat("Enabled quickplay.","#DA0808","#1EBCC1");
  1154. }
  1155. else{
  1156. stopquickplay = 1;
  1157. quicki = 0;
  1158. displayInChat("Disabled quickplay.","#DA0808","#1EBCC1");
  1159. }
  1160. e.preventDefault();
  1161. }
  1162. else if(keycode == 70){
  1163. if(freejoin == false){
  1164. freejoin = true;
  1165. displayInChat("Freejoin is now on.","#DA0808","#1EBCC1");
  1166.  
  1167. }
  1168. else{
  1169. freejoin = false;
  1170. displayInChat("Freejoin is now off.","#DA0808","#1EBCC1");
  1171. }
  1172. e.preventDefault();
  1173. }
  1174. }
  1175. else{
  1176. if(keycode == 69){
  1177. e.preventDefault();
  1178. }
  1179. else if(keycode == 84){
  1180. e.preventDefault();
  1181. }
  1182. else if(keycode == 77){
  1183. e.preventDefault();
  1184. }
  1185. else if(keycode == 75){
  1186. e.preventDefault();
  1187. }
  1188. else if(keycode == 83){
  1189. e.preventDefault();
  1190. }
  1191. else if(keycode == 68){
  1192. e.preventDefault();
  1193. }
  1194. else if(keycode == 65){
  1195. e.preventDefault();
  1196. }
  1197. else if(keycode == 81){
  1198. e.preventDefault();
  1199. }
  1200. else if(keycode == 70){
  1201. e.preventDefault();
  1202. }
  1203. }
  1204. if(keycode == 76){
  1205. lobby();
  1206. e.preventDefault();
  1207. }
  1208. if(keycode == 67){
  1209. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  1210. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]=="0px"){
  1211. Gdocument.getElementById("ingamechatcontent").style["max-height"]="250px";
  1212. }
  1213. else{
  1214. Gdocument.getElementById("ingamechatcontent").style["max-height"]="0px";
  1215. }
  1216. }
  1217. e.preventDefault();
  1218. }
  1219. }
  1220. };
  1221.  
  1222. Gdocument.onkeydown = hotkeys;
  1223.  
  1224. function timeout123() {
  1225. if(Gdocument.getElementById("gamerenderer").style["visibility"]=="hidden"){
  1226. Gdocument.getElementById("ingamechatcontent").style["max-height"]="250px";
  1227. }
  1228. if(Gdocument.getElementById("sm_connectingContainer").style["visibility"] == "hidden"){
  1229. var chatbox = Gdocument.getElementById("newbonklobby_chat_content");
  1230. while (chatbox.firstChild) {
  1231. chatbox.removeChild(chatbox.firstChild);
  1232. }
  1233. rcaps_flag = false;
  1234. space_flag = false;
  1235. number_flag = false;
  1236. echo_list = [];
  1237. scroll = false;
  1238. stopquickplay = 1;
  1239. freejoin = false;
  1240. defaultmode = "";
  1241. recmodebool = false;
  1242. playerids = {};
  1243. pingids = {};
  1244. ishost = false;
  1245. sandboxplayerids = {};
  1246. sandboxcopyme = false;
  1247. sandboxon = false;
  1248. sandboxid = 1;
  1249. if(chatlog[chatlog.length-1]!="ROOM END"){
  1250. chatlog.push("ROOM END");
  1251. }
  1252. }
  1253. else{
  1254. if(chatlog[chatlog.length-1]=="ROOM END"){
  1255. chatlog.push("ROOM START");
  1256. }
  1257. var pingidkey = Object.keys(pingids);
  1258. var playeridkey = Object.keys(playerids);
  1259. for(var i = 0; i<pingidkey.length;i++){
  1260. if(!playeridkey.includes(pingidkey[i])){
  1261. var pingtext = Gdocument.getElementsByClassName("newbonklobby_playerentry_pingtext");
  1262. var found = [];
  1263. if(Gdocument.getElementById("newbonklobby").style["display"] != "block"){
  1264. mess2 = Gdocument.getElementById("ingamechatinputtext").value;
  1265. Gdocument.getElementById("ingamechatinputtext").value = "";
  1266. Gdocument.getElementById("newbonklobby_editorbutton").click();
  1267. Gdocument.getElementById("mapeditor_close").click();
  1268. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  1269. Gdocument.getElementById("ingamechatinputtext").value = mess2;
  1270.  
  1271. }
  1272. for(var e=0; e<pingtext.length;e++){
  1273. if(pingtext[e].textContent == pingids[pingidkey[i]].toString()+"ms"){
  1274. found.push(pingtext[e].parentElement);
  1275. }
  1276. }
  1277. if(found.length == 1){
  1278. playerids[pingidkey[i]] = found[0].children[1].textContent;
  1279. break;
  1280. }
  1281. }
  1282. }
  1283. pingids = {};
  1284. }
  1285. if(Gdocument.getElementById("ingametextwarning_afk").style["display"]=="table"){
  1286. Gdocument.getElementById("pretty_top_settings").click();
  1287. key2 = Gdocument.getElementById("redefineControls_table").children[0].children[5].children[1].innerHTML.charCodeAt(0);
  1288. Gdocument.getElementById("settings_close").click();
  1289.  
  1290. if(key2>0){
  1291. fire("keydown",{keyCode:key2},Gwindow);
  1292. setTimeout(function(){fire("keyup",{keyCode:key2},Gwindow)},100);
  1293. }
  1294.  
  1295. }
  1296.  
  1297. if(Gdocument.getElementById("newbonklobby").style["display"]=="block"){
  1298. Gdocument.getElementById("ingamechatinputtext").style["visibility"]="hidden";
  1299. }
  1300. else{
  1301. Gdocument.getElementById("ingamechatinputtext").style["visibility"]="visible";
  1302.  
  1303. }
  1304. mode = Gdocument.getElementById("newbonklobby_modetext").textContent;
  1305. var userlist = Gdocument.getElementsByClassName("newbonklobby_playerentry_name");
  1306. users = [];
  1307. for(var i = 0;i<userlist.length;i++){
  1308. users.push(userlist[i].textContent);
  1309. }
  1310. if(Gdocument.getElementsByClassName('newbonklobby_settings_button brownButton brownButton_classic buttonShadow brownButtonDisabled').length == 0){
  1311. ishost = true;
  1312. }
  1313. else{
  1314. ishost = false;
  1315. }
  1316.  
  1317. if(Gdocument.getElementById("pretty_top_name")!=null){
  1318. username = Gdocument.getElementById("pretty_top_name").textContent;
  1319. }
  1320. try{
  1321. Last_message = lastmessage()
  1322. } catch{
  1323. Last_message = "";
  1324. }
  1325. if (Laster_message != Last_message){
  1326. Laster_message = Last_message;
  1327. if(changed_chat==false){
  1328. new_message = true;
  1329. }
  1330. else{
  1331. changed_chat = false;
  1332. }
  1333. }
  1334. if(new_message){
  1335. chatlog.push(Last_message);
  1336. if(freejoin && Last_message.startsWith("* ") && Last_message.endsWith(" has joined the game") && ishost){
  1337.  
  1338. var userjoined = Last_message.substring(2,Last_message.length-20);
  1339.  
  1340. if(Gdocument.getElementById("newbonklobby").style["display"] != "block"){
  1341. mess2 = Gdocument.getElementById("ingamechatinputtext").value;
  1342. Gdocument.getElementById("ingamechatinputtext").value = "";
  1343. Gdocument.getElementById("newbonklobby_editorbutton").click();
  1344. Gdocument.getElementById("mapeditor_close").click();
  1345. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  1346. Gdocument.getElementById("ingamechatinputtext").value = mess2;
  1347.  
  1348. }
  1349. var playing = Gdocument.getElementsByClassName("newbonklobby_playerentry newbonklobby_playerentry_half");
  1350. var inplaying = false;
  1351. for(var i = 0;i<playing.length;i++){
  1352. if(userjoined == playing[i].children[1].textContent){
  1353. inplaying = true;
  1354. break;
  1355. }
  1356. }
  1357.  
  1358. if(playing.length<=2 && inplaying){
  1359. Gdocument.getElementById("newbonklobby_editorbutton").click();
  1360. Gdocument.getElementById("mapeditor_close").click();
  1361. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  1362. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  1363. if(transitioning == true){
  1364. canceled = true;
  1365. }
  1366. }
  1367.  
  1368. }
  1369. var lm = "";
  1370. try{
  1371. lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  1372. if(typeof(lm[0].parentElement.style["parsed"]) == 'undefined'){
  1373. if (lm[0].className == "newbonklobby_chat_msg_colorbox"){
  1374. lm[2].innerHTML = urlify(lm[2].innerHTML);
  1375. Laster_message = lastmessage();
  1376. lm[0].parentElement.style["parsed"] = true;
  1377. }
  1378. if (lm[0].className == "newbonklobby_chat_status"){
  1379. lm[0].innerHTML = urlify(lm[0].innerHTML);
  1380. Laster_message = lastmessage();
  1381. lm[0].parentElement.style["parsed"] = true;
  1382. }
  1383. }
  1384. }
  1385. catch{
  1386. lm = "";
  1387. }
  1388.  
  1389. if(Last_message.indexOf("@"+username)!=-1 && npermissions == 1){
  1390. var n = new Notification(Last_message);
  1391. }
  1392.  
  1393. try{
  1394. lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  1395. if(typeof(lm[0].parentElement.style["parsed"])=='undefined'){
  1396. if(lm[0].className == "ingamechatname"){
  1397. lm[1].innerHTML = urlify(lm[1].innerHTML);
  1398. Laster_message = lastmessage();
  1399. lm[0].parentElement.style["parsed"] = true;
  1400. }
  1401. if(lm[0].className == ""){
  1402. lm[0].innerHTML = urlify(lm[0].innerHTML);
  1403. Laster_message = lastmessage();
  1404. lm[0].parentElement.style["parsed"] = true;
  1405. }
  1406. }
  1407. }
  1408. catch{
  1409. lm = "";
  1410. }
  1411. for(i=0;i<echo_list.length;i++){
  1412. if(Last_message.substring(0,echo_list[i].length+2) == echo_list[i]+": "){
  1413. message = Last_message.substring(echo_list[i].length+2);
  1414. chat(flag_manage(message));
  1415. }
  1416. }
  1417.  
  1418. }
  1419. if (ishost==true && new_message){
  1420. for(i=0;i<banned.length;i++){
  1421. if(Last_message == "* "+banned[i]+" has joined the game "){
  1422. chat("/kick '"+banned[i]+"'");
  1423. }
  1424. }
  1425. }
  1426. if(ishost == true && stopquickplay == 0){
  1427.  
  1428. if(Gdocument.getElementById("ingamewinner").style["visibility"]=="inherit" && stopquickplay == 0 && dontswitch == false){
  1429. quicki++;
  1430. transitioning = true;
  1431. map(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  1432.  
  1433. dontswitch = true;
  1434. setTimeout(function(){Gdocument.getElementById("ingamewinner").style["visibility"]="hidden"; dontswitch = false;},timedelay);
  1435.  
  1436. }
  1437. }
  1438. new_message = false;
  1439. };
  1440. });
  1441.  

QingJ © 2025

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