User:Peoplelikeyou/common.js

From Test Wiki
Revision as of 05:23, 24 October 2022 by Peoplelikeyou (talk | contribs)

Note: After publishing, 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 (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
//adapted from [[User:ais523/adminrights.js]]
//
// This script highlights bluelinks to selected users' userpages or talkpages in bodyContent 

var adminrights=new Array();

adminrights['3PPYB6']=1;
adminrights['Abuse%20filter']=1;
adminrights['AlPaD']=1;
adminrights['Brewster239']=1;
adminrights['C1K98V']=1;

//Highlighting script. Based on [[User:ais523/highlightmyname.js]].

function highlightusers_inner(n,h) //node, relevant hyperlink fragment
{
  if (n.nodeType!=1||n.tagName.toLowerCase()!="a") return 0; // not an anchor
  if (n.href.indexOf(wgScript+"?title="+h) == -1 &&
      n.href.indexOf(wgArticlePath.split("$1")[0]+h) == -1) return 0; // to the wrong target
  var u=n.href.split(h)[1];
  if(adminrights[u.split("_").join("%20")]==1)
  {
    n.style.backgroundColor="#FACDD5";
  }
  return 1;
}

function highlightusers(n) //node
{
  while(n!=null)
  {
    if(highlightusers_inner(n,"User:")) n=n.nextSibling;
    else if(highlightusers_inner(n,"User_talk:")) n=n.nextSibling;
    else if(highlightusers_inner(n,"Special:Contributions:")) n=n.nextSibling;
    else
    {
      if(n.firstChild!=null) highlightusers(n.firstChild);
      n=n.nextSibling;
    }
  }
}

$(function() {
    highlightusers(document.getElementById('bodyContent'));
});

//[[Category:Wikipedia scripts]]