User:Bencmq/confirmIrreversibleRightsChange.js

维基百科,自由的百科全书

注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google ChromeFirefoxMicrosoft EdgeSafari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。

!(jQuery(function($){
    if (mw.config.get( 'wgPageName' ).indexOf( "Special:用户权限" ) !== 0) {
        return; // only execute on userrights page
    }

    $('#mw-userrights-form2').submit(
        function(e) {
            var shouldAlert = false;
            $('.mw-userrights-groups input[type=checkbox]').each(function() {
                var $this = $(this);
                // if it is checked and not disabled
                if ($this.is(":checked") && !$this.is(":disabled") &&
                    // and it has a star meaning it cannot be removed
                    $this.next('label').text().indexOf('*') >= 0) {

                    shouldAlert = true;
                }
            });
            if (shouldAlert && confirm("一些无法撤消的权限已被选中,确定吗?")) {
                return true;
            } else {
                e.preventDefault();
            }
        }
    );
}));