Skip to content

feat(browsers): declarative GitHub notifications filter userscript #205

@Bad3r

Description

@Bad3r

Context

A Violentmonkey userscript hides notification rows whose first path segment matches the configured owner. The current draft lives at /tmp/hide-own-repo-notifications.user.js and works against https://github.com/notifications.

// ==UserScript==
// @name         Hide own-repo notifications
// @match        https://github.com/notifications*
// @run-at       document-idle
// @grant        none
// ==/UserScript==
(() => {
  const OWNER = 'bad3r';
  const ROW_SELECTOR =
    'li.js-notifications-list-item, li.notifications-list-item, [data-notification-id]';
  const hideRows = () => {
    document.querySelectorAll('a.notification-list-item-link').forEach((a) => {
      let path;
      try { path = new URL(a.href, location.origin).pathname; } catch { return; }
      const firstSegment = path.split('/').filter(Boolean)[0] || '';
      if (firstSegment.toLowerCase() !== OWNER) return;
      const row = a.closest(ROW_SELECTOR);
      if (row) row.style.display = 'none';
    });
  };
  hideRows();
  new MutationObserver(hideRows).observe(document.body, { childList: true, subtree: true });
})();

Goals

  1. Manage the userscript declaratively from this repo. A fresh Home Manager activation should drop the script into the managed browser profile (or load it via a managed Violentmonkey config) without manual install steps.
  2. Add a keyboard shortcut on the notifications page to toggle filtering on and off without disabling the script in Violentmonkey.

Acceptance criteria

  • Owner is a parameter, not a literal. Default value comes from a single source (e.g. an option under the relevant browser module namespace).
  • Filter state persists across reloads (e.g. localStorage keyed by owner list).
  • Toggle key bind is configurable; default suggestion Alt+H.
  • Hidden rows reveal again on toggle without a full reload.
  • Script source lives under modules/ (or packages/) and renders into the managed browser profile through Home Manager.

Open questions

  • Decide where the script file lives in the browser profile (e.g. a chrome/-style override path or a managed userscript-manager storage entry). Pick the option least brittle across browser upgrades.
  • Consider whether a WebExtension is a better long-term home than a userscript, given that a manifest can declare commands and shortcuts natively.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    area(home-manager)Home Manager modules, activation, or user-environment config.area(scripts)Operational scripts and command-line automation helpers.priority(p3)Normal priority.status(backlog)Accepted work that is intentionally unscheduled.type(enhancement)Net-new capability or intentional improvement.

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions