User:Hat600/script/lightningstorm.js
外观
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google Chrome、Firefox、Microsoft Edge及Safari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
// UNDER CONSTRUCTION
// ONLY ALLOW SYSOP USE
/******************************************/
/* It's a tool on the other side of Nuke. */
/* So as in The Red Alert. */
/******************************************/
// OK, Seriously.
/******************************************/
/* LIGHTNING STORM VER 0.1alpha */
/* Developer: Hat600 */
/* Function: Mass Rollback */
/* Usage: See talk page */
/******************************************/
;(function($){
var htmls = '<div id="lightningstormcreated"><fieldset><legend>Ligntning Storm Control Pad</legend><div>Start time:<input id="lightningstormstart" /><br />Namespace:<input id="lightningstormns" /><br /><button id="lightningstormbutton1">Check</button></div><button id="lightningstormbutton2">Rollback</button><button id="lightningstormbutton3">Auto10</button><button id="lightningstormbutton4">Skip</button><ul id="lightningstormresultarea"></ul></fieldset></div>';
$('.mw-contributions-form').after(htmls);
var username = $('#contentSub').children('a:eq(0)').text();
var starttime = '';
var namespace = '';
// Check User Groups
if ($.inArray('sysop', window.wgUserGroups) == -1)
$('#lightningstormcreated').remove();
// Load edits
$('#lightningstormbutton1').click(function(){
$('#lightningstormresultarea').empty();
starttime = $('#lightningstormstart').val();
namespace = $('#lightningstormns').val();
$.ajax({
url: 'https://zh-two.iwiki.icu/w/api.php?format=xml',
type: 'POST',
data: {
action: 'query',
list: 'usercontribs',
ucstart: starttime,
ucnamespace: namespace,
uclimit: 10,
ucuser: username,
ucprop: 'ids|title|timestamp|sizediff'
},
dataType: 'xml',
success: function(xml){
$(xml).find('usercontribs').children('item').each(function(index){
var html = '<li class="lightningstormresultitem"><span class="lightningstormtitle">' + $(this).attr('title')
+ '</span> ' + $(this).attr('timestamp')
+ ' <a href="https://zh-two.iwiki.icu/w/index.php?diff=' + $(this).attr('revid') + '">diff</a> ('
+ $(this).attr('sizediff') + ')';
$('#lightningstormresultarea').append(html);
});
if($(xml).find("continue")){
$('#lightningstormstart').val($(xml).find("continue").attr('uccontinue'));
var strings = $('#lightningstormstart').val().split('|');
$('#lightningstormstart').val(strings[0]);
}
}
});
});
// skip
$('#lightningstormbutton4').click(function(){
$('.lightningstormresultitem:first').remove();
if ($('.lightningstormresultitem').length === 0)
$('#lightningstormbutton1').trigger("click");
});
var rtoken = '';
$('#lightningstormbutton2').click(function(){
// get token
var title = $('.lightningstormtitle:first').text();
$.ajax({
url: 'https://zh-two.iwiki.icu/w/api.php?format=xml',
type: 'POST',
data: {
action: 'query',
prop: 'revisions',
rvtoken: 'rollback',
titles: title,
},
dataType: 'xml',
success: function(xml){
rtoken = $(xml).find('rev').attr('rollbacktoken');
// just roll it
$.ajax({
url: 'https://zh-two.iwiki.icu/w/api.php?format=xml',
type: 'POST',
data: {
action: 'rollback',
markbot: 1,
user: username,
title: title,
token: rtoken
},
dataType: 'xml',
success: function(xml){
console.log('fin');
}
});
}
});
$('#lightningstormbutton4').trigger("click");
});
$('#lightningstormbutton3').click(function(){
var i = 0;
for ( i = 1; i <= 10; i++ ){
$('#lightningstormbutton2').trigger("click");
}
});
})(jQuery);