Medium:淡化已读文章
记住你点开过的文章并淡化其信息流卡片,避免重复阅读。
可复制的代码
// Dim feed cards whose article link has already been visited
(function () {
const STYLE_ID = 'jz-med-visited';
if (!document.getElementById(STYLE_ID)) {
const s = document.createElement('style');
s.id = STYLE_ID;
s.textContent = '.jz-med-seen{opacity:.5!important}';
document.head.appendChild(s);
}
function mark() {
document.querySelectorAll('article a[href]').forEach(function (a) {
try {
const key = 'jzmed:' + new URL(a.href).pathname;
if (localStorage.getItem(key)) {
const card = a.closest('article');
if (card) { card.classList.add('jz-med-seen'); }
}
a.addEventListener('click', function () {
try { localStorage.setItem(key, '1'); } catch (e) {}
});
} catch (e) {}
});
}
mark();
new MutationObserver(mark).observe(document.body,
{ childList: true, subtree: true });
})();
如何使用此示例
- 用上方按钮复制代码。
- 安装 JustZix(2 分钟),在目标页面打开扩展。
- 添加一条匹配该页面的新规则。
- 将代码粘贴到规则的 JavaScript 面板并保存 — 每次访问页面时都会运行。
为此示例评分
暂无评分 — 成为第一个。