Adblocker
PublicA simple ad blocker written in Rak — a test project for the language.
Rak 2026 Updated 2 weeks ago RakTest Project
| Name | Size |
|---|---|
| adblock.rak | 5.0 KB |
| blocklist.txt | 530 B |
| hosts.blocked | 245 B |
| README.md | 1.3 KB |
| report.txt | 1.1 KB |
| sample.html | 1.4 KB |
A demo adblocker
Files
blocklist.txt- blocklist, one0.0.0.0 domainper line.sample.html- demo page referencing blocked ad domains.adblock.rak- the blocker script.report.txt- generated scan report.hosts.blocked- generated0.0.0.0 domainentries, one per unique hit.
Usage
rakc run adblocker/adblock.rak
By default it scans the local sample.html and writes report.txt and
hosts.blocked. Two environment variables control the inputs:
RAK_ADBLOCK_LIST- path to the blocklist (defaultadblocker/blocklist.txt)RAK_ADBLOCK_PAGE- page to scan. A URL (starts withhttp) is fetched over the network; otherwise it is read as a local file (defaultadblocker/sample.html).
Example - scan a live page:
$env:RAK_ADBLOCK_PAGE = "https://example.com/"; rakc run adblocker/adblock.rak
How it works
- Loads the blocklist, handling both
0.0.0.0 domainand plaindomainlines. - Extracts script, image, and link URLs from the page, then does a raw
src=scan to catch iframes and anything the tag parser missed. - Flags any URL that contains a blocklisted domain.
- Writes
report.txt(per-resource hits) andhosts.blocked(deduplicated hosts entries you can append to a Pi-hole or hosts file).
Note: the adblocker is a demo.