MediaWiki:Common.js
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)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
$(document).ready(function() {
var cache = {};
function addSkin(link, mcName) {
if ($(link).find('img').length > 0) return;
var img = $('<img>')
.attr('src', 'https://minotar.net/helm/' + encodeURIComponent(mcName) + '/16')
.css({ width: '16px', height: '16px', verticalAlign: 'middle', marginRight: '4px', imageRendering: 'pixelated' });
$(link).prepend(img);
}
$('a[href*="/User:"], a[href*="index.php?title=User:"]').not('#ca-nstab-user a, #p-personal a').each(function() {
if ($(this).find('img').length > 0) return;
var username = $(this).attr('href').match(/User:([^&|#/]+)/);
if (!username) return;
var wikiName = decodeURIComponent(username[1]);
var link = $(this);
if (cache[wikiName] !== undefined) {
addSkin(link, cache[wikiName]);
return;
}
$.get('/index.php/User:' + wikiName, function(data) {
var mcName = $(data).find('.mc-username').first().text() || wikiName;
cache[wikiName] = mcName;
addSkin(link, mcName);
});
});
});