Bonk Commands

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

当前为 2022-11-01 提交的版本,查看 最新版本

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

QingJ © 2025

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