// ==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
// @downloadURL none
// ==/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 = ""
$('.readerControls').append(butDiy);
// 添加监听
document.getElementById('lv-button1').addEventListener('click', () => changeWidth(true));
document.getElementById('lv-button2').addEventListener('click', () => changeWidth(false));
var butDiy2 = ""
$('.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;
}
});
})();