2023年政策修订增补工作正在进行中,欢迎参与!
MediaWiki:Gadget-Force preview.js
跳转到导航
跳转到搜索
注意:在保存之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。
- Firefox/Safari:按住“Shift”的同时单击“刷新”,或按“Ctrl-F5”或“Ctrl-R”(Mac为“⌘-R”)
- Google Chrome:按“Ctrl-Shift-R”(Mac为“⌘-Shift-R”)
- Internet Explorer:按住“Ctrl”的同时单击“刷新”,或按“Ctrl-F5”
- Opera:在“工具→首选项”中清除缓存
- 如果您已登录但该页面出现未登录状态,请尝试在地址栏的地址最后添加代码
?_=1
来访问最新页面。 - 添加代码后的本页地址如下:
-{R|https://moegirl.icu/MediaWiki:Gadget-Force_preview.js?_=1}-
萌娘百科界面管理员团队提醒您
本页面由萌娘百科界面管理员团队在其 GitHub 库内进行维护,通过机器人自动生成可被 MediaWiki Gadget 扩展接受的版本并保存到此处。
如果您有任何意见或建议,建议您到技术实现版提出。
- 本页面的内容为自动生成,手动修改可能会被覆盖,源码可在此处查看;
- 最新修订由 U:AnnAngela 与 U:Bhsd、GH:github-actions[bot] 共同做出,相关 commit 为:bf83eaea - ci: use eslint flat config (#400) [展开/折叠]
Co-authored-by: Bhsd <55071315+bhsd-harry📧users.noreply.github.com>↩Co-authored-by: github-actions[bot] <41898282+github-actions[bot]📧users.noreply.github.com>
/** * ------------------------------------------------------------------------- * !!! DON'T MODIFY THIS PAGE MANUALLY, YOUR CHANGES WILL BE OVERWRITTEN !!! * ------------------------------------------------------------------------- */ var _addText = '{{GHIACode|page=GHIA:MoegirlPediaInterfaceCodes/blob/master/src/gadgets/Force_preview/MediaWiki:Gadget-Force_preview.js|user=[[U:AnnAngela]]|co-authors=[[U:Bhsd]]、GH:github-actions[bot]|longId=bf83eaea8eb4d94405bdf6885ec072fec997dd56|shortId=bf83eaea|summary=ci: use eslint flat config (#400)|body=<nowiki>Co-authored-by: Bhsd <55071315+bhsd-harry📧users.noreply.github.com>↩Co-authored-by: github-actions[bot] <41898282+github-actions[bot]📧users.noreply.github.com></nowiki>}}'; /* <pre> */ "use strict"; $(function () { var wgPermittedGroups = ["autoconfirmed", "staff"]; var intersects = function (arr1, arr2) { if (!Array.isArray(arr1) || !Array.isArray(arr2)) { return false; } for (var i1 = 0, l1 = arr1.length; i1 < l1; i1++) { if (arr1.indexOf(arr1[i1]) === -1) { continue; } for (var i2 = 0, l2 = arr2.length; i2 < l2; i2++) { if (arr2.indexOf(arr2[i2]) === -1) { continue; } if (arr1[i1] === arr2[i2]) { return true; } } } return false; }; if (mw.config.get("wgAction") !== "edit" || (intersects(mw.config.get("wgUserGroups"), wgPermittedGroups) && +mw.user.options.get("gadget-ForcePreviewUponUserRequest", 0) !== 1)) { return; } var saveButton = $("#wpSave"); var previewButton = $("#wpPreview"); var previewContainer = $("#wikiPreview"); var isUserChosenPreviewLive = [true, 1, "1"].includes(mw.user.options.get("uselivepreview")); var isPreviewedLive = false; if (!saveButton[0]) { return; } var oldSaveBottonValue = saveButton.val(); var tcb = $("#TencentCaptchaBtn"); if (tcb.length > 0) { tcb.attr("disabled", "disabled").hide().after('<button type="button" class="mw-ui-button mw-ui-progressive mw-ui-primary" style="display: block;" disabled="disabled">请先预览</button>'); } saveButton.attr("disabled", "disabled").val("预览一次后才可保存内容").css("font-weight", "normal").parent().removeClass("oo-ui-widget-enabled oo-ui-flaggedElement-primary oo-ui-flaggedElement-progressive").addClass("oo-ui-widget-disabled"); var hook = mw.hook("wikipage.editform"); var hookFunc = function () { var previewArea = previewContainer.children(".mw-content-ltr, .mw-content-rtl"); if (previewArea[0] && previewArea.is(":not(:empty)")) { if (!isPreviewedLive) { isPreviewedLive = true; saveButton.removeAttr("disabled").val(oldSaveBottonValue).css("font-weight", "700").parent().addClass("oo-ui-widget-enabled oo-ui-flaggedElement-primary oo-ui-flaggedElement-progressive").removeClass("oo-ui-widget-disabled"); previewButton.closest(".oo-ui-buttonElement-framed").removeClass("oo-ui-flaggedElement-primary oo-ui-flaggedElement-progressive"); if (tcb.length > 0) { tcb.removeAttr("disabled").show().next().remove(); } } hook.remove(hookFunc); } }; previewButton.closest(".oo-ui-buttonElement-framed").addClass("oo-ui-flaggedElement-primary oo-ui-flaggedElement-progressive").on("click", function () { if (isUserChosenPreviewLive && !isPreviewedLive) { hook.add(hookFunc); } }); var captureSupported = false; try { var options = Reflect.defineProperty({}, "capture", { get: function () { captureSupported = true; return undefined; } }); window.addEventListener("test", null, options); } catch (_a) { } saveButton[0].addEventListener("click", function (e) { if (!isPreviewedLive) { e.preventDefault(); e.stopImmediatePropagation(); e.stopPropagation(); return false; } }, captureSupported ? { capture: true } : true); if (Reflect.has(window, "MutationObserver")) { var observer = new MutationObserver(function () { if (!isPreviewedLive) { if (saveButton.is(":enabled")) { saveButton.attr("disabled", "disabled"); } } else { if (saveButton.is(":disabled")) { saveButton.removeAttr("disabled"); } } }); observer.observe(saveButton[0], { attributes: true, childList: true, subtree: true }); } }); /* </pre> */