GreaseMonkey latest visitor filter
Posted by: Fritz. in GreaseMonkey, Hacking, JavaScriptI’ve hacked together a simple GreaseMonkey script for filtering the latest visitor log, which my web hosting service, SiteGround.com, the cPanel calls it “Raw Access Log”. I wrote it primarily to remove the Yahoo web scraper bots, which, unlike the Google bots, scrape from many different IP addresses. This makes reading the visitor log tedious as you have to skip over all the (benign) IP addresses generated by Yahoo “slurp” scrapers.
This GreaseMonkey script (see below for the guts of it) simply hides log entries from specified IP addresses. Oh yes, it also makes the IP addresses listed into links. You can get a sanitized version of the script here. You’ll have to customize it for your specific web host IP address.
// Google: 66.249.64.0 - 66.249.95.255 // 66.249.72.141 //var toFilter = [ ]; // // Add IPs to filter here: // var filterHash = { '66.249.72.141':'Google bot' }; // var allLegends; var aLegend; var aFieldset; var aDataTable; allLegends = document.getElementsByTagName('legend'); //GM_log("Found " + allLegends.length + " legend elements."); for (var i = 0; i < allLegends.length; ++i) { aLegend = allLegends[i]; //aLegend.style.backgroundColor = "green"; // legend = "Host: ipAddress" //var text = aLegend.nodeValue; var text = aLegend.innerHTML; var ipAddress = text.substring( 6 ); var httpAddress = "http://" + ipAddress; var filter = filterHash[ipAddress]; // yahoo slurp, the most annoying of the crawlers in that many ip addresses are involved if ( 0 == ipAddress.indexOf( "74.6." ) || 0 == ipAddress.indexOf( "67.195." ) ) { //aLegend.innerHTML = "<a href=\"" + httpAddress + "\">" + text + " Yahoo Slurp" + "</a>"; aFieldset = aLegend.parentNode; aFieldset.style.display = "none"; } else if ( null == filter ) { // make the IP address available as link aLegend.innerHTML = "<a href=\"" + httpAddress + "\">" + text + "</a>"; } else { aFieldset = aLegend.parentNode; aFieldset.style.display = "none"; } } //GM_log("Processed " + allLegends.length + " legend elements.");
(Converted to HTML by http://www.palfrader.org/code2html/code2html.html)
Entries (RSS)
April 22nd, 2008 at 4:41 pm
[...] GreaseMonkey latest visitor filter || fritz freiheit.com (GreaseMonkey,Script,Filter,Hosting,Fritz) [...]