I really liked bole5's dnsmasq-based adblocking script for its elegance and simplicity, but I wanted more features, so I've used his as a base to create my own.
- Supports Attitude Adjustment, Chaos Calmer, Designated Driver
- Doesn't stay in memory -- creates the list of blocked domains and then uses DNSMASQ and firewall to redirect requests to a 1x1 transparent gif served with uhttpd
- Supports both hosts files and list of domains for blocking
- Supports remote whitelist URLs, just put whitelisted domains one per line
- Supports whitelisted domains in config file
- Uses ufetch-client on DD instead of wget
- As some of the standard lists URLs are using https, requires either wget/libopenssl (AA, CC) or ustream-ssl (DD)
- Has setup function which installs dependencies and configures everything (/etc/init.d/adblock setup)
- Has update function which downloads updated script version from github.com (/etc/init.d/adblock update)
- Has verbosity settings (adblock.config.verbosity, default value 2) controlling output verbosity
- Very lightweight, the whole script is just one /etc/init.d/adblock file
- Logs single entry in the system log with the number of blocked domains if verbosity is set to 0
- Shows ad blocking status in the banner (can be disabled)
The setup script also installs the proper sort binary instead of using busybox which should speed things up.
Everything is available at https://github.com/stangri/openwrt-simple-adblock and feel free to fork/submit pull requests or use in your own build.
I'm only using this in my custom builds, but it should work on a stock OpenWrt image (let me know if you try and it doesn't). It *requires* uhttpd and installs coreutils-sort and either wget/libopenssl (AA, CC) or libustream-polarssl (DD).
For more details check out the github page and script sources.
Again, all the credit goes to bole5, I've just slightly improved on his work and made a one-line installer. Now that it's on github people can contribute to the script easier. Would be great if someone volunteers to make this into a package.
(Last edited by stangri on 4 Apr 2016, 01:46)