A couple weeks ago I posted a userscript that makes banning MediaWiki spammers easier by setting good defaults for the user ban form. Since then, I’ve had to ban a lot of spammers, so I thought I should remove another point of friction.
For some reason, MediaWiki chooses to not provide direct deletion links on the User Contributions page, so after banning a spammer you have to click through to each piece of spam before deleting it. This may have been an acceptable user experience in Web 1.0 days, but it’s a ridiculous set of hoops to jump through today.
My goal is to eventually make banning a spammer and deleting all the spam they’ve posted a one-click process. If there’s an existing solution for this, I’d love to hear about it.
Since I needed to do some DOM manipulation, I chose to use jQuery in the userscript. This was also a lot easier than I might have expected. Userscripts really are a very solid technology.
// ==UserScript== // @name Mediawiki - Fast delete on user contributions view // @namespace https://userscripts.org/users/457667 // @description Adds a delete link for every page on the user contributions view // @include http://example.com/index.php/Special:Contributions/* // @require https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js // ==/UserScript== // Add page delete links to the user contributions page function enhanceHistory() { "use strict"; // Find the history link for each revision $('#bodyContent ul li') .find('a[href*="action=history"]') .each(function(i) { // Append a page delete link after each history link var url = this.toString().replace('action=history', 'action=delete'); $('<span> | </span><a href="' + url + '">del</a>').insertAfter($(this)); }); } enhanceHistory();
I passed the above through JSHint to make sure there’s nothing silly in it, but I haven’t consulted the jQuery style guide so it may not conform to the usual formatting.
The page delete links still lead to a standard confirmation form, so this doesn’t violate the RESTful practice of only using links for reading content rather than changing it.
Here’s a screenshot of what it adds to the user interface: