$ show foxyproxy/browser-extension
FoxyProxy is a cross-browser extension (Chrome, Firefox, Edge) for advanced proxy management. It allows users to configure individual proxies, use pattern-based proxying (wildcard, regex, match patterns), set proxy per tab or container (Firefox), enable global exclude lists, and manage WebRTC settings. The codebase is highly modular, using ES modules and Manifest V3. It implements single proxy, PAC, and 'proxy by patterns' modes, with features like sync, import/export, a live log, pattern tester, and enterprise policy support. The architecture separates concerns clearly: background service worker handles proxy configuration via browser APIs, options page provides full UX, popup offers quick controls, and context menus add convenience. The code is well-structured, uses modern JavaScript (ES2022), and shows solid engineering practices. Reusable modules include pattern validation, file I/O, and flag display utilities.
The LLM identified 3 files worth highlighting for reuse:
This module provides static methods for validating and converting URL patterns across three types: wildcard (glob), match pattern (as used by Chrome/Firefox), and regular expression. It converts wildcards and match patterns into regex strings for testing. The validation includes detailed error messages for match patterns (e.g., invalid host or scheme) making it user-friendly. This component is self-contained (no internal module imports) and could be extracted for any project needing URL pattern matching or validation.
A lightweight utility that converts two-letter country codes (ISO 3166-1 alpha-2) to corresponding flag emojis using Unicode regional indicator symbols. It also provides a 'show' method that returns appropriate icons for proxies: flag for country, globe for unknown, direct arrow, or computer for local hosts. The code is completely isolated and can be reused in any web application or extension needing flag display from country codes.
Handles file import and export operations for extension settings. Provides a static 'import' method that reads a JSON file from a file input and parses it, and an 'export' method that writes data to a file via either browser.downloads API (desktop) or a data URI fallback (Android). It handles MIME type validation and file reading errors. This is a reusable pattern for any extension that needs to backup/restore configuration using standard file dialogs.