forked from brave/adblock-rust
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.rs
29 lines (24 loc) · 802 Bytes
/
example.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use adblock::{
Engine,
lists::{FilterSet, ParseOptions},
request::Request,
};
fn main() {
let rules = vec![
String::from("-advertisement-icon."),
String::from("-advertisement-management/"),
String::from("-advertisement."),
String::from("-advertisement/script."),
];
let debug_info = true;
let mut filter_set = FilterSet::new(debug_info);
filter_set.add_filters(&rules, ParseOptions::default());
let engine = Engine::from_filter_set(filter_set, true);
let request = Request::new(
"http://example.com/-advertisement-icon.",
"http://example.com/helloworld",
"image",
).unwrap();
let blocker_result = engine.check_network_request(&request);
println!("Blocker result: {:?}", blocker_result);
}