Chat Box Section

Creates a separated section for the chat box

当前为 2024-12-01 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Chat Box Section
  3. // @namespace Violentmonkey Scripts
  4. // @match https://web.simple-mmo.com/travel*
  5. // @grant none
  6. // @license GPL-v3
  7. // @version 1.0.0
  8. // @author Freaky Fingers
  9. // @description Creates a separated section for the chat box
  10. // ==/UserScript==
  11. let newHTML = document.createElement("section")
  12. let smmoChat = document.querySelectorAll("[x-init]")[3]
  13. let chatBox = document.getElementById("chatBox")
  14. let chatButton = document.getElementById("show_hide_chat_btn")
  15.  
  16. newHTML.innerHTML = `
  17. <section id="chatSection"></section>
  18. `; //create new div
  19.  
  20. setTimeout(function() {
  21. let buttonAttrib = document.querySelectorAll("[x-show]")[1].getAttribute("style")
  22. if (buttonAttrib !== null) {
  23. chatButton.click();
  24. }
  25. chatButton.style.display = "none"
  26. }, 1000); //Automatically show the chat and then hide the show/hide chat button
  27.  
  28. newHTML.style = "background-color: #0000; height: 100vh; width: 20vw; float: right; position: sticky; z-index: 0"; //Style new div
  29. document.getElementById("app").insertBefore(newHTML, document.getElementsByClassName("h-screen flex overflow-hidden bg-gray-100")[0]); //Insert new div into page at correct position
  30.  
  31. smmoChat.style = "position: fixed; height: 100vh; width: 20vw";
  32. chatBox.style = "position: relative; height: 100%; width: 20vw; padding: 0rem";
  33.  
  34. newHTML.appendChild(smmoChat); //Add the chat to new div