MediaWiki:Common.js

H萌娘,万物皆可H的百科全书!
imported>=海豚=2021年5月17日 (一) 22:44的版本
跳到导航 跳到搜索

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

  • 按住CTRL+SHIFT+DEL 或 ⌘-Shift-R来清除缓存!
  • 或尝试在地址栏的地址最后添加代码?_=1来访问最新页面。
    添加代码后的本页地址如下:-{R|https://hmoegirl.com/MediaWiki:Common.js?_=1}-
  • 你还可以在设置中勾选小工具在页面右上角添加清除缓存按钮!
1. 桌面版CSS MediaWiki:Common.css
2. 桌面版JS MediaWiki:Common.js
3. 移动端CSS MediaWiki:Mobile.css
4. 移动端JS MediaWiki:Mobile.js
5. 全局共用CSS MediaWiki:Gadget-site-styles.css
6. 全局共用JS MediaWiki:Gadget-site-javascript.js
7. 管理员CSS MediaWiki:Group-sysop.css
8. 管理员JS MediaWiki:Group-sysop.js
9. 编辑时载入 MediaWiki:Common.js/edit.js
引用api时用mw.loader.using("mw.Api"),引用uri时用mw.loader.using("mediawiki.Uri")
/* 这里的任何JavaScript将在全站加载 */
// <nowiki>
"use strict";
(function($, mw) { //使用匿名函数防止污染顶级变量
    /* capture支持检测 */
    var captureSupported = false;
    try {
        var options = Object.defineProperty({}, "capture", {
            get: function () {
                captureSupported = true;
                return true;
            },
        });
        window.addEventListener("test", null, options);
    } catch (err) { /* */ }
    /* 检查是否为维护组成员 */
    var wgUserGroups = mw.config.get("wgUserGroups");
    var isMGPMGUser = wgUserGroups.includes("patroller") || wgUserGroups.includes("sysop");
    //滚动公告
    function autoScroll(obj) {
        $(obj).animate({
            height: "show",
            paddingTop: "show",
            marginTop: "show",
            paddingBottom: "show",
            marginBottom: "show",
        });
        var isFrozen = false;
        setInterval(function() {
            if (!isFrozen) {
                $(obj).find("ul:first").animate({
                    marginTop: "-25px",
                }, 500, function() {
                    $(this).css({
                        marginTop: "0px",
                    }).find("li:first").appendTo(this);
                });
            }
        }, 5000);
        $(window).on({
            blur: function() {
                isFrozen = true;
            },
            focus: function() {
                isFrozen = false;
            },
        });
    }
        autoScroll("#scrollDiv");
    /* MediaViewer#populateStatsFromXhr 错误屏蔽 */
    (function() {
        var getResponseHeader = XMLHttpRequest.prototype.getResponseHeader;
        XMLHttpRequest.prototype.getResponseHeader = function(name) {
            return ("\n" + this.getAllResponseHeaders().toLowerCase()).includes("\n" + name.toLowerCase() + ": ") ? getResponseHeader.call(this, name) : (console.debug('Refused to get unsafe header "' + name + '"\n', this, "\n", new Error().stack), null);
        };
    })();
    //Extension:MultimediaViewer的半透明化修改。
    function multimediaViewer() {
        var _scrollTo = window.scrollTo;
        var flag = location.hash !== "";
        window.scrollTo = function scrollTo(x_option, y) {
            if (flag) {
                console.info("Prevent multimediaViewer called");
            } else {
                if (y === undefined) { _scrollTo(x_option); } else { _scrollTo(x_option, y); }
            }
        };
        setInterval(function() {
            $("a.image img[data-file-width], a.image img[data-file-height], .mw-mmv-filepage-buttons a.mw-mmv-view-expanded").not(".multimediaViewerScrollSet").each(function() {
                this.addEventListener("click", function(e) {
                    if ($(e.target).closest(".TabLabelText")[0] || $(e.target).closest("a").closest(".mw-customtoggle")[0]) {
                        e.preventDefault();
                        e.stopPropagation();
                        e.stopImmediatePropagation();
                        $($(e.target).closest(".TabLabelText")[0] || $(e.target).closest("a").closest(".mw-customtoggle")[0]).click();
                        return false;
                    }
                    flag = true;
                }, captureSupported ? {
                    capture: true,
                } : true);
                $(this).addClass("multimediaViewerScrollSet");
            });
            if ($(".mw-mmv-close")[0]) {
                if (mw.config.get("wgMultimediaViewerInjected") !== "on") {
                    mw.config.set("wgMultimediaViewerInjected", "on");
                    $(".mw-mmv-image").off("click")[0].addEventListener("click", function(e) {
                        if ($(e.target).is("img")) {
                            window.open($(e.target).attr("src").replace(/(www\.hmoegirl\.com\/common\/)thumb\/([a-z\d]+\/[a-z\d]+\/)([^/]+)\/\d+px-\3/i, "$1$2$3"), "_blank").focus();
                            e.preventDefault();
                            e.stopPropagation();
                            e.stopImmediatePropagation();
                            return false;
                        } else if ($(e.target).closest(".error-box")[0]) { return; }
                        $(".mw-mmv-close").click();
                    }, captureSupported ? {
                        capture: true,
                    } : true);
                }
            } else if (mw.config.get("wgMultimediaViewerInjected") === "on") {
                flag = false;
                mw.config.set("wgMultimediaViewerInjected", "off");
            }
        }, 137);
    }
        //修复代码编辑器$.ucFirst引用错误
        $.extend({
            ucFirst: function (_s) {
                var s = _s + "";
                return s.charAt(0).toUpperCase() + s.substring(1);
            },
        });
    //子页面页顶链接
    function subpage_links() {
        var links = mw.config.get("wgPageName").split("/"),
            link = "",
            subpages = $(".subpages")[0] ? $(".subpages").remove().empty().text("<") : $('<span class="subpages"/>').text("<"),
            length = links.length - 1,
            index;
        if (mw.config.get("wgPageName").indexOf("Special:移动页面") !== -1) { links.splice(0, 1); }
        for (index = 0; index < length; index++) {
            link += "/" + links[index];
            subpages.append($("<a/>", {
                text: " " + links[index],
                href: link,
            }));
            if (length - index > 1) { subpages.append(" |"); }
        }
        if (subpages.find("a")[0]) { $("#contentSub").prepend(subpages); }
    }
    //跨站重定向页顶链接
    function crossDomain_link() {
        var url = new mw.Uri(new mw.Uri().query.rdfrom);
        var link = url.query.title;
        var domain = url.host;
        var crossDomain = $("<div/>");
        var anchor = $("<a/>");
        crossDomain.text("<");
        anchor.attr("href", url + "").text(link + "【来自 " + domain + "】");
        crossDomain.append(anchor);
        $("#contentSub").prepend(crossDomain);
    }
    //重复文件列表函数
    function duplicatedFileList() {
        if (window.location.href.indexOf("title") === -1) { window.location.replace("http://www.hmoegirl.com/index.php?title=Special:ListDuplicatedFiles&limit=500&offset=0"); }
        $("#mw-content-text .mw-spcontent ol").attr("id",
            "picOl");
        $("#picOl").before('<p id="picOlTitle">图片列表:</p>').after('<p id="MP3OlTitle">MP3列表:</p><ol start="1" id="MP3Ol"></ol>');
        $("#picOlTitle, #MP3OlTitle").hide();
        $("#picOl").find("[href$='.mp3'], [href$='.ogg']").parent().appendTo("#MP3Ol");
        if ($("#picOl").find("li").length) { $("#picOlTitle").show(); }
        if ($("#MP3Ol").find("li").length) { $("#MP3OlTitle").show(); }
        $(".mw-spcontent > p:nth-child(1), .mw-spcontent > p:nth-child(2), .mw-spcontent > p:nth-child(7)").hide();
    }
        //关键词警告
    function antiAbuseListener(textarea, event) {
        var filters = [
            "{{即将删除",
            "{{挂删",
            "{{模板:即将删除",
            "{{template:即将删除",
            "[[分类:即将删除的页面]]",
            "[[category:即将删除的页面]]",
            "全家暴",
            "开发票",
            "男科",
            "老虎机",
            "傻逼",
            "弱智",
            "智障",
            "支那",
            "zhina",
        ];
        var text1 = textarea.value;
        text1 = text1.replace(/<\/?(?:nowiki|noinclude)>/g, "");
        text1 = text1.replace(/<(onlyinclude|includeonly)>.*?<\/\1>/g, "");
        var text2 = textarea.value;
        text2 = text2.replace(/<\/?(?:onlyinclude|includeonly)>/g, "");
        text2 = text2.replace(/<(nowiki|noinclude)>.*?<\/\1>/g, "");
        var results = [];
        for (var i = 0, l = filters.length; i < l; i++) {
            var regExp = new RegExp(filters[i].replace(/\[/g, "\\["), "i");
            if (regExp.test(text1) || regExp.test(text2)) { results.push(filters[i]); }
        }
        if (results.length > 0) {
            var messageDialog = new OO.ui.MessageDialog();
            var windowManager = new OO.ui.WindowManager();
            $("body").append(windowManager.$element);
            windowManager.addWindows([messageDialog]);
            messageDialog.title.$label.html("H萌娘提醒您");
            messageDialog.message.$label.html("<br>您提交的内容包含以下违规内容,被禁止提交:<br><br><ul>" + results.map(function (result) {
                return "<li>" + result + "</li>";
            }).join("") + '</ul><br>如果您认为您的编辑无误,请在自行保存编辑内容后到讨论版提问!');
            windowManager.openWindow(messageDialog, {
                actions: [{
                    action: "accept",
                    label: "我知道了",
                    flags: "primary",
                }],
            });
            event.preventDefault();
            event.stopImmediatePropagation();
            event.stopPropagation();
            return false;
        }
    }
    function antiAbuse(textarea, submitButton, form) {
        mw.loader.using(["oojs-ui"]).then(function () {
            if (submitButton) {
                submitButton.addEventListener("click", function (e) {
                    antiAbuseListener(textarea, e);
                }, captureSupported ? {
                    capture: true,
                } : true);
            }
            if (form) {
                form.addEventListener("submit", function (e) {
                    antiAbuseListener(textarea, e);
                }, captureSupported ? {
                    capture: true,
                } : true);
            }
        });
    }
       //防滥用即将删除
        if (!isMGPMGUser) {
            setInterval(function () {
                if ($(".Wikiplus-InterBox")[0]) {
                    var targetBox = $(".Wikiplus-InterBox");
                    var textarea = $("#Wikiplus-Quickedit")[0];
                    var submitButton = $("#Wikiplus-Quickedit-Submit");
                    if (textarea && targetBox.data("isTrusted") !== true) {
                        targetBox.data("isTrusted", true);
                        targetBox.css("z-index", 100);
                        antiAbuse(textarea, submitButton[0], undefined);
                        var events = $._data(textarea, "events");
                        if (events && events.keydown) {
                            events.keydown.sort(function (a, b) {
                                return a.guid - b.guid;
                            });
                            events.keydown[0].handler = function (e) {
                                if (e.ctrlKey && e.which === 83) {
                                    if (e.shiftKey) {
                                        $("#Wikiplus-Quickedit-MinorEdit").click();
                                    }
                                    if (antiAbuseListener(textarea, e) !== false) {
                                        submitButton.click();
                                        e.preventDefault();
                                        e.stopPropagation();
                                    }
                                }
                            };
                        }
                    }
                }
                if ($("form#editform")[0]) {
                    var targetForm = $("form#editform");
                    if (targetForm.data("isTrusted") !== true) {
                        targetForm.data("isTrusted", true);
                        antiAbuse($("#wpTextbox1")[0], $("#wpSave")[0], targetForm[0]);
                    }
                }
            }, 1000);
        }
    //编辑请求
    function editRequest() {
        var nsIds = mw.config.get("wgNamespaceIds"),
            nsId = mw.config.get("wgNamespaceNumber"),
            ns = [];
        for (var i in nsIds) {
            if (nsIds[i] === nsId) { ns.push(i); }
        }
        if (!ns[0]) { return; }
        var page = mw.config.get("wgPageName"),
            talkns;
        for (var j = 0, l = ns.length; j < l; j++) {
            if (/^[A-Za-z0-9]+[ _]talk$/i.test(ns[j])) { return; }
            if (/^[a-zA-Z0-9]+$/.test(ns[j])) { talkns = ns[j] + "_talk:"; }
            page = page.replace(new RegExp("^" + ns[j] + ":", "i"), "");
        }
        var talkpage = talkns + page;
        var container = $("<div/>", {
            "class": "editRequest",
        });
        container.append("您虽然无权编辑本页面,但您可以点击右侧按钮在本页的讨论页提出编辑请求,让可以编辑的人代为编辑:");
        $("<span/>").addClass("newComment").text("提出编辑请求").on("click", function() {
            window.open("https://www.hmoegirl.com/index.php?action=edit&preload=Template:编辑请求/comment&preloadtitle=编辑请求 - " + mw.config.get("wgUserName") + "&section=new&title=" + talkpage, "_blank");
        }).appendTo(container);
        $("#mw-content-text").children(".wikiEditor-ui:first, textarea[readonly]:first").before("<hr>").before(container);
    }
    /* 函数执行体 */
    $(function() {
        //Template:heimu在safari上的暴力workaround
        mw.loader.using("jquery.client", function() {
            if ($.client.profile().name === "safari") {
                $(".heimu").on("click", function() {
                    $(this).toggleClass("off");
                });
            }
        });
        //Extension:MultimediaViewer的半透明化修改
        if ($("img[srcset][data-file-width][data-file-height]")[0]) { multimediaViewer(); }
        //重复文件列表区分图片和音频
        if ($(".mw-special-ListDuplicatedFiles").length && $(".mw-spcontent > p").length > 1) { duplicatedFileList(); }
        //需要时载入对应的 scripts
        if (mw.config.get("wgAction") === "edit" || mw.config.get("wgAction") === "submit" || mw.config.get("wgCanonicalSpecialPageName") === "Search") { mw.loader.load("/index.php?title=MediaWiki:Common.js/edit.js&action=raw&ctype=text/javascript"); }
        //子页面页顶链接
        if (mw.config.get("wgPageName").indexOf("/") !== -1 && (mw.config.get("wgNamespaceIds").special !== mw.config.get("wgNamespaceNumber") || mw.config.get("wgPageName").indexOf("Special:移动页面") !== -1) && !window._unsubpage) { subpage_links(); }
        //跨站重定向页顶链接
        mw.loader.using("mediawiki.Uri").then(function() {
            if (new mw.Uri().query.rdfrom && new mw.Uri(new mw.Uri().query.rdfrom).query.title && new mw.Uri(new mw.Uri().query.rdfrom).query.redirect === "no") { crossDomain_link(); }
        });
        //编辑请求
        if (["edit", "submit"].indexOf(mw.config.get("wgAction")) !== -1 && !!$(".permissions-errors, #wpTextbox1[readonly]")[1] && mw.config.get("wgUserName")) { editRequest(); }
        //修复代码编辑器$.ucFirst引用错误
        $.extend({
            ucFirst: function(_s) {
                var s = _s + "";
                return s.charAt(0).toUpperCase() + s.substring(1);
            },
        });
        //注释内列表
        $(".reference-text > ul,.reference-text > ol").each(function() {
            if (this.parentElement.childNodes[0] === this) { $(this).addClass("listInRef"); }
        });
        //列表侧边距
        setInterval(function() {
            $(".mw-parser-output ul, .mw-parser-output ol").not(".margin-left-set").each(function() {
                if (/none.+none/i.test($(this).css("list-style")) || $(this).is(".gallery")) {
                    if ($(this).parent().is("li") && $(this).parent().parent().is("ul,ol")) { $(this).css("margin-left", "1.2em"); } else { $(this).css("margin-left", "0.2em"); }
                } else if ($(this).is("ol")) {
                    var l = $(this).children("li").length;
                    if ($(this).attr("start")) { l += parseInt($(this).attr("start")); }
                    $(this).css("margin-left", (l + "").length * 0.5 + 1.2 + "em");
                } else { $(this).css("margin-left", "1.2em"); }
                $(this).addClass("margin-left-set");
            });
        }, 200);
        /**
 * 侧边栏隐藏工具
 * 本工具参考自维百的同功能小工具——https://zh.wikipedia.org/wiki/MediaWiki:Gadget-CollapsibleSidebar.js
 * [[User:AnnAngela]]/[[User:850710247liu]]做了一点改进
 * 此处代码已转化为可通过mw检测的格式,源码可在 https://zh.moegirl.org.cn/User:AnnAngela/js/sidebarHidden.js 找到
 */
/* eslint-disable prefer-arrow-callback */
/* eslint-disable prefer-template */
/* eslint-disable comma-dangle */
/* eslint-disable no-var */
/* global $, mw, localforage*/
"use strict";
$(function () {
    if (mw.config.get("skin") !== "vector" || mw.config.get("wgCanonicalSpecialPageName") === "Blankpage" || getComputedStyle(document.body).direction !== "ltr") {
        return;
    }
    mw.loader.using(["ext.gadget.localforage"]).then(function () {
        var test = localforage.createInstance({
            name: "AnnTools",
            storeName: "IndexedDB-test",
            driver: [localforage.INDEXEDDB]
        });
        return new Promise(function (res) {
            var random = Math.random().toString().substring(2);
            var fired = false;
            test.setItem("test", random).then(function () {
                return test.getItem("test");
            }).then(function (result) {
                if (!fired) {
                    fired = true;
                    res(result === random);
                }
            });
            setTimeout(function () {
                if (!fired) {
                    fired = true;
                    res(false);
                }
            }, 137);
        });
    }).then(function (indexedDBCanRun) {
        var store = localforage.createInstance({
            name: "AnnTools",
            storeName: "SidebarHidden",
            driver: indexedDBCanRun ? [localforage.INDEXEDDB] : [localforage.LOCALSTORAGE]
        });
        store.getItem("hidden").then(function (_hidden) {
            var hidden = _hidden;
            var saving = false;
            var generateImageObject = function (svg) {
                return URL.createObjectURL(new Blob([svg], {
                    type: "image/svg+xml"
                }));
            };
            var logoPic = "https://www.hmoegirl.com/images/b/bc/Hmoegirl_logo.png";
            var arrowRightSvg = generateImageObject('<svg version="1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" enable-background="new 0 0 48 48"><polygon fill="#2196F3" points="17.1,5 14,8.1 29.9,24 14,39.9 17.1,43 36,24"/></svg>');
            var arrowLeftSvg = generateImageObject('<svg version="1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" enable-background="new 0 0 48 48"><polygon fill="#2196F3" points="30.9,43 34,39.9 18.1,24 34,8.1 30.9,5 12,24"/></svg>');
            var $body = $(document.body);
            var $mwNavigation = $("#mw-navigation");
            var $mwWikiLogo = $(".mw-wiki-logo");
            var $logoLink = $mwWikiLogo.clone(false);
            var $logo = $("<img>").attr({
                id: "sidebarHidden-logo",
                src: logoPic
            });
            var $arrow = $("<img>").attr({
                id: "sidebarHidden-arrow",
                src: arrowLeftSvg
            });
            $logoLink.empty().removeAttr("class").attr("id", "sidebarHidden-logo-link").append($logo);
            var hide = function () {
                if (saving) {
                    return;
                }
                hidden = true;
                saving = true;
                $body.addClass("sidebarHidden");
                $arrow.attr("src", arrowRightSvg);
                store.setItem("hidden", hidden).then(function () {
                    saving = false;
                });
            };
            var show = function () {
                if (saving) {
                    return;
                }
                saving = true;
                hidden = false;
                $body.removeClass("sidebarHidden");
                $arrow.attr("src", arrowLeftSvg);
                store.setItem("hidden", hidden).then(function () {
                    saving = false;
                });
            };
            $mwNavigation.append($arrow).append($logoLink);
            if (hidden) {
                hide();
            }
            $arrow.on("click", function () {
                (hidden ? show : hide)();
            });
        });
    });
});
/* Tabs */
/* eslint-disable no-var */
/* eslint-disable no-magic-numbers */
/* global OO, mediaWiki, jQuery */
/* eslint-disable comma-dangle */
/* eslint-disable prefer-arrow-callback */
/* eslint-disable no-var */
"use strict";
$(function () {
    var defaultStyle = {
        purple: {
            labelColor: " ", //anti check
            labelBackgroundColor: "#9070c0",
            labelBorderColor: "#b090e0 #7050a0 #9070c0 #b090e0",
            labelPadding: ".2em .3em .2em .3em",
            textBorderColor: "#9070c0",
            textBackgroundColor: "#f0edf5",
            textPadding: "1em",
        },
        green: {
            labelColor: " ",
            labelBackgroundColor: "#75c045",
            labelBorderColor: "#90d060 #60b030 #75c045 #90d060",
            labelPadding: ".2em .3em .2em .3em",
            textBorderColor: "#75c045 #60b030 #60b030 #75c045",
            textBackgroundColor: "#f5fffa",
            textPadding: "1em",
        },
        red: {
            labelColor: " ",
            labelBackgroundColor: "#FF0000",
            labelBorderColor: "#FF8888 #CC0000 #FF0000 #FF8888",
            labelPadding: ".2em .3em .2em .3em",
            textBorderColor: "#FF0000 #CC0000 #CC0000 #FF0000",
            textBackgroundColor: "#fffafa",
            textPadding: "1em",
        },
        blue: {
            labelColor: " ",
            labelBackgroundColor: "#5b8dd6",
            labelBorderColor: "#88abde #3379de #5b8dd6 #88abde",
            labelPadding: ".2em .3em .2em .3em",
            textBackgroundColor: "#f0f8ff",
            textBorderColor: "#5b8dd6 #3379de #3379de #5b8dd6",
            textPadding: "1em",
        },
        yellow: {
            labelColor: " ",
            labelBackgroundColor: "#ffe147",
            labelBorderColor: "#ffe977 #ffd813 #ffe147 #ffe977",
            labelPadding: ".2em .3em .2em .3em",
            textBackgroundColor: "#fffce8",
            textBorderColor: "#ffe147 #ffd813 #ffd813 #ffe147",
            textPadding: "1em",
        },
        orange: {
            labelColor: " ",
            labelBackgroundColor: "#ff9d42",
            labelBorderColor: "#ffac5d #ff820e #ff9d42 #ffac5d",
            labelPadding: ".2em .3em .2em .3em",
            textBackgroundColor: "#ffeedd",
            textBorderColor: "#ff9d42 #ff820e #ff820e #ff9d42",
            textPadding: "1em",
        },
        black: {
            labelColor: " ",
            labelBackgroundColor: "#7f7f7f",
            labelBorderColor: "#999999 #4c4c4c #7f7f7f #999999",
            labelPadding: ".2em .3em .2em .3em",
            textBackgroundColor: "#e5e5e5",
            textBorderColor: "#7f7f7f #4c4c4c #4c4c4c #7f7f7f",
            textPadding: "1em",
        },
    };
    var sides = {
        top: {
            className: "tabLabelTop",
            labelColorSide: "top",
            labelBorderSide: ["left", "right"],
            labelColorSideReverse: "bottom",
            dividerSizeType: "height"
        },
        bottom: {
            className: "tabLabelBottom",
            labelColorSide: "bottom",
            labelBorderSide: ["left", "right"],
            labelColorSideReverse: "top",
            dividerSizeType: "height"
        },
        left: {
            className: "tabLabelLeft",
            labelColorSide: "left",
            labelBorderSide: ["top", "bottom"],
            labelColorSideReverse: "right",
            dividerSizeType: "width"
        },
        right: {
            className: "tabLabelRight",
            labelColorSide: "right",
            labelBorderSide: ["top", "bottom"],
            labelColorSideReverse: "left",
            dividerSizeType: "width"
        }
    };
    var truthy = ["1", "on", "true", "yes"];
    $("body").addClass("tab");
    function getOwnPropertyNamesLength(obj) {
        return Object.getOwnPropertyNames(obj).length;
    }
    function toLowerFirstCase(str) {
        return str.substring(0, 1).toLowerCase() + str.substring(1);
    }
    function toUpperFirstCase(str) {
        return str.substring(0, 1).toUpperCase() + str.substring(1);
    }
    mw.hook("wikipage.content").add(function () {
        $(".Tabs").each(function () {
            if ($(this).children(".TabLabel")[0]) {
                return true;
            }
            var self = $(this),
                classList = Array.from(this.classList).filter(function (n) {
                    return n in defaultStyle;
                }),
                data = $.extend({
                    labelPadding: "2px",
                    labelBorderColor: "#aaa",
                    labelColor: "green",
                    labelBackgroundColor: $("#content").css("background-color"),
                    textPadding: "20px 30px",
                    textBorderColor: "#aaa",
                    textBackgroundColor: "white",
                    defaultTab: 1,
                }, classList[0] ? defaultStyle[classList[0]] || {} : {}, this.dataset || {}),
                tabLabel = self.append('<div class="TabLabel"></div>').children(".TabLabel"),
                tabDivider = self.append('<div class="TabDivider"></div>').children(".TabDivider"),
                tabContent = self.append('<div class="TabContent"></div>').children(".TabContent"),
                labelPadding = data.labelPadding,
                labelColor = data.labelColor,
                styleSheet = {
                    label: {},
                    text: {},
                },
                labelSide = data.labelSide in sides ? data.labelSide : "top",
                side = sides[labelSide],
                labelColorSideReverse = truthy.includes(data.labelColorSideReverse),
                dividerSize = parseInt(data.dividerSize),
                defaultTab = parseInt(data.defaultTab);
            if(labelSide==="top"){
                tabLabel.after(tabDivider);
                tabDivider.after(tabContent);
            }else if(labelSide==="bottom"){
                tabContent.after(tabDivider);
                tabDivider.after(tabLabel);
            }
            if (!isNaN(dividerSize) && dividerSize > 0) {
                self.find(".TabDivider")[side.dividerSizeType](dividerSize);
            }
            var labelColorName = toUpperFirstCase(labelColorSideReverse ? side.labelColorSideReverse : side.labelColorSide);
            self.addClass(side.className);
            if (labelColorSideReverse) {
                self.addClass("reverse");
            }
            self.children(".Tab").each(function () {
                if ($(this).children(".TabLabelText").text().replace(/\s/g, "").length || $(this).children(".TabLabelText").children().length) {
                    $(this).children(".TabLabelText").appendTo(tabLabel);
                    $(this).children(".TabContentText").appendTo(self.children(".TabContent"));
                }
                $(this).remove();
            });
            if (isNaN(defaultTab) || defaultTab <= 0 || defaultTab > tabLabel.children(".TabLabelText").length) {
                defaultTab = 1;
            }
            tabLabel.children(".TabLabelText").on("click", function () {
                var label = $(this);
                label.addClass("selected").siblings().removeClass("selected").css({
                    "border-color": "transparent",
                    "background-color": "inherit",
                });
                tabContent.children(".TabContentText").eq(tabLabel.children(".TabLabelText").index(label)).addClass("selected").siblings().removeClass("selected").removeAttr("style");
                if (getOwnPropertyNamesLength(styleSheet.label) > 0) {
                    label.css(styleSheet.label);
                }
            }).eq(defaultTab - 1).click();
            if (labelPadding) {
                tabLabel.children(".TabLabelText").css("padding", labelPadding);
            }
            ["labelBorderColor", "labelBackgroundColor", "textPadding", "textBorderColor", "textBackgroundColor"].forEach(function (n) {
                var target = /^label/.test(n) ? "label" : "text",
                    key = toLowerFirstCase(n.replace(target, ""));
                styleSheet[target][key] = data[n];
            });
            if (labelColor) {
                styleSheet.label["border" + labelColorName + "Color"] = labelColor;
            } else if (styleSheet.label.borderColor) {
                styleSheet.label["border" + labelColorName + "Color"] = "green";
            }
            tabLabel.find(".selected").click();
            if (getOwnPropertyNamesLength(styleSheet.text) > 0) {
                tabContent.css(styleSheet.text);
            }
            if (data.autoWidth === "yes") {
                self.addClass("AutoWidth");
            }
            if (data.float === "left") {
                self.addClass("FloatLeft");
            }
            if (data.float === "right") {
                self.addClass("FloatRight");
            }

        });
    });
});
        //图片地址
        mw.loader.using("mediawiki.Uri").then(function () {
            setInterval(function () {
                $(document.querySelectorAll('img[src*="//img.moegirl.org/"]:not(.org-changed), img[src*="//commons.moegirl.org/"]:not(.org-changed)')).each(function (_, ele) {
                    try {
                        var url = new mw.Uri(ele.src);
                        if (["img.moegirl.org", "commons.moegirl.org"].includes(url.host)) {
                            url.host += ".cn";
                            ele.src = url;
                        }
                        ele.classList.add("org-changed");
                    } catch (e) { }
                });
            }, 200);
        });
        //修正hash跳转错误
        if ($(".mw-collapsible")[0]) {
            mw.loader.using("jquery.makeCollapsible", function() {
                $(".mw-collapsible").makeCollapsible();
                var hash = location.hash;
                location.hash = "";
                location.hash = hash;
            });
        }
           $(window).on("load", function () {
    //R18警告
    function r18Warning() {
        var content = $('<div id="x18"><div id="x18Context"><div id="x18Title"><div id="x18Icon"></div></div><div class="x18Button"></div></div></div>');
        if (!window.localStorage.getItem('x18')) { //如果没有x18记录
            $('body').css('overflow', 'hidden'); //禁止滚屏
            $('#mw-content-text').css({
                'opacity': 0
            }); 
     //禁止偷看
            content.prependTo('body').find('.x18Button').append('<div id="x18Yes">是</div><div id="x18No" class="x18Button">否</div>')
                .end().find('#x18Title').append('你是否已年满十八岁?')
                .end().delay(400).queue(function() {
                    $(this).css({
                        'opacity': 1
                    }); //显示警告信息
                    $(this).dequeue();
                });
            $('#x18Yes').on('click', function() {
                window.localStorage.setItem('x18', true); //记录x18
                $('#mw-content-text').css('opacity', 1).removeAttr('style'); //显示内容
                $("#x18").remove(); //移除警告信息
                $('body').removeAttr('style'); //允许滚屏
            });
            $('#x18No').on('click', function() {
                window.location.replace(window.location.origin + '/' + mw.config.get('wgMainPageTitle')); //不给你看
            });
        } else $("#x18").remove(); //如果有x18记录
    }
    $(function() {
        r18Warning();
    });
           });
})();
})(jQuery, mediaWiki); //立即执行匿名函数并传递原始变量以防止冲突
// </nowiki>