Keylol_Mobile_Tweaker

移除一些元素

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name:zh-CN      Keylol_手机版优化
// @name            Keylol_Mobile_Tweaker
// @namespace       https://blog.chrxw.com
// @supportURL      https://blog.chrxw.com/scripts.html
// @contributionURL https://afdian.com/@chr233
// @version         1.0
// @description     移除一些元素
// @description:zh-CN  移除一些元素
// @author          Chr_
// @match           https://keylol.com/*
// @license         AGPL-3.0
// @icon            https://blog.chrxw.com/favicon.ico
// ==/UserScript==


(() => {
  "use strict";

  const isPc = !!document.querySelector('a[href="forum.php?mobile=yes"]')

  if (!isPc) {
    const replay = document.getElementById('fastpostform');
    if (replay) {
      replay.style.display = "none";
    }
  }

  tweakerBtns();

  const observer = new MutationObserver((mutations) => {
    mutations.forEach((mutation) => {
      if (mutation.addedNodes.length > 0) {
        tweakerBtns();
      }
    });
  });

  observer.observe(document.body, { childList: true, subtree: true });

  function tweakerBtns() {
    const rateBtns = document.querySelectorAll('div[id^="dppf"]>a');
    if (rateBtns.length > 0) {
      for (let btn of rateBtns) {
        const span = document.createElement('span');
        span.innerHTML = btn.innerHTML;
        span.style.margin = "0 3px";
        btn.parentNode.replaceChild(span, btn);
      }
    }

    const ratePcBtns = document.querySelectorAll('div.pob.cl>em>a');
    if (ratePcBtns.length > 0) {
      for (let btn of ratePcBtns) {
        const span = document.createElement('span');
        span.innerHTML = btn.innerHTML;
        span.className = btn.className;
        span.style.padding = "5px 10px 5px 25px";
        btn.parentNode.replaceChild(span, btn);
      }
    }
  }
})();