Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
By cadj at 2005-04-21 22:03
INTRO: UNIVERSAL ADD BLOCKER
This tutorial will explain how to replace those annoying banner ad's on webpages with a simple "Ad Blocked" message.
As far as i know this method will work with ALL web browsers, but i have only tested on Konqueror and Firefox.
This method is very easy to do, and can either take 2 or 5 steps, depending on if you want custom messages.
STEP ONE: CREATE YOUR .PAC FILE
STEP TWO: CONFIGURING YOUR FILE / BROWSER
(If you want "Ad Blocked" message)
STEP THREE: INSTALLING CONFIGURING THTTPD
STEP FOUR: RECONFIGURING YOUR PROXY.PAC SCRIPT
STEP FIVE: ITS ALL DONE!
Have you ever noticed "Use the following proxy configuration URL" in the proxy configuration of you browser?
It turns out that this URL is nothing that a very simple script file, often referred to a .PAC file (Proxy Auto
Configuration?)
After looking around the net, i discovered that you could create your own .PAC file/add filters and redirect your
requests.
Using the idea of the Firefox adblock project, i decided to configure my .PAC file to redirect any requests for
banner ad's.
STEP ONE: CREATE YOUR .PAC FILE
Create a file and call it PROXY.PAC in /home/user
Enter the following code
The above is quite easy to understand, Basically every request is passed thru the "IF" statement, which says in english
Code:
if (the host) contains the word ".ad" or ".ads" etc.. set the browser to use the proxy 0.0.0.0:8000
if you read the script now, you will notice that the || means OR
STEP TWO: CONFIGURING YOUR FILE / BROWSER
Now that you understand how the script works, you can add your own filters! These could include adult content, ads,
or bad websites.
Open your favorite web browser (Konqueror?) and configure it to use your /home/user/PROXY.PAC file. This configuration
option is usually found in the proxy config section of your web browser.
Restart your browser to be sure, and start browsing. You will notice that most of you banner ad's will be replaced
with
If the error message doesn't bother you, skip this step
Instead of our PROXY.PAC script sending requests thru a 0.0.0.0 (a location that doesn't exist), we will
configure our script to use a webserver we setup ourselves, with a custom error message, or none at all!
You may need to look elsewhere to install THTTPD, but as far as i know there are binaries available for many
platforms.
Once THTTPD is installed / configured and started, we need to create a custom 404 error message, to do this, create
an "errors" directory in your web root (mine is in /var/www, so this is what i will use here)
in /var/www/errors, create a file called err404.html (not.htm, wont work) and add the following
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.