Jump to content

User:Dragoniez/AjaxBlock

From Meta, a Wikimedia project coordination wiki
AjaxBlock dialog

AjaxBlock is a global user script that helps administrators perform block and unblock actions quickly without visiting the corresponding special pages. Its main features include:

  • Blocking and unblocking users through a dialog interface
  • One-click block and unblock actions
  • A dedicated configuration page for managing preferences without editing user JavaScript

Block options specified in the dialog are preserved after the dialog is closed. By combining this feature with repeated one-click actions, AjaxBlock can also function as a mass-blocking tool.

Installation

[edit]

Add the following code to Special:MyPage/common.js on the wiki where you wish to enable the script. (source code)

mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Dragoniez/AjaxBlock.js&action=raw&ctype=text/javascript');

Alternatively, you can install the script via Special:MyPage/global.js if you belong to a global group that grants you the block right everywhere.

You can use this installation method even if you do not belong to such a group, but in that case, it is recommended that you restrict the script to the projects where you actually have the ability to block users. Otherwise, the script will unnecessarily load and initialize itself on wikis where it cannot be used.

// Example 1: Load AjaxBlock only on metawiki via global.js
if (mw.config.get('wgWikiID') === 'metawiki') {
	mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Dragoniez/AjaxBlock.js&action=raw&ctype=text/javascript');
}
// Example 2: Load AjaxBlock only on metawiki and enwiki via global.js
if (['metawiki', 'enwiki'].includes(mw.config.get('wgWikiID'))) {
	mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Dragoniez/AjaxBlock.js&action=raw&ctype=text/javascript');
}

Usage

[edit]

Initialization

[edit]

When a page loads, the AjaxBlock logo appears in the lower-right corner while the script is initializing. AjaxBlock becomes available once the logo disappears.

If you click a block or unblock link before initialization is complete, you will be redirected to the link's original destination.

Configuration page

[edit]

You can access the configuration page by clicking the config link in the dialog or by visiting:

The configuration page allows you to customize:

  • The script's interface language
  • Warning preferences
  • Preset block options
  • User-defined block and unblock reasons

If you need to delete the script's internal data, that can also be done on this configuration page.

[edit]

After installing AjaxBlock, links to Special:Block and Special:Unblock gain additional functionality:

  • Normal click
Open the AjaxBlock dialog.
  • Shift-click
Perform a one-click block or unblock action (warnings displayed when necessary).
  • Ctrl-click
Open the link's original destination.
  • Shift+Ctrl-click
Perform a one-click block or unblock action with all warnings suppressed. (not recommended)
  • Unprocessable links
Displayed with a dotted underline.

When blocking users, AjaxBlock internally maintains separate settings for registered accounts, temporary accounts, and IP users. As a result, block settings configured for registered accounts are not applied to temporary accounts or IP users, and vice versa. Keep this distinction in mind when performing one-click blocks.

"Unprocessable links" are links that AjaxBlock cannot process, such as block links without a specified target username. These links are displayed with a dotted underline and behave normally when clicked, redirecting you to the corresponding special page.

Language support

[edit]

AjaxBlock supports multiple languages. If you would like to add support for another language, please refer to the messages below and submit your translations on the talk page.

Messages for translation

