jQuery.fn.historycheck = function(check_urls) {
    /* Call on any element with an array of URLs. If any of the URLs have been
     * visited by the user (they are in the browser cache), show the element.
     * The default CSS should hide the element. */
    return this.each(function() {
        var el = this;
        /* First create an invisible iframe. */
        var iframe = document.createElement('iframe');
        iframe.style.position = 'absolute';
        iframe.style.left = '-1000px';
        iframe.height = '1';
        iframe.width = '1';
        $('body').append(iframe)

        /* Write the necessary HTML into the iframe. We have to break up the
         * strings so they don't get rewritten by some overzealous javascript
         * rewriting. */
        win = iframe.contentDocument || iframe.contentWindow.document;
        win.write([
            '<!' + 'DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"',
            '    "http://www.w3.org/TR/html4/loose.dtd">',
            '<' + 'html><' + 'head><' + 'title>visited<'+ '/title><' + 'style>',
            'a#hcheck:link { color: #f00 }',
            'a#hcheck:visited { color: #0f0 }',
            '<' + '/style><' + '/head><' + '/body>'
        ].join("\n"));
        /* Iterate over URLs and write links. */
        for(i = 0; i < check_urls.length; i++) {
            win.write('<a id="hcheck" href="' + check_urls[i] + '">&nbsp;</a>');
        }
        win.write('<' + '/body><' + '/html>');
        win.close();
    
        /* Check the resulting links. */
        jQuery('a', win).each(function(i) {
            if(this.currentStyle) {
                color = this.currentStyle['color'];
            } else if(win.defaultView.getComputedStyle) {
                color = win.defaultView.getComputedStyle(this, null).getPropertyValue('color');
            }
            if(color == 'rgb(0, 255, 0)' || color == '#0f0') {
                /* If any of the links are visited, show the element. */
                jQuery(el).show();
            }
        });

        /* Get rid of the iframe. */
        $(iframe).remove();
    });
};
