MediaWiki:Gadget-edit.js

来自兽耳维基
跳到导航 跳到搜索

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

  • Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5Ctrl-R(Mac为⌘-R
  • Google Chrome:Ctrl-Shift-R(Mac为⌘-Shift-R
  • Internet Explorer或Edge:按住Ctrl的同时单击刷新,或按Ctrl-F5
  • Opera:Ctrl-F5
"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");
    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;
    });
    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;
    };
    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();
    }
});