shumin-微信读书

自用特化版本,原版参见https://greasyfork.org/zh-CN/scripts/421994

질문, 리뷰하거나, 이 스크립트를 신고하세요.
// ==UserScript==
// @name         shumin-微信读书
// @version      1.0.3
// @namespace    http://tampermonkey.net/
// @description  自用特化版本,原版参见https://greasyfork.org/zh-CN/scripts/421994
// @contributor  Li_MIxdown;hubzy;xvusrmqj;LossJ;JackieZheng;das2m;harmonyLife;SimonDW
// @author       qianjunlang
// @match        https://weread.qq.com/web/reader/*
// @require      https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js
// @icon         https://weread.qq.com/favicon.ico
// @grant        GM_log
// @grant        GM_addStyle
// @grant        unsafeWindow
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_openInTab
// @grant        GM_download
// @grant        GM_setClipboard
// @grant        GM_notification
// ==/UserScript==
'use strict';

/*
GM_addStyle('*{font-family: FangSong !important;}');
//GM_addStyle(".readerChapterContent{color: #FeFeFe;}");
var style_tag = document.createElement('style');
style_tag.innerHTML = `
    .bookInfo_title, .readerHeaderButton, .readerFooter_button, .readerTopBar, .readerTopBar_title_link, .readerTopBar_title_chapter, .actionItem.addShelfItem {
        font-family: Microsoft YaHei UI !important;
    }
`;
document.head.appendChild(style_tag);
*/

//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

$(window).on('load', async function () {

    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 item1 = document.querySelector(".readerContent .app_content");
        const item2 = document.querySelector('.readerTopBar');
        const currentValue = getCurrentMaxWidth(item1);

        item1.style['max-width'] = item2.style['max-width'] = parseInt( currentValue + 100*increse ) + 'px';

        const myEvent = new Event('resize');
        window.dispatchEvent(myEvent)
    }

    $(".readerControls_item.download").css("display", "none");    // 删除下载APP按钮
    $(".readerControls_item.isNormalReader").css("display", "none");    // 删除双栏
    $(".readerControls_item.wetype").css("display", "none");  // 删除微信输入

    var butDiy = `<button id='lv-button1' class='readerControls_item widthIncrease' style='color:#ffffff;cursor:pointer;'>←→</button><button id='lv-button2' class='readerControls_item widthDecrease' style='color:#ffffff;cursor:pointer;'>→←</button>`;
    $('.readerControls').append(butDiy);
    document.getElementById('lv-button1').addEventListener('click', () => changeWidth(+1));
    document.getElementById('lv-button2').addEventListener('click', () => changeWidth(-1));
    changeWidth(5); // 默认加宽到最大

    let rightBorder=14, rightOffset=-10;
    $('.readerControls').css({
        "position": "fixed",
        "transition": "right 0.05s ease-in 0s",
        "border-right": rightBorder +"px solid transparent",
        "left": "auto", 'opacity':'0.3', "right": rightOffset-rightBorder +"px",
    });
    $('.readerControls').hover(
        () => { $('.readerControls').css({'opacity':'1', "right": 0+"px",}) },
        () => { $('.readerControls').css({'opacity':'0.3', "right": rightOffset-rightBorder +"px",}) },
    );//等于.mouseleave().mouseenter()

//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

    document.querySelector('.readerTopBar').style.transition = "top 0.1s ease-in 0s";

    var windowTop = 0;
    $(window).scroll( () => {
        let scrollS = $(this).scrollTop();

        document.querySelector('.readerTopBar').style.top = ( scrollS>=windowTop ? -70 : 0 ) +"px";

        windowTop = scrollS;
    });

})();