User:Dragoniez/Selective Rollback

From Meta, a Wikimedia project coordination wiki
Jump to navigation Jump to search
The Selective Rollback dialog (English)
The Selective Rollback dialog (Japanese)

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
Makes it possible to specify an edit summary for rollback (see #Usage for special expressions).
  • Selective rollback
Resolves multiple rollback links of the user's choice at once.
  • Mass rollback
Resolves all rollback links on the page at once.
  • Mark bot
Marks edits as bot edits, if the user has the rights to do so. (configurable)
  • Watch page
Adds pages to watchlist when performing rollback. (configurable)

Installation[edit]

Add the following to Special:MyPage/global.js for global use, or to Special:MyPage/common.js for use on meta, or to your common.js on the wiki you want to enable the script (please always include a backlink; don't forget the prefix "m:" when you install the script outside meta). (source)

// Selective Rollback ([[User:Dragoniez/Selective Rollback.js]])
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 #Configuration for how to configure some options along the installation.

Usage[edit]

Dialog[edit]

The position of the portlet link

The script adds a portlet link to open the Selective Rollback dialog on p-cactions (if the skin is vector; see image).

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 input box). 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 in specifying summaries ($1-6 are mediawiki's default functions):

  • $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

Assume that $1 is Example and $2 is Example2. Then, on meta,

  • Long-term abuse $0

for example, will be displayed as

  • Long-term abuse Reverted changes by Example2 (talk) to last version by Example

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 would be useful when you want to add a comment to your rollback and at the same time want to include the default rollback summary. So, Selective Rollback makes it possible to perform rollback the way undo works.


You can also predefine edit summaries and prepare your own special expressions on your .js page (see #Configuration).

Selective rollback[edit]

If the current page has rollback links, "SR" checkboxes will be added to the page. Check the boxes of the edits you want to rollback, then open the dialog and hit "Rollback checked".

Note: This feature is disabled on Special:RecentChanges and Special:Watchlist.

Mass rollback[edit]

Open the dialog, hit "Check all", and then hit "Rollback checked".

Note: This feature is disabled on Special:RecentChanges and Special:Watchlist.

Mark bot[edit]

Check the relevant checkbox on the dialog. You can configure the default (un)check state if you wish (see #Configuration).

Watch page[edit]

Check the relevant checkbox on the dialog. You can configure the default (un)check state if you wish (see #Configuration).

Configuration[edit]

Selective Rollback has the following JavaScript object for personal settings.

selectiveRollbackConfig: {
    lang: '',
    editSummaries: {},
    showKeys: false,
    specialExpressions: {},    
    markBot: true,
    watchPage: true
}

Basically, your installation should look like:

// Selective Rollback ([[User:Dragoniez/Selective Rollback.js]])
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]

You can configure the default language of the script. When the default language isn't configured, it's automatically set to the content language of the wiki on which the script is loaded. For example, if you install the script in your global.js, the dialog will be shown in Japanese when you're on the Japanese Wikipedia, and in English if you're on Meta, or on the English Wikipedia (or its sister projects). Note that if the content language isn't available in the script, the default language will be set to English (see below for how to submit a new translation).

If you want to always use a certain language regardless of the content language of the wiki you're on, set the language config as in the following (the example sets the default language to English):

// Selective Rollback ([[User:Dragoniez/Selective Rollback.js]])
mw.loader.load("//meta.wikimedia.org/w/index.php?title=User:Dragoniez/Selective Rollback.js&action=raw&ctype=text/javascript");
window.selectiveRollbackConfig = {};
selectiveRollbackConfig.lang = "en";

I would appreciate it if anyone could provide a new translation. Take a look at the following, and post your translation on User talk:Dragoniez/Selective Rollback.

Texts for translation
'error-defaultSummary': 'Selective Rollback: Failed to get the default rollback summary for the local wiki.',
'error-parentNode': 'Selective Rollback: Parent node not defined.',
'error-parentNode-notify': 'Bug: Parent node not defined. Please notify the developer of the name of the page on which this error occured.',
'portletlink-tooltip': 'Open the Selective Rollback dialog',
'editSummary-label-primary': 'Edit summary:',
'editSummary-option-default': 'Default edit summary',
'editSummary-option-custom': 'Custom',
'editSummary-label-custom': 'Custom edit summary:',
'editSummary-tooltip-$0': '($0 will be replaced with the default rollback summary.)',
'editSummary-tooltip-$0-error': '($0 will be replaced with the default rollback summary in English.)',
'editSummary-tooltip-specialExpressions': 'SE', // Special expressions to replace with certain texts
'editSummary-checkbox-watchpage': ' Add the target page(s) to watchlist',
'editSummary-checkbox-markbot': ' Mark edits as bot edits',
'button-rollbackchecked': 'Rollback checked',
'button-checkall': 'Check all',
'button-close': 'Close',
'msg-nonechecked': 'No checkbox is checked.',
'msg-linksresolved': 'Rollback links on this page have all been resolved.',
'text-reverted': '[reverted]',
'text-rollbackfaliled': '[failed]'

editSummaries & showKeys[edit]

To predefine edit summaries, install the script in a way like the following:

// Selective Rollback ([[User:Dragoniez/Selective Rollback.js]])
mw.loader.load("//meta.wikimedia.org/w/index.php?title=User:Dragoniez/Selective Rollback.js&action=raw&ctype=text/javascript");
//<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>

Then, the dropdown on the dialog will be:

  • 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

// Selective Rollback ([[User:Dragoniez/Selective Rollback.js]])
mw.loader.load("//meta.wikimedia.org/w/index.php?title=User:Dragoniez/Selective Rollback.js&action=raw&ctype=text/javascript");
window.selectiveRollbackConfig = {};
selectiveRollbackConfig.editSummaries = {};
selectiveRollbackConfig.editSummaries["LTA"] = "Long-term abuse";
selectiveRollbackConfig.editSummaries["CWA"] = "Cross-wiki abuse";
selectiveRollbackConfig.showKeys = true;

and the dropdown on the dialog 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.

// Selective Rollback ([[User:Dragoniez/Selective Rollback.js]])
mw.loader.load("//meta.wikimedia.org/w/index.php?title=User:Dragoniez/Selective Rollback.js&action=raw&ctype=text/javascript");
//<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]]". I recommend that you prefix your special expressions with "$" or something similar, to avoid unintentional replacement of texts.

markBot & watchPage[edit]

The markBot and watchPage checkboxes are checked on the dialog by default (although the first is unchecked and in fact not shown if the user doesn't have a required flag). If you want to change this bahaviour, use:

// Selective Rollback ([[User:Dragoniez/Selective Rollback.js]])
mw.loader.load("//meta.wikimedia.org/w/index.php?title=User:Dragoniez/Selective Rollback.js&action=raw&ctype=text/javascript");
window.selectiveRollbackConfig = {};
selectiveRollbackConfig.markBot = false;
selectiveRollbackConfig.watchPage = false;