User:Neiltyson1fan/ForcePreview.js
Jump to navigation
Jump to search
Note: After saving, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
if (mw.config.get("wgAction") === "edit")
$.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("Save page (use preview first)")
.parent().removeClass(classNames).addClass("oo-ui-widget-disabled");
$wpPreview.one("click", function (e) { // re-enable
$wpSave.prop("disabled", false)
.val(saveVal)
.parent().removeClass("oo-ui-widget-disabled").addClass(classNames);
}).parent().addClass(classNames);
}
});