MediaWiki:Gadget-UserLinkAvatar.js

From HUIJIA FUN
Revision as of 10:30, 22 December 2025 by PlurimodSU (talk | contribs)

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.
/* From https://otomad.wiki/MediaWiki:Gadget-UserLinkAvatar.js */
$('.mw-userlink').each(function(_, item) {
    item = $(item);
    const username = item.find("bdi").text();
    const avatarUrl = "https://huijia.fun/Special:GetAvatar/" + encodeURIComponent(username);
    const avatarImg = $("<img>")
        .attr("src", avatarUrl)
        .attr("loading", "lazy")
        .addClass("userlink-avatar");

    item.prepend(avatarImg);
});