User:Pratyya Ghosh/stewardhighlighter.js

( function( $, mw ) { mw.loader.using( [ 'mediawiki.util', 'mediawiki.api', 'mediawiki.Title' ], function { var api = new mw.Api; var stewards = {}; var params = { list: 'allusers', augroup: 'steward', aulimit: 'max' };   var load = function { api.get( params, {           ok: function( data ) {                $.each( data.query.allusers, function { stewards[this.name] = 1; } );               if ( data['query-continue'] ) {                    $.extend( params, data['query-continue'].allusers );                    load;                } else {                    $( function { $( 'a', mw.util.$content ).each( function {                           var $this = $( this );                            var title = $this.attr( 'title' );                            if ( !title ) {                                return;                            }                            if ( $this.hasClass( 'new' ) ) {                                title = title.replace( /[（\(][^）\)]+[）\)]$/, '' ); }                           title = new mw.Title( title ); if ( ( title.getNamespaceId & ~1 ) == 2 && stewards[title.getMainText.split( '/' )[0]] == 1                               || title.getNamespaceId == -1 && title.getMainText.indexOf( '/' ) != -1                                    && stewards[title.getMainText.split( '/' )[1]] == 1 ) { $this.css( 'background-color', '#FFFF00' ).addClass( 'amalthea_userhighlighter_sysop' ); }                       } );                    } );                }            }        } );    };    load; } ); } )( jQuery, mediaWiki );