Skip to content

DavidVentura/webextension-adblocker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ad blocker for GTK/WebKit2

This is an ad-blocker for WebKit2 based browsers.

What does it do

This extension will block all "bad requests" towards blocked domains or matching "bad url fragments".

How to use it

Blocking domains

Create a file with domains or subdomains you want to block and put it in ~/.config/wk_adblock/hosts.txt.

An example:

very-bad.domain.com
something-bad.other-domain.com

Every request going to these domains or any subdomain (ie: to really.very-bad.domain.com) will be blocked.

Blocking url fragments

Create a file with url fragments you want to block and put it in ~/.config/wk_adblock/fragments.txt.

An example:

-fb-pixel-
-coin-hive.js

Every request matching these substrings (ie: to http://good.com/some-fb-pixel-ad.png) will be blocked.

How does it work

WebKit2 does not expose a direct way to block requests, see here. You need to build a WebExtension shared object, which webkit can be instructed to load at runtime and that WebExtension can process / reject requests.

This crate implements the necessary bits to reject "bad" requests

Copy-pasted everything from

Building

sudo apt install llvm clang libwebkit2gtk-4.0 pkg-config libglib2.0-dev
cargo build --release

Docs:

Similar things

Not-benchmark

Randomly clicking on pages for a while, the average time to decide whether or not a page was an ad was ~30µs.