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

Content deleted Content added
minor aesthetic changes
hand writing icon wasn't displaying correctly in my version of firefox - ๐Ÿ“š seems to appear better. also swapping NPP to ๐Ÿงบ (rather than ๐Ÿงฝ)
Line 1:
// [[User:Bugghost]]
// <nowiki>
// Copied and edited from novemNovem linguaeLinguae's user highlighter simple: [[User:Novem_Linguae/Scripts/UserHighlighterSimple.js]]
 
class UserRoleIndicator {
Line 18 โŸถ 17:
async execute() {
// console.time("get usernames")
await this.getUsernames();
// console.timeEnd("get usernames")
this.addCSS('user-role-indicator', 'font-size: smaller; display: inline; background: #b7b9ff55; padding: 0.1em; border-radius: 5px; margin-left: 3px;')
Line 26 โŸถ 25:
const $links = this.$( '#article a, #bodyContent a, #mw_contentholder a' );
 
// console.time("linkloop")
$links.each( ( index, element ) => {
this.$link = this.$( element );
Line 39 โŸถ 38:
this.hasAdvancedPermissions = false;
this.addClassesAndHoverTextToLinkIfNeeded();
// If the user has any advanced perms, they are likely to have a signature, so be aggressive about overriding the background and foreground color. That way there's no risk their signature is unreadable due to background color and foreground color being too similar. Don't do this for users without advanced perms... being able to see a redlinked username is useful.
if ( this.hasAdvancedPermissions ) {
this.$link.addClass( this.$link.attr( 'class' ) + ' UHS-override-signature-colors' );
}
} );
// console.timeEnd("linkloop")
}
 
Line 236 โŸถ 231:
checkForPermission( listOfUsernames, className, descriptionForHover ) {
if ( listOfUsernames[ this.user ] === 1 ) {
this.addHoverIconaddRoleIcon( className, descriptionForHover );
}
}
 
addHoverIconaddRoleIcon( icon, descriptionForHover ) {
 
const title = this.$link.attr( 'title' );
Line 254 โŸถ 249:
// 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 ) ) {
this.addHoverIconaddRoleIcon( '๐ŸŒ', 'Wikimedia Foundation (WMF)' );
}
 
Line 264 โŸถ 259:
this.checkForPermission( this.admins, '๐Ÿงน', 'Admin' );
this.checkForPermission( this.formeradmins, '๐Ÿšฌ', 'Former Admin' );
this.checkForPermission( this.newPageReviewers, '๐Ÿงฝ๐Ÿงบ', 'New page reviewer' );
this.checkForPermission( this.tenThousandEdits, '๐Ÿฅ‡', 'More than 10,000 edits' );
this.checkForPermission( this.extendedConfirmed, 'โœ๐Ÿ“š', 'Extended confirmed' );
 
// If they have no perms, then they are non-EC, so <500 edits
if ( !this.hasAdvancedPermissions ) {
this.addHoverIconaddRoleIcon("๐Ÿฃ", "Less than 500 edits");
}
}