跳转到内容

User:Vanished user 1929210/block.js

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

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

/*
 * {{幽默}}
 *
 * 一鍵封禁 v1.0
 *
 * 嚴肅的話:請在自行架設的MediaWiki或管理員試驗場(例如 https://test.wikipedia.org/wiki/Wikipedia:Requests/Tools 中提到的網站)試驗,不要在維基百科使用!
 */

$(mw.util.addPortletLink('p-cactions', '#', '一鍵封禁', 'p-onekeyblock')).click(function (e) {
    e.preventDefault();
    var username = prompt('封誰?');
    if (username) {
        $.ajax({
            url: mw.util.wikiScript('api'),
            data: {
                format: 'json',
                action: 'block',
                user: username,
                expiry: 'never',
                reason: 'by [[User:逆襲的天邪鬼/block.js|一鍵封禁]]',
                nocreate: true,
                autoblock: true,
                noemail: true,
                reblock: true,
                token: mw.user.tokens.get('editToken'),
            },
            dataType: 'json',
            type: 'POST',
            success: function (data) {
                alert('OK');
            },
            error: function (xhr) {
                alert('Error');
            }
        });
    }
});