MediaWiki:Gadget-CancellazioneUltraRapida.js
Nota: dopo aver pubblicato, potrebbe essere necessario pulire la cache del proprio browser per vedere i cambiamenti.
- Firefox / Safari: tieni premuto il tasto delle maiuscole Shift e fai clic su Ricarica, oppure premi Ctrl-F5 o Ctrl-R (⌘-R su Mac)
- Google Chrome: premi Ctrl-Shift-R (⌘-Shift-R su un Mac)
- Internet Explorer / Edge: tieni premuto il tasto Ctrl e fai clic su Aggiorna, oppure premi Ctrl-F5
- Opera: premi Ctrl-F5.
$(document).ready(function() {
deletePage = function(pageTitle) {
mw.loader.using( 'mediawiki.api', function () {
( new mw.Api() ).post( {
action: 'query',
meta: 'tokens',
format: 'json'
} ).done(function (data) {
token = data.query.tokens.csrftoken;
( new mw.Api() ).post( {
action: 'delete',
title: pageTitle,
token: token
} ).done(function (data) {
console.log('Pagina ' + pageTitle + ' cancellata');
} );
} );
} );
};
activateCancellazioneUltraRapida = function() {
$('.cancellaultraRapidaButton').remove();
if (typeof activateCancellazione != 'undefined' && activateCancellazione.length) {
$("#mw-pages li a:not(.new)[href^='/wiki/']").each(function() {
titolo = $(this).attr('title');
href = $(this).attr('href').replace('/wiki/', '');
if (typeof titolo == 'undefined') {
titolo = href;
}
if (typeof titolo != 'undefined' && !titolo.startsWith('Indice:') && titolo.indexOf('Speciale:') !== 0 && href.indexOf('/w/index.php') !== 0) {
link = $('<a class="cancellaultraRapidaButton" href="#" title="Cancella questa pagina" data-title="' + titolo.replace(/"/g, '"') + '">[X]</a>').click(function(e) {
e.preventDefault();
deletePage(decodeURIComponent($(this).data('title').replace(/"/g, '"')));
});
$(this).after(link).after(' ');
}
});
}
};
activateCancellazione = (typeof activateCancellazione === 'undefined') ? $('.page-Categoria_Da_cancellare_subito') : activateCancellazione;
activateCancellazioneUltraRapida();
ns = mw.config.get('wgNamespaceNumber');
if (ns != 0 && ns != 110 && mw.config.get('wgPageName').indexOf('Wikisource:Bar') == -1) {
$('body').append('<a id="cancellaUltraRapidaBigButton" href="#" title="CANCELLAZIONE ULTRARAPIDA!">X</a>');
$('#cancellaUltraRapidaBigButton').click(function(e) {
e.preventDefault();
deletePage(mw.config.get('wgPageName'));
});
}
});