MediaWiki:Common.js: Difference between revisions

From BetaHaven Wiki
Jump to navigationJump to search
No edit summary
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
mw.hook('wikipage.content').add(function() {
$(document).ready(function() {
     $('.mw-userlink').each(function() {
     $('a[href*="/User:"], a[href*="index.php?title=User:"]').each(function() {
         var username = $(this).text();
        if ($(this).find('img').length > 0) return;
         var username = $(this).attr('href').match(/User:([^&|#/]+)/);
        if (!username) return;
        var name = decodeURIComponent(username[1]);
         var img = $('<img>')
         var img = $('<img>')
             .attr('src', 'https://minotar.net/helm/' + encodeURIComponent(username) + '/16')
             .attr('src', 'https://minotar.net/helm/' + name + '/16')
             .css({ width: '16px', height: '16px', verticalAlign: 'middle', marginRight: '4px', imageRendering: 'pixelated' });
             .css({ width: '16px', height: '16px', verticalAlign: 'middle', marginRight: '4px', imageRendering: 'pixelated' });
         $(this).prepend(img);
         $(this).prepend(img);
     });
     });
});
});

Latest revision as of 05:23, 3 June 2026

$(document).ready(function() {
    $('a[href*="/User:"], a[href*="index.php?title=User:"]').each(function() {
        if ($(this).find('img').length > 0) return;
        var username = $(this).attr('href').match(/User:([^&|#/]+)/);
        if (!username) return;
        var name = decodeURIComponent(username[1]);
        var img = $('<img>')
            .attr('src', 'https://minotar.net/helm/' + name + '/16')
            .css({ width: '16px', height: '16px', verticalAlign: 'middle', marginRight: '4px', imageRendering: 'pixelated' });
        $(this).prepend(img);
    });
});