Chat Box Section

Creates a separated section for the chat box

当前为 2025-01-08 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 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.4.3
// @author      Freaky Fingers
// @description Creates a separated section for the chat box
// ==/UserScript==
//Startup Sequence Variables
let smmoChat = null

document.querySelectorAll("[x-init]").forEach(xinit => {
  if (xinit.outerHTML.includes("chat:false,chatSrc:'about:blank;'")){
    smmoChat = xinit
  }
})

if (!smmoChat) return;
smmoChat.style = "position: fixed; height: 100%; margin-top: 4rem";

//Script Variables
const chatWidth = 20
const gameParent = document.body.querySelector('.h-screen.flex.overflow-hidden.bg-gray-100')
const newButton = document.createElement("button")
const newHTML = document.createElement("chatArea")
const chatBox = document.getElementById("chatBox")
const chatButton = document.getElementById("show_hide_chat_btn")

chatBox.style.cssText = `position: relative; height: calc(100% - 4rem); width: ${chatWidth}vw; padding: 0rem`;
chatButton.style.display = 'none';

//Functions
function show_hide_chat() {
  newHTML.style.display = newHTML.style.display === "none" ? "block" : "none";
  chatButton.click();
}
//Main Script
newButton.id = "newChatButton";
newButton.innerHTML = "Show/Hide Chat";
newButton.style.cssText = "position: fixed; padding: 0.5rem; background-color: #000; border: 2px solid #C0C0C0; right: 5rem; top: 0.6rem; border-radius: 0.5rem; color: #C0C0C0; z-index: 30";
newButton.onmousedown = show_hide_chat;
newHTML.id = "chatSection";
newHTML.style.cssText = `background-color: rgb(17 17 17 / var(--tw-bg-opacity)); height: 94vh; width: ${chatWidth}vw; float: right; position: sticky; z-index: 1; display: none`;

document.onkeydown = function (event) {
  if (event.code === 'NumpadEnter') {
    show_hide_chat()
  }
}

if(docCookies.getItem('show_chat') === 'true') {
  newHTML.style.display = "block"
}

gameParent.style.cssText = `z-index: 2; position: relative`;

document.getElementById("app").insertAdjacentElement(`afterbegin`, newHTML);
document.querySelector(".web-app-container").insertAdjacentElement(`afterbegin`, newButton);
newHTML.appendChild(smmoChat);