VOOZH about

URL: https://minecraft.wiki/w/MediaWiki:Gadget-blueUsers.js

⇱ MediaWiki:Gadget-blueUsers.js – Minecraft Wiki


MediaWiki:Gadget-blueUsers.js

From Minecraft Wiki
Jump to navigation Jump to search
In other languages

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 key and click the Reload toolbar button.
For details and instructions about other browsers, see Wikipedia:Bypass your cache.

mw.loader.using(['mediawiki.api','mediawiki.util']).then(function(){
constnamespaceIds=mw.config.get('wgNamespaceIds');
constnamespaces=Object.keys(namespaceIds).filter(ns=>namespaceIds[ns]===2);
constselector=namespaces.map(ns=>mw.config.get('wgArticlePath').replace('$1',ns+':').toLowerCase());
// User cache to not check them multiple times.
varblueUsers=[];
varmissingUsers=[];
if(mw.config.get('wgUserName')){
blueUsers.push(mw.util.wikiUrlencode(mw.config.get('wgUserName')));
}
varapi=newmw.Api({
parameters:{
action:'query',
list:'users',
formatversion:2
},
userAgent:'Gadget-blueUsers'
});
// Run every time content is added
mw.hook('wikipage.content').add(makeUsersBlue);
// Catch links outside the content area
makeUsersBlue($('a.new').not('#mw-content-text a.new').parent());
functionmakeUsersBlue($content){
varusers=[];
varuserlinks=$content.find('a.new').filter(function(){
varpathname=decodeURIComponent(this.pathname).toLowerCase();
returnselector.some(ns=>pathname.startsWith(ns));
}).each(function(){
varencodedUsername=this.pathname.split(':')[1];
if(missingUsers.includes(encodedUsername))return;
if(blueUsers.includes(encodedUsername)){
this.href=this.pathname;
this.classList.remove('new');
this.classList.add('mw-newuserlink');
return;
}
varusername=decodeURIComponent(encodedUsername);
if(users.includes(username)||username.includes('/'))return;
users.push(username);
});
if(!users.length)return;
varapiRequests=[];
while(users.length){
apiRequests.push(api.get({
ususers:users.splice(0,50)
}).then(function(data){
data.query.users.forEach(function(user){
if(user.missing||user.invalid){
missingUsers.push(mw.util.wikiUrlencode(user.name));
return;
}
blueUsers.push(mw.util.wikiUrlencode(user.name));
});
}));
}
Promise.all(apiRequests).then(function(){
userlinks.each(function(){
if(!blueUsers.includes(this.pathname.split(':')[1]))return;
this.href=this.pathname;
this.classList.remove('new');
this.classList.add('mw-newuserlink');
});
});
}
});
Retrieved from "https://minecraft.wiki/w/MediaWiki:Gadget-blueUsers.js?oldid=3602654"

Navigation menu