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

Content deleted Content added
hand writing icon wasn't displaying correctly in my version of firefox - ๐Ÿ“š seems to appear better. also swapping NPP to ๐Ÿงบ (rather than ๐Ÿงฝ)
refactoring to allow for custom labels
Line 37:
}
this.hasAdvancedPermissions = false;
this.addClassesAndHoverTextToLinkIfNeededaddRoleInfoIfNeeded();
} );
// console.timeEnd("linkloop")
Line 97:
this.bureaucrats = dataJSON.bureaucrat;
this.admins = dataJSON.sysop;
this.formeradminsformerAdmins = dataJSON.formeradmin;
this.newPageReviewers = dataJSON.patroller;
this.tenThousandEdits = dataJSON[ '10k' ];
Line 229:
}
 
checkForPermissionaddRoleInfoIfAppropriate( listOfUsernames, classNamelabel, descriptionForHover ) {
if ( listOfUsernames[ this.user ] === 1 ) {
this.addRoleIcon( classNamelabel, descriptionForHover );
}
}
Line 246:
}
 
addRoleInfoIfNeeded() {
addClassesAndHoverTextToLinkIfNeeded() {
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
if ( this.user.match( /^[^/]*WMF/i ) ) {
Line 253 โŸถ 266:
 
// 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.checkForPermissionaddRoleInfoIfAppropriate( this.wmf, '๐ŸŒ'roleLookup.wmf[0], 'Wikimedia Foundation (WMF)' roleLookup.wmf[1]);
this.checkForPermissionaddRoleInfoIfAppropriate( this.stewards, '๐Ÿฉบ'roleLookup.stewards[0], 'Steward or Ombud' roleLookup.stewards[1]);
this.checkForPermissionaddRoleInfoIfAppropriate( this.arbcom, 'โš–๏ธ'roleLookup.arbcom[0], 'Arbitration Committee member' roleLookup.arbcom[1]);
this.checkForPermissionaddRoleInfoIfAppropriate( this.bureaucrats, '๐Ÿ’ผโ€'roleLookup.bureaucrats[0], 'Bureaucrat' roleLookup.bureaucrats[1]);
this.checkForPermissionaddRoleInfoIfAppropriate( this.admins, '๐Ÿงน'roleLookup.admins[0], 'Admin' roleLookup.admins[1]);
this.addRoleInfoIfAppropriate( this.formerAdmins, roleLookup.formerAdmins[0], roleLookup.formerAdmins[1]);
this.checkForPermission( this.formeradmins, '๐Ÿšฌ', 'Former Admin' );
this.checkForPermissionaddRoleInfoIfAppropriate( this.newPageReviewers, '๐Ÿงบ'roleLookup.newPageReviewers[0], 'New page reviewer' roleLookup.newPageReviewers[1]);
this.checkForPermissionaddRoleInfoIfAppropriate( this.tenThousandEdits, '๐Ÿฅ‡'roleLookup.tenThousandEdits[0], 'More than 10,000 edits' roleLookup.tenThousandEdits[1]);
this.checkForPermissionaddRoleInfoIfAppropriate( this.extendedConfirmed, '๐Ÿ“š'roleLookup.extendedConfirmed[0], 'Extended confirmed' roleLookup.extendedConfirmed[1]);
 
// If they have no perms, then they are non-EC, so <500 edits
if ( !this.hasAdvancedPermissions ) {
this.addRoleIcon("๐Ÿฃ"roleInfoLookup.lessThan500[0], "Less than 500 edits"roleInfoLookup.lessThan500[1]);
}
}