微信读书护眼模式

给微信读书增加护眼模式

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

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @namespace yunyuyuan
// @name 微信读书护眼模式
// @description 给微信读书增加护眼模式
// @match *://*.weread.qq.com/web/reader/*
// @version 0.0.1.2
// @license MIT
// ==/UserScript==

(function () {
  'use strict';
  const epClass = '.epTheme';
  const epColor = '#f1e5c9';
  const style = document.createElement("style");
  style.innerHTML = `
    html body${epClass},${epClass} .readerContent .app_content, ${epClass} .readerTopBar, ${epClass} .readerControls_fontSize, ${epClass} .readerControls_item, ${epClass} .readerChapterContent_container, ${epClass} .readerChapterContent {
      background: ${epColor} !important;
    }
    ${epClass} .readerFooter_button {
      background-color: ${epColor};
      color: black;
      border: 1px solid black;
    }
  `;
  document.head.appendChild(style);

  const controlContainer = document.querySelector('.readerControls');
  const getInEP = document.createElement('button');
  getInEP.className = 'readerControls_item';
  getInEP.onclick = () => {
    document.body.classList.toggle(epClass.substring(1));
  }
  getInEP.innerHTML = '<span>护眼</span>';
  setTimeout(() => {
    controlContainer.appendChild(getInEP);
  },1000)
})()