$ show philc/vimium
Vimium is an open-source browser extension for Chrome and Firefox that brings Vim-style keyboard navigation to the web. The codebase implements a sophisticated mode system (Normal, Insert, Find, Visual, etc.) with a central HandlerStack for event interception and bubbling. It provides link hints, a Vomnibar for URL/bookmark/tab search with autocomplete, scrolling, marks, and tab management. The architecture is split into background scripts (service worker) and content scripts injected into every page, communicating via message passing. The extension uses a custom key-mapping DSL parsed by the Commands module, and stores settings in chrome.storage. The UI (options page, help dialog, HUD, Vomnibar) is rendered in iframes with secure messaging via MessageChannel. The codebase is mature, well-tested (unit and DOM tests), and actively maintained by a community of contributors. While primarily an application, it includes a curated list of top-level domains (resources/tlds.txt) for URL parsing, but no research or data pipelines.
The LLM identified 3 files worth highlighting for reuse:
A reusable event handler stack that allows modes to push/pop handlers and control event propagation. It supports bubbling, suppression, and restarting. The implementation is self-contained with no internal dependencies, making it easy to extract into any JavaScript project that needs layered event interception (e.g., modal UI frameworks, game input handling).
A standalone collection of rectangle utility functions for DOM bounding rects, including containment checks, intersection, area, and midpoint calculations. It has zero dependencies and can be reused in any project that needs geometric operations on rectangles (e.g., visual hit-testing, layout calculations).
A generic cache implementation (SimpleCache) that stores key-value pairs with an expiry time and a rotation-based eviction policy. It is self-contained and uses only standard JavaScript constructs. This pattern is easily extractable for any application that needs a lightweight, time-bounded cache (e.g., API response caching, memoization).