您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
实现微信读书自动翻书功能
当前为
// ==UserScript== // @name 微信懒人翻书 // @namespace http://tampermonkey.net/ // @version 0.5 // @description 实现微信读书自动翻书功能 // @author yuankaiyu // @match https://weread.qq.com/* // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== // @grant none // @license MIT // ==/UserScript== const primaryColor = "linear-gradient(45deg, rgb(44, 106, 255),rgb(48, 173, 254))"; const createBtn = (innerText, id, style, fn) => { const btn = document.createElement("button"); btn.innerText = innerText; btn.id = id; btn.style.marginRight = "5px"; btn.style.cursor = "pointer"; btn.style.color = "white"; btn.style.fontSize = "24px"; btn.style.backgroundColor = "transparent"; btn.style.border = "none"; btn.addEventListener("click", function (event) { fn(); }); return btn; }; const minus = (speedEle) => { let speed = +speedEle.innerText; speed -= 0.1; speed = Math.round(speed * 100) / 100; speedEle.innerText = speed; }; const add = (speedEle) => { let speed = +speedEle.innerText; speed += 0.1; speed = Math.round(speed * 100) / 100; speedEle.innerText = speed; }; (function () { "use strict"; const box = document.createElement("div"); const divEle = document.createElement("div"); var textNode = document.createTextNode("懒人翻书"); divEle.appendChild(textNode); box.style.position = "fixed"; box.style.top = "24px"; box.style.left = "100px"; box.style.fontSize = "18px"; box.style.background = primaryColor; box.style.padding = "10px"; box.style.borderRadius = "5px"; box.style.boxShadow = "4px 4px 20px rgba(0, 0, 0, 0.4)"; box.style.cursor = "grab"; divEle.addEventListener("click", function (event) { scrollAuto(); }); divEle.onclick = "scrollAuto()"; box.appendChild(divEle); const speedController = document.createElement("div"); speedController.id = "speedController"; const speedEle = document.createElement("span"); speedEle.id = "speed"; speedEle.innerText = "0.5"; const minusBtn = createBtn("-", "minusBtn", "", () => minus(speedEle)); const addBtn = createBtn("+", "addBtn", "", () => add(speedEle)); speedController.appendChild(minusBtn); speedController.appendChild(speedEle); speedController.appendChild(addBtn); box.appendChild(speedController); const hint1 = document.createElement("div"); hint1.innerText = "Min 0.1"; hint1.style.cursor = "pointer"; hint1.addEventListener("click", function (event) { speedEle.innerText = 0.1; }); const hint2 = document.createElement("div"); hint2.innerText = "Max 2"; hint2.style.cursor = "pointer"; hint2.addEventListener("click", function (event) { speedEle.innerText = 2; }); box.appendChild(hint1); box.appendChild(hint2); document.body.appendChild(box); let animationFrameId; let scrollPosition = 0; const scrollSpeed = 20; // 你可以调整这个值来改变滚动速度 // 为元素添加keydown事件监听器 document.addEventListener("keydown", function (event) { // 检查按下的键是否是空格键 if (event.key === " " || event.keyCode === 32) { event.preventDefault(); scrollAuto(); } }); function scrollAuto() { const scrollDistance = +speedEle.innerText; // 每次滚动的距离 const renderTargetContainer = document.querySelector( ".renderTargetContainer" ); scrollPosition = window.scrollY; function smoothScroll() { cancelAnimationFrame(animationFrameId); scrollPosition += scrollDistance; window.scrollTo(0, scrollPosition); // 当你想要停止滚动时,清除这个间隔 if (isScrolledToBottom()) { console.log("滚动到底部了"); cancelAnimationFrame(animationFrameId); return; } animationFrameId = requestAnimationFrame(smoothScroll); } // 空格键被按下,执行相应的操作 if (animationFrameId) { console.log("清除"); animationFrameId = cancelAnimationFrame(animationFrameId); } else { // 在这里你可以添加你想要执行的代码 animationFrameId = requestAnimationFrame(smoothScroll); } } function isScrolledToBottom() { return window.scrollY + window.innerHeight >= document.body.scrollHeight; } // 键盘按下加减键 document.addEventListener("keydown", function (event) { // 检查按下的键的键码 if (event.key === "+") { console.log("加号键被按下"); add(); // 这里可以添加加号键的响应逻辑 } else if (event.key === "-") { console.log("减号键被按下"); minus(); // 这里可以添加减号键的响应逻辑 } }); // 给组件增加拖拽功能 const dragHandle = () => { const draggable = box; let offsetX, offsetY, drag = false; draggable.onmousedown = function (e) { offsetX = e.clientX - draggable.getBoundingClientRect().left; offsetY = e.clientY - draggable.getBoundingClientRect().top; drag = true; }; document.onmousemove = function (e) { if (drag) { draggable.style.left = e.clientX - offsetX + "px"; draggable.style.top = e.clientY - offsetY + "px"; } }; document.onmouseup = function () { drag = false; }; }; dragHandle(); // Your code here... })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址