MediaWiki:Gadget-avatar.js

此后如竟没有炬火,我便是唯一的光。
物灵留言 | 贡献2024年1月25日 (四) 15:50的版本
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转到导航 跳转到搜索

注意:在发布之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。

  • Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5Ctrl-R(Mac为⌘-R
  • Google Chrome:Ctrl-Shift-R(Mac为⌘-Shift-R
  • Internet Explorer或Edge:按住Ctrl的同时单击刷新,或按Ctrl-F5
  • Opera:Ctrl-F5
$(function(){
if (!mw.user.isAnon()) {
var img = $("<img>").attr(
  "src",
  mw.config.get("wgScriptPath") +
    "/index.php?title=Special:Avatar&wpUsername=" +
    mw.user.id()
).attr("width",28).attr("height",28);
var link = $("<a>")
  .attr("href", mw.util.getUrl("Special:UploadAvatar"))
  .append(img);
  if (!document.body.classList.contains("skin-vector-legacy")) {
    $("#pt-userpage-2").before($('<li id="pt-avatar"></li>').append(link));
  } else {
    $("#pt-userpage").before($('<li id="pt-avatar"></li>').append(link));
  }
}
$(".mw-userlink").each(function (_, item) {
  item = $(item);
  item.prepend(
    $("<img/>")
      .addClass("userlink-avatar")
      .attr(
        "src",
        mw.config.get("wgScriptPath") +
          "/index.php?title=Special:Avatar&wpUsername=" +
          item.text()
      )
  );
});
$(".context-userlink").each(function (_, item) {
  item = $(item);
  item.prepend(
    $("<img/>")
      .addClass("userlink-avatar")
      .attr(
        "src",
        mw.config.get("wgScriptPath") +
          "/index.php?title=Special:Avatar&wpUsername=" +
          item.attr('data-u')
      )
  );
});
});