User:Peoplelikeyou/common.js: Difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
No edit summary Tag: Reverted |
No edit summary Tag: Reverted |
||
Line 1: | Line 1: | ||
var adminrights = {}; |
|||
//This script ([[User:ais523/highlightmyname.js]]) highlights all instances of the |
|||
//logged-in user's username on pages by giving them a bright red background. It only |
|||
//Start of section to update |
|||
//checks bodyContent, not titles or sidebars. |
|||
adminrights['3PPYB6']=1; |
|||
adminrights['Abuse%20filter']=1; |
|||
//<nowiki><pre> |
|||
adminrights['AlPaD']=1; |
|||
function highlightmyname(n,p) //node, parent node |
|||
adminrights['Brewster239']=1; |
|||
{ |
|||
adminrights['C1K98V']=1; |
|||
while(n!=null) |
|||
//End of section to update |
|||
//Updating script |
|||
⚫ | |||
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 |
|||
⚫ | |||
h=h.split(/\< *li *\>/i); |
|||
⚫ | |||
while(++i<h.length) |
|||
{ |
{ |
||
a[h[i].split(">")[1].split("<")[0]]=h[i].split(/\< *\/ *li *\>/i)[0]; |
|||
if(n.data.toLowerCase().indexOf(mw.config.get('wgUserName').toLowerCase())!=-1) |
|||
⚫ | |||
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; |
|||
} |
} |
||
for(i in a) |
|||
{ |
{ |
||
document.write("adminrights['"+ |
|||
if(n.firstChild!=null) highlightmyname(n.firstChild,n); |
|||
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/>"); |
|||
} |
} |
||
} |
} |
||
} |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
document.getElementById('bodyContent')); |
|||
}); |
}); |
||
//</pre></nowiki> |
|||
$( function() { |
|||
//[[Category:Wikipedia scripts]] |
|||
⚫ | |||
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");
}
}
});
}
});