← All examples

JavaScript Productivity medium.com

Medium: dim already-read articles

Remembers articles you clicked and dims their feed cards so you do not revisit the same text.

Code to copy

// 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 });
})();

How to use this example

  1. Copy the code with the button above.
  2. Install JustZix (2 minutes) and open the extension on the target page.
  3. Add a new rule matching that page.
  4. Paste the code into the rule's JavaScript panel and save — it runs on every page visit.

Rate this example

No ratings yet — be the first.

Does this example work?

Snippets are useless without somewhere to paste them.

JustZix takes 2 minutes to install and runs your code on every matching page. No account, no payment.

Download free See use cases