top | item 7743202

(no title)

dcc1 | 11 years ago

http://someonewhocares.org/hosts/zero/

discuss

order

bru|11 years ago

I switched from ABP to this hosts file a few months ago and I have zero regret. My browser's faster, lighter and ads are blocked just as well as with ABP.

I actually even started splitting my hosts file: the layout is

    /etc/hosts                ('compiled' version)
    /etc/hosts.d/
    /etc/hosts.d/aaa-warning  (warning reminding me to run `update-hosts` instead of modifying /etc/hosts. Appears atop the compiled file)
    /etc/hosts.d/adblock      (that website's hosts file)
    /etc/hosts.d/base         (original system hosts file)
    /etc/hosts.d/dolead       (work-related file for development)
And I have the following functions in my .bashrc file:

    function update-hosts() {
        cat /etc/hosts.d/* > /etc/hosts;
    }

    function update-adblock() {
        curl http://someonewhocares.org/hosts/zero/hosts -o /etc/hosts.d/adblock 2> /dev/null
        update-hosts
    }
So if I want to update "adblock" (it is obviously an improper name) I simply do `sudo update-adblock` and if I change another file (mostly `/etc/hosts.d/dolead`) I'll just run `sudo update-hosts`.

Works wonders.

barrkel|11 years ago

Most of my adblock stuff is CSS based. I use element hiding helper to figure out which bits to kill. I have hundreds of these custom rules.

userbinator|11 years ago

If you want to pull hosts files from multiple sources, you may want to consider sort'ing and uniq'ing to remove duplicates.

TarpitCarnivore|11 years ago

Have you been able to block stuff like Tynt, and other copy/paste triggered JS stuff?

throwaway7767|11 years ago

Interesting, my experience with hosts files has been that they do not block ads nearly as well as ABP. A lot of the ads I see are served from the same host as the content. ABP also blocks things like youtube ads that I don't think can be blocked at the DNS level.

I'd love to move the ad filtering out of my browser though, either into a proxy like privoxy or DNS filtering, if it worked well.

mp3geek|11 years ago

Host files are very limited, and when you start dealing with anti-adblock scripts and other css/js scripts on some sites it falls apart. Basically hosts file was great 10+ years ago when the Web was new(ish) and Adblock was only used by a few. Now we're dealing with CSS, objects, subrequests, first party ad/tracking scripts.

With all the features Adblock Plus gives us, far far more than just blocking xx and yy domains like in a hosts file... Why not just use the extension? Let's leave the host file to the history books.

userbinator|11 years ago

ABP is filtering content that's already been retrieved over the network and read into the browser. With hosts, the blocked content never makes it into my machine, which saves bandwidth.

I think using both is better than either one alone. A hosts file to quickly remove most of the unwanted stuff, and ABP to finish off the rest that does get through.

ElongatedTowel|11 years ago

That doesn't hide the blocked elements though.

math0ne|11 years ago

I like this as well, even works great for windows 8 IE which there is no ad block for otherwise, but sometime I need to see ads and then switching is not worth the hassle. I've been thinking of developing a system tray hosts file switcher for this purpose. You think anyone else would use it?

aidos|11 years ago

I'd tried this in the past but my machine slowed to a crawl. I guess it was to do with the algorithm used for handling the list of hosts (this sounds like a job for a bloom filter).

I've just tried the list you provided and it seems to be ok. Will try it for a while to see how I get on.

bru|11 years ago

A quick dive brought me to glibc: seems like everything is done in `resolv/gethnamaddr.c`. Look for `_PATH_HOSTS` mentions: it is defined as "/etc/hosts/". The parsing seems done by the function `gethtent`. However it returns a single `hostent`...

I'll try to understand it tonight.

thegeomaster|11 years ago

It'd be interesting to dive into parts of e.g. Linux source to see how it tests domains against the hosts file. It probably isn't doing anything as clever as Bloom, though, but who knows...

joeblau|11 years ago

This is great. I just implemented it and I can already tell that my web experience is going faster.