Użytkownik:PixelGGamer/common.js: Różnice pomiędzy wersjami
Z Nonsensopedii, polskiej encyklopedii humoru
(nowa strona) Znacznik: edytor źródłowy |
(Ale ze mnie lama, wandalizuję Nonsensopedię... Byłbym bardzo wdzięczny za otrzymanie bana) Znacznik: edytor źródłowy |
||
Linia 1: | Linia 1: | ||
importScript( "User:PixelGGamer/monobook.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 ((wgCanonicalSpecialPageName == 'Contributions') && (Candidates > 0)) { |
|||
addPortletLink('p-cactions', 'javascript:RollbackAll()', "Roll all " + Candidates, "ca-rollbackall", "Rollback all top edits displayed here"); |
|||
} |
|||
}; |
|||
// 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. |
|||
$("#ca-rollbackall").remove(); |
|||
}; //RollbackAll |
|||
$(document).ready(RollbackAllButton); |