Greasy Fork

Greasy Fork is available in English.

笔趣阁外观优化

排除干扰专注阅读

目前为 2021-10-30 提交的版本,查看 最新版本

// ==UserScript==
// @name         笔趣阁外观优化
// @namespace    https://gitee.com/linhq1999/OhMyScript
// @version      1.0
// @description  排除干扰专注阅读
// @author       LinHQ
// @match        https://www.shuquge.com/*
// @grant        GM_addStyle
// @inject-into content
// @license MIT
// ==/UserScript==
'use strict';

(function () {
  var oldCfg = localStorage.getItem("bqg_cfg");
  var cfg = oldCfg === null ? {
    "fontSize": 1.2,
    "lineHeight": 1.5
  } : JSON.parse(oldCfg);
  new MutationObserver(function (_, ob) {
    var _document$querySelect, _document$querySelect2, _document$querySelect3;

    (_document$querySelect = document.querySelector("div.header")) === null || _document$querySelect === void 0 ? void 0 : _document$querySelect.remove();
    (_document$querySelect2 = document.querySelector("div.link")) === null || _document$querySelect2 === void 0 ? void 0 : _document$querySelect2.remove();
    (_document$querySelect3 = document.querySelector("div.nav")) === null || _document$querySelect3 === void 0 ? void 0 : _document$querySelect3.remove();
    document.body.style.backgroundColor = '#EAEAEF';
    var mainWin = document.querySelector("div.book.reader");
    mainWin.style.width = '50%';
    mainWin.style.border = '2px double gray';
    var title = mainWin.getElementsByTagName("h1")[0];
    title.style.color = "black";
    title.style.fontFamily = "楷体";
    var textWin = document.querySelector("#content");
    textWin.style.fontFamily = 'kaiti';
    textWin.style.fontSize = cfg.fontSize + "rem";
    textWin.style.lineHeight = cfg.lineHeight + "rem";

    document.body.onkeydown = function (ev) {
      if (ev.key === "-") {
        cfg.fontSize -= 0.1;
        textWin.style.fontSize = "".concat(cfg.fontSize, "rem");
      } else {
        cfg.fontSize += 0.1;
        textWin.style.fontSize = "".concat(cfg.fontSize, "rem");
      }

      cfg.lineHeight = cfg.fontSize + 0.3;
      textWin.style.lineHeight = "".concat(cfg.lineHeight, "rem");
      localStorage.setItem("bqg_cfg", JSON.stringify(cfg));
    };

    if (textWin !== null || textWin !== undefined) ob.disconnect();
  }).observe(document.body, {
    subtree: true,
    childList: true
  });
})();