uBlock Origin is a high-performance, wide-spectrum content blocker implemented as a browser extension for Chromium, Firefox, Edge, Opera, and Thunderbird. The architecture is a multi-platform browser extension with a core filtering engine (static network filtering, cosmetic filtering, scriptlet injection) written in highly optimized JavaScript with WebAssembly acceleration (custom HNTrie/BidiTrie compressed tries, LZ4 block codec, public suffix list). The MV2 variant uses webRequestBlocking for real-time request interception, while the MV3 variant (uBO Lite) uses declarativeNetRequest with offscreen documents for filter compilation. A standalone npm package (@gorhill/ubo-core) exposes the static network filtering engine for programmatic use outside the browser. The codebase demonstrates exceptional craftsmanship in its filtering engines: the static network filtering parser and matcher handle the full EasyList syntax plus extensive uBO-specific extensions (replace=, urlskip=, ipaddress=, header=, csp=, permissions=, etc.). The HNTrieContainer implements a compressed trie specialized for right-to-left hostname matching with both JS and WASM implementations. The cosmetic filtering engine supports procedural selectors, scriptlet injection with 50+ scriptlets, and HTML filtering. The s14e-serializer provides efficient binary serialization with LZ4 compression for fast engine state snapshots. Differential updates for filter lists minimize bandwidth. The code is meticulously optimized for CPU and memory efficiency, which is critical for a content blocker processing every network request.
hBlock is a POSIX-compliant shell script that downloads multiple ad, tracking, and malware domain blocklists from curated sources, processes them into a unified hosts file (or alternative formats like dnsmasq, unbound, adblock, Windows PowerShell), and installs it to block those domains at the system level. The core architecture is a single self-contained script (hblock) with a custom option parser, robust error handling, and support for parallel downloads, allow/deny lists, template-based output formatting, and subdomain filtering. It is not a reusable library but a complete CLI tool; however, its companion scripts (resource/alt-formats/*.sh) demonstrate a clean plugin pattern for generating multiple output formats, and the stats script (resources/stats/stats.sh) provides a reusable utility for analyzing domain lists against the Public Suffix List. The project is well-maintained, tested across multiple shells and platforms, and follows strict POSIX shell practices.
Pi-hole is a network-wide ad blocking application that operates as a DNS sinkhole. The repository contains the core shell scripts for installation, configuration, and management of the Pi-hole system. The primary entry points are the `pihole` CLI command and `gravity.sh`, which downloads and compiles blocklists into a SQLite database. The architecture is a collection of bash scripts that orchestrate the FTLDNS daemon (a separate binary) and provide a command-line interface for allow/deny lists, querying, debugging, and updates. The code is well-structured with modular functions, error handling, and extensive test coverage across multiple Linux distributions. It is a mature, actively maintained project with a large community.
AdAway is an open-source Android ad-blocking application that provides two methods for blocking ads: modifying the system hosts file (requires root) and a local VPN-based DNS filter. The app downloads and manages multiple hosts sources from URLs, parses them into a local Room database, and applies the blocklists either by writing to /etc/hosts or by intercepting DNS queries through a local VPN service. The VPN mode maps real DNS servers to fake addresses, forwards allowed queries, and returns blocked or redirected responses. The architecture follows MVVM with LiveData, ViewModel, and Room, and includes background workers for periodic updates. The app bundles a legacy native C library (tcpdump/libpcap) for packet capture, used for DNS logging. The codebase is actively maintained, with frequent commits and releases, but some native components are outdated and the VPN implementation may have compatibility issues on newer Android versions.