/////////////////////////////////////////////////////////////////////////////// // // John's No-ADS proxy auto configuration script // http://www.schooner.com/~loverso/no-ads/ // loverso@schooner.com // // Copyright 1996-2001, John LoVerso. All Rights Reserved. // // Permission is given to use and distribute this file, as long as this // copyright message and author notice are not removed. // // No responsibility is taken for any errors on inaccuracies inherent // either to the comments or the code of this program, but if reported // to me, then an attempt will be made to fix them. // // ("no monies exchanged" in Copyright clause removed 11/2001) // // $Id: no-ads.pac,v 3.5 2001/11/27 00:33:00 loverso Exp loverso $ // /////////////////////////////////////////////////////////////////////////////// // // This simple kludge uses a mechanism built into most browsers (IE, // Netscape, and Mozilla) on most platforms to block connections to // banner ad servers. // // This mechanism uses the "proxy auto configuration" to blackhole requests // to load ad images without forcing all your traffic through an ad-blocking // proxy server. Of course, unlike ad-blocking proxy servers, this does not // otherwise not strip cookies. // // "Proxy auto configuration" invokes the JavaScript FindProxyForURL function // below each time your browser requests a URL. This works even if you have // JavaScript otherwise disabled in your browser! (Which you should!) // /////////////////////////////////////////////////////////////////////////////// // // TO USE: // // // 1. Save this as a file (no-ads.pac) on your local disk or off your home page. // 2. Select a no-ads "blackhole". // 3. Configure your browser to use this file as it's auto proxy configuration. // 4. Clear your browser's cache // (or else it may still show you ads it has saved on your disk). // /////////////////////////////////////////////////////////////////////////////// // // 1. SAVE THIS FILE // // // PLEASE don't load this over and over again from my server (please!) // /////////////////////////////////////////////////////////////////////////////// // // 2. SELECT A NO-ADS BLACKHOLE // // // The basic trick is to match the site or URL of annoying web content and // tell the browser to use a proxy that will deny loading of that resource // (image, page, etc). // // You basically need a proxy server that always denies loading a particlar // object. // // As distributed, the selection of the blackhole proxy is done with the line // below that reads: // return "PROXY localhost:3421"; // // Some possibilities for the blackhole: // // a. A server that doesn't respond. // // If you do nothing, then this is configured to direct annoying // content to the proxy running on your localhost at port 3421. // Since you shouldn't have anything running on that port, that // connection will timeout and the annoying content will never be // loaded. // // THIS ONLY WORKS FOR IE! // // Netscape waits for the proxy server to connect (usually it // needs to load part of the image to layout the web page), and // then asks if you want to disable the proxy that won't answer. // Mozilla will given alert saying it couldn't connect to the // image server. // // IE doesn't care that the proxy server isn't responding. As // this avoids a connection for annoying content, it is fastest. // // b. A simple, blackhole server // // When needed, I run a simple "server" at port 3421 that denies // all requests. I include the shell script I use; this could // also be done with a "wait"-style perl script that did the same // thing, if exec'ing a shell was overly expensive on your computer // (it isn't on mine). // // Add this to inetd.conf: ("bmap" is the defined server on port // 3421) // // bmap stream tcp nowait nobody /usr/local/lib/noproxy noproxy // // Create /usr/local/lib/noproxy as this shell script: // // #!/bin/sh // read a // read b // echo HTTP/1.0 501 No Ads Accepted // echo "" // exit // // This doesn't work for Linux (because of the way it's TCP // stack works). I'll have a fix, I'll add to my web page soon. // // c. A trick: use an HTTP/1.0 non-proxy server // // An HTTP/1.0 non-proxy server will return a 501 error when // given a proxy request! If you So, you can just return as the // PROXY your local intranet web server! However, it will likely // also log error, wasting a tad bit of resources. // // *** // *** Be sure to update the "PROXY" line below with the correct // *** hostname:port of your blackhole server!! // *** // // *** // *** If you already use a proxy server to access the WWW, // *** change the "DIRECT" line below to your proxy server. // *** /////////////////////////////////////////////////////////////////////////////// // // 3. TO CONFIGURE YOUR BROWSER // // // The Proxy Auto Configuration file can be either on the local disk or // accessed from a web server, with the following constraints: // // a. IE before 5.5 can only load the PAC from a web server (http:// URL) // b. Netscape, Mozilla, and IE 5.5 can load the PAC from anywhere. // c. Netscape and Mozilla require the correct MIME type when loading // the PAC from a web server. // // // To set the Proxy Auto Configuration with Netscape Navigator or Mozilla: // // 1. Enable Proxy Auto Config: // // Open "Edit->Preferences" // Select "Advanced" // Select "Proxies" // Select "Auto proxy configuration" option // Enter URL or path of this file // // http://yourserver/no-ads.pac // // If you place this on your local disk, you can configure Netscape and // Mozilla with a file: URL such as: // // file:/home/loverso/no-ads.pac (UNIX) // file://c:/windows/no-ads.pac (Windows) // // 2. If you are using Netscape or Mozilla and serving this from a web server, // then you need to configure your web server to serve this file with the // correct MIME type. // // a. For Apache, name the file with a ".pac" extension and add this // line to the http.conf (or your own .htaccess file): // // AddType application/x-ns-proxy-autoconfig .pac // // b. For IIS (instructions form Kevin Roth ) // // Open Internet Services Manager // Right click on the web site (or directory) you wish to change. // Choose Properties // Click the "HTTP Headers" tab // Click the "File Types" button in the "MIME Map" section // Click the "New Type..." button // Enter "pac" for "Associated Extension" // Enter "application/x-ns-proxy-autoconfig" for "Content Type (MIME)" // Click OK to close the Add type dialog, the MIME types dialog, // and the main properties dialog. // // (This is definately needed for NS, but not for IE) // // // To set the Proxy Auto Configuration with IE: // // 1. Enable Proxy Auto Config: // // Open "Tools->Internet Options" // Select "Connections" tab // Click "LAN Settings" box // Select "Use automatic configuration script" // // Enter the URL of this file in Address field. // // http://yourserver/no-ads.pac // file://c:/no-ads.pac // // You can only use a file: URL with IE5.5. It does not work with // previous versions of IE. It might not work with IE6. // // 2. Fix Security Settings (IMPORTANT): // // Select "Security" tab // Select "Local intranet" // Click "Sites" box // Unselect "include all sites that bypass the proxy server" option // // 3. Disable "Auto Proxy Caching": // // IE contains a proxy caching mechanism that will defeat the ability // to block ad servers that share content with non-ads. To prevent this, // add the registry key described in this MS KB article: // // http://support.microsoft.com/support/kb/articles/Q271/3/61.ASP // // To make it easy, download this file and click it: // http://www.schooner.com/~loverso/no-ads/no-auto-proxy-cache.reg // // (thanks to Kevin Roth for alerting me of this!) // // IE doesn't currently check the MIME type of the loaded file. // // To see some notes from MS on PAC in IE, see // http://msdn.microsoft.com/library/periodic/period99/faq0599.htm // /////////////////////////////////////////////////////////////////////////////// // // To see the definition of this page's JavaScript contents, see // // http://home.netscape.com/eng/mozilla/2.0/relnotes/demo/proxy-live.html // // Microsoft includes this in thie KB article: // http://support.microsoft.com/support/kb/articles/Q209/2/66.ASP // // Special PAC functions: // Hostname: // isPlainHostName(host) // dnsDomainIs(host, domain) // localHostOrDomainIs(host, hostdom) // isResolvable(host) // isInNet(host, pattern, mask) // Utility: // dnsResolve(host) // myIpAddress() // dnsDomainLevels(host) // URL: // shExpMatch(str, shexp) // Time: // weekdayRange(wd1, wd2, gmt) // dateRange(...) // timeRange(...) // // Other methods: // alert(), etc // http://developer.netscape.com/docs/manuals/communicator/jsref/win1.htm // function FindProxyForURL(url, host) { // debug // alert("checking: " + url); // To add more sites, simply include them in the correct list in the // correct format. // The sites below are ones I currently block. Tell me of others you add! if (0 // Block IE4/5 "favicon.ico" fetches // (to avoid being tracked as having bookmarked the site) // // NOTE: IE5 *sometimes* fetches facicon.ico w/o using the proxy! || shExpMatch(url, "*/favicon.ico") ////// // // Global Section // tries to match common names // // Uncomment these if you want to really knock out ads. After doing // so, you can probably remove rules below that mention ads or Ads. // || shExpMatch(url, "*ads*") // || shExpMatch(url, "*Ads*") // More targeted than the above || shExpMatch(url,"*/ads/*") || (shExpMatch(url,"*/Ads/*") // avoid false positives // www.priceworld.com/Ads/SundayAds_sub.asp && !(dnsDomainIs(host, ".priceworld.com") || dnsDomainIs(host, ".intertraq.com")) ) || shExpMatch(url,"*/banners/*") || shExpMatch(url,"*/Banners/*") || shExpMatch(url,"*/banner/*") || shExpMatch(url,"*/Banner/*") // This removes all hostnames with "ad", but not "add" // (for instance, add.yahoo.com) || (shExpMatch(url, "http://ad*") && !shExpMatch(url, "http://add*")) // or any subdomain "ads" || (dnsDomainLevels(host) > 2 && shExpMatch(url, "http://*.ads.*/*")) ////// // // banner/ad organizations -- delete the entire organization // // these set cookies || dnsDomainIs(host, ".doubleclick.com") || dnsDomainIs(host, ".doubleclick.net") || dnsDomainIs(host, ".globaltrack.com") || dnsDomainIs(host, ".burstnet.com") || dnsDomainIs(host, ".adbureau.net") || dnsDomainIs(host, ".hitbox.com") || dnsDomainIs(host, ".targetnet.com") || dnsDomainIs(host, ".humanclick.com") // these use 1x1 images to track you || dnsDomainIs(host, ".admonitor.com") || dnsDomainIs(host, ".focalink.com") || dnsDomainIs(host, ".websponsors.com") || dnsDomainIs(host, ".commission-junction.com") || dnsDomainIs(host, ".advertising.com") || dnsDomainIs(host, ".cybereps.com") || dnsDomainIs(host, ".postmasterdirect.com") || dnsDomainIs(host, ".advertising.com") || dnsDomainIs(host, ".mediaplex.com") || dnsDomainIs(host, ".adtegrity.com") || dnsDomainIs(host, ".bannerbank.ru") || dnsDomainIs(host, ".bannerspace.com") || dnsDomainIs(host, ".theadstop.com") || dnsDomainIs(host, ".l90.com") || dnsDomainIs(host, ".webconnect.net") || dnsDomainIs(host, ".avenuea.com") || dnsDomainIs(host, ".flycast.com") || dnsDomainIs(host, ".engage.com") || dnsDomainIs(host, ".imgis.com") || dnsDomainIs(host, ".datais.com") || dnsDomainIs(host, ".link4ads.com") || dnsDomainIs(host, ".247media.com") || dnsDomainIs(host, ".hightrafficads.com") || dnsDomainIs(host, ".qkimg.net") || dnsDomainIs(host, ".tribalfusion.com") || dnsDomainIs(host, ".rightserve.net") || dnsDomainIs(host, ".admaximize.com") || dnsDomainIs(host, ".valueclick.com") || dnsDomainIs(host, ".adlibris.se") || dnsDomainIs(host, ".vibrantmedia.com") || dnsDomainIs(host, ".coremetrics.com") // hit counting "services" || dnsDomainIs(host, ".allhits.ru") || dnsDomainIs(host, ".list.ru") || dnsDomainIs(host, ".counted.com") ////// // // banner servers // (typically these set cookies or serve animated ads) // || dnsDomainIs(host, "commonwealth.riddler.com") || dnsDomainIs(host, "banner.freeservers.com") || dnsDomainIs(host, "usads.futurenet.com") || dnsDomainIs(host, "banners.egroups.com") || dnsDomainIs(host, "ngadclient.hearme.com") /// matched by global rules /// || shExpMatch(url, "*freewebsites.com/banner/*") /// || shExpMatch(url, "*linkexchange.com/*banner*") /// || dnsDomainIs(host, "ad.linkexchange.com") /// || dnsDomainIs(host, "ads.infi.net") /// || dnsDomainIs(host, "adclub.net") /// || dnsDomainIs(host, "adserv.newcentury.net") /// || dnsDomainIs(host, "ad.adsmart.net") /// || dnsDomainIs(host, "adbot.com") /// || dnsDomainIs(host, "ads.softbank.net") /// || dnsDomainIs(host, "ad.preferences.com") /// || dnsDomainIs(host, "ads.jwtt3.com") /// || dnsDomainIs(host, "ads.ugo.com") /// || dnsDomainIs(host, "ads.csi.com") /// || dnsDomainIs(host, "ads.enliven.com") /// || dnsDomainIs(host, "adcontent.gamespy.com") /// || dnsDomainIs(host, "adrunner.mycomputer.com") /// || shExpMatch(url, "*.computers.com/Ads*") /// || shExpMatch(url, "*.cnet.com/Ads*") /// || shExpMatch(url, "*/cnet*/Ads*") /// || shExpMatch(url, "*socialnet.com/banners*") /// || shExpMatch(url, "*adex*.flycast.com/*") /// || shExpMatch(url, "*ads*.sandpiper.com/*") /// || dnsDomainIs(host, "ads.bla-bla.com") ////// // // Directed // || dnsDomainIs(host, "remotead.cnet.com") // GeoCities Ad Square (From "Prakash Persaud" ) || (dnsDomainIs(host,"geocities.yahoo.com") && shExpMatch(url,"*/toto?s*")) // Yahoo ads via Akamai // http://us.a1.yimg.com/us.yimg.com/a/... || (dnsDomainIs(host,"yimg.com") && shExpMatch(url,"*yimg.com/a/*")) // FortuneCity - ads and tracking || (dnsDomainIs(host,".fortunecity.com") && (shExpMatch(url,"*/js/adscript*") || shExpMatch(url,"*/js/fctrack*"))) // zdnet || (dnsDomainIs(host, ".zdnet.com") && (dnsDomainIs(host, "ads3.zdnet.com") || shExpMatch(url, "*/texis/cs/ad.html") || shExpMatch(url, "*/adverts"))) // Dell || (dnsDomainIs(host, ".dell.com") && shExpMatch(url, "*/images/affiliates/*")) /// matched by global rules /// // intellicast /// || (dnsDomainIs(host, ".intellicast.com") && /// shExpMatch(url, "*images/ads/*")) // they are most annoying: // - cookies on their background images to track you // - looping shockwave ads // this kills most of the crud || ((dnsDomainIs(host, ".tomshardware.com") || isInNet(host, "216.92.21.0", "255.255.255.0")) && ( shExpMatch(url, "*/cgi-bin/banner*") || shExpMatch(url, "*/cgi-bin/bd.m*") || shExpMatch(url, "*/images/banner/*") ) ) // these set cookies || shExpMatch(url, "*.dejanews.com/ads*") || shExpMatch(url, "*.deja.com/ads*") || shExpMatch(url, "*MapsOnUs.com/ad.images*") // Slashdot: added these when I saw hidden 1x1 images with cookies || dnsDomainIs(host, "adfu.blockstackers.com") || (dnsDomainIs(host, "slashdot.org") && ( shExpMatch(url, "*/Slashdot/pc.gif*") || shExpMatch(url, "*/pagecount.gif*") || shExpMatch(url, "*/adlog.pl*") ) ) // OfficeMax affiliate art || (dnsDomainIs(host, "officemax.com") && shExpMatch(url, "*/affArt/*") ) /// matched by global rules /// // shockwave & animated ads /// || shExpMatch(url, "*sharkyextreme.com/ads/*") /// || (dnsDomainIs(host,"anandtech.com") /// && shExpMatch(url,"*/banners/*")) // complicated JavaScript for directed ads! || (dnsDomainIs(host, ".anandtech.com") && shExpMatch(url,"*/js/*") ) ////// // // User tracking (worse than ads) // || dnsDomainIs(host, "web-stat.com") || dnsDomainIs(host, "webtrendslive.com") // javascript || dnsDomainIs(url, "superstats.com") // 1x1 tracking images // ** (but also used in some pay-for-clicks that I want to follow, // ** so disabled for now. 9/2001) // || dnsDomainIs(url, "service.bfast.com") ////// // // popups // || dnsDomainIs(url, "mousebucks.com") ////// // // Contributed adult sites // || dnsDomainIs(host, "porntrack.com") || dnsDomainIs(host, "sexe-portail.com") || dnsDomainIs(host, "sextracker.com") || dnsDomainIs(host, "sexspy.com") || dnsDomainIs(host, "offshoreclicks.com") ////////////////// // // My sites // || (dnsDomainIs(host, "hardocp.com") && ( shExpMatch(url, "*/ads/*") ) ) || (dnsDomainIs(host, "arstechnica.com") && ( shExpMatch(url, "*/phpAdsNew/*") ) ) || (dnsDomainIs(host, "page3.com") && ( shExpMatch(url, "*/home_banners/*") ) ) || (dnsDomainIs(host, "rcm-images.amazon.com") && ( shExpMatch(url, "*banner*") ) ) || (dnsDomainIs(host, "209.197.107.132") && ( shExpMatch(url, "*banner*") ) ) || dnsDomainIs(host, "ar.atwola.com") || dnsDomainIs(host, "specialoffers.aol.com") || dnsDomainIs(host, "popme.163.com") || dnsDomainIs(host, "45495915461") || dnsDomainIs(host, "151.196.147.197") || dnsDomainIs(host, "www.fuck-portal.com") || dnsDomainIs(host, "clickit.go2net.com") || dnsDomainIs(host, "adincl.gopher.com") || dnsDomainIs(host, "ads.ad-flow.com") || dnsDomainIs(host, "ads.snowball.com") || dnsDomainIs(host, "ads.adservingcentral.com") || dnsDomainIs(host, "ads.aceweb.net") || dnsDomainIs(host, "www.qksrv.net") || dnsDomainIs(host, "www.popuptraffic.com") || dnsDomainIs(host, "ads.ascensionweb.net") || dnsDomainIs(host, "ads.danni.com") || dnsDomainIs(host, "www.pinkchocolate.com") || dnsDomainIs(host, "www.lickinlovers.com") || dnsDomainIs(host, "www.cutegirlfriend.com") || dnsDomainIs(host, "www.maximumcash.com") || dnsDomainIs(host, "www.vulgarteens.com") || dnsDomainIs(host, "www.amateuruniversity.com") || dnsDomainIs(host, "www.sinfulhardcore.com") || dnsDomainIs(host, "link.siccash.com") || dnsDomainIs(host, "www.justtoons.com") || dnsDomainIs(host, "www.hardinterracial.com") || dnsDomainIs(host, "www.allpetite.com") || dnsDomainIs(host, "arsconsole.global-intermedia.com") || dnsDomainIs(host, "66.40.3.5") || dnsDomainIs(host, "209.25.173.3") || dnsDomainIs(host, "209.25.173.4") || dnsDomainIs(host, "html.andr.net") || dnsDomainIs(host, "www.adscpm.com") || dnsDomainIs(host, "www.xxxteenclub.de") || dnsDomainIs(host, "hg1.hitbox.com") || dnsDomainIs(host, "www.babylonteen.com") || dnsDomainIs(host, "banners.cracks.am") || dnsDomainIs(host, "www.babylonlesbian.com") || dnsDomainIs(host, "www.hardcorepornos.org") || dnsDomainIs(host, "banners.adultfriendfinder.com") || dnsDomainIs(host, "ads.web.aol.com") || dnsDomainIs(host, "ad-adex3.flycast.com") || dnsDomainIs(host, "js-adex3.flycast.com") || dnsDomainIs(host, "itrash.discountclick.com") || dnsDomainIs(host, "ads.admonitor.net") || dnsDomainIs(host, "popup.terrashare.com") || dnsDomainIs(host, "adserver.ugo.com") || dnsDomainIs(host, "ads.clickagents.com") || dnsDomainIs(host, "ads.gamespy.com") || dnsDomainIs(host, "ad.doubleclick.net") || dnsDomainIs(host, "connect.247media.ads.link4ads.com") || dnsDomainIs(host, "banners.orbitcycle.com") || dnsDomainIs(host, "ads.x10.com") || dnsDomainIs(host, "servedby.advertising.com") || dnsDomainIs(host, "ad.preferences.com") || dnsDomainIs(host, "ads.monster.com") || dnsDomainIs(host, "ads.gamespy.com") || dnsDomainIs(host, "euniverseads.com") || dnsDomainIs(host, "ads.tucows.com") || dnsDomainIs(host, "ads.whitepages.com") || dnsDomainIs(host, "ads.enliven.com") || dnsDomainIs(host, "ads.stileproject.com") || dnsDomainIs(host, "ads3.zdnet.com") || dnsDomainIs(host, "lubid.lycos.com") || dnsDomainIs(host, "leader.linkexchange.com") || dnsDomainIs(host, "media.admonitor.net") || dnsDomainIs(host, "exitstitial.gopher.com") || dnsDomainIs(host, "ads14.focalink.com") || dnsDomainIs(host, "ads.telegraph.co.uk") || dnsDomainIs(host, "ad.br.doubleclick.net") || dnsDomainIs(host, "ads.admonitor.net") || dnsDomainIs(host, "image.ugo.com") || dnsDomainIs(host, "mjxads.internet.com") || dnsDomainIs(host, "banners.revenuelink.com") || dnsDomainIs(host, "205.180.85.40") // ////////////////// // debug // || (alertmatch("NOT:" + url) && 0) ) { // alert("blackholing: " + url); // *** // *** Update the next line with the correct // *** hostname:port of your blackhole proxy server // *** // return "PROXY localhost:3421"; return "PROXY localhost"; } else { // debug // alert("allowing: " + url); // all other requests go direct and avoid any overhead return "DIRECT"; // **** // **** If you cannot go direct or need to use an actual proxy // **** (such as used by an ISP or business or on a firewall), // **** change the "DIRECT" above to "PROXY hostname:port", // **** with the correct hostname:port for your proxy server. // **** } } /////////////////////////////////////////////////////////////////////////////// // // This line is just for testing; you can ignore it. But, if you are having // problems where you think this PAC file isn't being loaded, then change this // to read "if (1)" and the alert box should appear when the browser loads this // file. // if (0) { alert("autoconfig notice: LOADED"); } // The above should show you that this JavaScript is executed in an // unprotected global context. NEVER point at someone elses autoconfig file; // always load from your own copy! // an alert that returns true function alertmatch(url) { alert("match: "+url); return 1; } // "window.confirm" does not work. // function confirmmatch(url) // { // if (window.confirm(url)) // return 0; // else // return 1; // } /////////////////////////////////////////////////////////////////////////////// // // Tired of reading boring comments? Try reading today's comics: // http://www.schooner.com/~loverso/comics/ // // or getting a quote from my collection: // http://www.schooner.com/~loverso/quote/ // // eof