MediaWiki:Gadget-ShowAvatar.js

来自萌娘文库
跳转至: 导航搜索

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

  • 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:屠麟傲血]]|longId=4b1de2510314971dbb478c813a2e0000189d2dd2|shortId=4b1de25|message=fix: showavatar styles and upload title (#71)}}';

"use strict";
$(function () {
    var commonsUrl = new mw.Uri("https://commons.moegirl.org.cn/");
    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,
        title: "上传头像"
    });
    var link = $("<a>").attr("href", "https://commons.moegirl.org.cn/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> */