Lighter alternative to AdBlock Plus

How to do things, solutions, recipes, tutorials
Post Reply
Message
Author
User avatar
cimarron
Posts: 292
Joined: Fri 31 May 2013, 01:57

Lighter alternative to AdBlock Plus

#1 Post by cimarron »

A how-to about this was posted years ago by Iguleder, who explains how to block ads using the /etc/hosts file.

I found out about it by trying sc0ttman's Pup-Advert-Blocker, which makes the process easier (read the end of that thread to see recent changes). I used the "Systcl.org" hosts file (I think that's supposed to be Sysctl.org) and found it blocks almost as well as the Adblock Plus addon in Firefox. And it works for any browser, since it is not an addon.

I just wanted to highlight this again because I was surprised how much better Firefox ran using the /etc/hosts ad-blocking. I have a 12-year-old Thinkpad X24, with just 256M RAM, and Firefox's memory use can cause a lot of swapping, which slows everything down considerably. But when I removed a couple Adblock Plus subscription lists (using /etc/hosts instead) the memory use and swapping were greatly reduced and my savefile dropped 6MB. Webpages loaded much faster, flash video played better.

I still use the Adblock Plus addon for its ability to easily block any page elements you want gone (or find video streams in pages for downloading), but it's very light without the huge subscription lists.

Bruce B

Re: Lighter alternative to AdBlock Plus

#2 Post by Bruce B »

cimarron wrote:A how-to about this was posted years ago by Iguleder, who explains how to block ads using the /etc/hosts file.
I just skimmed over the thread referenced.

I didn't see anything mentioned about running a local web-server.

When using 127.0.0.1 as the address to route the request, this is saying in effect, "There is a server at this address". With 127.0.0.1 being a valid IP address for our computers but can only be accessed by our own computers.

The address 127.0.0.1 is true and the browser will look for a server there but it won't find it. The search for the browser continue until it times out.

If there is a lightweight server such as 'hiawatha' which is included with most if not all Puppys the server will be quickly found and return an appropriate error code.

When a server is not found a different error code is returned.

(I suspect that Ad Block Plus returns a error 200, which is good for us users)

If anyone wants to experiment I include some links.
http://127.0.0.1

http://127.0.0.1/somefile.txt

http://www.example.com

http://www.example.com/somefile.txt

(example.com is intended to be used for testing, teaching and other purposes, it expects to be used and abused)



Try it with and without hiawatha running, the user can determine for himself what he prefers.

~~~

What I would really like is for hiawatha to always return an error 200 (which basically says 'success')


I went through the code thinking it might be obvious how to accomplish this task, but it wasn't.

I would really appreciate it if someone could find a way to do this and post a how-to or attach the modified source code.

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#3 Post by technosaurus »

You can use 0.0.0.0 to block completely.

I have used 127.0.0.1 to implement a local CDN proxy server for commonly used js libs and other resources (it cuts web traffic roughly in half), but 0.0.0.0 for sites I just wanted to block altogether so it didn't try to cache useless ads on my server.
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
cimarron
Posts: 292
Joined: Fri 31 May 2013, 01:57

#4 Post by cimarron »

With subsequent experimenting, I found that the /etc/hosts blocking definitely works, but that most all ads on the pages I'm visiting are blocked by my use of the NoScript add-on (it seems most ads are loaded by scripts). I don't have to identify and block all the ad servers, since NoScript only allows the scripts I whitelist.

So that's another much lighter alternative to Adblock Plus with its huge subscription lists.

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#5 Post by technosaurus »

NoScript only works on the browser that has it installed though. /etc/hosts applies the filter to all browsers, wget, curl, javascript ... anything that links to system libraries (pretty much everything, though I did write a test web server that replaced gethostbyname and other system functions in order to download /etc/hosts blocked resources with 127.0.0.1 ... so it could for example download jquery once and serve it locally from then on)

Here is a nice free list if you want to block more than ads:
ftp://ftp.ut-capitole.fr/pub/reseau/cac ... d_contrib/
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

Post Reply