微信读书网页版功能综合

书籍内容字体修改为苍耳今楷,修改标题等字体,更改背景颜色,更改字体颜色,增减页面宽度,上划隐藏头部侧栏,PC自动滚动

目前為 2021-02-22 提交的版本,檢視 最新版本

// ==UserScript==
// @name         微信读书网页版功能综合
// @version      0.2
// @namespace    http://tampermonkey.net/
// @description  书籍内容字体修改为苍耳今楷,修改标题等字体,更改背景颜色,更改字体颜色,增减页面宽度,上划隐藏头部侧栏,PC自动滚动
// @contributor  Li_MIxdown;hubzy;xvusrmqj;LossJ;JackieZheng;das2m
// @author       SimonDW
// @match        https://weread.qq.com/web/reader/*
// @require      https://cdn.staticfile.org/jquery/3.3.1/jquery.min.js
// @require      http://cdn.staticfile.org/jquery/1.8.3/jquery.min.js
// @grant        GM_log
// @grant        GM_addStyle
// ==/UserScript==

GM_addStyle("*{font-family: TsangerJinKai05 !important;}");
GM_addStyle(".readerTopBar{font-family: SourceHanSerifCN-Bold !important;}");
GM_addStyle(".bookInfo_title{font-family: SourceHanSerifCN-Bold !important;}");
GM_addStyle(".readerTopBar_title_link{font-family: SourceHanSerifCN-Bold; !important; font-weight:bold !important;}");
GM_addStyle(".readerTopBar_title_chapter{font-family: SourceHanSerifCN-Bold !important;}");
GM_addStyle(".wr_whiteTheme .renderTargetContainer .renderTargetContent .wr_readerImage_opacity {background-color: rgba(216,226,200,80) !important;}");
GM_addStyle(".wr_whiteTheme .renderTargetContainer .renderTargetContent .wr_readerBackground_opacity{background-color: rgba(216,226,200,80) !important;}");
GM_addStyle(".wr_whiteTheme .readerContent .app_content{background-color: rgba(216,226,200,80) !important;}");
GM_addStyle(".readerChapterContent{color: rgba(0,0,0,100) !important;}");
GM_addStyle(".readerControls{margin-left: calc(50% - 60px) !important;}");
GM_addStyle(".readerControls{margin-bottom: -28px !important;}");
//GM_addStyle(".readerChapterContent{font-weight: bold !important;}");

$(window).on('load', 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(increse) {
        const step = 100;
        const item1 = document.querySelector(".readerContent .app_content");
        const item2 = document.querySelector('.readerTopBar');
        const currentValue = getCurrentMaxWidth(item1);
        let changedValue;
        if (increse) {
            changedValue = currentValue + step;
        } else {
            changedValue = currentValue - step;
        }
        item1.style['max-width'] = changedValue + 'px';
        item2.style['max-width'] = changedValue + 'px';
        const myEvent = new Event('resize');
        window.dispatchEvent(myEvent)
    }

    // 添加内容
    var butDiy = "<button id='lv-button1' class='readerControls_item widthIncrease' style='color:#6a6c6c;cursor:pointer;'>加宽</button><button id='lv-button2' class='readerControls_item widthDecrease' style='color:#6a6c6c;cursor:pointer;'>减宽</button>"
    $('.readerControls').append(butDiy);
    // 添加监听
    document.getElementById('lv-button1').addEventListener('click', () => changeWidth(true));
    document.getElementById('lv-button2').addEventListener('click', () => changeWidth(false));

    var butDiy2 = "<button id='自动滚动' class='readerControls_item autoScroll' style='color:#6a6c6c;cursor:pointer;'>滚动X1</button><button id='停止滚动' class='readerControls_item autoScrollOff' style='color:#6a6c6c;cursor:pointer;'>停止</button>"
    $('.readerControls').append(butDiy2);
    var num = 1
    $('.autoScroll').click(function () {
        num++;
        autoScroll()
        $('.autoScroll').html('播放X' + num)
    })
    // 滑动屏幕,滚至页面底部
    function autoScroll() {
        var distance = 1;
        var timer = setInterval(() => {
            var totalHeight = document.documentElement.scrollTop;
            var scrollHeight = document.body.scrollHeight;
            window.scrollBy(0, distance);
            totalHeight += distance;
            if (totalHeight >= scrollHeight) {
                clearInterval(timer);
            }
            $('.autoScrollOff').click(function () {
                num = 0
                clearInterval(timer);
            })
        }, 20);
    }

    var windowTop = 0;
    $(window).scroll(function () {
        let scrollS = $(this).scrollTop();
        let selBtn = document.querySelector('.readerTopBar');
        let readerControl = document.querySelector(".readerControls");
        $('.readerControls').mouseenter ( function () {
            $('.readerControls').css('opacity','1')
        })
        $('.readerControls').mouseleave ( function () {
            $('.readerControls').css('opacity','0')
        })
        if (scrollS >= windowTop) {
            // 上划显示
            selBtn.style.opacity = 0;
            windowTop = scrollS;

        } else {
            // 下滑隐藏
            selBtn.style.opacity = 1;          
            windowTop = scrollS;
        }
    });
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址