User:Guycn2/VandalCleaner

Vandal Cleaner is a user script that makes it easier to handle massive vandalism.

This tool allows you to quickly block the vandal, rollback all edits, delete all pages and hide all edits – all at the touch of a button.

Administrators may use this tool to perform all of the above actions (block, rollback, delete and hide), while rollbackers who are not administrators can use the rollback functionality only.

On the English Wikipedia
To use this script on the English Wikipedia, add the following line to your local JS page:

On other wikis
To use this script globally (i.e. on all Wikimedia wikis), add the following line to your global JS page:

Localization to other languages
This script is operable on all MediaWiki projects, regardless of the site's language. It uses English text by default, and is currently available in Hebrew as well. Therefore, if your wiki has an interface language other than English or Hebrew, the script will still work there, albeit with English text.

Localizing this script to your language is very easy. All it takes is adding the appropriate text in your language to the script's configuration file. If you are interested in having the script's interface text translated to your language, please contact Guycn2.

Skin and platform support
The script is fully supported on all skins currently available on Wikimedia wikis. These include Vector (2022), Vector legacy (2010), MinervaNeue, Monobook, and Timeless.

It is also fully supported on the site's mobile interface.

Opening the tool's interface
First, navigate to the "Contributions" page of the user (or IP) whose vandalism you want to clean.

If the script was installed correctly, a red button with the text Vandal Cleaner should appear at the top of the vandal's "Contributions" page.

Clicking the button will open a dialog window where you'll first be asked to set the way the tool should run.

Edit summary
In the "Edit summary" field, you may enter an edit summary that will appear in page histories and logs next to all actions made with this tool.

This field is optional: If you leave it blank, all rollbacks performed with this tool will use the system's default summary, and all other actions (blocks, deletions and hidings) will be recorded in the appropriate logs with no summary.

If you mark the "Use this summary by default" checkbox, the entered edit summary will be remembered and inserted automatically from now on (you will still be able to change it individually each time you run this tool).

Advanced options
Right below the edit summary box there is a button to show advanced options. In simple use it is usually unnecessary to modify the advanced configurations, although it may sometimes be helpful. The advanced options are:

Number of days to look for
The tool will retrieve edits made by the vandal during the set number of recent days.

For example, if set to 10, only edits made by the vandal during the last ten days will be affected, and earlier edits will be ignored. Value must be an integer between 1 (one day) and 60 (about two months).

This option is mainly useful when the vandal is an unregistered user who is identified by their IP address. In such cases, the same IP address may have been used by other people who had made constructive edits before the vandal started editing. It is therefore necessary to only clean actions made by that IP since the day it was first used by the vandal.

If you mark the "Use this number of days by default" checkbox, the entered number of days will be remembered and inserted automatically from now on (you will still be able to change it individually each time you run this tool).

Maximum number of actions
The maximum number of rollbacks, page deletions and revision deletions to perform.

The limit is individual for each type of action. For example, if set to 50, this tool will perform up to 50 rollbacks, up to 50 page deletions, and up to 50 revision deletions within a single run. Value must be an integer between 1 and 300.

This option is mainly useful in two types of scenarios:
 * The first scenario deals with cases where you are not sure that all actions made by the vandal are unconstructive, and you only wish to clean a specific portion of them. For example, if a user's 20 latest edits are all external link spamming, you may choose to only rollback the 20 most recent edits and ignore earlier ones, some of which may be constructive and therefore require manual review.
 * The second scenario is sort of the opposite of the first one: It deals with cases where a vandal made a very large amount of edits (in the order of hundreds) and you wish to clean them all in bulk. In such cases, you may choose a large number of maximum actions. Note that numbers greater than 300 cannot be entered: If the vandal has made more than 300 edits, you may need to run the tool again after it has finished running, to complete the cleanup.

If you mark the "Use this maximum number of actions by default" checkbox, the entered number of actions will be remembered and inserted automatically from now on (you will still be able to change it individually each time you run this tool).

Selecting actions to perform
After you have configured the initial settings, click the "Continue" button (at the top right). You will then see a panel in which you can make sure the tool is set to run with the correct settings, and choose which actions it should take.

The top of the panel includes an overview of the tool's execution settings, as determined at the previous panel. Among other information, you will be able to see the earliest date of edits that can be affected upon running the tool (according to the number of days set at the previous panel), and a preview of the edit summary will appear. Make sure these settings are correct, and if they're not – click the Back button (at the top left) to return to the previous panel and change them.

Below this overview, select the actions you wish to perform with this tool. The possible actions are:

Rollback all edits
Enable this option to rollback all edits made by the vandal.

The number of rollbacks to be performed appears at the field's description. No rollback will be made on pages that were edited by someone else after being edited by the vandal, or on pages where the vandal was the only editor (those pages should usually be deleted instead, see the "Delete all pages" option below).

The rollback functionality is available for rollbackers and administrators.

Delete all pages
Enable this option to delete all pages created by the vandal (whether subsequently edited by someone else or not).

The number of pages to be deleted appears at the field's description.

The deletion functionality is available exclusively for administrators.

Block this user
Enable this option to hermetically block the vandal. In addition to being blocked from editing pages, the vandal will also be blocked from creating new accounts as well as sending emails to users. If the vandal is a registered user, they will be blocked from editing their own talk page, too. If the vandal is an unregistered user (IP address), the system will also automatically block registered users who use that IP address during the block.

If you enable the block option, you may choose the block duration. The default is one day for unregistered users and an indefinite block for registered users. Click the "change" button to modify the default block duration.

The block functionality is available exclusively for administrators.

Hide all edits
Enable this option to hide all edits made by the vandal from public view.

The number of edits to be hidden appears at the field's description.

Use this option sparingly, and in accordance with the policy: Even in cases of trolls and outright vandals, wholesale hiding of all edits from history pages is unnecessary if they do not contain harassments, defamations, hate speech, copyright infringements, or other contents that warrant hiding according to the policy.

If you enable the hiding option, you may choose whether to hide the edit contents only, the edit summaries only, or both.

The hiding functionality is available exclusively for administrators.

Running the tool
After you have selected the actions to perform, click the "Run cleaner" button (at the top right).

You will then see a panel with details about the actions being taken, as well as a progress bar indicating the amount of completed and remaining actions.

If a certain action fails for some reason, a message will be displayed. Further details about the error may be found at the browser console. In most browsers you can open the console window by pressing F12 on your keyboard and navigating to the "Console" tab.

To abort the tool's operation, you can click the "Stop" button (at the top left) at any time. Note, however, that this will not automatically undo actions that have already been performed, and so you will have to manually undo them if necessary.

When the tool finishes performing all actions, you will be presented with a message. It is recommended to review the performed actions and make sure they were done intentionally and correctly. All actions made with this tool are marked with the "VandalCleaner" tag, so they are easier to find. You can click the bold link at the finish message to view a chronological list of actions you've made with this tool.