您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
在分享的百度网盘页面自动按修改日期排序
当前为
// ==UserScript== // @name 百度网盘分享页面默认按修改日期排序 // @namespace http://tampermonkey.net/ // @version 0.1.3.4 // @description 在分享的百度网盘页面自动按修改日期排序 // @author 15d23 // @match *://pan.baidu.com/s/* // @match *://pan.baidu.com/share/* // @description 2025/1/15 23:00:19 // @run-at document-end // @license GPL // ==/UserScript== (function() { 'use strict'; function findAndClickDateSort() { console.log('开始查找排序按钮'); // 等待页面加载完成 function waitForElements() { // 查找包含"已全部加载"的元素,确认列表已加载 const loadStatus = document.querySelector('.FcucHsb'); if (!loadStatus || !loadStatus.textContent.includes('已全部加载')) { console.log('等待文件列表加载完成...'); setTimeout(waitForElements, 500); return; } // 查找修改日期按钮 const spans = document.querySelectorAll('span.text'); let dateSpan = null; for (const span of spans) { if (span.textContent === '修改日期') { dateSpan = span; break; } } if (!dateSpan) { console.log('未找到修改日期按钮,重试中...'); setTimeout(waitForElements, 500); return; } // 找到包含修改日期的li元素 const dateLi = dateSpan.closest('li[data-key="time"]'); if (!dateLi) { console.log('未找到排序按钮的父元素,重试中...'); setTimeout(waitForElements, 500); return; } console.log('找到排序按钮,执行点击'); // 添加300ms延时后执行单次点击,并保持足够的染色延时 setTimeout(() => { dateLi.click(); // 保持原有的染色延时为1000ms,确保颜色能正常显示 setTimeout(colorGroupByDate, 300); }, 300); } waitForElements(); } // 添加按日期分组着色函数 function colorGroupByDate() { console.log('开始执行颜色分组...'); const colors = [ '#f0f7ff', // 浅蓝 '#fff7f0', // 浅橙 '#f5fff0', // 浅绿 '#fff0f7', // 浅粉 '#f0ffff', // 浅青 ]; // 先找到所有日期单元格,然后通过它们找到对应的行 const dateCells = document.querySelectorAll('.ctime'); console.log('找到日期单元格数量:', dateCells.length); let currentDate = ''; let colorIndex = 0; dateCells.forEach((dateCell, index) => { // 获取父行元素(dd标签) const row = dateCell.closest('dd'); if (row) { const dateText = dateCell.textContent.split(' ')[0]; // 只取日期部分 console.log(`第${index + 1}行 - 日期: ${dateText}, 当前颜色索引: ${colorIndex}`); // 如果日期变化,切换颜色 if (dateText !== currentDate) { currentDate = dateText; colorIndex = (colorIndex + 1) % colors.length; console.log(`日期变化 - 新日期: ${dateText}, 新颜色索引: ${colorIndex}, 颜色值: ${colors[colorIndex]}`); } // 应用背景色 row.style.backgroundColor = colors[colorIndex]; // 确保背景色可见 row.style.position = 'relative'; row.style.zIndex = '1'; console.log(`应用颜色到第${index + 1}行: ${colors[colorIndex]}`); } else { console.log(`第${index + 1}个日期单元格未找到对应的行元素`); } }); console.log('颜色分组完成'); } // 页面加载完成后执行 console.log('页面加载完成,开始执行脚本'); setTimeout(findAndClickDateSort, 1000); // 监听URL变化 let lastUrl = location.href; new MutationObserver(() => { const url = location.href; if (url !== lastUrl) { lastUrl = url; console.log('检测到URL变化,重新执行排序'); setTimeout(() => { findAndClickDateSort(); }, 1000); } }).observe(document, {subtree: true, childList: true}); })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址