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 "";
}
}
-rick