User:Dragoniez/Selective Rollback
| If you have requests, bug reports, etc., please leave a comment on User talk:Dragoniez/Selective Rollback. |


Selective Rollback is a user script that provides a bunch of useful features for rollback (partially forked from User:Hoo man/smart rollback.js and en:User:DannyS712/AjaxRollback.js).
This script adds the following features:
- In-situ rollback
- Resolves rollback links without page transition.
- Rollback summary
- Allows you to specify a custom edit summary for rollback (see #Usage for special expressions).
- Selective rollback
- Performs multiple rollbacks of your choice at once.
- Mass rollback
- Resolves all rollback links on the page at once.
- Mark bot
- Marks rollbacks as bot edits, if the user has the rights to do so (configurable).
- Watch page
- Adds the reverting pages to watchlist (configurable). The expiration time can also be specified.
- Confirm rollback
- Pops up a confirmation dialog before performing rollback (disabled by default; see #confirm & mobileConfirm for details).
- Note that this script automatically disables the built-in confirmation prompt available in Preferences.
Installation
[edit]Add the following to Special:MyPage/global.js for global use, to Special:MyPage/common.js for metawiki only, or to your local common.js on the wiki where you want to enable the script. (source code)
mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Dragoniez/Selective_Rollback.js&action=raw&ctype=text/javascript');
See #Usage below for how to use this script, and #Configurations for how to configure some options along with your installation.
Usage
[edit]Dialog
[edit]
This script adds a portlet link to open the Selective Rollback dialog in p-cactions (if the skin is vector; see image). The dialog can also be opened by clicking a rollback link with the CTRL key pressed down.
In-situ rollback
[edit]Just hit a rollback link.
Rollback summary
[edit]Select "Custom" on the dialog and type in a summary (or directly type your summary into the relevant textbox). This custom edit summary will be preserved after closing the dialog, and you can perform (in-situ) rollback with the specified edit summary when you hit rollback links on the page.
You can use the following special expressions when specifying summaries ($1-7 are MediaWiki's built-in variables):
$0: The default rollback summary on the wiki$1: Name of the user who made the last edit before the user whose edits are to be rolled back$2: Name of the user whose edits are to be rolled back$3: The revision number of$1's edit$4: The timestamp of$1's edit$5: The revision number of$2's edit$6: The timestamp of$2's edit$7: The number of revisions to revert (mw:MediaWiki 1.41/wmf.10; see the collapsed section below)
Assume that $1 is Example and $2 is Example2. Then, on meta,
Long-term abuse $0
for example, will be outputted as
because the default rollback summary on meta is
Reverted changes by [[Special:Contributions/$2|$2]] ([[User talk:$2|talk]]) to last version by $1
The $0 replacement feature is useful when you want to add a comment to your rollback while still including the default rollback summary. In essence, this feature enables rollback to work similarly to undo.
You can also predefine edit summaries and prepare your own special expressions in your user JS (see #Configurations).
Update (task T165798)
|
|---|
The magic word {{PLURAL}} has been added to the default message of MediaWiki:Revertpage:
Currently, Selective Rollback parses the magic word in a rough way, and the last operand is always parsed out:
|
Selective rollback
[edit]If the current page has rollback links, "SR" checkboxes will be added to it. Check the boxes of the edits you want to rollback, open the dialog, and then hit "Rollback".
Note: This feature is disabled on Special:RecentChanges and Special:Watchlist.
Mass rollback
[edit]Open the dialog, hit "Select all", and then hit "Rollback".
Note: This feature is disabled on Special:RecentChanges and Special:Watchlist.
Mark bot
[edit]Check the relevant box on the dialog. You can configure the default checked state if you wish (see #Configurations).
Watch page
[edit]Check the relevant box on the dialog. You can configure the default checked state if you wish (see #Configurations).
Cache purger
[edit]On script initialization, Selective Rollback fetches the default rollback summary and the user's rights, then caches them to reduce the number of API requests. However, this also means that these internal data are not immediately updated when changes occur.
If this ever causes an issue, click the Purge cache for Selective Rollback button in the portlet menu. This will clear the cache and refresh the page, allowing the script to recognize the latest changes.
Configurations
[edit]Selective Rollback provides the following JavaScript object for personal configuration.
window.selectiveRollbackConfig = {
lang: '',
editSummaries: {},
showKeys: false,
specialExpressions: {},
markBot: true,
watchPage: false,
watchExpiry: 'indefinite',
confirm: 'never',
mobileConfirm: 'always',
checkboxLabelColor: 'orange'
};
Basically, your installation should look like:
mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Dragoniez/Selective_Rollback.js&action=raw&ctype=text/javascript');
window.selectiveRollbackConfig = {}; // This declaration is necessary when you add configs (but NEVER repeat this)
// Add your configs here
lang
[edit]| Currently available languages: ja, en, zh, es, ro, vi, ar |
You can set the default interface language of the script. If not specified, it automatically uses the language defined in your preferences. Note that if the script doesn't have translations in the language, English messages will be used (see below for how to submit new translations).
By assigning a value to the lang config, you can explicitly tell the script to use that language, as below (the example sets the interface language to English):
window.selectiveRollbackConfig = {};
selectiveRollbackConfig.lang = 'en';
I would appreciate it if anyone could provide new translations. Take a look at the following, and post your translations on User talk:Dragoniez/Selective Rollback.
Texts for translation
|
|---|
{
'scriptname': 'Selective Rollback', // Added in v5.0.1
'portletlink-main-tooltip': 'Open the Selective Rollback dialog',
'portletlink-uncacher-label': 'Purge cache for Selective Rollback', // v4.4.3
'summary-label-primary': 'Edit summary',
'summary-option-default': 'Default edit summary',
'summary-option-custom': 'Custom',
'summary-label-custom': 'Custom edit summary',
'summary-help-$0': '<code>$0</code> will be replaced with the default rollback summary.',
'summary-help-$0-error': '<code>$0</code> will be replaced with the default rollback summary <b>in English</b>.',
'summary-help-specialexpressions': 'Replacement expressions', // Deprecated since v5.0.0
'summary-label-preview': 'Summary preview', // v4.0.0
'summary-help-preview': '<code>{{PLURAL:$7}}</code> will be replaced.', // Updated in v5.0.0
'markbot-label': 'Mark rollbacks as bot edits',
'watchlist-label': 'Add the target pages to watchlist',
'watchlist-expiry-label': 'Expiry', // Deprecated since v5.0.0
'watchlist-expiry-indefinite': 'Indefinite',
'watchlist-expiry-1week': '1 week',
'watchlist-expiry-1month': '1 month',
'watchlist-expiry-3months': '3 months',
'watchlist-expiry-6months': '6 months',
'watchlist-expiry-1year': '1 year',
'button-rollback': 'Rollback', // Updated in v5.0.0
'button-documentation': 'Docs', // Added in v5.0.0
'button-selectall': 'Select all', // Updated in v5.0.0
'button-selectall-count-label': 'Selected:', // Added in v5.0.7
'button-close': 'Close', // Deprecated since v5.0.0
'msg-nonechecked': 'No checkbox is checked.',
'msg-linksresolved': 'Rollback links on this page have all been resolved.',
'msg-confirm': 'Are you sure you want to rollback this edit?',
'rbstatus-reverted': 'reverted',
'rbstatus-failed': 'rollback failed',
'rbstatus-notify-success': 'Success', // v4.0.0
'rbstatus-notify-failure': 'Failure' // v4.0.0
}
|
editSummaries & showKeys
[edit]To predefine edit summaries, include config lines like the following along with the script loader:
//<nowiki>
window.selectiveRollbackConfig = {};
selectiveRollbackConfig.editSummaries = {};
selectiveRollbackConfig.editSummaries[0] = 'Long-term abuse';
selectiveRollbackConfig.editSummaries[1] = 'Cross-wiki abuse';
selectiveRollbackConfig.editSummaries[2] = 'Spam';
selectiveRollbackConfig.editSummaries[3] = '[[WP:SOCK]]';
//</nowiki>
The dropdown menu will then display:
- Default edit summary
- Long-term abuse
- Cross-wiki abuse
- Spam
- [[WP:SOCK]]
- Custom
Note that it's safer to include <nowiki/> for cases when your custom summaries include internal wikilinks.
You can also name each option and show them on the dialog instead of the whole edit summaries, if you specify selectiveRollbackConfig.showKeys = true.
For example, install the script with
//<nowiki>
window.selectiveRollbackConfig = {};
selectiveRollbackConfig.editSummaries = {};
selectiveRollbackConfig.editSummaries['LTA'] = 'Long-term abuse';
selectiveRollbackConfig.editSummaries['CWA'] = 'Cross-wiki abuse';
selectiveRollbackConfig.showKeys = true;
//</nowiki>
and the dropdown options will be:
- Default edit summary
- LTA
- CWA
- Custom
but if you choose "LTA" for instance, the output will be "Long-term abuse".
specialExpressions
[edit]In addition to $0 and the like, you can prepare your own special expressions to be replaced with certain texts.
//<nowiki>
window.selectiveRollbackConfig = {};
selectiveRollbackConfig.specialExpressions = {};
selectiveRollbackConfig.specialExpressions['$SLIME'] = '[[LTA:SLIME]]';
selectiveRollbackConfig.specialExpressions['$QCHM'] = '[[LTA:QCHM]]';
//</nowiki>
In this case, any occurrence of "$SLIME", for example, will be replaced with "[[LTA:SLIME]]". It is recommended to prefix your special expressions with $ or a similar symbol to avoid unintentional text replacements.
markBot
[edit]If you have the markbotedits right on the wiki where SR is loaded, the markBot checkbox is checked on the dialog by default (hence true; note that this box is always hidden and unchecked if you don't have the user right). If you want to have the box unchecked by default, use:
window.selectiveRollbackConfig = {};
selectiveRollbackConfig.markBot = false;
watchPage & watchExpiry
[edit]The watchPage checkbox is unchecked on the dialog by default (hence false), and the expiration time is set to indefinite. If you want to change these default settings, use e.g.:
window.selectiveRollbackConfig = {};
selectiveRollbackConfig.watchPage = true;
selectiveRollbackConfig.watchExpiry = '1 month';
This is an example to automatically add the reverting pages to your watchlist for 1 month. The accepted values for watchExpiry are indefinite, infinite, infinity, never, 1 week, 1 month, 3 months, 6 months, and 1 year. The script includes basic typo-checking, so you don't need to worry about spaces, plural suffixes, and similar variations. Note that if an invalid value is specified, an error message will be shown in the browser console (or the more notable consequence is that the default value doesn't change on the dialog).
confirm & mobileConfirm
[edit]Selective Rollback has the confirm and mobileConfirm configs for rollback confirmation, where the former (defaulted to never) is referred to in non-mobile contexts and the latter (defaulted to always) in mobile contexts.
Accepted values are never, always, RCW, and nonRCW, where "RCW" stands for Recentchanges and Watchlist. When the configs are valued with never or always, the script never/always shows you a confirmation message before performing rollback, and when they are valued with RCW or nonRCW, the script shows you a confirmation message when you're (not) on either Special:RecentChanges or Special:Watchlist. Note that you can suppress the confirmation popup by clicking a rollback link with the SHIFT key pressed down (in non-mobile contexts).
window.selectiveRollbackConfig = {};
selectiveRollbackConfig.confirm = 'RCW';
selectiveRollbackConfig.mobileConfirm = 'always';
checkboxLabelColor
[edit]checkboxLabelColor is a config to change the color of "SR" checkbox labels, which defaults to orange.
window.selectiveRollbackConfig = {};
selectiveRollbackConfig.checkboxLabelColor = 'pink';