User:MacFan4000/findInactiveSysops.js: Difference between revisions

no edit summary
(Created page with "//This script automates the process of finding inactive sysops. //Warning: the script will replace the contents of the page you are currently viewing when you click the link a...")
 
No edit summary
 
(7 intermediate revisions by the same user not shown)
Line 1:
//<nowiki>
//This script automates the process of finding inactive sysops.
//Warning: the script will replace the contents of the page you are currently viewing when you click the link at the top right of the page.
//Output is in the format of "[[User:Example|Example]] || [[Special:PermanentLink/1234|timestamp]] || [[Special:Log/Example|timestamp]]"
mw.loader.using(['oojs-ui', 'mediawiki.util']).done( function () {
 
var scriptActivationLink = mw.util.addPortletLink(
'p-personaltb',
'#',
'Find Inactive Sysops',
Line 46 ⟶ 49:
function filterUsers (userlist){
var userstring = userlist.toString();
var exempt = ["MaFan4000John","MbrtPup","Void","FuzzyBotNDKilla","Test Wiki message deliveryReception123","Revi","Southparkfan","Abuse filter"];
for (i = 0; i < exempt.length; i++){
userstring = userstring.replace(exempt[i]+",","");
Line 104 ⟶ 107:
} ).fail(/*console.log( "While getting the userlist, there was an AJAX error." )*/);
}
var updButton = new OO.ui.ButtonWidget( {
label: 'Update Inactive Administrators?',
id: 'upd-inactive-bttn'
} );
$("#inactiveList").after(updButton.$element.click(function(){updList();}));
}
function compareDates ( data, dataType ){
Line 111 ⟶ 119:
var mm = today.getMonth() + 1; //January is 0!
var yyyy = today.getFullYear();
//Set back 13 monthmonths
mm -= 13;
if (mm < 0){
mm += 12;
Line 147 ⟶ 155:
 
function listInactiveUsers( userName, tribsArray, logsArray ){
var userLink = "[[User:<a href=\"https://testwikipublictestwiki.com/wiki/index.php/Special:Contribs/" + userName + "\">" + userName + "</a>|" + userName + "]]";
var tribsInfo = tribsArray[0].timestamp;
tribsInfo = tribsInfo.slice(0, tribsInfo.indexOf("T"));
Line 157 ⟶ 165:
$("#inactiveList").append( "<li>" + userLink + " || " + tribsInfo + " || " + logsInfo + "</li>" );
}
 
function updList() {
var list = $("#inactiveList")[0].innerText;
list = '|-\n|' + list;
while(list.indexOf("\n[[User:") > 0){
list = list.substr(0,list.indexOf("\n[[User:")) + '\n|-\n|' + list.substr(list.indexOf("\n[[User:") + 1);
}
$.getJSON(
mw.util.wikiScript('api'),
{
format: 'json',
action: 'query',
pageids: 440,
prop: 'revisions',
rvprop: 'content'
}
).done( function ( data ) {
try {
var wtext = data.query.pages[440].revisions[0]['*'];
wtext = wtext.substr(0, wtext.indexOf("|-")) + list + wtext.substr(wtext.indexOf("|}"));
$.ajax( {
url: mw.util.wikiScript( 'api' ),
type: 'POST',
dataType: 'json',
data: {
format: 'json',
action: 'edit',
title: 'TestWiki:Inactivity/Inactive administrators',
text: wtext,
summary: 'automatically updating list',
token: mw.user.tokens.get( 'csrfToken' ),
}
} ).done(function() {
alert( "Updated TestWiki:Inactivity/Inactive administrators" );
var reload = new OO.ui.ButtonWidget({ label: 'Load origional page' });
$('#upd-inactive-bttn').replaceWith(reload.$element.click(function(){window.location.reload();}));
}
).fail( function ( e, data ){
console.log( e.message );
console.log( JSON.stringify( data ) );
});
}
catch(e){}
}).fail
( function ( e, data ){
console.log( e.message );
console.log( JSON.stringify( data ) );
});
}
 
});
//</nowiki>