All Work

Adblocker

Public

A simple ad blocker written in Rak — a test project for the language.

Rak 2026 Updated 2 weeks ago RakTest Project
main Live from GitHub Updated 2 weeks ago View on GitHub
Repository contents
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
README.md

A demo adblocker

Files

  • blocklist.txt - blocklist, one 0.0.0.0 domain per line.
  • sample.html - demo page referencing blocked ad domains.
  • adblock.rak - the blocker script.
  • report.txt - generated scan report.
  • hosts.blocked - generated 0.0.0.0 domain entries, 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 (default adblocker/blocklist.txt)
  • RAK_ADBLOCK_PAGE - page to scan. A URL (starts with http) is fetched over the network; otherwise it is read as a local file (default adblocker/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 domain and plain domain lines.
  • 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) and hosts.blocked (deduplicated hosts entries you can append to a Pi-hole or hosts file).

Note: the adblocker is a demo.