User:Peoplelikeyou/common.js: Difference between revisions

From Test Wiki
Jump to navigation Jump to search
No edit summary
Tag: Manual revert
No edit summary
Line 1: Line 1:
var adminrights = {};
//adapted from [[User:ais523/adminrights.js]]
//
//Start of section to update
// This script highlights bluelinks to selected users' userpages or talkpages in bodyContent
 
var userlist=new Array();
 
adminrights['3PPYB6']=1;
adminrights['3PPYB6']=1;
adminrights['Abuse%20filter']=1;
adminrights['Abuse%20filter']=1;
Line 7: Line 10:
adminrights['Brewster239']=1;
adminrights['Brewster239']=1;
adminrights['C1K98V']=1;
adminrights['C1K98V']=1;
//End of section to update
 
//Highlighting script. Based on [[User:ais523/highlightmyname.js]].
//Updating script
 
$( function() {
function highlightusers_inner(n,h) //node, relevant hyperlink fragment
   if(location.href==mw.config.get( 'wgServer' )+ mw.config.get( 'wgScript') + "?title=Special:ListUsers&limit=5000&"+
{
                    "group=sysop&adminupdate=y")
   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(userlist[u.split("_").join("%20")]==1)
   {
   {
     var h=document.getElementById('bodyContent').innerHTML;
     n.style.backgroundColor="#FACDD5";
    var a= [];
  }
    h=h.split(/\< *li *\>/i);
  return 1;
    var i=0;
}
    while(++i<h.length)
 
    {
function highlightusers(n) //node
      a[h[i].split(">")[1].split("<")[0]]=h[i].split(/\< *\/ *li *\>/i)[0];
{
     }
  while(n!=null)
    for(i in a)
  {
    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
     {
     {
       document.write("adminrights['"+
       if(n.firstChild!=null) highlightusers(n.firstChild);
        encodeURIComponent(i).split("\\").join("\\\\").split("'").join("%27")
      n=n.nextSibling;
                            .split("(").join("%28").split(")").join("%29")
                            .split("!").join("%21").split(",").join("%2C")
                            .split("%3A").join(":")+"']=1;<BR/>");
     }
     }
   }
   }
}
$(function() {
    highlightusers(document.getElementById('bodyContent'));
});
});
 
$( function() {
//[[Category:Wikipedia scripts]]
  if( location.href.indexOf("?adminupdate") == -1 && location.href.indexOf("&adminupdate")==-1 &&
    mw.config.get( 'wgAction') != 'edit' && mw.config.get( 'wgAction') != 'submit' &&
    mw.config.get( 'wgPageName')!="Special:Preferences")
  {
  $("#bodyContent a").each(function() {
  linkTarget = $(this).attr("href");
  if(linkTarget !== undefined && linkTarget.startsWith("/wiki/User_talk:")) {
  pageTitle = linkTarget.split("/wiki/User_talk:")
  if(adminrights[pageTitle[1].replace("_", " ")]==1) {
  $(this).addClass("adminrights_admin");
  $(this).css("background-color", "#BBFFFF");
  }
  }
  });
  }
});

Revision as of 05:21, 24 October 2022

//adapted from [[User:ais523/adminrights.js]]
//
// This script highlights bluelinks to selected users' userpages or talkpages in bodyContent 

var userlist=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(userlist[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]]