跳转到内容

MediaWiki:Gadget-CleanDeleteReasons.js

勤求古训,博采众方

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

  • Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5Ctrl-R(Mac为⌘-R
  • Google Chrome:Ctrl-Shift-R(Mac为⌘-Shift-R
  • Edge:按住Ctrl的同时单击刷新,或按Ctrl-F5
//Written and maintained by [[User:Mike.lifeguard]]
function deletemods(){
    if (mw.config.get('wgAction') === "delete") { // 使用严格相等运算符提升严谨性
        const wpReason = document.getElementById("wpReason"); // 使用 const 声明非重新赋值变量
        if (!wpReason) return;
        const regexp = /(内容为|page was empty|content before blanking was)/i;
        if (regexp.test(wpReason.value)){
            wpReason.value = "";
        }
    }
}
// 原生JS文档就绪事件,替代$(deletemods)
document.addEventListener('DOMContentLoaded', deletemods);