A small power transformer building covered in graffiti.
Need to clean up userspace spam or vandalism? SpamUserPage can help!

The SpamUserPage gadget allows administrators to delete a userspace page, block the user, and issue them with a block notice, all in one click. It is mainly intended for use with user-page spammers or vandals whose usernames violate the username policy, but can be customised for a number of different scenarios where you might need to delete a user page and block the user.

It should go without saying that you need to be an admin to use this script. Non-admins can install it, but it will not work properly.

Installation

Add the following to your common.js:

importScript('User:Mr. Stradivarius/gadgets/SpamUserPage.js'); // Linkback: [[User:Mr. Stradivarius/gadgets/SpamUserPage.js]]

After you have saved the page, you may need to bypass your browser cache.

Usage

Menu item in the "More" dropdown menu.
The "Delete and block" menu item.
  1. Go to a page in the "User" or "User talk" namespaces.
  2. Click on the "Delete and block" menu item.
  3. Choose your settings.
  4. Click on "Submit" to delete the page you are viewing, block the user, and issue them with a block notice.

Where it will run

This gadget will run on most pages in the User and User talk namespaces. However, it will not run in your own userspace (you wouldn't want to block yourself by accident, would you?), and it will not run on any user talk pages. User talk pages are a special case: they should generally be blanked, not deleted, and blocked users are usually allowed to edit their own talk pages.

Settings window

When you click on the "Delete and block" menu item, you should see a window like this.

Here you can adjust all of the options that are available.

Presets

For quick and easy option adjustment, choose a preset from the Preset drop-down menu. The options in it should cover most scenarios in which you would need to delete a user page and block the user. Once you choose a preset, it will update the text input fields and the block options for you. (Watchlist options are not affected.)

Text inputs

There are five different text input boxes that you can adjust. There are two different ways you can edit these:

  1. Type text directly into the text box.
  2. Choose from a list of standard values by clicking the down arrow on the right hand side of the box.

The following input boxes are available:

Block options

There are four block options in addition to the block summary and the expiry. Each of these can be either turned on or off.

Watchlist options

You can choose from one of four watchlist options. The setting that you choose will affect both the page you are deleting and the user's talk page.

Progress notifications

After you have finished adjusting the options, click "Submit". This will initiate the process of deleting the current page, blocking the user, and notifying them.

If the current page is successfully deleted, and the user is successfully blocked and notified, the gadget will open the user's talk page to the section they were warned at. This section will have a heading with the current month and year (in the format "Month YYYY"). If the latest section on the page already has a heading of the current month and year, then the gadget will use that rather than adding a new section.

If there were any errors during deletion, blocking, or notification, the gadget will display the relevant error messages, and the user's talk page will not be opened. The gadget isn't clever enough to know how to deal with these errors, so you won't be able to use it again until you reload the page.

Options

As well as adjusting the options each time you use the gadget, you can also change the defaults. To do this, you have to edit your common.js page.

First, add the following line directly above the line where you loaded the script:

SpamUserPage = {}; // Don't remove this line! It is necessary for SpamUserPage settings.

Then you can add custom defaults directly below that, and above the line where you loaded the script. So your common.js page should contain code that looks something like this:

SpamUserPage = {}; // Don't remove this line! It is necessary for SpamUserPage settings.
SpamUserPage.preset = "vaublock";
SpamUserPage.template = "((subst:User:Mr. Stradivarius/uw-vaublock)) ~~~~";
SpamUserPage.watchlist = "watch";
importScript('User:Mr. Stradivarius/gadgets/SpamUserPage.js'); // Linkback: [[User:Mr. Stradivarius/gadgets/SpamUserPage.js]]

preset

SpamUserPage.preset = "vaublock";

The preset to select when the dialog is opened. The following values are available:

You can also choose your own custom presets with this setting. The default is "spamublock".

Other settings take precedence over the preset setting. For example, if you set the preset setting to "voablock" and also added a custom deletion summary, your custom deletion summary would still be visible.

deletesummary

SpamUserPage.deletesummary = "[[WP:CSD#G11|G11]]: [[WP:SPAM|spam]] user page";

The deletion summary that appears in the "Deletion summary" text input box.

blocksummary

SpamUserPage.blocksummary = "[[WP:Spam|Spam]]-only account";

The block summary that appears in the "Block summary" text input box.

editsummary

SpamUserPage.editsummary = "You have been blocked for [[WP:SPAM|Spamming]]";

The edit summary that appears in the "Edit summary" text input box.

expiry

SpamUserPage.expiry = "1 year";

The block expiry that appears in the "Block expiry" text input box.

template

SpamUserPage.template = "((subst:User:Mr. Stradivarius/my block template)) ~~~~";

The block template that appears in the "Template" text input box.

Hint: to prevent the template and your signature from being expanded inside your common.js page itself, you can use nowiki tags inside JavaScript comments.

// <nowiki>
SpamUserPage.template = "((subst:User:Mr. Stradivarius/my block template)) ~~~~";
// </nowiki>

You can also put the nowiki tags right at the start and end of your common.js file if that is convenient for you.

nocreate

SpamUserPage.nocreate = false;

Whether users are blocked from creating accounts. This should be either true or false. The default is true.

autoblock

SpamUserPage.autoblock = false;

Whether autoblock is used. This should be either true or false. The default is true.

noemail

SpamUserPage.noemail = true;

Whether users are blocked from sending email. This should be either true or false. The default is false.

nousertalk

SpamUserPage.nousertalk = false;

Whether users are blocked from editing their user talk page while blocked. This should be either true or false. The default is false.

watchlist

SpamUserPage.watchlist = "nochange";

The watchlist settings for both the current page and the user's talk page. This can be one of "watch", "unwatch", "preferences" or "nochange". The default is "preferences".

menulocation

SpamUserPage.menulocation = "p-tb";

The location of the "Delete and block" menu item. The following options are available:

menuposition

SpamUserPage.menuposition = "#t-whatlinkshere";

The position of the "Delete and block" menu item in the menu specified in the "menulocation" option. This should be a CSS selector of an item in the same menu that you want the "Delete and block" link to appear directly before.

For example, if you set the link to display in the tools menu, and you want the link to appear directly before the "What links here" link, then you would set it to "#t-whatlinkshere". The list of possible values will vary depending on the menu you chose, your user rights, and what user scripts and gadgets you have installed. Common values include the following:

Views menu (Vector only)

Content actions menu

Personal toolbar

Tools menu

The default behaviour is for the "Delete and block" item to be put at the end of the list when it is loaded. (Other list items loaded later may be placed after it.)

oneclick

SpamUserPage.oneclick = true;

If this option is set, you will not have the chance to change the options. As soon as the "Delete and block" menu item is clicked, the current page will be deleted, and the user will be blocked and notified. This should be either true or false. The default is false.

Warning: don't use this option if you are prone to mis-clicks! You might end up blocking Jimbo.

Custom presets

It is even possible to create your own custom presets. However, the syntax is a little bit involved. (Feel free to ask on the talk page if you get stuck.)

Custom preset settings are specified in SpamUserPage.presets. This must be a JavaScript array, and each item in the array must be a JavaScript object. Each object must have an "id" property, and can have any of the optional properties "label", "deletesummary", "editsummary", "template", "blocksummary", "expiry", "nocreate", "noemail", "nousertalk", and "autoblock". The "id" property is a unique property that identifies your preset, and the "label" property is the text that is shown in the preset dropdown menu. All the other properties are settings as described above. If you use an original "id" property then you will create a new preset, and if you use the id of an existing preset then that preset will be altered.

Perhaps it is easiest to show some examples.

This code adds one new preset called "test", with an edit summary of "just testing":

SpamUserPage.presets = [
  {
    id: 'test',
    label: 'A test preset',
    editsummary: 'just testing'
  }
];

This next example adds the "test" preset and alters the "sblock" preset to have an expiry of 1 month:

SpamUserPage.presets = [
  {
    id: 'test',
    label: 'A test preset',
    editsummary: 'just testing'
  },
  {
    id: 'sblock',
    expiry: '1 month'
  }
];

To do

The following features are planned for implementation at some point in the future:

Bugs?

If you find a bug or want to suggest a new feature, ask on the talk page.