// ==UserScript==
// @name            Body ID for all
// @namespace       http://people.opera.com/rijk/opera/scripts/
// @description     Adds an ID attribute to body elements
// @include         *
// ==/UserScript==

/*
  ID value is build from the server name:
   - www is dropped
   - dots are replaced with dashes
   - numbers are prepended with an underscore

  Rewritten by liorean, 2005-03-20. Repackaged by Rijk.
*/

(function() {
    if(document.body){
        var
            b=document.body;
        if(!b.hasAttribute('id'))
            b.setAttribute('id',location.host
                .replace(/^www\./,'')
                .replace(/^\d/,'_$&')
                .replace(/\./g,'-'));
    // debug: uncomment the next line to see the body-IDs (this gets old really fast)
    //  alert(document.body.id);
    }
})();

