Swine Flu + Google-Fu = Monkey Wank Fever

I think something must have clicked in my brain when I read this tweet:

If it was Monkey Wank Fever going around, rather than swine flu, I think the national mood would be a lot more buoyant.

Graham Linehan

I knew that I had some code sitting around from playing with the Google Ajax Search API. Within a few minutes I’d cobbled together a simple text-replacement for search results to see if Monkey Wank Fever really did lighten the mood.

Monkey Wank Fever News

I think it did, but then I have a twisted sense of humor sometimes.

One upshot of this is that I realised just how easy and useful the Google AJAX Search API can be.

To include the API loader, a single script call is added into the page:

<script src="http://www.google.com/jsapi?key=[Insert API Key]" type="text/javascript"></script> 

then by following the API documentation and examples, it’s quite easy to build a search query with a customised output.

google.load("search", "1");
var webSearch;
google.setOnLoadCallback(wOnLoad);

function wOnLoad() {
    webSearch = new google.search.WebSearch();
    webSearch.setResultSetSize( google.search.Search.SMALL_RESULTSET );
    webSearch.setSearchCompleteCallback(this, webSearchComplete, null);
    webSearch.execute("swine-flu or \"swine flu\"");
}
 
function webSearchComplete() {
    if (webSearch.results && webSearch.results.length > 0) {
        var contentDiv = document.getElementById('webresults');
        contentDiv.innerHTML = '';
        var results = webSearch.results;
        for (var i = 0; i < webSearch.results.length; i++) {
            var result = results[i];
            var resContainer = document.createElement('div');
            var title = document.createElement('h3');
            title.innerHTML = result.titleNoFormatting.replace( /swine/ig, 'Monkey').replace( /influenza|flu/ig, 'Wank Fever').replace( /H1N1/ig, 'MNK3Y');
            var content = document.createElement('div');
            content.setAttribute('class', 'content');
            content.innerHTML = result.content.replace( /swine/ig, 'Monkey').replace( /influenza|flu/ig, 'Wank Fever').replace( /H1N1/ig, 'MNK3Y');
            resContainer.appendChild(title);
            resContainer.appendChild(content);
            contentDiv.appendChild(resContainer);
        }
    }
}

It may be in bad taste, but I feel like I’ve added to my arsenal of web weapons – sometimes you just can’t work on something without a goal to aim for. Aimless testing of the AJAX Search API had left me cold, but this silly little project made me sit up and pay attention to what I was doing.

2 Responses

  1. More fuel for my monkey spunk motorbike – brilliant!

Pings

  1. [...] This post was Twitted by brandjoe – Real-url.org [...]

Leave a Reply