Greasy Fork is available in English.
点击链接变暗并添加波浪线,标记会保存直到标签页关闭
当前为
// ==UserScript==
// @name 标记已点击链接(会话版)
// @description 点击链接变暗并添加波浪线,标记会保存直到标签页关闭
// @version 3.1
// @author WJ
// @match *://*/*
// @license MIT
// @grant none
// @namespace http://greasyfork.icu/users/914996
// ==/UserScript==
(function() {
'use strict';
// 注入强制样式(核心修改)
const style = document.createElement('style');
style.textContent = 'a.x-marked{opacity:0.5!important;text-decoration:underline wavy #00CED1!important}';
document.head.appendChild(style);
const marked = JSON.parse(sessionStorage.xMarkedLinks || '{}');
// 简化标记函数
const mark = a => a.classList.add('x-marked');
// 精简初始化
const init = () => {
document.querySelectorAll('a[href]').forEach(a => {
if (marked[a.href]) mark(a);
});
};
// 基本DOM监听
new MutationObserver(init).observe(document, {
childList: true,
subtree: true
});
// 精简点击处理
document.addEventListener('click', e => {
const a = e.target.closest('a[href]');
if (!a || a.closest('nav,.nav,.navbar,.navigation,.menu,.menubar,.breadcrumb,header,.header,footer,.footer,.pagination,.tabs,.tabbar,.sidebar,.aside,#sidebar,#aside,[role="navigation"],[role="menu"],[role="tablist"],[role="banner"]')) return;
marked[a.href] = true;
sessionStorage.xMarkedLinks = JSON.stringify(marked);
mark(a);
}, true);
// 启动初始化
if (document.readyState === 'complete') init();
else document.addEventListener('DOMContentLoaded', init);
})();