Ad Block engine in Rust
Native Rust module for Adblock Plus syntax (e.g. EasyList, EasyPrivacy) filter parsing and matching.
It uses a tokenisation approach for qucikly reducing the potentially matching rule search space against a URL.
The algorithm is inspired by, and closely follows the algorithm of uBlock Origin and Cliqz.
Somewhat graphical explanation of the algorithm:
Demo
Demo use in Rust:
extern crate adblock;
use Engine;
Node.js module demo
Note the Node.js module has overheads inherent to boundary crossing between JS and native code.
const AdBlockClient = require;
let rules = fs..;
// create client with debug = true
const client = ;
const serializedArrayBuffer = client.; // Serialize the engine to an ArrayBuffer
console.log;
console.log
// Match with full debuging info
console.log
// No, but still with debugging info
console.log
TODO
- Generate redirect addresses based on provided resources.txt (uBo style)
- Function for extracting CSP directives
- Generate string representation of a rule when debug mode is off (i.e. initial rule is not available)
- Cosmetic filters