MediaWiki:Common.js:修订间差异

imported>=海豚=
不起作用
imported>=海豚=
无编辑摘要
第1行: 第1行:
/* 这里的任何JavaScript将为所有用户在每次页面载入时加载。 */
/* eslint-disable no-var */
(function() {
/* eslint-disable no-magic-numbers */
/* global OO, mediaWiki, jQuery */
// <nowiki>
/* 这里的任何JavaScript将在全站加载
* 请尊重版权,以下代码复制需要注明原自H萌娘,并且附上URL地址http://www.hmoegirl.com/MediaWiki:Common.js
* 版权协定:知识共享 署名-非商业性使用-相同方式共享 3.0
*  loader模块 写法参见 https://www.mediawiki.org/wiki/ResourceLoader/Modules#mw.loader.load
*/
"use strict";
(function($, mw) { //使用匿名函数防止污染顶级变量
    /* 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的半透明化修改,用于保持背景文字处于原位,本应修改插件达成的,暂时先用JavaScript应急处理下
    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("wgMultimediaViewer") !== "on") {
                    mw.config.set("wgMultimediaViewer", "on");
                    $(".mw-mmv-image").off("click")[0].addEventListener("click", function(e) {
                        if ($(e.target).is("img")) {
                            window.open($(e.target).attr("src").replace(/(img\.moegirl\.org\/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("wgMultimediaViewer") === "on") {
                flag = false;
                mw.config.set("wgMultimediaViewer", "off");
            }
        }, 137);
    }
     //Tabs
     //Tabs
     function tabs() {
     function tabs() {
         var defaultStyle = {
         var defaultStyle = {
             purple: {
             purple: {
                 labelColor: ' ', //anti check
                 labelColor: " ", //anti check
                 labelBackgroundColor: '#9070c0',
                 labelBackgroundColor: "#9070c0",
                 labelBorderColor: '#b090e0 #7050a0 #9070c0 #b090e0',
                 labelBorderColor: "#b090e0 #7050a0 #9070c0 #b090e0",
                 labelPadding: '.2em .3em .2em .3em',
                 labelPadding: ".2em .3em .2em .3em",
                 textBorderColor: '#9070c0',
                 textBorderColor: "#9070c0",
                 textBackgroundColor: '#f0edf5',
                 textBackgroundColor: "#f0edf5",
                 textPadding: '1em'
                 textPadding: "1em",
             },
             },
             green: {
             green: {
                 labelColor: ' ',
                 labelColor: " ",
                 labelBackgroundColor: '#75c045',
                 labelBackgroundColor: "#75c045",
                 labelBorderColor: '#90d060 #60b030 #75c045 #90d060',
                 labelBorderColor: "#90d060 #60b030 #75c045 #90d060",
                 labelPadding: '.2em .3em .2em .3em',
                 labelPadding: ".2em .3em .2em .3em",
                 textBorderColor: '#75c045 #60b030 #60b030 #75c045',
                 textBorderColor: "#75c045 #60b030 #60b030 #75c045",
                 textBackgroundColor: '#f5fffa',
                 textBackgroundColor: "#f5fffa",
                 textPadding: '1em'
                 textPadding: "1em",
             },
             },
             red: {
             red: {
                 labelColor: ' ',
                 labelColor: " ",
                 labelBackgroundColor: '#FF0000',
                 labelBackgroundColor: "#FF0000",
                 labelBorderColor: '#FF8888 #CC0000 #FF0000 #FF8888',
                 labelBorderColor: "#FF8888 #CC0000 #FF0000 #FF8888",
                 labelPadding: '.2em .3em .2em .3em',
                 labelPadding: ".2em .3em .2em .3em",
                 textBorderColor: '#FF0000 #CC0000 #CC0000 #FF0000',
                 textBorderColor: "#FF0000 #CC0000 #CC0000 #FF0000",
                 textBackgroundColor: '#fffafa',
                 textBackgroundColor: "#fffafa",
                 textPadding: '1em'
                 textPadding: "1em",
             },
             },
             blue: {
             blue: {
                 labelColor: ' ',
                 labelColor: " ",
                 labelBackgroundColor: '#5b8dd6',
                 labelBackgroundColor: "#5b8dd6",
                 labelBorderColor: '#88abde #3379de #5b8dd6 #88abde',
                 labelBorderColor: "#88abde #3379de #5b8dd6 #88abde",
                 labelPadding: '.2em .3em .2em .3em',
                 labelPadding: ".2em .3em .2em .3em",
                 textBackgroundColor: '#f0f8ff',
                 textBackgroundColor: "#f0f8ff",
                 textBorderColor: '#5b8dd6 #3379de #3379de #5b8dd6',
                 textBorderColor: "#5b8dd6 #3379de #3379de #5b8dd6",
                 textPadding: '1em'
                 textPadding: "1em",
             },
             },
             yellow: {
             yellow: {
                 labelColor: ' ',
                 labelColor: " ",
                 labelBackgroundColor: '#ffe147',
                 labelBackgroundColor: "#ffe147",
                 labelBorderColor: '#ffe977 #ffd813 #ffe147 #ffe977',
                 labelBorderColor: "#ffe977 #ffd813 #ffe147 #ffe977",
                 labelPadding: '.2em .3em .2em .3em',
                 labelPadding: ".2em .3em .2em .3em",
                 textBackgroundColor: '#fffce8',
                 textBackgroundColor: "#fffce8",
                 textBorderColor: '#ffe147 #ffd813 #ffd813 #ffe147',
                 textBorderColor: "#ffe147 #ffd813 #ffd813 #ffe147",
                 textPadding: '1em'
                 textPadding: "1em",
             },
             },
             orange: {
             orange: {
                 labelColor: ' ',
                 labelColor: " ",
                 labelBackgroundColor: '#ff9d42',
                 labelBackgroundColor: "#ff9d42",
                 labelBorderColor: '#ffac5d #ff820e #ff9d42 #ffac5d',
                 labelBorderColor: "#ffac5d #ff820e #ff9d42 #ffac5d",
                 labelPadding: '.2em .3em .2em .3em',
                 labelPadding: ".2em .3em .2em .3em",
                 textBackgroundColor: '#ffeedd',
                 textBackgroundColor: "#ffeedd",
                 textBorderColor: '#ff9d42 #ff820e #ff820e #ff9d42',
                 textBorderColor: "#ff9d42 #ff820e #ff820e #ff9d42",
                 textPadding: '1em'
                 textPadding: "1em",
             },
             },
             black: {
             black: {
                 labelColor: ' ',
                 labelColor: " ",
                 labelBackgroundColor: '#7f7f7f',
                 labelBackgroundColor: "#7f7f7f",
                 labelBorderColor: '#999999 #4c4c4c #7f7f7f #999999',
                 labelBorderColor: "#999999 #4c4c4c #7f7f7f #999999",
                 labelPadding: '.2em .3em .2em .3em',
                 labelPadding: ".2em .3em .2em .3em",
                 textBackgroundColor: '#e5e5e5',
                 textBackgroundColor: "#e5e5e5",
                 textBorderColor: '#7f7f7f #4c4c4c #4c4c4c #7f7f7f',
                 textBorderColor: "#7f7f7f #4c4c4c #4c4c4c #7f7f7f",
                 textPadding: '1em'
                 textPadding: "1em",
             }
             },
         };
         };
         $('body').addClass('tab');
         $("body").addClass("tab");
         // 新建一个Class 以避免许多问题
         // A Class
         function StyleSheet() {}
         function StyleSheet() {}
         StyleSheet.prototype.getOwnPropertyNamesLength = function getOwnPropertyNamesLength() {
         StyleSheet.prototype.getOwnPropertyNamesLength = function getOwnPropertyNamesLength() {
第77行: 第142行:
             return this[0].toLowerCase() + this.substring(1);
             return this[0].toLowerCase() + this.substring(1);
         };
         };
         $('.Tabs').each(function(i) {
         $(".Tabs").each(function() {
             if ($(this).find('.TabLabel')[0]) return true;
             if ($(this).children(".TabLabel")[0]) { return true; }
             var self = $(this),
             var self = $(this),
                classList = Array.from(this.classList).filter(function(n) { return n in defaultStyle; }),
                 data = $.extend({
                 data = $.extend({
                     labelPadding: null,
                     labelPadding: "2px",
                     labelBorderColor: null,
                     labelBorderColor: "#aaa",
                     labelColor: null,
                     labelColor: "green",
                     labelBackgroundColor: $('#content').css('background-color'),
                     labelBackgroundColor: $("#content").css("background-color"),
                     textPadding: null,
                     textPadding: "20px 30px",
                     textBorderColor: null,
                     textBorderColor: "#aaa",
                     textBackgroundColor: null,
                     textBackgroundColor: "white",
                     defaultTab: 1,
                     defaultTab: 1,
                 }, self.attr('class').length > 4 ? defaultStyle[self.attr('class').slice(5)] || {} : {}, this.dataset || {}),
                 }, classList[0] ? defaultStyle[classList[0]] || {} : {}, this.dataset || {}),
                 tabLabel = self.append('<div class="TabLabel"></div>').find('.TabLabel'),
                 tabLabel = self.append('<div class="TabLabel"></div>').children(".TabLabel"),
                 tabContent = self.append('<div class="TabContent"></div>').find('.TabContent'),
                 tabContent = self.append('<div class="TabContent"></div>').children(".TabContent"),
                 labelPadding = data.labelPadding,
                 labelPadding = data.labelPadding,
                 labelColor = data.labelColor,
                 labelColor = data.labelColor,
                 styleSheet = {
                 styleSheet = {
                     label: new StyleSheet(),
                     label: new StyleSheet(),
                     text: new StyleSheet()
                     text: new StyleSheet(),
                 },
                 },
                 defaultTab = parseInt(data.defaultTab);
                 defaultTab = parseInt(data.defaultTab);
             self.find('.Tab').each(function() {
             self.children(".Tab").each(function() {
                 $(this).find('.TabLabelText').appendTo(self.find('.TabLabel'));
                 if ($(this).children(".TabLabelText").text().replace(/\s/g, "").length || $(this).children(".TabLabelText").children().length) {
                $(this).find('.TabContentText').appendTo(self.find('.TabContent'));
                    $(this).children(".TabLabelText").appendTo(tabLabel);
                    $(this).children(".TabContentText").appendTo(self.children(".TabContent"));
                }
                 $(this).remove();
                 $(this).remove();
             });
             });
             if (isNaN(defaultTab) || defaultTab <= 0 || defaultTab > self.find('.TabLabelText').length) defaultTab = 1;
             if (isNaN(defaultTab) || defaultTab <= 0 || defaultTab > tabLabel.children(".TabLabelText").length) { defaultTab = 1; }
             self.find('.TabLabelText').on('click', function() {
             tabLabel.children(".TabLabelText").on("click", function() {
                 var label = $(this);
                 var label = $(this);
                 label.addClass('selected').siblings().removeClass('selected').css({
                 label.addClass("selected").siblings().removeClass("selected").css({
                     'border-color': '#aaa',
                     "border-color": "transparent",
                     'background-color': 'inherit'
                     "background-color": "inherit",
                 });
                 });
                 self.find('.TabContentText').eq(self.find('.TabLabelText').index(label)).addClass('selected').siblings().removeClass('selected').removeAttr('style');
                 tabContent.children(".TabContentText").eq(tabLabel.children(".TabLabelText").index(label)).addClass("selected").siblings().removeClass("selected").removeAttr("style");
                 if (styleSheet.label.getOwnPropertyNamesLength()) label.css(styleSheet.label);
                 if (styleSheet.label.getOwnPropertyNamesLength()) { label.css(styleSheet.label); }
                self.find('.TabLabel').height(label.height() + parseFloat(label.css('padding-top')) + parseFloat(label.css('padding-bottom')) + 2);
             }).eq(defaultTab - 1).click();
             }).eq(defaultTab - 1).click();
             if (labelPadding) self.find('.TabLabelText').css('padding', labelPadding);
             if (labelPadding) { tabLabel.children(".TabLabelText").css("padding", labelPadding); }
             ['labelBorderColor', 'labelBackgroundColor', 'textPadding', 'textBorderColor', 'textBackgroundColor'].forEach(function(n) {
             ["labelBorderColor", "labelBackgroundColor", "textPadding", "textBorderColor", "textBackgroundColor"].forEach(function(n) {
                 var target = /^label/.test(n) ? 'label' : 'text',
                 var target = /^label/.test(n) ? "label" : "text",
                     key = n.replace(target, '').toLowerFirstCase();
                     key = n.replace(target, "").toLowerFirstCase();
                 styleSheet[target][key] = data[n];
                 styleSheet[target][key] = data[n];
             });
             });
             if (labelColor) styleSheet.label.borderTopColor = labelColor;
             if (labelColor) {
             else if (styleSheet.label.borderColor) styleSheet.label.borderTopColor = 'green';
                styleSheet.label.borderTopColor = labelColor;
             tabLabel.find('.selected').click();
 
             if (styleSheet.text.getOwnPropertyNamesLength()) tabContent.css(styleSheet.text);
             } else if (styleSheet.label.borderColor) {
             if (data.autoWidth == 'yes') self.css('display', 'inline-block');
                styleSheet.label.borderTopColor = "green";
            }
             tabLabel.find(".selected").click();
             if (styleSheet.text.getOwnPropertyNamesLength()) { tabContent.css(styleSheet.text); }
             if (data.autoWidth === "yes") { self.css("display", "inline-block"); }
        });
    }
    //子页面页顶链接
    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://zh.moegirl.org/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 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://zh.moegirl.org/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 antiAbuseListener(textarea, event) {
        var filters = [
            "{{即将删除",
            "{{即將刪除",
            "{{挂删",
            "{{模板:即将删除",
            "{{模板:即將刪除",
            "{{template:即将删除",
            "{{template:即將刪除",
            "[[分类:即将删除的页面",
            "[[分類:即將刪除的頁面",
            "[[category:即将删除的页面",
            "[[category:即將刪除的頁面",
            "{{文件转移到萌娘共享",
            "{{文件轉移到萌娘共享",
            "{{模板:文件转移到萌娘共享",
            "{{模板:文件轉移到萌娘共享",
            "{{template:文件转移到萌娘共享",
            "{{template:文件轉移到萌娘共享",
            "[[分类:需要删除执行员删除的页面",
            "[[分類:需要刪除執行員刪除的頁面",
            "[[category:需要删除执行员删除的页面",
            "[[category:需要刪除執行員刪除的頁面",
        ];
        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萌娘提醒您<br>您的编辑包含禁止内容!");
            messageDialog.message.$label.html("<br>您提交的内容包含以下部分,被禁止提交:<br><br><ul>" + results.map(function(result) {
                return "<li>" + result + "</li>";
            }).join("") + '</ul><br><br>如果您认为您的编辑无误,请在自行保存编辑内容后到<a target="_blank" rel="nofollow noreferrer noopener" class="external text" href="https://zh.moegirl.org/Talk:%E6%8F%90%E9%97%AE%E6%B1%82%E5%8A%A9%E5%8C%BA">提问求助区</a>提问。');
            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);
            }
         });
         });
     }
     }
    /* 函数执行体 */
    $(function() {
        //Template:heimu在safari上的暴力workaround
        mw.loader.using("jquery.client", function() {
            if ($.client.profile().name === "safari") {
                $(".heimu").on("click", function() {
                    $(this).toggleClass("off");
                });
            }
        });
        var copyRightsNameSpaces = [ // 以下为允许添加版权声明的名字空间列表
            0, // (主)
            4, // H萌娘
            8, // MediaWiki
            10, // Template
            12, // Help
            614, // R18
        ];
        //滚动公告
        autoScroll("#scrollDiv");
        //Extension:MultimediaViewer的半透明化修改
        if ($("img[srcset][data-file-width][data-file-height]")[0]) { multimediaViewer(); }
        // Add "mainpage" class to the body element
        if (mw.config.get("wgMainPageTitle") === mw.config.get("wgPageName") && mw.config.get("wgAction") === "view") { $("body").addClass("mainpage"); }
        //重复文件列表区分图片和音频
        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"); }
        // Tabs执行
        mw.hook('wikipage.content').add(function() { tabs(); });
        //子页面页顶链接
        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() {
         $(".reference-text > ul,.reference-text > ol").each(function() {
第145行: 第406行:
             });
             });
         }, 200);
         }, 200);
        //修正hash跳转错误
        if ($(".mw-collapsible")[0]) {
            mw.loader.using("jquery.makeCollapsible", function() {
                $(".mw-collapsible").makeCollapsible();
                var hash = location.hash;
                location.hash = "";
                location.hash = hash;
            });
        }
        //防滥用即将删除
        if (!mw.config.get("wgUserGroups").includes("sysop") && !mw.config.get("wgUserGroups").includes("patroller")) {
            setInterval(function() {
                if ($(".Wikiplus-InterBox")[0]) {
                    var targetBox = $(".Wikiplus-InterBox");
                    if (targetBox.data("isTrusted") !== true) {
                        targetBox.data("isTrusted", true);
                        targetBox.css("z-index", 100);
                        antiAbuse($("#Wikiplus-Quickedit")[0], $("#Wikiplus-Quickedit-Submit")[0], undefined);
                        var events = $._data($("#Wikiplus-Quickedit")[0], "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($("#Wikiplus-Quickedit")[0], e) !== false) {
                                        $("#Wikiplus-Quickedit-Submit").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);
        }
     //R18警告
     //R18警告
     function r18Warning() {
     function r18Warning() {
第152行: 第460行:
             $('#mw-content-text').css({
             $('#mw-content-text').css({
                 'opacity': 0
                 'opacity': 0
             }); //禁止偷看
             });  
    //禁止偷看
             content.prependTo('body').find('.x18Button').append('<div id="x18Yes">是</div><div id="x18No" class="x18Button">否</div>')
             content.prependTo('body').find('.x18Button').append('<div id="x18Yes">是</div><div id="x18No" class="x18Button">否</div>')
                 .end().find('#x18Title').append('你是否已年满十八岁?')
                 .end().find('#x18Title').append('你是否已年满十八岁?')
第177行: 第486行:
     });
     });
})();
})();
        //以下代码必须在全部内容加载完成后才能正常工作
        $(window).on("load", function() {
            //语言对应
            $(".mw-helplink").each(function() {
                var linkHref = this.href;
                if (linkHref.indexOf("/zh") !== linkHref.length - 3) { this.href += "/zh"; }
            });
        });
    });
})(jQuery, mediaWiki); //立即执行匿名函数并传递原始变量以防止冲突
// </nowiki>