您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
记住网页上访问过的链接,并将其颜色设置为浅蓝色。脚本菜单支持单独域名启用/禁用脚本。
// ==UserScript== // @name 记住访问过的链接 // @version 1.5 // @description 记住网页上访问过的链接,并将其颜色设置为浅蓝色。脚本菜单支持单独域名启用/禁用脚本。 // @author ChatGPT // @match *://*/* // @grant GM_setValue // @grant GM_getValue // @grant GM_registerMenuCommand // @grant GM_unregisterMenuCommand // @run-at document-end // @namespace https://gf.qytechs.cn/users/452911 // ==/UserScript== (function() { 'use strict'; const domain = window.location.hostname; const scriptKey = `scriptEnabled_${domain}`; let isEnabled = GM_getValue(scriptKey, true); function updateMenu() { GM_unregisterMenuCommand('toggleScriptMenuCommand'); GM_unregisterMenuCommand('clearLinksMenuCommand'); const toggleText = isEnabled ? '禁用记住访问过的链接脚本' : '启用记住访问过的链接脚本'; GM_registerMenuCommand(toggleText, toggleScript); GM_registerMenuCommand('清除所有记住的链接', clearLinks); } function toggleScript() { isEnabled = !isEnabled; GM_setValue(scriptKey, isEnabled); updateMenu(); if (isEnabled) { initScript(); } else { removeScript(); } } function clearLinks() { GM_setValue('visitedLinks', []); document.querySelectorAll('a[href]').forEach(link => { link.style.color = ''; }); } function initScript() { const visitedLinks = new Set(GM_getValue('visitedLinks', [])); function updateLinkStatus(link) { if (visitedLinks.has(link.href)) { link.style.color = '#88C6E5'; } else { link.addEventListener('click', () => { visitedLinks.add(link.href); GM_setValue('visitedLinks', Array.from(visitedLinks)); link.style.color = '#88C6E5'; }); } } document.querySelectorAll('a[href]').forEach(updateLinkStatus); const observer = new MutationObserver((mutations) => { mutations.forEach((mutation) => { mutation.addedNodes.forEach((node) => { if (node.nodeType === Node.ELEMENT_NODE) { node.querySelectorAll('a[href]').forEach(updateLinkStatus); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); } function removeScript() { document.querySelectorAll('a[href]').forEach(link => { link.style.color = ''; }); } updateMenu(); if (isEnabled) { initScript(); } })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址