$ show quoid/userscripts
Userscripts is a Safari WebExtension (and companion native macOS/iOS app) that lets users manage and inject userscripts/userstyles into web pages. It provides a popup for toggling scripts and checking updates, a full-featured code editor (CodeMirror 5) for editing scripts, and native apps that store scripts in a local filesystem directory. The extension communicates with the native app via Safari's native messaging, and supports all major Greasemonkey API methods, match patterns, and metadata blocks. The project uses Svelte+Vite for all UI surfaces, Swift for native platforms, and Xcode project with Fastlane for deployment. It is a polished, well-architected tool that fills a gap left by Safari's limited extension ecosystem.
The LLM identified 5 files worth highlighting for reuse:
Contains a standalone, zero-dependency implementation of the Greasemonkey @match pattern parser (matchPattern) and userscript metadata block parser (parseMetaBlock). The matchPattern function compiles glob-like patterns into efficient execution, handling wildcards, TLDs, and protocol restrictions. The metadata parser uses a middleware-based grammar to extract and validate metadata lines. Both functions can be extracted and reused in any JavaScript project that needs to parse or match against userscript specs, without internal coupling.
A custom Vite plugin that precompiles Markdown files (like help guides and release notes) into Svelte-compatible HTML at build time, using the `marked` library. It filters out migrated text and injects the result as a module. This is a self-contained, reusable pattern for any Vite+Svelte project that wants to embed Markdown content without runtime parsing overhead. It demonstrates non-obvious build-time transformation and can be dropped into another project with minimal changes.
Provides an abstraction over Safari's native messaging API (browser.runtime.connectNative) for long-lived connections. It handles reconnection, message queuing, and a request-response pattern using unique IDs. The module is self-contained (relies only on browser APIs) and can be extracted to any Safari extension that needs to communicate with a native app. It demonstrates good error handling and connection lifecycle management, a pattern that is often poorly implemented in WebExtensions.
A Svelte toggle component with CSS custom property theming (light/dark), keyboard accessibility, and a clean transition. It is decoupled from the rest of the app, only depending on CSS variables defined in the shared stylesheet. The pattern of using CSS variables for theming and ARIA attributes for accessibility is reusable across any Svelte project. The component is small, focused, and demonstrates good front-end craftsmanship.
A pure Swift implementation of URL parsing that mirrors the W3C URL Standard, filling gaps in Foundation's URL. It handles percent-encoding, base URLs, and special schemes (blob, data) that Safari's URL class struggles with. This is a standalone file with no dependencies on the rest of the project, making it directly reusable in any Swift application that needs robust URL manipulation. It demonstrates deep knowledge of the URL spec and Foundation limitations.