MediaWiki:Gadget-RollbackAll.js
Z Nonsensopedii, polskiej encyklopedii humoru
Uwaga: aby zobaczyć zmiany po zapisaniu, może zajść potrzeba wyczyszczenia pamięci podręcznej przeglądarki.
- Firefox / Safari: Przytrzymaj Shift podczas klikania Odśwież bieżącą stronę, lub naciśnij klawisze Ctrl+F5 lub Ctrl+R (⌘-R na komputerze Mac)
- Google Chrome: Naciśnij Ctrl-Shift-R (⌘-Shift-R na komputerze Mac)
- Internet Explorer: Przytrzymaj Ctrl jednocześnie klikając Odśwież lub naciśnij klawisze Ctrl+F5
- Konqueror: Kliknij polecenie Odśwież lub naciśnij klawisz F5
- Opera: Wyczyść pamięć podręczną w Narzędzia → Preferencje
/* ŹRÓDŁO: https://uncyclopedia.wikia.com/wiki/User:SPIKE/RollbackAll.js */
// Charitwo's rollback, rewritten with jQuery and Ajax
// A function to add a "Rollback all" button to the top of the page, if the page is Special:Contributions and
// if it shows any contributions that can be rolled back.
function RollbackAllButton () {
var Candidates = $("SPAN.mw-rollback-link").length;
if ((mw.config.get('wgCanonicalSpecialPageName') == 'Contributions') && (Candidates > 0)) {
$('#contentSub').append(' <span class="rollbackAllButton"> [<a title="Wycofaj wszystkie wyświetlone edycje tego użytkownika">Wycofaj wszystko (' + Candidates + ")</a>]</span>");
$('#contentSub').find(".rollbackAllButton a").click(RollbackAllConfirmAndExecute);
}
}
// A function to use as rollbackAllButton callback, shows a "confirm this action"
// popup and executes RollbackAll if the answer is positive
function RollbackAllConfirmAndExecute () {
OO.ui.confirm("Czy na pewno chcesz wycofać wszystkie wyświetlone edycje tego użytkownika?").done(function(confirmed) {
if (confirmed) {
RollbackAll();
}
});
}
// A function, called by that "Rollback all" button, to do the rollbacks.
function RollbackAll() {
var FailureCount = 0;
$("SPAN.mw-rollback-link A").each( function() {
var TheURI = $(this).prop("href") + "&bot=1";
var TheSPAN = $(this).parent();
// $(TheSPAN).text("Failed").css({"color": "red"}); // Assume failure
$.ajax({type: "GET", url: TheURI })
.done(function(data) {
if (data.indexOf("<title>Rollback failed") == -1) {
$(TheSPAN).parent().css({"text-decoration": "line-through"});
$(TheSPAN).parent().find(".mw-uctop").remove();
$(TheSPAN).remove();
}
else {
FailureCount++;
// alert("Debug: Got " + data + "--FailureCount=" + FailureCount);
};
}) //done
.fail(function() { FailureCount++ });
}); //each
if (FailureCount > 0) {
alert(FailureCount + " edit(s) could not be rolled back.");
};
// End by removing the RollbackAll button. If you want to try again, reload the page.
$(".rollbackAllButton").remove();
}; //RollbackAll
$(document).ready(RollbackAllButton);