Greasy Fork

微信读书阅读助手

现有功能:1.宽屏阅读

目前为 2021-01-27 提交的版本。查看 最新版本

// ==UserScript==
// @name         微信读书阅读助手
// @namespace   Violentmonkey Scripts
// @version      1.1
// @description  现有功能:1.宽屏阅读
// @author       mefengl
// @match        https://weread.qq.com/web/reader/*
// @grant        GM_log
// @grant        GM_addStyle
// ==/UserScript==

(function () {
    'use strict';
    // 基础方法
    function getCurrentMaxWidth(element) {
        let currentValue = window.getComputedStyle(element).maxWidth;
        currentValue = currentValue.substring(0, currentValue.indexOf('px'));
        currentValue = parseInt(currentValue);
        return currentValue;
    }
    function changeWidth() {
      
      
        // 修改宽度只需调节以下参数500即可,0为不修改
        const step = 500;
      
      
        const item = document.querySelector(".readerContent .app_content");
        const currentValue = getCurrentMaxWidth(item);
        let changedValue;
        changedValue = currentValue + step;
        item.style['max-width'] = changedValue + 'px';
        const myEvent = new Event('resize');
        window.dispatchEvent(myEvent)
    }
    // 增加宽度
    changeWidth()
})();