Chat Box Section

Creates a separated section for the chat box

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

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        Chat Box Section
// @namespace   Violentmonkey Scripts
// @match       https://web.simple-mmo.com/*
// @grant       none
// @license     GPL-v3
// @version     1.2.3
// @author      Freaky Fingers
// @description Creates a separated section for the chat box
// ==/UserScript==
//Config Variables
let chatWidth = 20
let chatHeight = 94

//Script Variables
let newHTML = document.createElement("chatArea")
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

function hideChat(chat, button) {
  if (button.includes("display: none") == false)
  chat.style.display = "none";
  console.log("success");
}

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

if (smmoChat !== null){

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

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

  smmoChat.style = "position: fixed; height: 100%";
  chatBox.style = `position: relative; height: ${chatHeight}%; width: ${chatWidth}vw; padding: 0rem`;
  newHTML.style = `background-color: #0000; height: ${chatHeight}vh; width: ${chatWidth}vw; float: right; position: sticky; z-index: 0`; //Style new div
  chatButton.style = `margin-bottom: 95vh; margin-right: 12vw`;

  document.getElementById("app").insertBefore(newHTML, document.getElementsByClassName("h-screen flex overflow-hidden bg-gray-100")[0]); //Insert new div into page at correct position
  document.getElementById("chatHeader").style = `background-color: rgb(17 17 17 / var(--tw-bg-opacity)); height: ${Math.max((100 - chatHeight), 0)}vh; z-index: 20`;
  document.getElementById("chatSection").appendChild(smmoChat); //Add the chat to new div

}