{
	'ajaxblock-link-title-unprocessable': '$1 cannot process this link',
	'ajaxblock-dialog-button-label-block': 'Block',
	'ajaxblock-dialog-button-label-unblock': 'Unblock',
	'ajaxblock-dialog-button-label-docs': 'Docs',
	'ajaxblock-dialog-button-label-config': 'Config',
	'ajaxblock-dialog-block-placeholder-preset': 'Select a preset to load',
	'ajaxblock-notify-block-placeholder-preset': 'Loaded preset "$1"',
	'ajaxblock-dialog-block-label-reason1': 'Reason 1',
	'ajaxblock-dialog-block-label-reason2': 'Reason 2',
	'ajaxblock-dialog-block-placeholder-reasonsuffix': 'Reason suffix',
	'ajaxblock-dialog-block-label-customreasons': 'Custom block reasons',
	'ajaxblock-dialog-block-label-partial': 'Partial block',
	'ajaxblock-dialog-block-label-option-autoblock': 'Apply autoblock',
	'ajaxblock-dialog-message-nonactive-id': 'The block with ID <b>#$1</b> specified by this link is no longer active and has been ignored.',
	'ajaxblock-dialog-message-existingblocks': '<b>This user already has active block(s).</b> Select the block you want to update.',
	'ajaxblock-dialog-message-existingblocks-canadd': '<b>This user already has active block(s).</b> Select the block you want to update, or check "{{int:block-create}}" to add a new block.',
	'ajaxblock-dialog-message-existingblocks-unblock': 'Select the block you want to remove.',
	'ajaxblock-dialog-message-existingblocks-dialogonly': '<b>This action must be performed via this dialog.</b> One-click execution is not supported.',
	'ajaxblock-dialog-message-predefinedparams-block': 'This link contains predefined block parameters.',
	'ajaxblock-dialog-message-predefinedparams-unblock': 'This link contains predefined unblock parameters.',
	'ajaxblock-dialog-message-applyparams-short': 'apply',
	'ajaxblock-dialog-message-applyparams-long': 'apply parameters',
	'ajaxblock-dialog-message-blocklog-missing': 'Failed to load the log for the block with ID <b>#$1</b>',
	'ajaxblock-notify-error-loadblocklogs': 'Failed to load block information ($1).',
	'ajaxblock-notify-error-idinactivenousername': 'This link cannot be processed because the block with ID <b>#$1</b> is no longer active and no username is specified.',
	'ajaxblock-notify-error-cannotunblock': '<b>$1</b> does not have any active blocks and cannot be unblocked.',
	'ajaxblock-notify-error-ambiguousblock': 'Select the block you want to update.',
	'ajaxblock-notify-error-ambiguousblock-canadd': 'Select the block you want to update, or check "{{int:block-create}}" to add a new block.',
	'ajaxblock-notify-error-notarget': 'This (un)block operation cannot be processed.',
	'ajaxblock-notify-error-emptyblock': 'This would result in an empty block. Please add restrictions or uncheck "{{int:ajaxblock-dialog-block-label-partial}}".',
	'ajaxblock-notify-error-processing': 'This link is temporarily unprocessable because another operation is currently processing it.',
	'ajaxblock-notify-error-noblocklinks': 'No associated block links found.',
	'ajaxblock-notify-error-cannotopendialog': 'Unable to open the $1 dialog because there are pending operations currently being processed. Please wait for them to finish and try again.',
	'ajaxblock-notify-error-cannotopendialog-oneclick': 'This link must be executed via the dialog, but could not open it because there are pending operations currently being processed. Please wait for them to finish and try again.',
	'ajaxblock-notify-error-paramapplier-presetsnotready': 'AjaxBlock is still loading block presets. Please try again in a few seconds. If this error occurs frequently, consider removing page restrictions from your presets.',
	'ajaxblock-notify-warning-paramapplier-filtered-top': 'Filtered invalid block parameter values:',
	'ajaxblock-notify-warning-paramapplier-filtered-pages': 'Page restrictions',
	'ajaxblock-notify-warning-paramapplier-filtered-namespaces': 'Namespace restrictions',
	'ajaxblock-confirm-block-noreason': 'Block with <b>no reason</b> specified',
	'ajaxblock-confirm-block-noexpiry': 'Block with <b>no expiry</b> specified (defaults to "{{int:infiniteblock}}")',
	'ajaxblock-confirm-block-hardblock': 'Apply a <b>hardblock</b>',
	'ajaxblock-confirm-block-hideuser': 'Block with <b>"Hide user" enabled</b>',
	'ajaxblock-confirm-block-reblock': '<b>Overwrite</b> the existing block',
	'ajaxblock-confirm-block-newblock': '<b>Add</b> a new block',
	'ajaxblock-confirm-block-self': 'Block <b>yourself</b>',
	'ajaxblock-confirm-block-ignorepredefined': 'Block while <b>ignoring predefined parameters</b>',
	'ajaxblock-confirm-unblock': '<b>Unblock</b> the user',
	'ajaxblock-confirm-unblock-noreason': 'Unblock with <b>no reason</b> specified',
	'ajaxblock-confirm-unblock-self': 'Unblock <b>yourself</b>',
	'ajaxblock-confirm-unblock-ignorepredefined': 'Unblock while <b>ignoring predefined parameters</b>',
	'ajaxblock-confirm-dialog-title-block': 'Confirm block',
	'ajaxblock-confirm-dialog-title-unblock': 'Confirm unblock',
	'ajaxblock-confirm-dialog-label-instruction': 'Please confirm the following warnings by <b>checking all the associated checkboxes</b> to proceed.',
	'ajaxblock-confirm-dialog-label-opendialog': 'Open the $1 dialog when cancelled',
	'ajaxblock-result-block-success': 'blocked',
	'ajaxblock-result-block-failure': 'block failed ($1)',
	'ajaxblock-result-unblock-success': 'unblocked',
	'ajaxblock-result-unblock-failure': 'unblock failed ($1)',
	'ajaxblock-config-title': 'Configure AjaxBlock',
	'ajaxblock-config-loading': 'Loading',
	'ajaxblock-config-loading-failure': 'Failed to initialize the AjaxBlock config interface',
	'ajaxblock-config-label-tab-common': 'Common',
	'ajaxblock-config-label-tab-global': 'Global',
	'ajaxblock-config-label-tab-local': 'Local',
	'ajaxblock-config-label-tab-misc': 'Miscellaneous',
	'ajaxblock-config-label-default': 'Default',
	'ajaxblock-config-label-languages-layout': 'Language options',
	'ajaxblock-config-label-languages-used': 'Used languages',
	'ajaxblock-config-placeholder-languages-used': 'Add languages',
	'ajaxblock-config-help-languages-used': 'Used when the interface language in use matches one of the selected languages.',
	'ajaxblock-config-label-languages-default': 'Default language',
	'ajaxblock-config-help-languages-default': 'Used when the interface language in use does not match any language selected in "{{int:ajaxblock-config-label-languages-used}}".',
	'ajaxblock-config-label-warning-layout': 'Warning options',
	'ajaxblock-config-label-warning-th-oneclick': 'One click',
	'ajaxblock-config-label-warning-th-dialog': 'Dialog',
	'ajaxblock-config-label-warning-block-noreason': 'When performing a block with no reason specified',
	'ajaxblock-config-label-warning-block-noexpiry': 'When performing a block with no expiry specified',
	'ajaxblock-config-label-warning-block-hardblock': 'When performing a hardblock',
	'ajaxblock-config-label-warning-block-hideuser': 'When performing a hideuser block',
	'ajaxblock-config-label-warning-block-reblock': 'When overwriting an existing block',
	'ajaxblock-config-label-warning-block-newblock': 'When adding a new block',
	'ajaxblock-config-label-warning-block-self': 'When performing a block on the performer themselves',
	'ajaxblock-config-label-warning-block-ignorepredefined': 'When not using predefined block parameters',
	'ajaxblock-config-label-warning-unblock': 'When performing an unblock',
	'ajaxblock-config-label-warning-unblock-noreason': 'When performing an unblock with no reason specified',
	'ajaxblock-config-label-warning-unblock-self': 'When performing an unblock on the performer themselves',
	'ajaxblock-config-label-warning-unblock-ignorepredefined': 'When not using predefined unblock parameters',
	'ajaxblock-config-label-reset': 'Reset',
	'ajaxblock-config-label-override': 'Override global options instead of merging with them',
	'ajaxblock-config-label-presetreasons-layout': 'Preset block options',
	'ajaxblock-config-label-presetreasons-name': 'Preset',
	'ajaxblock-config-placeholder-presetreasons-name': 'Enter a preset name',
	'ajaxblock-config-message-presetreasons-name-empty': 'The preset name must not be empty.',
	'ajaxblock-config-message-presetreasons-name-duplicate': 'The preset name must be unique.',
	'ajaxblock-config-notify-presetreasons-resolveerrors': 'Please fix the errors in the preset fields before continuing.',
	'ajaxblock-config-label-presetreasons-target-named': 'Registered users',
	'ajaxblock-config-label-presetreasons-target-temp': 'Temporary users',
	'ajaxblock-config-label-presetreasons-target-ip': 'IP users',
	'ajaxblock-config-placeholder-presetreasons-target': 'Add user types',
	'ajaxblock-config-notice-presetreasons-additionaloptions': 'In the dialog, some of the options below may be hidden depending on the target and user permissions.',
	'ajaxblock-config-title-presetreasons-hideuser-pseudodisabled': 'You cannot hide users on this project. If you have permission on another project, you can change this setting from this interface.',
	'ajaxblock-config-label-presetreasons-add': 'Add preset',
	'ajaxblock-config-label-presetreasons-delete': 'Delete preset',
	'ajaxblock-config-confirm-presetreasons-empty': 'The following empty presets will be removed before saving the options. Do you want to continue?',
	'ajaxblock-config-notify-save-nochange': 'No configuration changes detected.',
	'ajaxblock-config-notify-save-success': 'Configuration saved successfully.',
	'ajaxblock-config-notify-save-failure': 'Failed to save the configuration.',
	'ajaxblock-config-placeholder-customreasons': 'Enter reasons separated by line breaks',
	'ajaxblock-config-label-customreasons-block-layout': 'Custom block reason options',
	'ajaxblock-config-label-customreasons-unblock-layout': 'Custom unblock reason options',
	'ajaxblock-config-help-customreasons-block': 'Reasons specified here will be added to the block reason dropdown',
	'ajaxblock-config-help-customreasons-unblock': 'Reasons specified here will be shown as autocomplete suggestions in the unblock reason textbox',
	'ajaxblock-config-label-purgecache': 'Purge cache for AjaxBlock',
	'ajaxblock-config-label-deletelocal': 'Delete local config',
	'ajaxblock-config-help-deletelocal-absent': 'You do not have any local settings configured.',
	'ajaxblock-config-label-deletelocalall': 'Delete local config on all other projects',
	'ajaxblock-config-help-deletelocalall-present': 'Projects with saved local configuration: $1',
	'ajaxblock-config-help-deletelocalall-absent': 'You do not have any local settings configured on other projects.',
	'ajaxblock-config-label-deleteglobal': 'Delete global config',
	'ajaxblock-config-help-deleteglobal-absent': 'You do not have any global settings configured.',
	'ajaxblock-config-label-deletedata': 'Delete data',
	'ajaxblock-config-label-deletedata-short': 'Delete',
	'ajaxblock-config-confirm-deletedata': 'Are you sure you want to delete configuration data? This cannot be undone.',
	'ajaxblock-config-notify-deletedata-success': 'Deleted the specified configuration data.',
	'ajaxblock-config-notify-deletedata-failure': 'Failed to delete some of the specified configuration data.',
}