打开/关闭菜单
打开/关闭外观设置菜单
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。

MediaWiki:Gadget-CaoCaoBi.js

MediaWiki界面页面
OctoberSama留言 | 贡献2025年6月20日 (五) 20:39的版本

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

  • Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5Ctrl-R(Mac为⌘-R
  • Google Chrome:Ctrl-Shift-R(Mac为⌘-Shift-R
  • Edge:按住Ctrl的同时单击刷新,或按Ctrl-F5
'use strict';
if (!document.body.classList.contains("action-view")) return;

let elep_size = 64;
let elep_invl, einv_avail, c_kd, sw_s, c_clk_s;

function sho_elep_CCB() {
    sw_s = 1;
    const a = document.createElement("div");
    a.style = `cursor:none;left:0px;top:0px;width:${elep_size}px;height:${elep_size*1.3}px;position:fixed;pointer-events:none;background-size:cover;z-index:1145`;
    elep_invl = setInterval(() => {
        if (einv_avail) {
            a.style.backgroundImage = "url(/images/a/ab/Ccb_elep_1.webp)";
            setTimeout(() => {
                a.style.backgroundImage = "url(/images/9/97/Ccb_elep_2.webp)";
            }, 100);
        }
    }, 200);
    a.id = "ccb_elephant";
    document.body.appendChild(a);

    const b = document.createElement("div");
    const bse = `position:relative;left:${-elep_size*1.5}px;top:${-elep_size*.5}px;width:${elep_size*4}px;height:${elep_size*3}px;background-image:url(/images/4/4c/Ccb_waao.webp);background-size:cover;z-index:1144;transform:rotate(24deg)`;
    b.style = bse + ";opacity:0";
    a.appendChild(b);

    const c = document.createElement("audio");
    c.src = "/images/2/29/%E8%80%81%E7%88%B7%E7%88%B7%2C%E6%88%91%E6%9D%A5%E7%BB%99%E4%BD%A0%E8%B8%A9%E8%83%8C%E6%9D%A5%E5%96%BD.mp3";
    c.autoplay = 1;
    a.appendChild(c);

    document.body.style.cursor = "none";

    window.addEventListener("mousemove", (e) => {
        a.style.transform = `translate(${e.clientX - elep_size * 0.5}px,${e.clientY - elep_size * 1.2}px)`;
        einv_avail = 1;
    });
    window.addEventListener("mousedown", () => {
        einv_avail = 0;
        a.style.top = "8px";
    });
    window.addEventListener("mouseup", () => {
        einv_avail = 1;
        a.style.top = "0px";
        b.style = bse + " scale(.2);opacity:1;transition:none";
        setTimeout(() => { b.style = bse + ";opacity:0;transition:.2s"; }, 3);
    });
}

function gen_wow_CCB() {
    if (!sw_s) return;
    const a = document.createElement("audio");
    a.src = "/images/transcoded/c/ca/%E5%93%87%E8%A2%84.ogg/%E5%93%87%E8%A2%84.ogg.mp3";
    a.autoplay = 1;
    document.body.appendChild(a);
    setTimeout(() => { a.remove(); }, 1470);
}

function swit_so_CCB() {
    if (!sw_s) {
        sho_elep_CCB();
        return;
    }
    document.body.removeChild(document.getElementById("ccb_elephant"));
    document.body.style.cursor = "";
    if (document.body.getAttribute("style") === "") {
        document.body.removeAttribute("style");
    }
    sw_s = 0;
}

function elep_resz_CCB(z) {
    elep_size = z ? elep_size * 1.25 : elep_size * 0.8;
    document.body.removeChild(document.getElementById("ccb_elephant"));
    sho_elep_CCB();
}

window.addEventListener("mouseup", gen_wow_CCB);
window.addEventListener("keydown", (e) => {
    if (e.key === "c") c_kd = 1;
    if (c_kd) {
        if (e.key === "b") swit_so_CCB();
        if (e.key === "=") elep_resz_CCB(1);
        if (e.key === "-") elep_resz_CCB();
        if (e.key === "n") {
            const elep = document.getElementById("ccb_elephant");
            if (!elep) return;
            elep.style.pointerEvents = c_clk_s ? "none" : "auto";
            c_clk_s = !c_clk_s;
        }
    }
});
window.addEventListener("keyup", (e) => {
    if (e.key === "c") c_kd = 0;
});

console.log("Cao!Cao!Bi!Gadget 0.0.3 OTTOWiki.Ver updated 2025/6/10");

return {
    swit_so_CCB,
    sho_elep_CCB,
    gen_wow_CCB,
    elep_resz_CCB
};