User:Splarka/monobook.js
From Wikipedia
Note: After saving, you may have to bypass your browser's cache to see the changes. Mozilla / Firefox / Safari: hold down Shift while clicking Reload, or press Ctrl-Shift-R (Cmd-Shift-R on Apple Mac); IE: hold Ctrl while clicking Refresh, or press Ctrl-F5; Konqueror:: simply click the Reload button, or press F5; Opera users may need to completely clear their cache in Tools→Preferences.
/** body action class ***********************************************************
*
* Description: Sets a class on the body tag specifying significant actions for
* possible styling (similar to per-page classes).
*
* Takes the action= parameter (assumes action=view default) and
* creates a body tag class for it.
* A diff= parameter overwrites any action= with 'action-diff'
* An oldid= parameter appends a second class 'action-oldid'
* So, &action=edit&oldid=### will be 'action-edit action-diff'
* http://www.mediawiki.org/wiki/Manual:Parameters_to_index.php
*
* Experimental, would be better server-side (hint hint)
*/
function actionClass() {
var action='';
if(queryString('action')) {
// watch unwatch delete revert rollback protect unprotect
// info markpatrolled purge credits submit edit history
action = ' action-' + queryString('action').replace(/\W/g,'_');
} else {
action = ' action-view';
}
if(queryString('diff')) action = ' action-diff'; // overwrite
if(queryString('oldid')) action += ' action-oldid'; // append
document.getElementsByTagName('body')[0].className += action;
}
addOnloadHook(actionClass);
function queryString(p) {
var re = RegExp('[&?]' + p + '=([^&]*)');
var matches;
if (matches = re.exec(document.location)) {
try {
return decodeURI(matches[1]);
} catch (e) {
}
}
return null;
}
function debugAC() {
if(queryString('debug')) alert(document.getElementsByTagName('body')[0].className);
}
addOnloadHook(debugAC);

