// ==UserScript== // @name sztsg.nxeduyun.cn 电子书自动阅读翻页宁小阅任务 // @namespace http://tampermonkey.net/ // @version 0.6 // @description 持续悬浮触发下一页按钮,适配悬浮才显示的下一页宁夏的宁小阅任务,豆包生成的 // @author You // @match https://sztsg.nxeduyun.cn/webv2/book/nread/* // @grant none // @run-at document-start // @license MIT // ==/UserScript== (function() { 'use strict'; let running = true; function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } console.log("【脚本】✅脚本已经成功注入页面!"); // 模拟鼠标悬浮在阅读器中间区域,保持控制栏不消失 async function keepHoverReader() { const hoverEvt = new MouseEvent('mouseover', { bubbles: true, cancelable: true, clientX: window.innerWidth * 0.75, clientY: window.innerHeight * 0.5 }); document.dispatchEvent(hoverEvt); } // 模拟鼠标滚动 async function humanScroll() { for(let i=0; i<5; i++){ window.scrollBy(0, 100 + Math.random()*60); await sleep(250 + Math.random()*250); } await sleep(500); for(let i=0; i<2; i++){ window.scrollBy(0, -(70 + Math.random()*50)); await sleep(250 + Math.random()*250); } } // 等待并查找【下一页】元素,最多等待8秒 async function waitNextBtn(){ for(let t=0;t<8;t++){ keepHoverReader(); const list = document.querySelectorAll('div.ng-star-inserted'); for(let el of list){ if(el.offsetParent && el.textContent.trim() === '下一页'){ return el; } } await sleep(1000); } return null; } // 模拟悬浮 + 全套鼠标事件,适配angular async function triggerClick(el){ const over = new MouseEvent('mouseover', {bubbles:true, cancelable:true}); el.dispatchEvent(over); await sleep(300); const down = new MouseEvent('mousedown', {bubbles:true}); el.dispatchEvent(down); await sleep(100); const up = new MouseEvent('mouseup', {bubbles:true}); el.dispatchEvent(up); const clickEvt = new MouseEvent('click', {bubbles:true}); el.dispatchEvent(clickEvt); } async function mainLoop(){ while(running){ console.log("【脚本】开始模拟浏览滚动"); await humanScroll(); const waitSec = 70 + Math.random() * 15; console.log(`【脚本】等待 ${waitSec.toFixed(1)} 秒后翻页`); // 在等待的这段时间,每隔6秒悬浮一次,保证控制栏不会消失 const loopCount = Math.floor(waitSec / 6); for(let i=0; i{ running = false; stopBtn.innerText = "✅ 已停止"; stopBtn.style.background="#666"; }; document.body.appendChild(stopBtn); if(document.readyState === "loading"){ document.addEventListener("DOMContentLoaded", mainLoop); }else{ mainLoop(); } })();