MediaWiki:Gadget-instantDelete.js
Jump to navigation
Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
This user script seems to have a documentation page at MediaWiki:Gadget-instantDelete. |
/**
* 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 );
}
}());