MediaWiki:Gadget-edit.js:修订间差异

来自兽耳维基
跳到导航 跳到搜索
test>屠麟傲血
无编辑摘要
 
(导入1个版本)
(没有差异)

2024年1月2日 (二) 23:15的版本

/* <pre> */
/**
 * -------------------------------------------------------------------------
 * !!! DON'T MODIFY THIS PAGE MANUALLY, YOUR CHANGES WILL BE OVERWRITTEN !!!
 * -------------------------------------------------------------------------
 */
var _addText = '{{difMGP|适配镜像站、本地化}}';

"use strict";
var __values = (this && this.__values) || function(o) {
    var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
    if (m) return m.call(o);
    if (o && typeof o.length === "number") return {
        next: function () {
            if (o && i >= o.length) o = void 0;
            return { value: o && o[i++], done: !o };
        }
    };
    throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
var __read = (this && this.__read) || function (o, n) {
    var m = typeof Symbol === "function" && o[Symbol.iterator];
    if (!m) return o;
    var i = m.call(o), r, ar = [], e;
    try {
        while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
    }
    catch (error) { e = { error: error }; }
    finally {
        try {
            if (r && !r.done && (m = i["return"])) m.call(i);
        }
        finally { if (e) throw e.error; }
    }
    return ar;
};
$(function () {
    var e_1, _a, e_2, _b;
    var wgPageName = mw.config.get("wgPageName");
    var wgNamespaceNumber = mw.config.get("wgNamespaceNumber");
    if (wgPageName.startsWith("萌娘百科_talk:讨论版/")) {
        $(".mw-editnotice + .mw-warning-with-logexcerpt").hide();
    }
    var sanityClean = function (h) {
        return $("<span>").text(h).html();
    };
    var wpSummary = $('[name="wpSummary"]');
    $(".mw-summary-preset-item a").on("click", function (_a) {
        if ( $(this).parent().attr('title') != null){
    	    wpSummary.val((wpSummary.val()+" "+$(this).parent().attr('title')).trim());
            }
        else {
            var summary = _a.target;
            wpSummary.val((wpSummary.val()+" "+$(summary).text()).trim());
            }
        wpSummary.trigger("focus");
        return false;
    });
    $(".wikiEditor-ui-controls").css("background-color", $("#content").css("background-color"));
    if ($(".mw-summary-preset")[0]) {
        $(".CheckNewSectionOn").hide();
    }
    else {
        $(".CheckNewSectionOff").hide();
        $('.headerInputbox a[href*="preload=Template%3A权限申请%2F"], .headerInputbox a[href*="preload=Template%3A%E6%9D%83%E9%99%90%E7%94%B3%E8%AF%B7%2F"]').attr("target", "_self");
    }
    if ($(".AbusefilterWarningNoHttp")[0]) {
    	var replaces = [];
        $("#wpTextbox1").val($("#wpTextbox1").val().replace(/http:\/\/([a-z\d]+\.bilibili\.[a-z\d]+)/ig, function (raw, $1) {
            var result = "https://".concat($1);
            replaces.push(raw, result);
        }));
        oouiDialog.alert("您的编辑内容含有以下 http 链接,已自动替换为对应的 https 链接:<ul><li>".concat(replaces.map(function (raw, result) { return "<code>".concat(sanityClean(raw), "</code> \u2192 <code>").concat(sanityClean(result), "</code>"); }), "</li></ul>"), {
            title: "萌娘百科提醒您",
            size: "medium"
        });
    }
    var prefixNumber = function (num) {
        var result = "".concat(num);
        if (result.length === 1) {
            result = "0".concat(result);
        }
        return result;
    };
    if ($(".permissions-errors, #wpTextbox1[readonly]")[1] && mw.config.get("wgUserName") && !$(".newComment")[0]) {
        var ns = [];
        if (wgNamespaceNumber < 0 || wgNamespaceNumber % 2 === 1) {
            return;
        }
        var talkNamespaceNumber = wgNamespaceNumber + 1;
        var talkns = -1;
        try {
            for (var _c = __values(Object.entries(mw.config.get("wgNamespaceIds"))), _d = _c.next(); !_d.done; _d = _c.next()) {
                var _e = __read(_d.value, 2), k = _e[0], v = _e[1];
                if (v === wgNamespaceNumber) {
                    ns.push(k);
                }
                if (talkns === -1 && v === talkNamespaceNumber) {
                    talkns = k;
                }
            }
        }
        catch (e_1_1) { e_1 = { error: e_1_1 }; }
        finally {
            try {
                if (_d && !_d.done && (_a = _c["return"])) _a.call(_c);
            }
            finally { if (e_1) throw e_1.error; }
        }
        if (!ns[0]) {
            return;
        }
        var page_1 = mw.config.get("wgPageName");
        var pageToLowerCase = page_1.toLowerCase();
        try {
            for (var ns_1 = __values(ns), ns_1_1 = ns_1.next(); !ns_1_1.done; ns_1_1 = ns_1.next()) {
                var n = ns_1_1.value;
                if (pageToLowerCase.startsWith(n)) {
                    page_1 = page_1.replace(new RegExp("^".concat(n, ":"), "i"), "");
                    break;
                }
            }
        }
        catch (e_2_1) { e_2 = { error: e_2_1 }; }
        finally {
            try {
                if (ns_1_1 && !ns_1_1.done && (_b = ns_1["return"])) _b.call(ns_1);
            }
            finally { if (e_2) throw e_2.error; }
        }
        var talkpage_1 = "".concat(talkns, ":").concat(page_1);
        var container = $("<div/>", {
            "class": "editRequest"
        });
        var now_1 = new Date();
        container.append("虽然您无权编辑本页面,但您可以点击右侧按钮在本页的讨论页提出编辑请求,让可以编辑的人代为编辑:");
        $("<span/>").addClass("newComment").text("提出编辑请求").on("click", function () {
            window.open("".concat(mw.config.get("wgServer")).concat(mw.config.get("wgScriptPath"), "/index.php?action=edit&preload=Template:编辑请求/").concat(/^MediaWiki:Conversiontable\/zh-[a-z]+$/.test(wgPageName) ? page_1 : "comment", "&preloadtitle=编辑请求 - ").concat(encodeURIComponent("".concat(mw.config.get("wgUserName"), " - ").concat(now_1.getFullYear(), ".").concat(prefixNumber(now_1.getMonth() + 1), ".").concat(prefixNumber(now_1.getDate()))), "&section=new&title=").concat(encodeURIComponent(talkpage_1)), "_blank");
        }).appendTo(container);
        $("#mw-content-text").children(".wikiEditor-ui:first, textarea[readonly]:first").before("<hr>").before(container);
    }
    var explainconflict = $("#mw-content-text > .mw-explainconflict #explainconflict-info");
    if (explainconflict[0]) {
        $("html, body").animate({
            scrollTop: explainconflict.closest(".infoBox").offset().top - 2
        }, 137);
    }
    if (![0, 2].includes(wgNamespaceNumber) || wgNamespaceNumber === 2 && !wgPageName.includes("/") || mw.config.get("wgPageContentModel") !== "wikitext") {
        $("#multiboilerplateform").remove();
    }
    if (new URLSearchParams(location.search).get("preloadtitle").startsWith("编辑请求") &&
        wgNamespaceNumber === 5 &&
        !mw.config.get("wgUserGroups").some(function (value) { return ["patroller", "sysop", "techeditor", "interface-admin", "staff"].includes(value); })) {
        OO.ui.alert($('<p>进行<b>实质性</b>修改时,需要通过<a href="/萌娘百科:提案" style="font-weight:bold">提案</a>或<a href="/萌娘百科:快速提案" style="font-weight:bold">快速提案</a>流程才可对方针和指引进行改动。</p><p>在讨论页发起的编辑请求仅可用于修正错别字等<b>非实质性</b>修改。</p>'), {
            title: "提醒",
            size: "small",
            actions: [
                {
                    action: "Confirm",
                    label: "我知道了"
                },
            ]
        });
    }
});

/* </pre> */