FANDOM


/**
 * AddUserRightsTag.js
 *
 * Adds easy way to add user rights on the masthead
 * @author: [[w:User:Algorithmz]]
 */
$(function() {
    var config = mw.config.get([
        'skin',
        'wgUserLanguage',
        'wgNamespaceNumber',
        'wgCanonicalSpecialPageName',
        'wgUserName',
        'wgTitle'
    ]);
    if([2, 3, 500, 1200, -1].indexOf(config.wgNamespaceNumber) === -1) {
        return;
    }
    function getUser() {
        switch(config.wgCanonicalSpecialPageName) {
            case 'Contributions': return config.wgTitle.split('/')[1];
            case 'Following':
            case 'UserActivity':
                return config.wgUserName;
            default: return wgTitle;
        }
    }
    function init(text) {
        switch (config.skin) {
            case 'oasis':
            case 'wikia':
                $('<a>')
                    .attr({
                        class: 'tag',
                        href: '/wiki/Special:UserRights/' + getUser()
                    })
                    .text(text)
                    .css({
                        float: 'right',
                        color: 'inherit',
                        marginTop: '5px',
                        marginRight: '-15px'
                    })
                    .appendTo('.UserProfileMasthead hgroup');
                break;
            case 'monobook':
                $('<a>')
                    .attr('href', '/wiki/Special:UserRights/' + getUser())
                    .text('[' + text + ']')
                        .css({
                        float: 'right',
                        fontSize: '13px'
                    })
                    .appendTo('#firstHeading');
                break;
        }
    }
    mw.loader.using('mediawiki.api').then(function() {
        new mw.Api().get({
            action: 'query',
            meta: 'allmessages',
            ammessages: 'userrights',
            amlang: config.wgUserLanguage
        }).done(function(d) {
            if(!d.error) {
                init(d.query.allmessages[0]['*']);
            }
        });
    });
});

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.