MediaWiki:Gadget-instantDelete.js
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
/**
* Instantly delete a page in the file namespace.
* @author Krinkle, 2011
* @author Bryan, 2007
* @source commons.wikimedia.org/wiki/MediaWiki:Gadget-instantDelete.js
* @version 1.0 (2011-12-28)
* @compatible MediaWiki 1.18
*/
( function () {
"use strict";
function vqdNow(){
var reason, container;
reason = document.getElementById('vqdReason').value;
container = document.getElementById('vqdContainer');
$(container).html('<img src="//upload.wikimedia.org/wikipedia/commons/3/39/Spinning_wheel_throbber_blue.gif" /> Deleting page...');
new mw.Api().postWithToken( 'csrf', {
format: 'json',
action: 'delete',
title: mw.config.get( 'wgPageName' ),
reason: reason,
}).done(function(data){
if(data && !data.error){
$(container).html('<span style="color: green;">Page deleted.</span>');
} else {
$(container).html('<span style="color: red;">Deletion failed.</span>');
}
}).fail(function(){
$(container).html('<span style="color: red;">Deletion failed.</span>');
});
}
function veryQuickDelete (){
var form, inputbox, submit, container, filetoc;
form = document.createElement('form');
form.onsubmit = function () { return false; };
form.style.display = 'inline';
inputbox = document.createElement('input');
inputbox.value = 'Copyright violation, see [[Commons:Licensing]]';
inputbox.id = 'vqdReason';
inputbox.size = '60';
form.appendChild(inputbox);
submit = document.createElement('input');
submit.type = 'submit';
submit.value = 'Delete';
submit.onclick = vqdNow;
form.appendChild(submit);
container = document.createElement('li');
container.id = 'vqdContainer';
container.appendChild(form);
filetoc = document.getElementById('filetoc');
if (filetoc) {
filetoc.appendChild(container);
}
}
if ( mw.config.get( 'wgNamespaceNumber' ) === 6 ) {
$( document ).ready( veryQuickDelete );
}
}());