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

Content deleted Content added
better placement
more icons
Line 230:
checkForPermission( listOfUsernames, className, descriptionForHover ) {
if ( listOfUsernames[ this.user ] === 1 ) {
this.addClassAndHoverTextaddHoverIcon( className, descriptionForHover );
}
}
 
addClassAndHoverTextaddHoverIcon( classNameicon, descriptionForHover ) {
this.$link.addClass( className );
 
const title = this.$link.attr( 'title' );
if ( !title || title.startsWith( 'User:' ) ) {
this.$link.attr( 'title', descriptionForHover );
this.$link.prepend($("<div class='user-role-indicator-container'><div class='user-role-indicator-inner'>๐Ÿงน"+icon+"</div></div>"))
}
 
Line 249 โŸถ 248:
// 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.addClassAndHoverTextaddHoverIcon( 'UHS-wmf', 'Wikimedia Foundation (WMF)' );
}
 
// 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.checkForPermission( this.wmf, 'UHS-wmf๐ŸŒ', 'Wikimedia Foundation (WMF)' );
this.checkForPermission( this.stewards, 'UHS-stewardโš’', 'Steward or Ombud' );
this.checkForPermission( this.arbcom, 'UHS-arbitration-committeeโš–๏ธ', 'Arbitration Committee member' );
this.checkForPermission( this.bureaucrats, 'UHS-bureaucrat๐Ÿ’ผโ€', 'Bureaucrat' );
this.checkForPermission( this.admins, 'UHS-administrator๐Ÿงน', 'Admin' );
this.checkForPermission( this.formeradmins, 'UHS-former-administrator๐Ÿšฌ', 'Former Admin' );
this.checkForPermission( this.newPageReviewers, 'UHS-new-page-reviewer๐Ÿงฝ', 'New page reviewer' );
this.checkForPermission( this.tenThousandEdits, 'UHS-10000edits๐Ÿฅ‡', 'More than 10,000 edits' );
this.checkForPermission( this.extendedConfirmed, 'UHS-500edits-bot-trustedIPโœ', 'Extended confirmed' );
 
// If they have no perms, just draw a box around their username, to make it more visible.
if ( !this.hasAdvancedPermissions ) {
this.$link.attraddHoverIcon( 'title'"๐Ÿฃ", '"Less than 500 edits' ");
this.$link.addClass( 'UHS-no-permissions' );
const title = this.$link.attr( 'title' );
if ( !title || title.startsWith( 'User:' ) ) {
this.$link.attr( 'title', 'Less than 500 edits' );
}
}
}
Line 275 โŸถ 270:
setHighlightColors() {
// Highest specificity goes on bottom. So if you want an admin+steward to be highlighted steward, place the steward CSS below the admin CSS in this section.
// this.addCSS( 'UHS-override-signature-colors', `
// color: #0645ad !important;
// background-color: transparent !important;
// background: unset !important;
// ` );
 
this.addCSS('user-role-indicator-container', 'position: relative !important; display: inline;')
this.addCSS('user-role-indicator-inner', 'position: absolute; top: 1em; left: 0px; font-size: smaller; background-color: #1333 !important;')
 
// this.mw.util.addCSS( '.UHS-no-permissions { border: 1px solid black !important; }' );
 
// // 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.addCSS( 'UHS-500edits-bot-trustedIP', 'background-color: #0f0 !important;' );
// this.addCSS( 'UHS-10000edits', 'background-color: #9c9 !important;' );
// this.addCSS( 'UHS-new-page-reviewer', 'background-color: #99f !important;' );
// this.addCSS( 'UHS-former-administrator', 'background-color: #D3AC8B !important;' );
// this.addCSS( 'UHS-administrator', 'background-color: #9ff !important;' );
// this.addCSS( 'UHS-bureaucrat', 'background-color: orange !important; color: #0645ad !important;' );
// this.addCSS( 'UHS-arbitration-committee', 'background-color: #FF3F3F !important; color: white !important;' );
// this.addCSS( 'UHS-steward', 'background-color: #00FF00 !important;' );
// this.addCSS( 'UHS-wmf', 'background-color: hotpink !important; color: #0645ad !important;' );
}
}