This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

A solution against shouting (for Firefox/Greasemonkey)

For those of you who don't know, Greasemonkey is a Firefox addon that allows execution of custom JavaScript for web pages.

Because of the inflation of shouting here, I have written a small script that displays shouting extra small.

// ==UserScript==
// @name        Anti Shout
// @namespace   kamikaze.bsdforen.de
// @include     http://www.keil.com/forum/*
// @description Scale down excessive shouting on the Keil forums
// ==/UserScript==

var tables = document.getElementsByTagName("table");
var table;
for (var i = 0; i < tables.length; i++) {
        if (tables[i].getAttribute("class") == "thd") {
                table = tables[i];
                break;
        }
}

function descent(node) {
        if (node.data) {
                var volume = node.data.match(/[A-Z]/g);
                if (volume && volume.length / node.data.length > 0.5) {
                        node.parentNode.style.fontSize = "x-small";
                }
        }
        for (var i = 0; i < node.childNodes.length; i++) {
                descent(node.childNodes[i]);
        }
}

descent(table);

Parents Reply Children
  • I'm afraid to say it's a little buggy. descent(table) might be executed without table being set.

    The bug doesn't cause any problems, but still:

    // ==UserScript==
    // @name        Anti Shout
    // @namespace   kamikaze.bsdforen.de
    // @include     http://www.keil.com/forum/*
    // @description Scale down excessive shouting on the Keil forums
    // ==/UserScript==
    
    function descent(node) {
            if (node.data) {
                    var volume = node.data.match(/[A-Z]/g);
                    if (volume && volume.length / node.data.length > 0.5) {
                            node.parentNode.style.fontSize = "x-small";
                    }
            }
            for (var i = 0; i < node.childNodes.length; i++) {
                    descent(node.childNodes[i]);
            }
    }
    
    var tables = document.getElementsByTagName("table");
    for (var i = 0; i < tables.length; i++) {
            if (tables[i].getAttribute("class") == "thd") {
                    descent(tables[i]);
            }
    }
    

  • This update gets rid of a false positive condition.

    // ==UserScript==
    // @name        Anti Shout
    // @namespace   kamikaze.bsdforen.de
    // @include     http://www.keil.com/forum/*
    // @description Scale down excessive shouting on the Keil forums
    // ==/UserScript==
    
    function descent(node) {
            var length = 0;
            var shouted = 0;
            for (var i = 0; i < node.childNodes.length; i++) {
                    var child = node.childNodes[i];
                    if (child.data) {
                            var caps = child.data.match(/[A-Z]/g);
                            length += child.data.length;
                            if (caps) {
                                    shouted += caps.length;
                            }
                    } else {
                            descent(child);
                    }
            }
            if (length && shouted / length > 0.5) {
                    node.style.fontSize = "x-small";
            }
    }
    
    var tables = document.getElementsByTagName("td");
    for (var i = 0; i < tables.length; i++) {
            if (tables[i].getAttribute("class") == "bod") {
                    descent(tables[i]);
            }
    }
    

  • you could get Keil to incorporate it.

    Incorporating it locally will have no effect on the IDIOTs screen.

    Erik

  • Sadly, the days when you could break into a company's web service without repercussions, as long as you didn't do any real harm, are long over.