您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
还原旧版倒序显示文件,自动滚动加载全部文件并回到顶部
当前为
// ==UserScript== // @name 百度网盘 - 自动加载全部文件,倒序显示文件 // @namespace http://tampermonkey.net/ // @version 1.0 // @description 还原旧版倒序显示文件,自动滚动加载全部文件并回到顶部 // @author 一直咸鱼猫 // @match https://pan.baidu.com/s/* // @grant none // @run-at document-start // @license CC-BY-NC // ==/UserScript== (function () { 'use strict'; // 全局开关:是否启用自动滚动 const enableAutoScroll = false; // ← 设置为 true 可以开启自动滚动 // 劫持 XMLHttpRequest const origOpen = XMLHttpRequest.prototype.open; XMLHttpRequest.prototype.open = function (method, url) { if (typeof url === 'string' && url.includes('/share/list')) { const u = new URL(url, location.origin); u.searchParams.set('num', '100'); u.searchParams.set('desc', '1'); arguments[1] = u.toString(); } return origOpen.apply(this, arguments); }; // 劫持 fetch const origFetch = window.fetch; window.fetch = function (input, init) { let url = input; let isRequest = false; if (input instanceof Request) { url = input.url; isRequest = true; } if (typeof url === 'string' && url.includes('/share/list')) { const u = new URL(url, location.origin); u.searchParams.set('num', '100'); u.searchParams.set('desc', '1'); const newUrl = u.toString(); input = isRequest ? new Request(newUrl, input) : newUrl; } return origFetch.call(this, input, init); }; // 滚动逻辑 function autoScrollLoad(container) { if (!enableAutoScroll || !container || window.__panScrollRunning__) return; window.__panScrollRunning__ = true; let lastScrollTop = -1; let stableCount = 0; const loop = setInterval(() => { container.scrollTop = container.scrollHeight; if (container.scrollTop === lastScrollTop) { stableCount++; } else { stableCount = 0; lastScrollTop = container.scrollTop; } if (stableCount >= 5) { clearInterval(loop); setTimeout(() => { container.scrollTop = 0; window.__panScrollRunning__ = false; }, 100); } }, 200); } // 判断路径是否发生变化(点击子目录) function hasDirectoryChanged() { const now = location.pathname + location.search + location.hash; if (window.__panLastPath !== now) { window.__panLastPath = now; return true; } return false; } // 启动逻辑 + 监听子目录切换 function observeAndTriggerScroll() { const wait = setInterval(() => { const container = document.querySelector('.NHcGw'); if (container) { clearInterval(wait); if (enableAutoScroll) { setTimeout(() => autoScrollLoad(container), 100); // 页面首次加载触发 } window.__panLastPath = location.pathname + location.search + location.hash; const observer = new MutationObserver(() => { if (hasDirectoryChanged() && enableAutoScroll) { setTimeout(() => { const newContainer = document.querySelector('.NHcGw'); if (newContainer) autoScrollLoad(newContainer); }, 1000); } }); observer.observe(container, { childList: true, subtree: false }); } }, 300); } // 页面加载完成后启动 window.addEventListener('load', () => { observeAndTriggerScroll(); }); })();