MediaWiki:RankColor.js

From Zelda Dungeon Wiki
Revision as of 04:52, March 19, 2017 by Emma (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Want an adless experience? Log in or Create an account.

Note: After saving, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: hold Shift while clicking Reload, or press either Ctrl+F5 or Ctrl+R (Command+R on a Mac)
  • Google Chrome: press Ctrl+Shift+R (Command+Shift+R on a Mac)
  • Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl+F5
  • Konqueror: click Reload or press F5
  • Opera: clear the cache in Tools → Preferences
// --------------------------------------------------------
// Rank Coloring
// (adapted from http://en.wikipedia.org/wiki/User:Ais523/adminrights.js)
// This script changes the color of links to admins' and patrollers' userpages in the bodyContent of Special, History pages, diff pages,
// and old page revisions.
// ("bodyContent" being everything but the tabs,personal links at the top of the screen and sidebar).
// --------------------------------------------------------
 
//Highlighting script. Based on [[User:ais523/highlightmyname.js]].
 
function highlight(a,c,n) { // users array, color, node
  if (!n) n = document.getElementById('bodyContent').firstChild;

  while(n!=null) {
    if(n.nodeType==1&&n.tagName.toLowerCase()=="a") { //anchor
      if(n.href.indexOf("/User:")!=-1) {
        var u=n.href.split("/User:")[1];
        if(a[u.split("_").join("%20")]==1) n.style.color=c;
      } else if(n.href.indexOf("/index.php?title=User:")!=-1) {
        var u=n.href.split("/index.php?title=User:")[1];
        if(a[u.split("_").join("%20")]==1) n.style.color=c;
      } else {
        if(n.firstChild!=null) highlight(a,c,n.firstChild);
      }
    } else {
      if(n.firstChild!=null) highlight(a,c,n.firstChild);
    }

    n=n.nextSibling;
  }
}

var patrollerrights=new Array();
mw.loader.load( '/wiki/index.php?title=MediaWiki:Patrollerlist.js&action=raw&ctype=text/javascript' );

var adminrights=new Array();
mw.loader.load( '/wiki/index.php?title=MediaWiki:Adminlist.js&action=raw&ctype=text/javascript' );

var botrights=new Array();
mw.loader.load( '/wiki/index.php?title=MediaWiki:Botlist.js&action=raw&ctype=text/javascript' );

if (mw.config.get('wgCanonicalNamespace') == 'Special' || mw.config.get('wgAction') == 'history' || document.URL.indexOf('diff=') > 0 || document.URL.indexOf('oldid=') > 0) {
  jQuery(function() {
    highlight(patrollerrights, "#E99216");
    highlight(adminrights, "#9B508A");
    highlight(botrights, "#3EB8C6");
  });
}