MediaWiki:ProfileTags.js

(function {   function addMastheadTags(tags) {        var $masthead = $('.UserProfileMasthead').find('hgroup');

$masthead.find('.tag').remove;

for (var i = 0, len = tags.length; i < len; i++) { $masthead.append(                $(' ').addClass('tag').text(tags[i])            ); }   };    function getUserName { var pageName; if (mw.config.get('wgCanonicalSpecialPageName') == 'Contributions') { pageName = mw.config.get('wgPageName'); user = pageName.substring(pageName.lastIndexOf('/')+1).replace(/_/g, ' '); } else { user = mw.config.get('wgTitle'); }       return user; }   function getUserBadges { $.get('/wiki/MediaWiki:UserBadges?action=raw', function(data) {           var list, badge, user, userName, tags;            if (!data.length) {                return;            }            list = data.split('\n');            userName = getUserName;            for (var i = 0, len = list.length; i < len; i++) {                badge = list[i].split('|');                if (badge.length === 2) {                    user = badge[0].trim;                    if (user === userName) {                        tags = badge[1].trim.split(',');                        break;                    }                }            }            if (tags) {                addMastheadTags(tags);            }        }); }   function init { if (mw.config.get('wgCanonicalSpecialPageName') === 'Contributions'            || ([2, 3].indexOf(mw.config.get('wgNamespaceNumber')) > -1 && mw.config.get('wgAction') === 'view')         ) { getUserBadges; }   }    $(init); });