// ==UserScript==
// @include http://www.flashkit.com/board*
// ==/UserScript==
 
(function () {
    var at = document.getElementsByTagName('a');
    var al = at.length;
    for (var i = 0; i < al; ++i) {
        if (at[i].hasAttribute('href') && at[i].getAttribute('href').match(/realmedia\/ads/i)) {
            var n = at[i];
            // climb the dom tree to try to find the table containing the link
            while (n.parentNode.nodeName.toLowerCase() != 'table') {
                n = n.parentNode;
                if (n.nodeName.toLowerCase() == 'html') {
                    break;
                }
            }
            if (n.nodeName.toLowerCase() != 'html') {
                // check the height of the containing table and if it's too tall remove it
                var h = parseInt(document.defaultView.getComputedStyle(n, null).getPropertyValue('height')); 
                if (h > 200) {
                    n.style.display = 'none';
                    break; // I assume there is only 1 of these adverts on the page and stop checking the links once it's removed
                }
            }
        }
    }
 
    // and get rid of any flash adverts
    var embeds = document.getElementsByTagName('embed');
    var el = embeds.length;
    for (var i = 0; i < el; ++i) {
        embeds[i].style.display = 'none';
    }
 
})();
