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 quickly 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 el_rules = fs..;
let ubo_unbreak_rules = fs..;
let rules = el_rules.;
let resources = fs.;
// create client with debug = true
const client = ;
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
// Example that inlcludes a redirect response
console.log
TODO
- 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