dynamic blocking

Everything about using Adblock Plus on Mozilla Firefox, Thunderbird and SeaMonkey
Post Reply
wessorh

dynamic blocking

Post by wessorh »

we set up a list of all the PPC (pay per click) domains in a realtime dns blacklist. The project is up at http://linkvac.com/ There is an example plugin there.

the basic idea is to check hostnames of URLs against the list and alter them accordingly.

To check if a domain is a PPC domain (there are about 5M listed) do the following

Code: Select all


//Javascript which loops through all links in a document doing DNS resolve on each
//coloring the ones with special meaning
//MPH 1-26-2005
var dns = Components
        .classes["@mozilla.org/network/dns-service;1"]
        .getService(Components.interfaces.nsIDNSService);

function CheckLinks() {

        var number_of_links = window.getBrowser().contentDocument.links.length;
        for (var i=0; i < number_of_links; i++)
        {
                var domainName = window.getBrowser().contentDocument.links[i].hostname;

                var DNSRecord = resolve_domain(domainName);
                if ( DNSRecord == "127.0.0.1" ) {
                        window.getBrowser().contentDocument.links[i].style.color = "#FFFFCC";
                        window.getBrowser().contentDocument.links[i].style.fontSize = "7px";
                        //window.getBrowser().contentDocument.links[i].style.visibility = "hidden";
                }
          else {
                        //alert("OK");
                }
        }

}

function resolve_domain(domainName)
{
        var DNSString = "abl.linkvac.com";
        var ips;
        var tempDNS = domainName + "." + "ppc.abl.linkvac.net";
        try
        {
                ips = dns.resolve(tempDNS, false);
                while ( ips.hasMore() )
                        return(ips.getNextAddrAsString());
        }
        catch(oException)
        {
                alert(oException);
                return "";
        }

}
I hope someone finds this stuff useful. Questions about to the DNSRBL drop a note to rick at ar dot com

-rick
IceDogg
Posts: 909
Joined: Fri Jun 09, 2006 11:22 pm

Post by IceDogg »

Interesting concept, but wouldn't checking against that large a list slow browsing down a lot?
Guest

Post by Guest »

there are many ways to optimize the checking of the links, building a hashtable of the host names of the urls on a page would improver performance by only checking each host once. Also the DNS caches results so the first hit for a host behind a caching DNS server would be slower for the first person to check a link and the next.

We are thinking of anycasting the black list which would bring the list closer to the endusers.

there are lots of thing to try I just don't have tie time to work on a plugin and wanted to see if anyone was interested in hacking this into existing code.
User avatar
mcm
Posts: 359
Joined: Sat Jun 10, 2006 2:36 am

Post by mcm »

It does look interesting, but the best way to not cause slow downs is to port the code into a XPCOM module. That way it can run in a different thread parallel to the browser down.
Post Reply