Match domain exactly instead of partially.
Gather list of domains to minimize number of times that hosts file must be enumerated.
Only add domain to whitelist if it isn't already present.
It's pretty slow because /etc/hosts is so large, but it works. You can
add any number of domains as arguments and it will search for and
remove each one.
Maybe someone smarter knows how to make it faster...