User:Bugghost/Scripts/UserRoleIndicator.js: Difference between revisions

Content deleted Content added
oops
added the ability to do custom labels (hopefully)
Line 17:
async execute() {
const defaultRoleInfoLookup = {
wmf: ['๐ŸŒ', 'Wikimedia Foundation (WMF)'],
stewards: ['๐Ÿฉบ', 'Steward or Ombud'],
arbcom: ['โš–๏ธ', 'Arbitration Committee member'],
bureaucrats: ['๐Ÿ’ผโ€', 'Bureaucrat'],
admins: ['๐Ÿงน', 'Admin'],
formerAdmins: ['๐Ÿšฌ', 'Former Admin'],
newPageReviewers: ['๐Ÿงบ', 'New page reviewer'],
tenThousandEdits: ['๐Ÿฅ‡', 'More than 10,000 edits'],
extendedConfirmed: ['๐Ÿ“š', 'Extended confirmed'],
lessThan500: ['๐Ÿฃ', 'Less than 500 edits'],
};
 
if(this.window.UserRoleIndicatorCustomLabels){
this.roleInfoLookup = { ...defaultRoleInfoLookup, ...window.UserRoleIndicatorCustomLabels };
}
 
// console.time("get usernames")
await this.getUsernames();
Line 247 โŸถ 264:
 
addRoleInfoIfNeeded() {
const roleInfoLookup = {
wmf: ['๐ŸŒ', 'Wikimedia Foundation (WMF)'],
stewards: ['๐Ÿฉบ', 'Steward or Ombud'],
arbcom: ['โš–๏ธ', 'Arbitration Committee member'],
bureaucrats: ['๐Ÿ’ผโ€', 'Bureaucrat'],
admins: ['๐Ÿงน', 'Admin'],
formerAdmins: ['๐Ÿšฌ', 'Former Admin'],
newPageReviewers: ['๐Ÿงบ', 'New page reviewer'],
tenThousandEdits: ['๐Ÿฅ‡', 'More than 10,000 edits'],
extendedConfirmed: ['๐Ÿ“š', 'Extended confirmed'],
lessThan500: ['๐Ÿฃ', 'Less than 500 edits'],
};
// highlight anybody with "WMF" in their name, case insensitive. this should not generate false positives because "WMF" is on the username blacklist. see https://meta.wikimedia.org/wiki/Title_blacklist
Line 266 โŸถ 271:
 
// TODO: grab the order from an array, so I can keep checkForPermission and addCSS in the same order easily, lowering the risk of the HTML title="" being one thing, and the color being another
this.addRoleInfoIfAppropriate( this.wmf, this.roleInfoLookup.wmf[0], this.roleInfoLookup.wmf[1]);
this.addRoleInfoIfAppropriate( this.stewards, this.roleInfoLookup.stewards[0], this.roleInfoLookup.stewards[1]);
this.addRoleInfoIfAppropriate( this.arbcom, this.roleInfoLookup.arbcom[0], this.roleInfoLookup.arbcom[1]);
this.addRoleInfoIfAppropriate( this.bureaucrats, this.roleInfoLookup.bureaucrats[0], this.roleInfoLookup.bureaucrats[1]);
this.addRoleInfoIfAppropriate( this.admins, this.roleInfoLookup.admins[0], this.roleInfoLookup.admins[1]);
this.addRoleInfoIfAppropriate( this.formerAdmins, this.roleInfoLookup.formerAdmins[0], this.roleInfoLookup.formerAdmins[1]);
this.addRoleInfoIfAppropriate( this.newPageReviewers, this.roleInfoLookup.newPageReviewers[0], this.roleInfoLookup.newPageReviewers[1]);
this.addRoleInfoIfAppropriate( this.tenThousandEdits, this.roleInfoLookup.tenThousandEdits[0], this.roleInfoLookup.tenThousandEdits[1]);
this.addRoleInfoIfAppropriate( this.extendedConfirmed, this.roleInfoLookup.extendedConfirmed[0], this.roleInfoLookup.extendedConfirmed[1]);
 
// If they have no perms, then they are non-EC, so <500 edits
if ( !this.hasAdvancedPermissions ) {
this.addRoleIcon(this.roleInfoLookup.lessThan500[0], this.roleInfoLookup.lessThan500[1]);
}
}