MediaWiki:RankColor.js: Difference between revisions

From Zelda Dungeon Wiki
Jump to navigation Jump to search
Want an adless experience? Log in or Create an account.
(addOnloadHook -> jQuery)
(update deprecated wg variables to mw.config ...and clean up the script. could be further optimized to not crawl the DOM 3 times though)
Line 6: Line 6:
// ("bodyContent" being everything but the tabs,personal links at the top of the screen and sidebar).
// ("bodyContent" being everything but the tabs,personal links at the top of the screen and sidebar).
// --------------------------------------------------------
// --------------------------------------------------------
var patrollerrights=new Array();
mw.loader.load( '/wiki/index.php?title=MediaWiki:Patrollerlist.js&action=raw&ctype=text/javascript' );
   
   
//Highlighting script. Based on [[User:ais523/highlightmyname.js]].
//Highlighting script. Based on [[User:ais523/highlightmyname.js]].
   
   
function highlightpatrollers(n,p) //node, parent node
function highlight(a,c,n) { // users array, color, node
{
  if (!n) n = document.getElementById('bodyContent').firstChild;
   while(n!=null)
 
  {
   while(n!=null) {
     if(n.nodeType==1&&n.tagName.toLowerCase()=="a") //anchor
     if(n.nodeType==1&&n.tagName.toLowerCase()=="a") { //anchor
    {
       if(n.href.indexOf("/User:")!=-1) {
       if(n.href.indexOf("/User:")!=-1)
      {
         var u=n.href.split("/User:")[1];
         var u=n.href.split("/User:")[1];
         if(patrollerrights[u.split("_").join("%20")]==1)
         if(a[u.split("_").join("%20")]==1) n.style.color=c;
        {
       } else if(n.href.indexOf("/index.php?title=User:")!=-1) {
          n.style.color="#E99216";
        }
       }
      else if(n.href.indexOf("/index.php?title=User:")!=-1)
      {
         var u=n.href.split("/index.php?title=User:")[1];
         var u=n.href.split("/index.php?title=User:")[1];
         if(patrollerrights[u.split("_").join("%20")]==1)
         if(a[u.split("_").join("%20")]==1) n.style.color=c;
        {
       } else {
          n.style.color="#E99216";
         if(n.firstChild!=null) highlight(a,c,n.firstChild);
        }
       }
      else
      {
         if(n.firstChild!=null) highlightpatrollers(n.firstChild,n);
       }
       }
    } else {
      if(n.firstChild!=null) highlight(a,c,n.firstChild);
     }
     }
    else
 
    {
      if(n.firstChild!=null) highlightpatrollers(n.firstChild,n);
    }
     n=n.nextSibling;
     n=n.nextSibling;
   }
   }
}
}


 
var patrollerrights=new Array();
if (wgCanonicalNamespace == 'Special' || wgAction == 'history' || document.URL.indexOf('diff=') > 0 || document.URL.indexOf('oldid=') > 0)
mw.loader.load( '/wiki/index.php?title=MediaWiki:Patrollerlist.js&action=raw&ctype=text/javascript' );
{
jQuery(function() {
    highlightpatrollers(document.getElementById('bodyContent').firstChild,
                    document.getElementById('bodyContent'));
});
}


var adminrights=new Array();
var adminrights=new Array();
mw.loader.load( '/wiki/index.php?title=MediaWiki:Adminlist.js&action=raw&ctype=text/javascript' );
mw.loader.load( '/wiki/index.php?title=MediaWiki:Adminlist.js&action=raw&ctype=text/javascript' );
//Highlighting script. Based on [[User:ais523/highlightmyname.js]].
function highlightadmins(n,p) //node, parent node
{
  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(adminrights[u.split("_").join("%20")]==1)
        {
          n.style.color="#2BA206";
        }
      }
      else if(n.href.indexOf("/index.php?title=User:")!=-1)
      {
        var u=n.href.split("/index.php?title=User:")[1];
        if(adminrights[u.split("_").join("%20")]==1)
        {
          n.style.color="#2BA206";
        }
      }
      else
      {
        if(n.firstChild!=null) highlightadmins(n.firstChild,n);
      }
    }
    else
    {
      if(n.firstChild!=null) highlightadmins(n.firstChild,n);
    }
    n=n.nextSibling;
  }
}
if (wgCanonicalNamespace == 'Special' || wgAction == 'history' || document.URL.indexOf('diff=') > 0 || document.URL.indexOf('oldid=') > 0)
{
jQuery(function() {
    highlightadmins(document.getElementById('bodyContent').firstChild,
                    document.getElementById('bodyContent'));
});
}


var botrights=new Array();
var botrights=new Array();
mw.loader.load( '/wiki/index.php?title=MediaWiki:Botlist.js&action=raw&ctype=text/javascript' );
mw.loader.load( '/wiki/index.php?title=MediaWiki:Botlist.js&action=raw&ctype=text/javascript' );
//Highlighting script. Based on [[User:ais523/highlightmyname.js]].
function highlightbots(n,p) //node, parent node
{
  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(botrights[u.split("_").join("%20")]==1)
        {
          n.style.color="#3EB8C6";
        }
      }
      else if(n.href.indexOf("/index.php?title=User:")!=-1)
      {
        var u=n.href.split("/index.php?title=User:")[1];
        if(botrights[u.split("_").join("%20")]==1)
        {
          n.style.color="#3EB8C6";
        }
      }
      else
      {
        if(n.firstChild!=null) highlightbots(n.firstChild,n);
      }
    }
    else
    {
      if(n.firstChild!=null) highlightbots(n.firstChild,n);
    }
    n=n.nextSibling;
  }
}


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

Revision as of 04:32, March 19, 2017

// --------------------------------------------------------
// 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, "#2BA206");
    highlight(botrights, "#3EB8C6");
  });
}