Jump to content

User:Supdiop/rollbackhighlighter.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Supdiop (talk | contribs) at 15:06, 1 August 2015 (Test). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
;(function($){
	$.getCurrentAdmins( $wi ), function(data){
		$(function(){
			function highlightadmins_inner(n,h) //node, relevant hyperlink fragment
			{
			  if (n.nodeType!=1||n.tagName.toLowerCase()!="a") return 0; // not an anchor
			  if (n.href.indexOf(mw.config.get('wgScript')+"?title="+h) == -1 &&
			      n.href.indexOf(mw.config.get('wgArticlePath').split("$1")[0]+h) == -1) return 0; // to the wrong target
			  var u=decodeURIComponent(n.href).split(h)[1];
			  if(data[u.split("_").join(" ")]==1)
			  {
			    n.style.backgroundColor="green";
			    if(n.className==null||n.className=="") n.className="amalthea_userhighlighter_sysop";
			    else n.className+=" amalthea_userhighlighter_sysop";
			  }
			  return 1;
			}
			 
			function highlightadmins(n) //node
			{
			  while(n!=null)
			  {
			    if(highlightadmins_inner(n,"User:")) n=n.nextSibling;
			    else if(highlightadmins_inner(n,"User_talk:")) n=n.nextSibling;
			    else if(highlightadmins_inner(n,"Special:Contributions:")) n=n.nextSibling;
			    else
			    {
			      if(n.firstChild!=null) highlightadmins(n.firstChild);
			      n=n.nextSibling;
			    }
			  }
			}
			
			highlightadmins(document.getElementById('bodyContent'));			
		});	
	});
}(jQuery));