AjaxBlock allows you to block and unblock users without leaving the current page you're on, by showing a block modal when you click on any block/unblock link.

Note: The modal won't open if you're holding either the shift or control key. This is to allow users to access the block and unblock special pages normally.

Installation

Usage

The block modal will show up when you click on any Special:Block link with a target. Using it is pretty self-explanatory. Set a block length from either the dropdown or typing on the input the custom time you prefer (times like 4 months and 2 weeks are acceptable formats). Then select one of the common block reasons or type your own on the input. You can specify the reason further if you choose a common reason and input your own at the same time, which would result in: <common reason>: <further ellaboration>. Check the options you'd like to be applied to the block and finally click the "Block this user" button, or "Cancel" to close the modal.

When unblocking, a modal will pop up prompting you to input a reason. Clicking "Unblock this user" will unblock the user, or "Cancel" to close the modal.

Customization

All custom variables are under the window.AjaxBlock object.

Custom default expiry times

To set custom expiry times, you just need to add to the window.AjaxBlock.expiryTimes object using the syntax: 'time to submit': 'time to display',. For example:

window.AjaxBlock = {
    expiryTimes: {
        '2 hours': '2 hours',
        '1 day': 'one day',
        '1 week': 'a week',
        '2 months 4 weeks 2 days 7 hours': 'overly specific block duration'
    }
};

The default is grabbed from MediaWiki:Ipboptions. On most English wikis, it's: 2 hours, 5 hours, 12 hours, 1 day, 3 days, 5 days, 1 week, 2 weeks, 1 month, 3 months, 6 months, 1 year, 2 years, 3 years, infinite.

Custom default block reasons

Pretty much the same as with expiry times, but you have to change window.AjaxBlock.blockReasons. Example:

window.AjaxBlock = {
    blockReasons: {
        '[[w:Help:Vandalism|Vandalism]]': 'Vandalism',
        '[[w:Help:Spam|Spam]]': 'Spam',
        'Under the legal age': 'COPPA',
        'Removing information/blanking articles': 'Blanking',
        'Failing to comply with the [[Project:File Policy|File Policy]]': 'File policy'
    }
};

There's a fancier syntax in case you want grouped reasons like the ones generated with the MediaWiki page. It does require some finnicky code so it's advised to stay away from it unless you're experienced with JavaScript object notation. An example can be found at the bottom of the page.

The defaults are grabbed from MediaWiki:Ipbreason-dropdown, so you may not need this setting!

Custom default unblock reasons

The object below represents the custom default unblock reasons selection. Pretty much the same as with the block reasons. But with unblock reasons. And it's window.AjaxBlock.unblockReasons. Example:

window.AjaxBlock = {
    unblockReasons: {
        'Error': 'Error',
        'Appealed': 'Appealed',
        'Covered by a Bigger Range Block': 'Range block'
    }
};

There are no defaults. If you don't provide this, you'll have to type out the unblock reason manually. Of course, Special:Unblock doesn't have a dropdown either, so it should be fine.

Auto-check options

Automatically checked checkboxes on the block modal. talk specifies whether the user will be stripped of rights to post on their talk page or message wall. autoBlock specifies whether the user will be autoblocked with their subsequent IPs. override specifies whether to override the current block. And noCreate specifies whether to prevent the user from creating new accounts. That one doesn't work.

window.AjaxBlock = {
    check: {
        talk: true,
        autoBlock: true,
        override: true,
        noCreate: true,
    }
};

Talk and autoBlock are unchecked by default.


Example configuration

window.AjaxBlock = {
    expiryTimes: {
        '2 hours': '2 hours',
        '1 day': 'one day',
        '1 week': 'a week',
        '2 months': '2m',
        'never': 'Never'
    },
    blockReasons: {
        '[[w:Help:Vandalism|Vandalism]]': 'Vandalism',
        '[[w:Help:Spam|Spam]]': 'Spam',
        'Under the legal age': 'COPPA',
        'Removing information/blanking articles': 'Blanking',
        'Failing to comply with the [[Project:File Policy|File Policy]]': 'File policy'
    },
    unblockReasons: {
        'Error': 'Error',
        'Appealed': 'Appealed',
        'Covered by a Bigger Range Block': 'Range block'
    },
    check: {
        talk: true,
        autoBlock: true,
        override: true,
        noCreate: true
    }
};

Example Configuration with all parameters

window.AjaxBlock = {
    blockReasons: {
        'General': {
            '[[w:c:community:Help:Vandalism|Vandalism]]': 'Vandalism',
            '[[WP:WP:CRV|Removing Content From Pages]]': 'Removing Content form Pages',
            '[[WP:WP:DISRUPT|Disruptive Editing]]': 'Disruptive Editing',
            '[[WP:Disinformation|Inserting False Information]]': 'Inserting False Information',
            'Creating Nonsense/[[w:c:community:Help:Vandalism|Vandalism]] Articles': 'Creating Spam Articles',
            'Inserting nonsense/gibberish into pages': 'Inserting nonsense/gibberish into pages',
        },
        'Accounts': {
            '[[wP:Wp:PROXY|Open Proxy/VPN]]': "Open Proxy/VPN",
            '[[WP:WP:VOA|Vandalism-Only Account]]': 'VoA Account',
            '[[WP:WP:IU|Unacceptable Username]]': 'Unacceptable Username',
            'Abusing Multiple Accounts ([[WP:WP:SOCK|Sockpuppetry]])': "Sockpuppety",
            'Long-Term Abuse': 'Long-Term Abuse',
        },
        'Spam': {
            '[[w:Help:Spam|Spam/Advertising]] Only account': 'Spam/Advertising Only account',
            '[[w:Help:Spam|Spam/Advertising]]': 'Spam/Advertising',
            '[[WP:WP:LINKSPAM|Spamming Links to External Sites]]': 'External Link Spam',
            '[[WP:WP:SPAM|Posting Spam on Userpage]]': 'Posting Spam on Userpage',
        },
        'Comments': {
            '[[Project:Article Comment Guidelines|Spamming Nonsense Comments/Posts]]': 'Spamming Nonsense Comments/Posts',
            'Intimidating/Harrasing Comments/Posts': 'Intimidating/Harrasing Comments/Posts',
            'Swearing In Comments/Discussions': 'Swearing In Comments/Discussions'
        },
    },
    unblockReasons: {
        'Error': 'Error',
        'Appealed': 'Appealed',
        'Covered by a Bigger Range Block': 'Range block'
    },
    expiryTimes: {
        '2 hours': '2 hours',
        '1 day': 'one day',
        '1 week': 'a week',
        '2 months': '2m',
        'never': 'Never'
    },
    check: {
        talk: true,
        autoBlock: true,
        override: true,
        noCreate: true
    }
};
Text above can be found here (edit)
Community content is available under CC-BY-SA unless otherwise noted.