// ==UserScript== // @name 笔趣阁外观优化 // @namespace https://gitee.com/linhq1999/OhMyScript // @version 1.2 // @description 专注阅读 // @author LinHQ // @match https://www.shuquge.com/txt/* // @inject-into content // @downloadURL none // ==/UserScript== 'use strict'; function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } var lineHeight = 1.3; (function () { var oldCfg = localStorage.getItem("bqg_cfg"); var cfg = oldCfg === null ? { "fontSize": 16, "lineHeight": 16 * lineHeight } : 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.minWidth = '600px'; 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 = "楷体"; textWin.style.fontSize = cfg.fontSize + "px"; textWin.style.lineHeight = cfg.lineHeight + "px"; document.body.onkeydown = function (ev) { switch (ev.key) { case "-": cfg.fontSize -= 2; textWin.style.fontSize = "".concat(cfg.fontSize, "px"); break; case "=": cfg.fontSize += 2; textWin.style.fontSize = "".concat(cfg.fontSize, "px"); break; case "j": window.scrollBy({ top: window.innerHeight - cfg.lineHeight }); break; case "k": window.scrollBy({ top: window.innerHeight * -1 + cfg.lineHeight }); break; case "h": var prevs = document.querySelectorAll("a"); var _iterator = _createForOfIteratorHelper(prevs), _step; try { for (_iterator.s(); !(_step = _iterator.n()).done;) { var prev = _step.value; if (prev.textContent === "上一章") { prev.click(); break; } } } catch (err) { _iterator.e(err); } finally { _iterator.f(); } break; case "l": var nexts = document.querySelectorAll("a"); var _iterator2 = _createForOfIteratorHelper(nexts), _step2; try { for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { var next = _step2.value; if (next.textContent === "下一章") { next.click(); break; } } } catch (err) { _iterator2.e(err); } finally { _iterator2.f(); } break; default: break; } cfg.lineHeight = cfg.fontSize * lineHeight; textWin.style.lineHeight = "".concat(cfg.lineHeight, "px"); localStorage.setItem("bqg_cfg", JSON.stringify(cfg)); }; if (textWin !== null || textWin !== undefined) ob.disconnect(); }).observe(document.body, { subtree: true, childList: true }); })();