MediaWiki:Gadget-ShowAvatar.js: Difference between revisions

    叶子和他的Vtuber们
    (Created page with ""use strict"; // <pre> $(() => { const commonsUrl = new mw.Uri(`${mw.config.get("wgServer")}${mw.config.get("wgScriptPath")}/`); commonsUrl.query.user = mw.config.get("wgPageName").replace(/^user:/i, ""); commonsUrl.path = "/extensions/Avatar/avatar.php"; const imgUrl = new mw.Uri(commonsUrl); imgUrl.query.user = mw.config.get("wgUserName"); const img = $("<img>").attr("src", imgUrl); const link = $("<a>").attr("href", `${mw.config.get("wgServ...")
     
    No edit summary
    Line 1: Line 1:
    "use strict";
    var img = $('<img>').attr('src', mw.config.get('wgScriptPath') + '/extensions/Avatar/avatar.php?user=' + mw.user.id());
    // <pre>
    var link = $('<a>').attr('href', mw.util.getUrl('Special:UploadAvatar')).append(img);
    $(() => {
    $('#pt-userpage').before($('<li id="pt-avatar"></li>').append(link));
        const commonsUrl = new mw.Uri(`${mw.config.get("wgServer")}${mw.config.get("wgScriptPath")}/`);
        commonsUrl.query.user = mw.config.get("wgPageName").replace(/^user:/i, "");
        commonsUrl.path = "/extensions/Avatar/avatar.php";
        const imgUrl = new mw.Uri(commonsUrl);
        imgUrl.query.user = mw.config.get("wgUserName");
        const img = $("<img>").attr("src", imgUrl);
        const link = $("<a>").attr("href", `${mw.config.get("wgServer")}/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("/")) {
            const hrefUrl = new mw.Uri(commonsUrl);
            hrefUrl.path = "/Special:Viewavatar";
            const 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>

    Revision as of 09:40, 22 December 2022

    var img = $('<img>').attr('src', mw.config.get('wgScriptPath') + '/extensions/Avatar/avatar.php?user=' + mw.user.id());
    var link = $('<a>').attr('href', mw.util.getUrl('Special:UploadAvatar')).append(img);
    $('#pt-userpage').before($('<li id="pt-avatar"></li>').append(link));