User:Nihiltres/monobook.js

From Wikipedia, the free encyclopedia

If a message on your talk page led you here, please be wary of who left it. The code below could contain malicious content capable of compromising your account; if your account appears to be compromised, it will be blocked. If you are unsure whether the code is safe, you can ask at the appropriate village pump.
Note: After saving, you have to bypass your browser's cache to see the changes. In Internet Explorer and Firefox, hold down the Ctrl key and click the Refresh or Reload button. Opera users have to clear their caches through Tools→Preferences, see the instructions for Opera. Konqueror and Safari users can just click the Reload button.
// Tab name fixer (copied from User:Anomie/fix-tab-text.js, target content modified)
/* A simple javascript function to change the text in various tabs at the top of the
 * page. Only tested with the monobook skin.
 */
addOnloadHook(function(){
    var fix=function(id, text){
        var el=document.getElementById(id);
        if(!el) return;
        for(el=el.firstChild; el && el.nodeName!='A'; el=el.nextSibling);
        if(!el) return;
        while(el.firstChild) el.removeChild(el.firstChild);
        el.appendChild(document.createTextNode(text));
    }
 
    /* Add lines as necessary. Use the Firefox DOM inspector or some such to determine
     * the appropriate IDs.
     */
//(disabled via commenting)    fix('ca-talk', 'discussion');
    fix('ca-edit', 'edit');
    fix('pt-preferences', 'preferences');
    fix('pt-watchlist', 'watchlist');
    fix('pt-mytalk', 'talk');
    fix('pt-mycontris', 'contributions');
});
//end tab name fixer
 
//Personal link function, code (but not content) copied from User:Adrian M. H./monobook.js
addOnloadHook(function() {
addPortletLink('p-personal','/wiki/Special:Log?user=Nihiltres','log','pt-log','Log of my non-edit actions','',document.getElementById('pt-mycontris'));
});
//a second one...
addOnloadHook(function() {
addPortletLink('p-personal','/wiki/User:Nihiltres/Sandbox','sandbox','pt-sandbox','My sandbox','',document.getElementById('pt-preferences'));
});
//end personal link function
 
//add a purge tab, URL bits started by me, but really the credit for this goes to User:Animum, thank you :)
addOnloadHook(function() {
  if (wgCanonicalNamespace != 'Special')
    {
addPortletLink('p-cactions', wgServer + wgScript + '?title=' + wgPageName + '&action=purge', 'purge', 'ca-purge', 'Purge the server cache of this page', null, (document.getElementById('ca-watch') ? document.getElementById('ca-watch') : document.getElementById('ca-unwatch')));
//and apply the "selected" class, so that one can confirm that the page has been purged. This subroutine is all my own, I'm so proud :p
    if (wgAction == "purge")
       {
document.getElementById('ca-purge').className='selected'
       }
    }
});
//end purge tab
 
//auto-check the "watch this page" tab when editing the MediaWiki namespace, my own code.
addOnloadHook(function() {
  if (wgCanonicalNamespace == 'MediaWiki' && wgAction == "edit")
    {
document.getElementById('wpWatchthis').checked = true;
    }
});
 
//end auto-check for MediaWiki-space editing
 
/* disabled because I don't know if I want it; also unfinished - needs to get rid of old block link once done.
//block tab, rather than toolbox - the toolbox feels far off. Not that I like blocking, seriously.
 
function getUserName(){
 
  switch (wgCanonicalNamespace) {
    case 'User': case 'User_talk': return wgTitle.split('/')[0];
    default: return null;
  }
 
}
 
addOnloadHook(function() {
  switch (getUserName()) {
case null: return null;
default: addPortletLink('p-cactions', 'http://en.wikipedia.org/wiki/Special:Blockip/' + getUserName(), 'block', 'ca-block', 'Block this user', null, document.getElementById('ca-edit'));
 
INSERT ORIGINAL-BLOCKLINK-REMOVING-CODE-HERE
 
}
});
 
//end block tab
*/