← All examples

JavaScript Productivity arxiv.org

arXiv: mark papers as read

When you click a PDF link, stores the paper ID locally and dims its rows in listings so you can see what you have already read.

Code to copy

// Mark papers as "read" once you click their PDF link, dim them in listings
(function () {
  var KEY = 'jzArxReadIds';
  function load() {
    try { return JSON.parse(localStorage.getItem(KEY) || '{}') || {}; }
    catch (e) { return {}; }
  }
  function save(map) { localStorage.setItem(KEY, JSON.stringify(map)); }
  function markId(id) {
    if (!id) { return; }
    var m = load(); m[id] = Date.now(); save(m);
    apply();
  }
  function extractId(href) {
    var m = href.match(/\/(?:abs|pdf)\/([\w.\-\/]+?)(?:v\d+)?(?:\.pdf)?$/);
    return m ? m[1] : null;
  }
  document.addEventListener('click', function (e) {
    var a = e.target.closest('a[href*="/pdf/"], a[href$=".pdf"]');
    if (!a) { return; }
    markId(extractId(a.getAttribute('href') || ''));
  }, true);
  function apply() {
    var read = load();
    document.querySelectorAll('a[href*="/abs/"]').forEach(function (a) {
      var id = extractId(a.getAttribute('href') || '');
      if (!id || !read[id]) { return; }
      var row = a.closest('dt, li, tr, .arxiv-result') || a.parentElement;
      if (row && !row.dataset.jzArxRead) {
        row.dataset.jzArxRead = '1';
        row.style.opacity = '0.55';
        row.style.filter = 'grayscale(0.5)';
        var tag = document.createElement('span');
        tag.textContent = ' ✓ read';
        tag.style.cssText = 'color:#0a7c3a;font-weight:700;font-size:12px;margin-left:6px;';
        a.appendChild(tag);
      }
    });
  }
  apply();
  new MutationObserver(function () {
    clearTimeout(window.__jzArxRead);
    window.__jzArxRead = setTimeout(apply, 400);
  }).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