add weread inject js

This commit is contained in:
YuanHui
2025-12-18 12:23:54 +08:00
parent cff1b6a6e4
commit fa5ad535da
2 changed files with 59 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
// --- 1. 屏蔽无限 debugger (防止控制台卡死) ---
(function() {
var _constructor = window.Function.prototype.constructor;
window.Function.prototype.constructor = function(str) {
if (str === 'debugger') return function() {};
return _constructor.apply(this, arguments);
};
})();
// --- 2. 解除右键拦截 ---
window.addEventListener('contextmenu', (e) => e.stopPropagation(), true);
// --- 3. 自动隐藏/显示顶栏和侧边栏 (原生 JS 实现) ---
(function() {
let windowTop = 0;
// 等待页面加载完成后再执行逻辑
window.addEventListener('load', () => {
window.addEventListener('scroll', () => {
const scrollS = window.scrollY || document.documentElement.scrollTop;
const topBar = document.querySelector('.readerTopBar');
const controls = document.querySelector('.readerControls');
if (!topBar || !controls) return; // 如果还没加载出这些元素则跳过
if (scrollS >= windowTop + 100) {
// 下滑隐藏:设置透明度和位移(比 fadeIn/Out 性能更好)
topBar.style.opacity = '0';
topBar.style.transition = 'opacity 0.3s ease';
controls.style.opacity = '0';
controls.style.transition = 'opacity 0.3s ease';
windowTop = scrollS;
}
else if (scrollS < windowTop) {
// 上划显示
topBar.style.opacity = '1';
controls.style.opacity = '1';
windowTop = scrollS;
}
});
});
console.log("微信读书增强脚本:隐藏顶栏/侧边栏功能已就绪");
})();

View File

@@ -1,5 +1,21 @@
window.addEventListener("DOMContentLoaded", (_event) => {
// Customize and transform existing functions
const wereadCSS = `
.readerContent .app_content, .readerTopBar {
max-width: 100% !important;
}
.readerControls {
align-items: flex-end !important;
margin-left: 45.5% !important;
}
.readerBottomBar_content {
display: none !important;
}
`;
const wereadStyleElement = document.createElement("style");
wereadStyleElement.innerHTML = wereadCSS;
document.head.appendChild(wereadStyleElement);
const contentCSS = `
#page #footer-wrapper,
.drawing-board .toolbar .toolbar-action,