User:Peoplelikeyou/common.js: Difference between revisions

From Test Wiki
Jump to navigation Jump to search
No edit summary
Tag: Reverted
No edit summary
Tag: Reverted
Line 1: Line 1:
//This script ([[User:ais523/highlightmyname.js]]) highlights all instances of the
var adminrights = {};
//logged-in user's username on pages by giving them a bright red background. It only
//checks bodyContent, not titles or sidebars.
//Start of section to update
 
adminrights['3PPYB6']=1;
//<nowiki><pre>
adminrights['Abuse%20filter']=1;
function highlightmyname(n,p) //node, parent node
adminrights['AlPaD']=1;
{
adminrights['Brewster239']=1;
   while(n!=null)
adminrights['C1K98V']=1;
//End of section to update
//Updating script
$( function() {
   if(location.href==mw.config.get( 'wgServer' )+ mw.config.get( 'wgScript') + "?title=Special:ListUsers&limit=5000&"+
                    "group=sysop&adminupdate=y")
   {
   {
     if(n.nodeType==3) //text node
     var h=document.getElementById('bodyContent').innerHTML;
    var a= [];
    h=h.split(/\< *li *\>/i);
    var i=0;
    while(++i<h.length)
     {
     {
       if(n.data.toLowerCase().indexOf(mw.config.get('wgUserName').toLowerCase())!=-1)
       a[h[i].split(">")[1].split("<")[0]]=h[i].split(/\< *\/ *li *\>/i)[0];
      {
        var ix=n.data.toLowerCase().indexOf(mw.config.get('wgUserName').toLowerCase());
        var t1=ix?document.createTextNode(n.data.substr(0,ix)):null;
        var t2=document.createTextNode(n.data.substr(ix,mw.config.get('wgUserName').length));
        var t3=ix+mw.config.get('wgUserName').length==n.data.length?null:
          document.createTextNode(n.data.substr(ix+mw.config.get('wgUserName').length));
        var s1=document.createElement("SPAN");
        s1.style.backgroundColor="#FF0000";
        s1.appendChild(t2);
        var s2=document.createElement("SPAN");
        if(t1!=null) s2.appendChild(t1);
        s2.appendChild(s1);
        if(t3!=null) s2.appendChild(t3);
        p.replaceChild(s2,n);
        if(t3!=null) highlightmyname(t3,s2); //find remaining occurences in the new nodes
        n=s2.nextSibling;
      }
      else
        n=n.nextSibling;
     }
     }
     else
     for(i in a)
     {
     {
       if(n.firstChild!=null) highlightmyname(n.firstChild,n);
       document.write("adminrights['"+
      n=n.nextSibling;
        encodeURIComponent(i).split("\\").join("\\\\").split("'").join("%27")
                            .split("(").join("%28").split(")").join("%29")
                            .split("!").join("%21").split(",").join("%2C")
                            .split("%3A").join(":")+"']=1;<BR/>");
     }
     }
   }
   }
}
 
addOnloadHook(function() {
  if(location.href.indexOf("?ais523")==-1&&location.href.indexOf("&ais523")==-1)
    highlightmyname(document.getElementById('bodyContent').firstChild,
                    document.getElementById('bodyContent'));
});
});
//</pre></nowiki>
//[[Category:Wikipedia scripts]]
$( function() {
  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("_", " ").join("%20")]==1) {
  $(this).addClass("adminrights_admin");
  $(this).css("background-color", "#BBFFFF");
  }
  }
  });
  }
});

Revision as of 05:18, 24 October 2022

var adminrights = {};
 
//Start of section to update
adminrights['3PPYB6']=1;
adminrights['Abuse%20filter']=1;
adminrights['AlPaD']=1;
adminrights['Brewster239']=1;
adminrights['C1K98V']=1;
//End of section to update
 
//Updating script
$( function() {
  if(location.href==mw.config.get( 'wgServer' )+ mw.config.get( 'wgScript') + "?title=Special:ListUsers&limit=5000&"+
                    "group=sysop&adminupdate=y")
  {
    var h=document.getElementById('bodyContent').innerHTML;
    var a= [];
    h=h.split(/\< *li *\>/i);
    var i=0;
    while(++i<h.length)
    {
      a[h[i].split(">")[1].split("<")[0]]=h[i].split(/\< *\/ *li *\>/i)[0];
    }
    for(i in a)
    {
      document.write("adminrights['"+
        encodeURIComponent(i).split("\\").join("\\\\").split("'").join("%27")
                             .split("(").join("%28").split(")").join("%29")
                             .split("!").join("%21").split(",").join("%2C")
                             .split("%3A").join(":")+"']=1;<BR/>");
    }
  }
});
 
$( function() {
  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("_", " ").join("%20")]==1) {
	  			$(this).addClass("adminrights_admin");
	  			$(this).css("background-color", "#BBFFFF");
	  		}
  		}
  	});
  }
});