Arras.io Chat GUI Template

Allows you to show words above your name in Arras.io

目前为 2023-11-21 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Arras.io Chat GUI Template
  3. // @description Allows you to show words above your name in Arras.io
  4. // @namespace https://google.com/
  5. // @version 1.0.0
  6. // @author ruubei
  7. // @match *://arras.io/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. let chatOpen = false;
  13. let chatInput;
  14.  
  15. const openChat = () => {
  16. if (!chatOpen) {
  17. chatInput = document.createElement('input');
  18. chatInput.type = 'text';
  19. chatInput.style.position = 'fixed';
  20. chatInput.style.bottom = '10px';
  21. chatInput.style.left = '10px';
  22. chatInput.style.width = '200px';
  23. chatInput.style.padding = '5px';
  24. chatInput.style.border = '1px solid black';
  25. chatInput.addEventListener('keydown', handleChatInput);
  26. document.body.appendChild(chatInput);
  27. chatInput.focus();
  28. chatOpen = true;
  29. }
  30. };
  31.  
  32. const closeChat = () => {
  33. if (chatOpen) {
  34. document.body.removeChild(chatInput);
  35. chatOpen = false;
  36. }
  37. };
  38.  
  39. const handleChatInput = (event) => {
  40. if (event.key === 'p') {
  41. const message = chatInput.value.trim();
  42. if (message !== '') {
  43. // Replace 'YOUR NAME' with your actual in-game name
  44. const name = 'YOUR NAME';
  45. const chatMessage = `^${name}^: ${message}`;
  46. chatInput.value = '';
  47. // Replace 'Socket' with the actual variable name for your socket connection
  48. // For example, if your socket connection variable is '123', replace 'Socket' with '123'
  49. // You may need to inspect the Arras.io page to find the correct variable name
  50. // Send the chat message to the server
  51. Socket.send('m', chatMessage);
  52. }
  53. closeChat();
  54. }
  55. };
  56.  
  57. // Listen for the 'p' key press to open/close the chat GUI
  58. window.addEventListener('keydown', (event) => {
  59. if (event.key === 'p') {
  60. if (!chatOpen) {
  61. openChat();
  62. } else {
  63. closeChat();
  64. }
  65. }
  66. });
  67. })();