MediaWiki:Gadget-CleanDeleteReasons.js

From Moegirlpedia
Revision as of 17:05, 27 March 2022 by 星海-adminbot (talk | contribs) (同步小工具)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, 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: 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.
/* eslint-disable prefer-arrow-callback */
/* eslint-disable prefer-template */
/* eslint-disable comma-dangle */
/* eslint-disable no-var */
/* eslint dot-notation: ["error", { "allowPattern": "^(?:catch|default)$" } ] */
/* eslint-disable no-unused-vars */
/* eslint-disable no-redeclare */
/* global mw, $, OO, moment, Cron, prettyPrint, LocalObjectStorage, lazyload, wgULS */
/* eslint-enable no-unused-vars */
/* eslint-enable no-redeclare */
"use strict";
// <pre>
$(function () {
    var wpReason = $("#wpReason");
    if (mw.config.get("wgAction") === "delete" && wpReason.length > 0) {
        if (/(?:^内容|內容|被清空前|页面为空|頁面為空|page was empty|content was|content before blanking was)/i.test($("#wpReason").val())) {
            $("#wpReason").val("");
        }
        $.get(mw.config.get("wgServer") + mw.config.get("wgScriptPath") + "/index.php?action=render&curid=" + mw.config.get("wgArticleId"), function (h) {
            var root = $("<div/>").html(h);
            var reason = root.find(".mw-parser-output > .infoBox.will2Be2Deleted #reason");
            var actor = root.find(".mw-parser-output > .infoBox.will2Be2Deleted #actor a").first();
            if (reason.length === 1 && actor.length === 1) {
                $("#wpReason").val("删除被挂删的页面,[[User_talk:" + actor.text() + "|" + actor.text() + "]]的挂删理由:''" + reason.text() + "''");
            }
        });
    }
});
// </pre>