User:Pinigin/fastundo.js
Appearance
(Redirected from User:MaksimPinigin/fastundo.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)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
// Copyright (c) 2017, Maksim Pinigin
if(mw.config.values.wgAction === "view" && location.search.indexOf("diff") !== -1) {
var diffId = location.search.split('=')[3].split('&')[0];
var pageName = mw.config.values.wgPageName;
var editToken = mw.user.tokens.get('editToken');
$('<strong>').html(' (<a href="javascript:void(0);" onClick="fastUndo();">быстро отменить</a>)').appendTo('#mw-diff-ntitle1');
function fastUndo() {
$.ajax({
type: 'post',
url: '/w/api.php',
data: {'action': 'edit', 'format': 'json', 'token': editToken, 'title': pageName, 'undo': diffId, 'minor': 1},
success:function (data) {
if(data.edit.result === "Success") {
mw.notify("Правка " + diffId + " отменена.");
setTimeout(function () { location.href = "/wiki/" + pageName; }, 3000);
}
}
});
}
}