微信读书

WeReadSytle

目前為 2023-07-23 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name    微信读书
// @icon    https://weread.qq.com/favicon.ico
// @namespace    https://greasyfork.org/users/878514
// @version    20230723
// @description    WeReadSytle
// @author    Velens
// @match    https://weread.qq.com/web/reader/*
// @require    https://code.jquery.com/jquery-3.6.0.min.js
// @license    MIT
// @grant    GM_addStyle
// @grant    GM_registerMenuCommand
// @grant    GM_setValue
// @grant    GM_getValue
// ==/UserScript==


    //正文
    //GM_addStyle(".readerContent .app_content {max-width: 100%; !important;}");
    //GM_addStyle(".wr_whiteTheme .readerContent .app_content {background-color: #C7EDCC; !important;}");
    //GM_addStyle(".wr_whiteTheme .readerChapterContent {color: #444444; !important;}");
    //导航栏
    //GM_addStyle(".readerTopBar {max-width: 100%; !important;}");
    //GM_addStyle(".wr_whiteTheme .readerTopBar {background-color: #C7EDCC; !important;}");
    //滚动条
    //GM_addStyle("body::-webkit-scrollbar {display: none; !important;}");
    //浮动菜单
    //GM_addStyle(".readerControls {margin-left: 46%; !important;}");
    //GM_addStyle(".readerControls {align-items: flex-end; !important;}");


const widths = [{width:"100%",align_items:"flex-end",margin_left:"45.5%"},{width:"80%",align_items:"center",margin_left:"41.5%"},{width:"默认",align_items:"flex-start",margin_left:""}];
var numw,iw = GM_getValue("numw",0);
GM_registerMenuCommand("宽度:" + widths[iw].width,width)
GM_addStyle(`.readerContent .app_content, .readerTopBar {max-width: ${widths[iw].width}; !important;}`);
GM_addStyle(`.readerControls {align-items: ${widths[iw].align_items}; !important;}`);
GM_addStyle(`.readerControls {margin-left: ${widths[iw].margin_left}; !important;}`);
function width(){
    if(iw < widths.length-1){iw++;}
    else{iw = 0;}
    GM_setValue("numw",iw);
    GM_addStyle(`.readerContent .app_content, .readerTopBar {max-width: ${widths[iw].width}; !important;}`);
    location.reload();
};


const scrollbars = [{titles:"滚动条:隐藏",displays:"none"},{titles:"滚动条:显示",displays:"auto"}];
var nums,is = GM_getValue("nums",0);
GM_registerMenuCommand(scrollbars[is].titles,scrollbar);
GM_addStyle(`body::-webkit-scrollbar {display: ${scrollbars[is].displays}; !important;}`);
function scrollbar(){
    if(is < scrollbars.length-1){is++;}
    else{is = 0;}
    GM_setValue("nums",is);
    GM_addStyle(`body::-webkit-scrollbar {display: ${scrollbars[is].displays}; !important;}`);
    location.reload();
};


const colors = [{titlec:"豆沙绿",RGB:"#C7EDCC"},{titlec:"杏仁黄",RGB:"#FAF9DE"},{titlec:"秋叶褐",RGB:"#FFF2E2"},{titlec:"胭脂红",RGB:"#FDE6E0"},{titlec:"海天蓝",RGB:"#DCE2F1"},{titlec:"葛巾紫",RGB:"#E9EBFE"},{titlec:"极光灰",RGB:"#EAEAEF"},{titlec:"青草绿",RGB:"#E3EDCD"},{titlec:"银河白",RGB:"#FFFFFF"}];
var numc,ic = GM_getValue("numc",0);
GM_registerMenuCommand("背景色:" + colors[ic].titlec,color);
GM_addStyle(`.wr_whiteTheme .readerContent .app_content, .wr_whiteTheme .readerTopBar, .wr_whiteTheme .readerFooter_button, .wr_whiteTheme .readerControls_fontSize, .wr_whiteTheme .readerControls_item {background-color: ${colors[ic].RGB}; !important;}`);
function color(){
    if(ic < colors.length-1){ic++;}
    else{ic = 0;}
    GM_setValue("numc",ic);
    GM_addStyle(`.wr_whiteTheme .readerContent .app_content, .wr_whiteTheme .readerTopBar {background-color: ${colors[ic].RGB}; !important;}`);
    location.reload();
};


const scrollTops = ["沉浸式阅读:开启","沉浸式阅读:关闭"];
let flagt = GM_getValue("flagt",true);
function scrollTop(){
    flagt = !flagt;
    GM_setValue("flagt",flagt);
    location.reload();
}
if(flagt){
    GM_registerMenuCommand(scrollTops[0],scrollTop);
    (function (){
        /* globals jQuery, $, waitForKeyElements */
        $(window).scroll(function(){
            var scroll = $(this).scrollTop();
            var paddingtop = $(".navBarOffset").css("padding-top");
            var lineheight = $(".readerHeaderButton").css("line-height");
            var scrollTop = parseFloat(paddingtop) + parseFloat(lineheight);
            var readerTopBar = document.getElementsByClassName("readerTopBar")[0];
            var readerControls = document.getElementsByClassName("readerControls")[0];
            if(scroll <= scrollTop){
                // 顶部显示
                readerTopBar.style.display = "flex";
                readerControls.style.display = "flex";
            }else{
                // 下滑隐藏
                readerTopBar.style.display = "none";
                readerControls.style.display = "none";
            }
        });
    })();
}
else{
    GM_registerMenuCommand(scrollTops[1],scrollTop);
}