Expand description
adblock-rust
is the engine powering Brave’s native adblocker, available as a library for
anyone to use. It features:
- Network blocking
- Cosmetic filtering
- Resource replacements
- Hosts syntax
- uBlock Origin syntax extensions
- iOS content-blocking syntax conversion
- Compiling to native code or WASM
- Rust bindings (crates)
- JS bindings (npm)
- Community-maintained Python bindings (pypi)
- High performance!
Check the Engine
documentation to get started with adblocking.
Modules§
- blocker
- Holds
Blocker
, which handles all network-based adblocking queries. - cosmetic_
filter_ cache - Provides behavior related to cosmetic filtering - that is, modifying a page’s contents after it’s been loaded into a browser. This is primarily used to hide or clean up unwanted page elements that are served inline with the rest of the first-party content from a page, but can also be used to inject JavaScript “scriptlets” that intercept and modify the behavior of scripts on the page at runtime.
- filters
- Contains representations and standalone behaviors of individual filter rules.
- lists
- Parsing functions and collections for handling with multiple filter rules.
- regex_
manager - Compiled regexes can take up large amounts of memory. To reduce the overall memory footprint of
the
crate::Engine
, infrequently used regexes can be discarded. TheRegexManager
is responsible for managing the storage of regexes used by filters. - request
- Contains structures needed to describe network requests.
- resources
- In adblocking terms,
Resource
s are special placeholder scripts, images, video files, etc. that can be returned as drop-in replacements for harmful equivalents from remote servers. Resources also encompass scriptlets, which can be injected into pages to inhibit malicious behavior. - url_
parser - Simplified URL parsing infrastructure, including the domain resolver
implementation if the
embedded-domain-resolver
feature is disabled.
Structs§
- Engine
- Drives high-level blocking logic and is responsible for loading filter lists into an optimized format that can be queried efficiently.
- Filter
Set - Manages a set of rules to be added to an
crate::Engine
.