Chat Box Section

Creates a separated section for the chat box

目前為 2024-12-02 提交的版本,檢視 最新版本

// ==UserScript==
// @name        Chat Box Section
// @namespace   Violentmonkey Scripts
// @include       https://web.simple-mmo.com/travel*
// @exclude       https://web.simple-mmo.com/travel/party*
// @grant       none
// @license     GPL-v3
// @version     1.2.0
// @author      Freaky Fingers
// @description Creates a separated section for the chat box
// ==/UserScript==
let newHTML = document.createElement("section")
let allxinits = document.querySelectorAll("[x-init]")
let show_hide_chat_btns = document.querySelectorAll("[x-show]")
let smmoChat = null
let chatBox = document.getElementById("chatBox")
let chatButton = document.getElementById("show_hide_chat_btn")
let buttonAttrib = null

allxinits.forEach(xinit => {
  if (xinit.outerHTML.includes("chat:false,chatSrc:'about:blank;'")){
    console.log("success");
    smmoChat = xinit
  }
})

if (smmoChat !== null){

newHTML.innerHTML = `
  <section id="chatSection"></section>
`;  //create new div

setTimeout(function() {
  show_hide_chat_btns.forEach(btn => {
    if (btn.outerHTML.includes("!chat")){
      buttonAttrib = btn
    }
  })
  console.log(buttonAttrib);
  if (buttonAttrib.outerHTML.includes("display: none") !== true) {
    chatButton.click();
  }
  chatButton.style.display = "none"
}, 1000);

newHTML.style = "background-color: #0000; height: 100vh; width: 20vw; float: right; position: sticky; z-index: 0"; //Style new div
document.getElementById("app").insertBefore(newHTML, document.getElementsByClassName("h-screen flex overflow-hidden bg-gray-100")[0]); //Insert new div into page at correct position

smmoChat.style = "position: fixed; height: 100vh; width: 20vw";
chatBox.style = "position: relative; height: 100%; width: 20vw; padding: 0rem";

newHTML.appendChild(smmoChat); //Add the chat to new div

}