您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
为世图科研助手增加已下载的红色链接,10天内点击记录生效,点击立即变色;动态元素持续监听;
当前为
// ==UserScript== // @name 世图增加已下载的红色链接 // @namespace http://tampermonkey.net/ // @version 2025-05-017-001 // @description 为世图科研助手增加已下载的红色链接,10天内点击记录生效,点击立即变色;动态元素持续监听; // @author You // @match https://research.worldlib.site/result_query.aspx // @icon https://www.google.com/s2/favicons?sz=64&domain=worldlib.site // @grant none // @license MIT // ==/UserScript== (function () { 'use strict'; // 添加样式 function addVisitedStyle() { if (!document.querySelector('style[data-visited-style]')) { const style = document.createElement('style'); style.setAttribute('data-visited-style', ''); style.textContent = ` .custom-visited { color: #e233eb !important; text-decoration: underline !important; } .cTable a:visited { color: #e233eb !important; } `; document.head.appendChild(style); } } // 当前时间戳 function now() { return Date.now(); } const EXPIRY_MS = 10 * 24 * 60 * 60 * 1000; // 10 天 let visited = {}; // 全局有效链接记录 // 只负责从 localStorage 加载全部记录,不清理 function loadVisitedLinks() { visited = JSON.parse(localStorage.getItem('visitedLinks') || '{}'); } // 保存点击链接并清理过期项 function saveVisitedLink(href) { const current = now(); visited[href] = current; const valid = {}; for (const h in visited) { if (current - visited[h] < EXPIRY_MS) { valid[h] = visited[h]; } } visited = valid; localStorage.setItem('visitedLinks', JSON.stringify(valid)); } // 添加下载按钮和访问标记 function addDownloadLinks() { document.querySelectorAll('.cTable a[data-url]').forEach(link => { if (!link.nextElementSibling || !link.nextElementSibling.classList.contains('new-download-link')) { const href = link.getAttribute('data-url'); const newA = document.createElement('a'); newA.textContent = "下载"; newA.href = href; newA.target = '_blank'; newA.classList.add('new-download-link'); if (visited[href] && now() - visited[href] < EXPIRY_MS) { newA.classList.add('custom-visited'); newA.textContent = "已下载" } newA.addEventListener('click', () => { saveVisitedLink(href); newA.classList.add('custom-visited'); newA.textContent = "已下载" }); link.parentNode.appendChild(newA); } }); } // 初始化 addVisitedStyle(); loadVisitedLinks(); setInterval(addDownloadLinks, 1000); })();