|
|
| 第131行: |
第131行: |
| }).appendTo(container); | | }).appendTo(container); |
| $("#mw-content-text").children(".wikiEditor-ui:first, textarea[readonly]:first").before("<hr>").before(container); | | $("#mw-content-text").children(".wikiEditor-ui:first, textarea[readonly]:first").before("<hr>").before(container); |
| }
| |
| //防滥用即将删除模板
| |
| function antiAbuseListener(textarea, event) {
| |
| var filters = [
| |
| "{{即将删除",
| |
| "{{即將刪除",
| |
| "{{挂删",
| |
| "{{模板:即将删除",
| |
| "{{模板:即將刪除",
| |
| "{{template:即将删除",
| |
| "{{template:即將刪除",
| |
| "[[分类:即将删除的页面",
| |
| "[[分類:即將刪除的頁面",
| |
| "[[category:即将删除的页面",
| |
| "[[category:即將刪除的頁面",
| |
| "{{文件转移到萌娘共享",
| |
| "{{文件轉移到萌娘共享",
| |
| "{{模板:文件转移到萌娘共享",
| |
| "{{模板:文件轉移到萌娘共享",
| |
| "{{template:文件转移到萌娘共享",
| |
| "{{template:文件轉移到萌娘共享",
| |
| "[[分类:需要删除执行员删除的页面",
| |
| "[[分類:需要刪除執行員刪除的頁面",
| |
| "[[category:需要删除执行员删除的页面",
| |
| "[[category:需要刪除執行員刪除的頁面",
| |
| ];
| |
| var text1 = textarea.value;
| |
| text1 = text1.replace(/<\/?(?:nowiki|noinclude)>/g, "");
| |
| text1 = text1.replace(/<(onlyinclude|includeonly)>.*?<\/\1>/g, "");
| |
| var text2 = textarea.value;
| |
| text2 = text2.replace(/<\/?(?:onlyinclude|includeonly)>/g, "");
| |
| text2 = text2.replace(/<(nowiki|noinclude)>.*?<\/\1>/g, "");
| |
| var results = [];
| |
| for (var i = 0, l = filters.length; i < l; i++) {
| |
| var regExp = new RegExp(filters[i].replace(/\[/g, "\\["), "i");
| |
| if (regExp.test(text1) || regExp.test(text2)) { results.push(filters[i]); }
| |
| }
| |
| if (results.length > 0) {
| |
| var messageDialog = new OO.ui.MessageDialog();
| |
| var windowManager = new OO.ui.WindowManager();
| |
| $("body").append(windowManager.$element);
| |
| windowManager.addWindows([messageDialog]);
| |
| messageDialog.title.$label.html("H萌娘提醒您<br>您的编辑包含禁止内容!");
| |
| messageDialog.message.$label.html("<br>您提交的内容包含以下部分,被禁止提交:<br><br><ul>" + results.map(function(result) {
| |
| return "<li>" + result + "</li>";
| |
| }).join("") + '</ul><br><br>如果您认为您的编辑无误,请在自行保存编辑内容后到<a target="_blank" rel="nofollow noreferrer noopener" class="external text" href="https://www.hmoegirl.com/Talk:讨论版">讨论版</a>提问。');
| |
| windowManager.openWindow(messageDialog, {
| |
| actions: [{
| |
| action: "accept",
| |
| label: "我知道了",
| |
| flags: "primary",
| |
| }],
| |
| });
| |
| event.preventDefault();
| |
| event.stopImmediatePropagation();
| |
| event.stopPropagation();
| |
| return false;
| |
| }
| |
| }
| |
|
| |
| function antiAbuse(textarea, submitButton, form) {
| |
| mw.loader.using(["oojs-ui"]).then(function() {
| |
| if (submitButton) {
| |
| submitButton.addEventListener("click", function(e) {
| |
| antiAbuseListener(textarea, e);
| |
| }, captureSupported ? {
| |
| capture: true,
| |
| } : true);
| |
| }
| |
| if (form) {
| |
| form.addEventListener("submit", function(e) {
| |
| antiAbuseListener(textarea, e);
| |
| }, captureSupported ? {
| |
| capture: true,
| |
| } : true);
| |
| }
| |
| });
| |
| } | | } |
| /* 函数执行体 */ | | /* 函数执行体 */ |
| 第268行: |
第191行: |
| }); | | }); |
| } | | } |
| //防滥用即将删除
| | |
| if (!mw.config.get("wgUserGroups").includes("sysop") && !mw.config.get("wgUserGroups").includes("patroller")) {
| |
| setInterval(function() {
| |
| if ($(".Wikiplus-InterBox")[0]) {
| |
| var targetBox = $(".Wikiplus-InterBox");
| |
| if (targetBox.data("isTrusted") !== true) {
| |
| targetBox.data("isTrusted", true);
| |
| targetBox.css("z-index", 100);
| |
| antiAbuse($("#Wikiplus-Quickedit")[0], $("#Wikiplus-Quickedit-Submit")[0], undefined);
| |
| var events = $._data($("#Wikiplus-Quickedit")[0], "events");
| |
| if (events && events.keydown) {
| |
| events.keydown.sort(function(a, b) {
| |
| return a.guid - b.guid;
| |
| });
| |
| events.keydown[0].handler = function(e) {
| |
| if (e.ctrlKey && e.which === 83) {
| |
| if (e.shiftKey) {
| |
| $("#Wikiplus-Quickedit-MinorEdit").click();
| |
| }
| |
| if (antiAbuseListener($("#Wikiplus-Quickedit")[0], e) !== false) {
| |
| $("#Wikiplus-Quickedit-Submit").click();
| |
| e.preventDefault();
| |
| e.stopPropagation();
| |
| }
| |
| }
| |
| };
| |
| }
| |
| }
| |
| }
| |
| if ($("form#editform")[0]) {
| |
| var targetForm = $("form#editform");
| |
| if (targetForm.data("isTrusted") !== true) {
| |
| targetForm.data("isTrusted", true);
| |
| antiAbuse($("#wpTextbox1")[0], $("#wpSave")[0], targetForm[0]);
| |
| }
| |
| }
| |
| }, 1000);
| |
| }
| |
| //R18警告 | | //R18警告 |
| function r18Warning() { | | function r18Warning() { |
| 第335行: |
第221行: |
| } | | } |
| $(function() { | | $(function() { |
| tabs();
| |
| r18Warning(); | | r18Warning(); |
| }); | | }); |