Fandom Developers Wiki
Advertisement

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/**
 * AddUserRightsTag.js
 *
 * Adds easy way to add user rights on the masthead
 * @author: [[w:User:Algorithmz]]
 * fork of EditcountTag
 */
(function() {
    var config = mw.config.get([
        'profileUserName',
        'wgUserGroups'
    ]);
    if (
        !/bureaucrat|sysop|staff|wiki-specialist/.test(config.wgUserGroups.join()) ||
        !mw.config.get('profileUserName') ||
        window.AddUserRightsTagLoaded
    ) {
        return;
    }
    window.AddUserRightsTagLoaded = true;
    function findContainer() {
        var promise = $.Deferred(),
            interval = setInterval(function() {
                var $element = $('#userProfileApp .user-identity-header__actions');
                if ($element.length) {
                    clearInterval(interval);
                    promise.resolve($element);
                }
            }, 300);
        return promise;
    }
    function init(text, $container) {
        $('<a>', {
            'class': 'wds-button user-identity-header__button',
            'href': mw.util.getUrl('Special:UserRights/' + config.profileUserName),
            'text': text
        }).appendTo($container);
    }
    mw.hook('dev.fetch').add(function(fetch) {
        $.when(fetch('userrights'), findContainer())
            .then(init);
    });
    importArticle({
        type: 'script',
        article: 'u:dev:MediaWiki:Fetch.js'
    });
})();
Advertisement