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

Content deleted Content added
m label swap
adding ability to place indicators before links (instead of just after)
Line 36:
this.roleInfoLookup = defaultRoleInfoLookup;
}
 
this.labelPosition = "after";
if(this.window.UserRoleIndicatorCustomPlacement){
this.labelPosition = this.window.UserRoleIndicatorCustomPlacement;
}
 
// console.time("get usernames")
Line 41 ⟶ 46:
// 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;')
this.addCSS('label-after', 'margin-left:3px;');
this.addCSS('label-before', 'margin-right:1px;margin-left:2px;');
 
const $links = this.$( '#article a, #bodyContent a, #mw_contentholder a' );
Line 260 ⟶ 267:
if ( !title || title.startsWith( 'User:' ) ) {
this.$link.attr( 'title', descriptionForHover );
 
this.$link.append($("<div class='user-role-indicator'>"+icon+"</div>"))
switch(this.labelPosition){
case "before":
this.$link.prepend($("<div class='user-role-indicator label-before'>"+icon+"</div>"))
break;
 
default:
// Defaults to "after"
this.$link.append($("<div class='user-role-indicator label-after'>"+icon+"</div>"))
break;
}
}