User:Mr. Stradivarius/gadgets/ConfirmRollback

Welcome to ConfirmRollback, the last word in customizing your rollback links. With this script you can:

  • Choose from three rollback link behaviours: hide, allow, or ask for confirmation
  • Use different behaviours on the watchlist, on page histories, in diff view, and more
  • Use different combinations of all the above for your desktop and mobile devices

The script uses sensible defaults, so if you are in a rush, just go ahead and install it.

InstallationEdit

RequiredEdit

Copy and paste the following code in Special:MyPage/common.js:

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

Then save the page and bypass your browser cache.

RecommendedEdit

Disable rollback links by default

Add the following code to Special:MyPage/common.css:

.mw-rollback-link {
	display: none;
}

This step hides the rollback links by default. They are then shown by the script if necessary. This avoids situations where rollback links are active when they shouldn't be, due to the script not having been loaded yet.

Deactivate conflicting gadgets

Some gadgets conflict with ConfirmRollback, so it is recommended that you disable them. Go to the "Gadgets" tab in your preferences, and in the "Browsing" section, deselect the following checkboxes:

  • "After rolling back a user's edit, automatically open their contributions page" (modrollback.js)
  • "Require confirmation before performing rollback on mobile devices" (confirmationRollback-mobile.js)

Then scroll to the bottom of the page, and click "Save".

Known conflicts
Gadget Behaviour
modrollback.js When you click on a rollback link, the user's contributions page will immediately open, causing the box to disappear and the rollback to happen with no confirmation.
confirmationRollback-mobile.js If your ConfirmRollback settings are set to "confirm", you will be shown two different confirmation dialogs each time you click a rollback link.

ConfigurationEdit

The configuration goes in Special:MyPage/common.js, and is always prefixed with ConfirmRollback. To help you edit it, take a look at the examples below and at the list of codes. Once you have finished, save the page, and bypass your browser cache.

Same everywhereEdit

The simplest set-up is to have the same rollback behaviour on every page, both mobile and desktop.

For example, this code will ask for confirmation for all rollback links.

ConfirmRollback = "confirm"

Different on different pagesEdit

To use different behaviours on different pages, you will need to use the JavaScript curly bracket syntax. Any pages that you don't specify will use the default behaviours.

For example, to hide rollback links from the watchlist, ask for confirmation on user contributions pages, and do the default behaviour everywhere else, use this:

ConfirmRollback = {
  watchlist: "hide",
  contributions: "confirm"
}

Mobile and desktopEdit

To use different behaviours on mobile and desktop, you need to have either "mobile" or "desktop" inside your curly brackets. The contents of "mobile" and "desktop" can be configured the same way as in the previous two sections.

For example, to hide all rollback links on mobile and ask for confirmation for all rollback links on desktops, use this:

ConfirmRollback = {
  mobile: "hide",
  desktop: "confirm"
}

To hide rollback links in diff view on mobile, ask for confirmation on page histories on desktops, and do the default everywhere else, use this:

ConfirmRollback = {
  mobile: {
    diff: "hide"
  },
  desktop: {
    history: "confirm"
  }
}

You can mix and match all of these settings however you want.

CodesEdit

The following three tables contain a complete list of available codes.

Behaviour codes
Code Description
confirm A confirmation dialog is displayed when you click on a rollback link.
hide Rollback links are hidden completely.
allow Rollback links behave as normal.

Page codes
Code Description Desktop default Mobile default
watchlist The watchlist. confirm confirm
recentchanges Recent changes. allow confirm
relatedchanges Related changes. allow confirm
contributions User contributions. allow confirm
history Page histories. allow confirm
diff Diff views. allow confirm
Device codes
Code Description
mobile Devices that can be identified as mobile from their user agent.
desktop All devices not classified as mobile.

Bugs and troubleshootingEdit

If you spot a bug, if you need help with your settings, or if you have any other kind of question, please ask on the talk page.