来自柯南百科

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

  • 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
// 权限设置
// 被豁免的用户组。当前设置为所有手动用户组。
const forcedPreviewExemptedGroups = ['bot', 'bureaucrat', 'canupload', 'goodeditor', 'inspector', 'interface-admin', 'replacetextor', 'suppress', 'sysop'];
// 被豁免的最小编辑数。当前设置为10。即使用户不在前述用户组中,达到该编辑数后强制预览的功能也会自动关闭。
const forcedPreviewExemptedEditCount = 10;

// Core
const forcedPreviewGJ = mw.config.get("wgUserGroups").filter(function (group) {
    return forcedPreviewExemptedGroups.indexOf(group) > -1;
}).length;
// 以下内容依CC BY-SA 3.0引用自https://www.mediawiki.org/wiki/Manual:Force_preview,作了触发条件的修改。
if (mw.config.get("wgAction") === "edit" && forcedPreviewGJ < 1 && mw.config.get("wgUserEditCount") < forcedPreviewExemptedEditCount)
    $.when(mw.loader.using("user.options"), $.ready).then(function () {
        var $wpSave = $("#wpSave"),
            $wpPreview = $("#wpPreview"),
            saveVal = $wpSave.val(),
            classNames = "oo-ui-widget-enabled oo-ui-flaggedElement-progressive oo-ui-flaggedElement-primary";
        if (!mw.user.options.get("forceeditsummary") || mw.user.options.get("previewonfirst"))
            mw.loader.using("mediawiki.api", function () {
                new mw.Api().saveOptions({ forceeditsummary: 1, previewonfirst: 0 });
            });
        if (!$("#wikiPreview,#wikiDiff").is(":visible") && $wpSave.length && $wpPreview.length) {
            $wpSave.prop("disabled", true)
                .val("预览后才能保存")
                .parent().removeClass(classNames).addClass("oo-ui-widget-disabled");
            $wpPreview.one("click", function (e) {
                $wpSave.prop("disabled", false)
                    .val(saveVal)
                    .parent().removeClass("oo-ui-widget-disabled").addClass(classNames);
            }).parent().addClass(classNames);
        }
    });