Archive for January, 2011


New in .NET 4.0: string.IsNullOrWhiteSpace

I thought I’d quickly mention this nice time-saver added in .NET 4.0: string.IsNullOrWhiteSpace. It works just like IsNullOrEmpty but also checks to see if there’s nothing but spaces in the string, so you don’t have to Trim before checking.

Recently there’s been an explosion of spam “aggregator” sites (like efreedom.com and mail-archive.com) that show up in Google search results that scrape real sites (like StackOverflow.com) and pack in blinding amounts of ads.

It’s a huge waste of time trying to look through the aggregator’s pages looking for the answer to your problems, only to find out you have to click through to get to the full discussion on the real site. I’ve learned to skip those spam sites in the search results, but that’s a waste of mental bandwidth. If you want to automatically remove them from the search results entirely, there are a couple ways of doing it.

You could type “-site:efreedom.com –site:mail-archive.com etc etc etc” into each search, but that’s hardly convenient. Or you could use Google’s Custom Search Engine feature to seamlessly remove sites from your search results, but the trade off is the Custom Search Engine has a half page of ads at the top, so that doesn’t really clean things up for us.

Here’s the solution I use: If you are willing to use Firefox (or do already) and turn off Google Instant Search, you can install a tool that customizes the Google search pages and automatically strips the spammy sites from the results.

You’ll need Firefox (I’m told this also works with Chrome) then
1. Turn off Instant Search on the Google search page (set to “Instant is off”). The Google Noise Reduction Version 0.2.9 script doesn’t work with Instant Search.
2. Install the Greasemonkey addon from the official Firefox site: https://addons.mozilla.org/en-US/firefox/addon/748/
3. Set the script editor for Greasemonkey:
a. Type “about:config” in the Firefox URL window (as if you were typing in a website address) and hit enter.
b. Hit the “I’ll be careful, I promise!” alert button.
c. In the Filter box, type “greasemonkey.editor” and doubleclick the preference when it appears.
d. Set the value to “C:\Windows\system32\notepad.exe” (or your favorite script editing tool) and hit ok.
4. Install the Google Noise Reduction script from the Greasemonkey script site: http://userscripts.org/scripts/show/44418
a. Hit the Install button and ok.
b. If you see the user.js file display instead, go to Tools –> Greasemonkey –> Enabled.
c. Version 0.2.9 has a small bug in it, so if you install that version, you’ll want to fix it:
i. Go to Tools –> Greasemonkey –> Manage User Scripts and edit the Google Noise Reduction script.
ii. Find the “if(window.AutoPagerize…” block and replace it with:

var addFilterHandler = function(){
window.AutoPagerize.addFilter(function(page){
    setTimeout(function(){
        var autopagerize_linkNode = 
            SITEINFO.linkNode.replace(/^\S+/,"");
        $(autopagerize_linkNode, page)
            .each(function(index, node){ 
                Filter.check(node); 
            });
        }, 0);
});} 
if(window.AutoPagerize)
{ 
    addFilterHandler(); 
} else { 
    window.addEventListener('GM_AutoPagerizeLoaded', addFilterHandler, false); 
}

iii. Hit Save.
5. Now when you run a Google search, you’ll see a “Filter” button next to every result. Hit that button for every spam site you want to filter out and select the URL you want to block. When you run your search, you’ll never see that site again!
6. You can manage your blocked sites in the “Noise Reduction” button at the top of the Google page.

P.S. There are literally thousands of Greasemonkey scripts out there that let you customize websites in all kinds of ways. You can find hundreds for hacking Google pages, but I’ve found they often conflict with each other, so be prepared to test new scripts and uninstall them if they block other scripts’ features you need. If you find a script that works better than Google Noise Reduction, let me know.

Happy searching!

© 2017 Robert Corvus