Skip to content

Instantly share code, notes, and snippets.

@mrozo
Created November 30, 2017 16:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrozo/081a3c383706c8dba3ef8d6e9daf11b6 to your computer and use it in GitHub Desktop.
Save mrozo/081a3c383706c8dba3ef8d6e9daf11b6 to your computer and use it in GitHub Desktop.
Convert blacklist of no coin chrome extension int a hosts file entry. https://github.com/keraf/NoCoin
import re
blacklist = open("/home/mroz/workspace/coin-hoster/blacklist.txt",'r')
domains = set()
wildcards = set()
domain_matcher = re.compile("[^/]+//(\*\.)?(?P<domain>[^/]+)")
for line in blacklist:
try:
domains.add(domain_matcher.match(line).groupdict()['domain'])
except:
pass
print(domains)
hosts_file = map(lambda d: "0.0.0.0 " + d, domains)
hosts_file = "\n".join(hosts_file)
print(hosts_file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment