User:Abigor/sidebar.js

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
$(function(){
  var c = mw.config.get('wgServer') + mw.config.get('wgScript') + '?title=';
  var ts = 'http://toolserver.org/'
  var bTitle = wgTitle.split('/')[0];
  var bPageName = wgPageName.split('/')[0];
 
  // == navigation ==
  // remove
  var welc = document.getElementById('n-welcome');
  var port = document.getElementById('n-portal');
  if(welc) welc.parentNode.removeChild(welc);
  if(port) port.parentNode.removeChild(port);
 
  // add
  mw.util.addPortletLink('p-navigation', c+'COM:AN', "Admins' noticeboard", 'n-an');
  mw.util.addPortletLink('p-navigation', c+'COM:AN/B', "Blocks and protections", 'n-an/b');
  mw.util.addPortletLink('p-navigation', c+'COM:AN/V', "Vandalism", 'n-an/v');
  mw.util.addPortletLink('p-navigation', c+'COM:AN/U', "User problems", 'n-an/u');
  mw.util.addPortletLink('p-navigation', c+'COM:RV', 'Requests and votes', 'n-rfx');
  mw.util.addPortletLink('p-navigation', c+'COM:DR', 'Deletion requests', 'n-dr');
  mw.util.addPortletLink('p-navigation', c+'CAT:CSD', 'Speedy deletions', 'n-csd');
  mw.util.addPortletLink('p-navigation', c+'Category:Commons protected edit requests ', "Prot. requests", 'n-cat. prot. requests');
  mw.util.addPortletLink('p-navigation', c+'COM:FPC', 'FPC', 'n-fpc');
  mw.util.addPortletLink('p-navigation', c+'COM:QIC', 'QIC', 'n-qic');
  mw.util.addPortletLink('p-navigation', c+'COM:VIC', 'VIC', 'n-vic');
  mw.util.addPortletLink('p-navigation', c+'Special:SpecialPages', 'Special pages', 'n-specialpages');
 
  // == participate ==
  // remove
  var help = document.getElementById('n-help');
  var cont = document.getElementById('n-contact');
  var rand = document.getElementById('n-randomimage');
  var dona = document.getElementById('n-sitesupport');
  if(help) cont.parentNode.removeChild(help);
  if(cont) cont.parentNode.removeChild(cont);
  if(rand) rand.parentNode.removeChild(rand);
  if(dona) dona.parentNode.removeChild(dona);
 
  // add
  mw.util.addPortletLink('p-participate', c+'Special:NewPages&namespace=0&hidepatrolled=1&limit=500', 'New unpatrolled', 'n-newunpatrolled');
 
  // == toolbox ==
  // remove
  var prin = document.getElementById('t-print');
  var spec = document.getElementById('t-specialpages');
  if(prin) prin.parentNode.removeChild(prin);
  if(spec) spec.parentNode.removeChild(spec); // moving
 
  // add
  if(wgNamespaceNumber != -1){
    mw.util.addPortletLink('p-tb', c+'Special:WhatLinksHere/'+wgPageName+'&hidetrans=1&hidelinks=1', 'What redirects here', 't-redirects', '', '', document.getElementById('t-subpages'));
    mw.util.addPortletLink('p-tb', c+'Special:PrefixIndex&from='+wgTitle+'&namespace='+wgNamespaceNumber, 'Prefix index', 't-prefixindex');
  }
 
  if(wgNamespaceNumber == 2 || wgNamespaceNumber == 3){
    mw.util.addPortletLink('p-tb', c+'Special:Listusers&limit=1&username='+bTitle, 'User rights', 't-userrights');
    mw.util.addPortletLink('p-tb', ts+'~vvv/yaec.php?user='+bTitle+'&wiki=commonswiki_p', 'Edit counter', 't-editcounter');
    mw.util.addPortletLink('p-tb', ts+'~vvv/sulutil.php?user='+bTitle, 'SUL util', 't-sulutil');
  }
});
 
//