Poe.com 美化

用来美化 poe.com

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Poe.com 美化
// @namespace    http://tampermonkey.net/
// @version      0.1.2
// @description  用来美化 poe.com
// @author       poeticalcode
// @match        https://poe.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=poe.com
// @grant        GM_addStyle
// @license GNU GPLv3
// ==/UserScript==

(function () {
  'use strict';
  GM_addStyle(`
        aside{
          min-width: unset !important;
        }
        section{
          max-width: unset !important;
          width: unset !important;
        }
        .Message_botMessageBubble__CPGMI{
          background-color: transparent;
        }
        .ChatPageMainFooter_footer__Hm4Rt{
          padding: 8px 18px;
        }
        .ChatMessageInputView_growWrap__mX_pX:after, .ChatMessageInputView_growWrap__mX_pX>.ChatMessageInputView_textInput__Aervw{
          border-radius:10px;
        }
    `);
    const link = document.createElement('link');
    link.rel = 'stylesheet';
    link.href = 'https://cdn.jsdelivr.net/gh/highlightjs/[email protected]/build/styles/default.min.css';
    document.head.appendChild(link);
    link.onload = () => {
      const script = document.createElement('script');
      script.src = 'https://cdn.jsdelivr.net/gh/highlightjs/[email protected]/build/highlight.min.js';
      document.body.appendChild(script);
      script.onload = () => {
        const highlightCode = () => {
          document.querySelectorAll('pre code').forEach((el) => {
            !el.classList.contains('hljs') && hljs.highlightElement(el);
          });
        }
        highlightCode();
        let flag = false;
        let clearId = null;
        document.querySelector(".InfiniteScroll_scrollContainerReverse__3F2Dd").addEventListener('scroll', () => {
          clearTimeout(clearId)
          clearId = setTimeout(() => {
            highlightCode()
          }, 500);
        });

        let btn = document.createElement("button")
        btn.innerText = "折叠";
        btn.addEventListener("click", () => {
          flag = !flag
          let aside = document.querySelector(".PageWithSidebarLayout_leftSidebar__Y6XQo")
          aside.style.display = flag ? "none" : "unset"
        })
        let header = document.querySelector(".PageWithSidebarNavbar_navbar__LpjAK")
        header.firstChild.before(btn);
      }
    }
})();