打开/关闭菜单
打开/关闭外观设置菜单
打开/关闭个人菜单
未登录
登录后可编辑和发表评论。

MediaWiki:Gadget-SideBarPic.js

MediaWiki界面页面

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

  • Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl + F5Ctrl + R(Mac为 R
  • Google Chrome:Ctrl + Shift + R(Mac为 Shift R
  • Edge:按住Ctrl的同时单击刷新,或按Ctrl + F5
/* <pre> */

"use strict";
(async () => {
    const sleep = (e = 1e3) => new Promise(i => setTimeout(i, e));
    await $.ready;
    const e = "#mw-navigation";
    let i = $(e);
    for (;0 === i.length;) await sleep(100), i = $(e);
    if (console.info("Widget:SideBarPic pre-init-check", i), $("body").hasClass("sideBarPic-executed")) return;
    const o = $(".sidebar-character:not(.executed)").slice(0, 3);
    0 !== o.length && ($("body").addClass("sideBarPic-executed"), o.addClass("executed"), await Promise.all(o.find("img").toArray().map(e => new Promise(i => {
        let o = 0;
        try {
            const t = new Image, n = new mw.Uri(e.dataset.src || e.src);
            n.host.endsWith(".moegirl.org") && (n.host += ".cn"), t.addEventListener("load", () => { e.src = n, i() }), t.addEventListener("error", () => {
                if (o++ < 3) {
                    const e = new mw.Uri(t.src);
                    e.query._ = Math.random(), t.src = e
                } else console.info("Widget:SideBarPic img-load-failed\n", e.dataset.src), e.remove(), i()
            }), t.src = n
        } catch (o) { console.info("Widget:SideBarPic img-load-failed\n", o), e.remove(), i() }
    }))), $("body").addClass("sideBarPic"), o.each((e, o) => {
        const t = $(o);
        t.find("img")[0] && (console.info("Widget:SideBarPic append-check\n", i), t.appendTo(i), t.fadeIn().addClass("top" === o.dataset.align ? "top" : "bottom").css("user-select", "none"), t.addClass("active").find("img").removeAttr("width").removeAttr("height"))
    }), $(window).on("resize", () => {
        o.each((e, i) => {
            const o = $(i);
            o.find("img").width(o.width())
        })
    }).trigger("resize"), "yes" === o.data("displaylogo") && $("body").addClass("show-logo"))
})();

/* </pre> */