您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
为 Linux.do 网站添加自动滚动功能,可缓慢滚动
当前为
// ==UserScript== // @name Linux.do 自动滚动工具 // @name:en Linux.do Auto Scroller // @name:zh-CN Linux.do 自动滚动工具 // @namespace https://gf.qytechs.cn/zh-TW/users/1252908-eep // @version 1.0.3 // @description 为 Linux.do 网站添加自动滚动功能,可缓慢滚动 // @description:en Add auto-scroll functionality to Linux.do // @description:zh-CN 为 Linux.do 网站添加自动滚动功能,可缓慢滚动 // @author EEP // @license MIT // @match https://linux.do/* // @icon https://linux.do/favicon.ico // @grant none // @run-at document-idle // @supportURL https://github.com/yourusername/linux-do-autoscroller/issues // @homepageURL https://github.com/yourusername/linux-do-autoscroller // ==/UserScript== (function() { 'use strict'; // 滚动状态变量 let isScrolling = false; let scrollInterval; let scrollSpeed = 3; // 每次滚动的像素数,数值越小滚动越慢 // 创建控制按钮 let button function createScrollButton() { button = document.createElement('button'); button.id = 'auto-scroll-button'; button.textContent = '开始自动滚动'; button.style.position = 'fixed'; button.style.bottom = '20px'; button.style.right = '20px'; button.style.zIndex = '9999'; button.style.padding = '8px 12px'; button.style.backgroundColor = '#4CAF50'; button.style.color = 'white'; button.style.border = 'none'; button.style.borderRadius = '4px'; button.style.cursor = 'pointer'; button.style.boxShadow = '0 2px 5px rgba(0,0,0,0.2)'; // 添加速度控制滑块 const speedControl = document.createElement('div'); speedControl.style.position = 'fixed'; speedControl.style.bottom = '60px'; speedControl.style.right = '20px'; speedControl.style.zIndex = '9999'; speedControl.style.backgroundColor = 'white'; speedControl.style.padding = '5px'; speedControl.style.borderRadius = '4px'; speedControl.style.boxShadow = '0 2px 5px rgba(0,0,0,0.2)'; speedControl.style.display = 'flex'; speedControl.style.flexDirection = 'column'; speedControl.style.alignItems = 'center'; const speedLabel = document.createElement('label'); speedLabel.textContent = '滚动速度:'; speedLabel.style.marginBottom = '5px'; speedLabel.style.color = '#333'; const speedSlider = document.createElement('input'); speedSlider.type = 'range'; speedSlider.min = '1'; speedSlider.max = '10'; speedSlider.value = scrollSpeed; speedSlider.style.width = '100px'; speedSlider.addEventListener('input', function() { scrollSpeed = parseInt(this.value); }); speedControl.appendChild(speedLabel); speedControl.appendChild(speedSlider); // 点击事件处理 button.addEventListener('click', function() { if (isScrolling) { stopScrolling(); button.textContent = '开始自动滚动'; button.style.backgroundColor = '#4CAF50'; } else { startScrolling(); button.textContent = '停止自动滚动'; button.style.backgroundColor = '#F44336'; } }); document.body.appendChild(button); document.body.appendChild(speedControl); } // 开始缓慢滚动到底部 function startScrolling() { if (isScrolling) return; isScrolling = true; // 使用setInterval方法实现平滑滚动 scrollInterval = setInterval(function() { // 获取当前滚动位置 const currentPosition = window.pageYOffset || document.documentElement.scrollTop; // 获取文档总高度 const totalHeight = Math.max( document.body.scrollHeight, document.body.offsetHeight, document.documentElement.clientHeight, document.documentElement.scrollHeight, document.documentElement.offsetHeight ); // 获取视窗高度 const windowHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight; // 如果已经到达底部,停止滚动 if (currentPosition + windowHeight >= totalHeight) { console.log('bottom') // 如果看到底部了,等待一段时间看是否有新内容加载 setTimeout(checkForNewContent, 1000, currentPosition, totalHeight); } else { // 否则继续向下滚动 window.scrollBy(0, scrollSpeed); } }, 10); // 每10毫秒滚动一次,确保平滑 } // 检查是否有新内容加载 function checkForNewContent(previousPosition, previousHeight) { // 获取新的文档高度 const newTotalHeight = Math.max( document.body.scrollHeight, document.body.offsetHeight, document.documentElement.clientHeight, document.documentElement.scrollHeight, document.documentElement.offsetHeight ); // 如果高度变化了,说明加载了新内容,继续滚动 if (newTotalHeight > previousHeight) { // 继续滚动,不做任何操作,让interval继续工作 } else { // 如果一段时间后没有新内容加载,可以选择停止滚动 // 这里我们选择不停止,继续观察是否有新内容 stopScrolling() button.textContent = '开始自动滚动'; button.style.backgroundColor = '#4CAF50'; } } // 停止滚动 function stopScrolling() { if (!isScrolling) return; clearInterval(scrollInterval); isScrolling = false; } // 等待页面完全加载后添加按钮 function init() { if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', createScrollButton); } else { createScrollButton(); } } // 监听动态内容加载 function observeDOMChanges() { const observer = new MutationObserver(function(mutations) { // 当页面内容变化时,确保我们的按钮仍然存在 if (!document.getElementById('auto-scroll-button')) { createScrollButton(); } }); observer.observe(document.body, { childList: true, subtree: true }); } // 执行初始化 init(); observeDOMChanges(); })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址