$ show hectorm/hblock
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.
The LLM identified 3 files worth highlighting for reuse:
A thin shell script that sets environment variables to configure hBlock for generating an Adblock Plus compatible format (||domain^). It demonstrates a clean, reusable pattern for defining new output formats without modifying the core tool. Each alt-format script is independent and can be extracted to create a new format generator for any tool that accepts environment variables.
Similar to the adblock format script, this one configures hBlock to produce a dnsmasq configuration file (address=/domain/). It also enables subdomain filtering to reduce redundancy. The pattern is reusable: any engineer can create a new format by writing a similar script that sets the appropriate environment variables (HBLOCK_REDIRECTION, HBLOCK_TEMPLATE, HBLOCK_COMMENT, etc.) and calls hBlock.
A standalone shell script that analyzes a list of domains to count occurrences of TLDs or public suffixes (using the Public Suffix List). It handles IDN punycode encoding, uses a quicksort algorithm in awk, and can be reused in any project needing domain statistics. The script is well-structured, handles temporary files, and is parameterized (input file and optional PSL URL).