MediaWiki:Common.js

From BetaHaven Wiki
Revision as of 03:59, 19 October 2026 by Jkobey (talk | contribs)
Jump to navigation Jump to search

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.
var skinOverrides = {
    'Jivezap': 'Jivezap_',
};

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

    $('[id^="skinmodel-"]').each(function() {
        var name = this.id.replace('skinmodel-', '');
        var iframe = $('<iframe>')
            .attr('src', 'https://minerender.org/embed/skin/?skin=' + encodeURIComponent(name) + '&type=body&camera=0&shadows=true&zoom=10&camera.position=5,42,5&controls.zoom=true&controls.pan=true')
            .attr('width', '200')
            .attr('height', '400')
            .css('border', 'none');
        $(this).replaceWith(iframe);
    });
});