MediaWiki:Gadget-ShowAvatar.js

来自萌娘文库
屠麟傲血讨论 | 贡献2022年11月30日 (三) 17:25的版本 (本地化)
跳转至: 导航搜索

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

  • Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5Ctrl-R(Mac为⌘-R
  • Google Chrome:Ctrl-Shift-R(Mac为⌘-Shift-R
  • Internet Explorer:按住Ctrl的同时单击刷新,或按Ctrl-F5
  • Opera:前往菜单 → 设置(Mac为Opera → Preferences),然后隐私和安全 → 清除浏览数据 → 缓存的图片和文件
/* <pre> */
/**
 * -------------------------------------------------------------------------
 * !!! DON'T MODIFY THIS PAGE MANUALLY, YOUR CHANGES WILL BE OVERWRITTEN !!!
 * -------------------------------------------------------------------------
 */
var _addText = '{{GHIACode|page=GHIA:MoegirlPediaInterfaceCodes/blob/master/src/gadgets/ShowAvatar/MediaWiki:Gadget-ShowAvatar.js|user=[[U:AnnAngela]]|longId=b660181c119c561ff763bc1ed249eaa2325fafeb|shortId=b660181|message=gadget s-t}}';

"use strict";
$(function () {
    var commonsUrl = new mw.Uri("".concat(mw.config.get("wgServer").replace("lbirary.moegirl", "commons.moegirl")).concat(mw.config.get("wgScriptPath"), "/"));
    commonsUrl.query.user = mw.config.get("wgPageName").replace(/^user:/i, "");
    commonsUrl.path = "/extensions/Avatar/avatar.php";
    var imgUrl = new mw.Uri(commonsUrl);
    imgUrl.query.user = mw.config.get("wgUserName");
    var img = $("<img>").attr("src", imgUrl);
    var link = $("<a>").attr("href", "".concat(mw.config.get("wgServer").replace("lbirary.moegirl", "commons.moegirl"), "/Special:UploadAvatar")).append(img);
    $("#pt-userpage").before($('<li id="pt-avatar"></li>').append(link));
    if (mw.config.get("wgNamespaceNumber") === 2 && !mw.config.get("wgPageName").includes("/")) {
        var hrefUrl = new mw.Uri(commonsUrl);
        hrefUrl.path = "/Special:Viewavatar";
        var srcUrl = new mw.Uri(commonsUrl);
        $(".ns-2 #firstHeading").prepend($("<a/>").attr({
            href: hrefUrl,
            title: "查看头像"
        }).prepend($("<img/>").attr("src", srcUrl).css({
            width: "1.2em",
            height: "1.2em",
            "border-radius": "10px",
            padding: "4px"
        })));
    }
});

/* </pre> */