User:Void/findInactiveSysops.js: Difference between revisions

From TestWiki
Content added Content deleted
(should just about do it)
m (Per removal. Consul action)
 
(63 intermediate revisions by 6 users not shown)
Line 1: Line 1:
/* jslint strict:false */
//<nowiki>
//This script automates the process of finding inactive sysops.
//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]]"
//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(
var scriptActivationLink = mw.util.addPortletLink(
'p-personal',
'#',
'p-tb',
'Find Inactive Sysops',
'#',
'pt-testscript',
'Find Inactive Sysops',
'pt-testscript',
'Replaces the contents of the current page with a list of inactive sysops',
'Replaces the contents of the current page with a list of inactive sysops',
null,
null,
'#pt-adminlinks'
'#pt-adminlinks'
);
);


$( scriptActivationLink ).click( function () {
$( scriptActivationLink ).click( function () {
var progressBar = new OO.ui.ProgressBarWidget();
var doThis = confirm('Do you want to run the script?');
var progressField = new OO.ui.FieldLayout(
if( doThis ){
progressBar,
$.getJSON(
{
//Get userlist
label: "Fetching users...",
mw.util.wikiScript('api'),
align: 'top'
{
}
format: 'json',
);
action: 'query',
list: 'allusers',
augroup: 'sysop',
aulimit: 50, //Set limit to 50 as there are no more than 50 sysops
}
).done( function ( data ) {
try {
var users = data.query.allusers;
var userlist = [];
users.forEach(function(object){
userlist.push(object.name);
});
filterUsers(userlist);
}
catch ( e ) {
console.log( "Content request error: " + e.message );
console.log( "Content request response: " + JSON.stringify( data ) );
}
} ).fail( function () {
console.log( "While getting the userlist, there was an AJAX error." );
} );
}
} );


var textPanel = new OO.ui.PanelLayout( {
function filterUsers (userlist){
expanded: false,
var userstring = userlist.toString();
framed: false,
var exempt = ["John","Pup","Void","NDKilla","Reception123","Revi","Southparkfan","Abuse filter"];
padded: false,
for (i = 0; i < exempt.length; i++){
} );
userstring = userstring.replace(exempt[i]+",","");

}
var canSave = false;
var reducedList = userstring.split(",");
var tribsData;
function InactiveUsersProc( config ) {
var logsData;
InactiveUsersProc.super.call( this, config );
//Visual output onto the page you activate the script on
}
$("#mw-content-text").replaceWith("The following users are inactive:" + "<ul id=\"inactiveList\" style=\"list-style-type:none;list-style-image:none;\"></ul>");
OO.inheritClass( InactiveUsersProc, OO.ui.ProcessDialog );
for (x = 0; x < reducedList.length; x++){

InactiveUsersProc.static.name = "Inactive Users Process";
InactiveUsersProc.static.title = "List of Inactive Users:";
InactiveUsersProc.static.actions = [
{
action: "save",
label: "Update",
flags: "primary"
},
{
label: "Cancel",
flags: "safe"
}
];

InactiveUsersProc.prototype.initialize = function() {
InactiveUsersProc.super.prototype.initialize.apply( this, arguments );

this.content = new OO.ui.FieldsetLayout();
this.content.addItems([ progressField ]);
this.content.$element.css( 'padding', '1em' );

this.$body.append( this.content.$element );
};
InactiveUsersProc.prototype.getActionProcess = function( action ) {
var dialog = this;
if( action && canSave ) {
return new OO.ui.Process( function() {
if( action == "save" ) {
updList();
}

dialog.close( {
action: action
} );
});
}
return InactiveUsersProc.super.prototype.getActionProcess.call( this, action );
};
InactiveUsersProc.prototype.getBodyHeight = function() {
return this.content.$element.outerHeight( true );
};
var windowManager = new OO.ui.WindowManager();
var inactiveUsersProc = new InactiveUsersProc( {
size: "large"
} );

windowManager.addWindows([ inactiveUsersProc ]);
$('body').append(windowManager.$element);
windowManager.openWindow(inactiveUsersProc);

var checked = 0;
var inactive = [];
var checkList = [];
var total = 0;

// Get user list
$.getJSON(
$.getJSON(
mw.util.wikiScript( 'api' ),
//Get contribs and log entries
mw.util.wikiScript('api'),
{
{
format: 'json',
format: 'json',
action: 'query',
action: 'query',
list: 'allusers',
augroup: 'bot|sysop|bureaucrat|consul|autopatrolled|rollbacker|interface-admin|flow-bot',
list: 'logevents|usercontribs',
leprop: 'timestamp',
aulimit: 150 // Unlikely to be more than 150 privilged users
ledir: 'older',
}
).done( function ( data ) {
leuser: reducedList[x],
try {
lelimit: 1, //We only need the most recent log action/edit
uclimit: 1,
var users = data.query.allusers;
ucuser: reducedList[x],
var userlist = [];

ucdir: 'older',
users.forEach( function( object ) {
ucprop: 'timestamp|ids'
}
userlist.push( object.name );
).done( function ( data ) {
});
try {
filterUsers( userlist );
}
tribsData = data.query.usercontribs;
catch ( e ) {
logsData = data.query.logevents;
console.log( "Content request error: " + e.message );
var activeLogs, activeTribs, active;
console.log( "Content request response: " + JSON.stringify( data ) );
var tribsInfo;
}
} ).fail( function () {
console.log( "While getting the userlist, there was an AJAX error." );
} );

function filterUsers ( userlist ) {
var userstring = userlist.toString();
var exempt = ["John", "NDKilla", "Reception123", "Revi", "Southparkfan", "Abuse filter", "Void", "Zppix", "RhinosF1", "MediaWiki message delivery", "MediaWiki default", "Babel AutoCreate", "Dmehus", "Revibot", "Delete page script", "Move page script", "Flow talk page manager", "Universal Omega", "HeartsDo", "MacFan4000"];

for ( i = 0; i < exempt.length; i++ ) {
userstring = userstring.replace( exempt[i] + ",", "" );
}

checkList = userstring.split( "," );
total = checkList.length;
checkUser( checkList.pop() );
}

function checkUser( user ) {
$.getJSON(
mw.util.wikiScript( 'api' ),
{
format: 'json',
action: 'query',
list: 'logevents|usercontribs',
leprop: 'timestamp',
ledir: 'older',
leuser: user,
lelimit: 1, //We only need the most recent log action/edit
uclimit: 1,
ucuser: user,
ucdir: 'older',
ucprop: 'timestamp|ids'
}
).done( function ( data ) {
try {
var tribsData = data.query.usercontribs;
var logsData = data.query.logevents;
var activeLogs, activeTribs, active, tribsInfo;

if( typeof( logsData[0] ) != "undefined" ) {
activeLogs = compareDates( logsData[0].timestamp, "logs" );
} else {
activeLogs = false;
}

if( typeof( tribsData[0] ) != "undefined" ) {
tribsInfo = tribsData[0].revid + "|" + tribsData[0].timestamp;
activeTribs = compareDates( tribsInfo, "tribs" );
} else {
activeTribs = false;
}

if( activeLogs === false && activeTribs === false ) {
inactive.push([user, tribsData, logsData]);
}

checked++;
progressBar.setProgress( parseInt( (checked/total) * 100 ) );

if( checkList.length > 0 ) {
checkUser( checkList.pop() );
} else {
listInactiveUsers();
}
} catch ( e ) {
console.log( "Content request error: " + e.message );
console.log( "Content request response: " + JSON.stringify( data ) );
}
} );
}
function compareDates ( data, dataType ) {
//Gets current date in yyyymmdd
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth() + 1; //January is 0!
var yyyy = today.getFullYear();

//Set back 3 months
mm -= 3;
if( mm < 0 ) {
mm += 12;
yyyy -= 1;
}

if( dd < 10 ) {
dd = '0' + dd;
}

if( mm<10 ) {
mm = '0' + mm;
}

today = '' + yyyy + mm + dd; //This is a string
var date;
var isActive;

if( dataType === "logs" ) {
date = data.slice( 0, data.indexOf('T') );
date = date.replace( /-/g, "" );
} else if( dataType === "tribs" ) {
date = data.slice( data.indexOf('|') + 1, data.indexOf('T') );
date = date.replace( /-/g, "" );
}

return date >= today;
}

function listInactiveUsers() {
sorted = inactive.sort( function( a, b ) {
return a[0].localeCompare( b[0] );
} );

for( var i in sorted ) {
var userName = sorted[i][0];
var tribsArray = sorted[i][1];
var logsArray = sorted[i][2];
var userLink = "[[User:<a href=\"https://publictestwiki.com/wiki/Special:Contribs/" + userName + "\">" + userName + "</a>|" + userName + "]]";


var tribsInfo;
if(typeof(logsData[0].timestamp) != "undefined") {
if( tribsArray[0] !== undefined ) {
activeLogs = compareDates( logsData[0].timestamp, "logs" );
tribsInfo = tribsArray[0].timestamp;
}
tribsInfo = tribsInfo.slice( 0, tribsInfo.indexOf("T") );
else {
tribsInfo = tribsArray[0].revid + "|" + tribsInfo;
activeLogs = false;
tribsInfo = "[[Special:PermanentLink/" + tribsInfo + "]]";
}
} else {
if( typeof(tribsData[0]) != "undefined" ) {
tribsInfo = (tribsData[0].revid+"|"+tribsData[0].timestamp);
tribsInfo = 'None';
}
activeTribs = compareDates( tribsInfo, "tribs" );
}
else {
activeTribs = false;
}
if( activeLogs === false && activeTribs === false ) {
var user = tribsData[0].user;
console.log(user + " is inactive");
listInactiveUsers( user, tribsData, logsData );
}
}
catch ( e ) {
console.log( "Content request error: " + e.message );
console.log( "Content request response: " + JSON.stringify( data ) );
}
} ).fail(/*console.log( "While getting the userlist, there was an AJAX error." )*/);
}
$("#inactiveList").after('<span class="mw-ui-button" onclick="updList()">Update Inactive Administrators?</span>');
}
function compareDates ( data, dataType ){
//Gets current date in yyyymmdd
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth() + 1; //January is 0!
var yyyy = today.getFullYear();
//Set back 3 months
mm -= 3;
if (mm < 0){
mm += 12;
yyyy -= 1;
}
if(dd<10) {
dd='0'+dd;
}


var logsInfo;
if(mm<10) {
if( logsArray[0] !== undefined ) {
mm='0'+mm;
logsInfo = logsArray[0].timestamp;
}
logsInfo = logsInfo.slice( 0, logsInfo.indexOf("T") );
today = ''+yyyy+mm+dd; //This is a string
logsInfo = "[[Special:Log/" + userName + "|" + logsInfo + "]]";
} else {
logsInfo = 'None';
}


textPanel.$element.append( "<li>" + userLink + " || " + tribsInfo + " || " + logsInfo + "</li>" );
var date;
}
var isActive;
inactiveUsersProc.content.clearItems();
if( dataType === "logs" ){
inactiveUsersProc.content.addItems([textPanel]);
date = data.slice(0,data.indexOf('T'));
inactiveUsersProc.updateSize();
date = date.replace("-","");
canSave = true;
}
}
else if( dataType === "tribs" ){
date = data.slice(data.indexOf('|') + 1, data.indexOf('T'));
function updList() {
date = date.replace("-","");
var list = textPanel.$element[0].innerText;
}
list = '|-\n|' + list;
if (date < today){
while( list.indexOf("\n[[User:") > 0 ) {
isActive = false;
list = list.substr( 0, list.indexOf( "\n[[User:" ) ) + '\n|-\n|' + list.substr( list.indexOf( "\n[[User:" ) + 1 );
}
}
else{
isActive = true;
}
return isActive;
}


// Get contents of TestWiki:Inactivity/Inactive administrators
function listInactiveUsers( userName, tribsArray, logsArray ){
$.getJSON(
var userLink = "[[User:<a href=\"https://publictestwiki.com/wiki/Special:Contribs/" + userName + "\">" + userName + "</a>|" + userName + "]]";
mw.util.wikiScript( 'api' ),
var tribsInfo = tribsArray[0].timestamp;
{
tribsInfo = tribsInfo.slice(0, tribsInfo.indexOf("T"));
format: 'json',
tribsInfo = tribsArray[0].revid + "|" + tribsInfo;
action: 'query',
var logsInfo = logsArray[0].timestamp;
pageids: 238,
logsInfo = logsInfo.slice(0, logsInfo.indexOf("T"));
prop: 'revisions',
tribsInfo = "[[Special:PermanentLink/" + tribsInfo + "]]";
rvprop: 'content',
logsInfo = "[[Special:Log/" + userName + "|" + logsInfo + "]]";
rvslots: 'main'
$("#inactiveList").append( "<li>" + userLink + " || " + tribsInfo + " || " + logsInfo + "</li>" );
}
}
).done( function ( data ) {
try {
var wtext = data.query.pages[238].revisions[0].slots.main['*'];
wtext = wtext.substr( 0, wtext.indexOf("|-") ) + list + '\n' + wtext.substr( wtext.indexOf( "|}" ) );


$.ajax( {
function updList() {
url: mw.util.wikiScript( 'api' ),
var list = $("#inactiveList")[0].innerText;
type: 'POST',
list = '|-\n|' + list;
dataType: 'json',
while(list.indexOf("\n[[User:") > 0){
data: {
list = list.substr(0,list.indexOf("\n[[User:")) + '\n|-\n|' + list.substr(list.indexOf("\n[[User:") + 1);
format: 'json',
}
action: 'edit',
console.log(list);
title: 'TestWiki:Inactivity/Inactive administrators',
$.getJSON(
text: wtext,
mw.util.wikiScript('api'),
summary: '[[User:Void/findInactiveSysops.js|Automatically]] updating list',
{
format: 'json',
token: mw.user.tokens.get( 'csrfToken' ),
action: 'query',
}
} ).done( function() {
pageids: 440,
alert( "Updated TestWiki:Inactivity/Inactive administrators" );
prop: 'revisions',
} ).fail( function ( e, data ) {
rvprop: 'content'
console.log( e.message );
}
).done( function ( data ) {
console.log( JSON.stringify( data ) );
} );
try {
}
var wtext = data.query.pages[440].revisions[0]['*'];
catch( e ) {
wtext = wtext.substr(0, wtext.indexOf("|-")) + list + wtext.substr(wtext.indexOf("|}"));
$.ajax( {
// ignore
}
url: mw.util.wikiScript( 'api' ),
type: 'POST',
} ).fail( function ( e, data ) {
console.log( e.message );
dataType: 'json',
console.log( JSON.stringify( data ) );
data: {
format: 'json',
} );
}
action: 'edit',
} );
title: 'TestWiki:Inactivity/Inactive administrators',
});
wikitext: wtext,
//</nowiki>
reason: 'automatically updating list',
token: mw.user.tokens.get( 'csrfToken' ),
}
} ).done(console.log( "Updated TestWiki:Inactivity/Inactive administrators" )
).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 ) );
});
}

Latest revision as of 05:31, 16 January 2022

/* jslint strict:false */
//<nowiki>
//This script automates the process of finding inactive sysops.
//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-tb',
	    '#',
	    'Find Inactive Sysops',
	    'pt-testscript',
	    'Replaces the contents of the current page with a list of inactive sysops',
	    null,
	    '#pt-adminlinks'
	);

	$( scriptActivationLink ).click( function () {
		var progressBar = new OO.ui.ProgressBarWidget();
		var progressField = new OO.ui.FieldLayout(
			progressBar,
			{
				label: "Fetching users...",
				align: 'top'
			}
		);

		var textPanel = new OO.ui.PanelLayout( {
			expanded: false,
			framed: false,
			padded: false,
		} );

		var canSave = false;
		
		function InactiveUsersProc( config ) {
			InactiveUsersProc.super.call( this, config );
		}
		OO.inheritClass( InactiveUsersProc, OO.ui.ProcessDialog );

		InactiveUsersProc.static.name = "Inactive Users Process";
		InactiveUsersProc.static.title = "List of Inactive Users:";
		InactiveUsersProc.static.actions = [
			{
				action: "save",
				label: "Update",
				flags: "primary"
			},
			{
				label: "Cancel",
				flags: "safe"
			}
		];

		InactiveUsersProc.prototype.initialize = function() {
			InactiveUsersProc.super.prototype.initialize.apply( this, arguments );

			this.content = new OO.ui.FieldsetLayout();
			this.content.addItems([ progressField ]);
			this.content.$element.css( 'padding', '1em' );

			this.$body.append( this.content.$element );
		};
		
		InactiveUsersProc.prototype.getActionProcess = function( action ) {
			var dialog = this;
			if( action && canSave ) {
				return new OO.ui.Process( function() {
					if( action == "save" ) {
						updList();
					}

					dialog.close( {
						action: action
					} );
				});
			}
			return InactiveUsersProc.super.prototype.getActionProcess.call( this, action );
		};
		
		InactiveUsersProc.prototype.getBodyHeight = function() {
			return this.content.$element.outerHeight( true );
		};
		
		var windowManager = new OO.ui.WindowManager();
		var inactiveUsersProc = new InactiveUsersProc( {
			size: "large"
		} );

		windowManager.addWindows([ inactiveUsersProc ]);
		$('body').append(windowManager.$element);
		windowManager.openWindow(inactiveUsersProc);

		var checked = 0;
		var inactive = [];
		var checkList = [];
		var total = 0;

		// Get user list
		$.getJSON(
	        mw.util.wikiScript( 'api' ),
	        {
	            format: 'json',
	            action: 'query',
	            list: 'allusers',
	            augroup: 'bot|sysop|bureaucrat|consul|autopatrolled|rollbacker|interface-admin|flow-bot',
	            aulimit: 150 // Unlikely to be more than 150 privilged users
	        }
	    ).done( function ( data ) {
	        try {
	        	var users = data.query.allusers;
	        	var userlist = [];

	        	users.forEach( function( object ) {
	        		userlist.push( object.name );
	        	});
	        	filterUsers( userlist );
	        }
	    	catch ( e ) {
	        	console.log( "Content request error: " + e.message );
	        	console.log( "Content request response: " + JSON.stringify( data ) );
	    	}
		} ).fail( function () {
	    	console.log( "While getting the userlist, there was an AJAX error." );
		} );

		function filterUsers ( userlist ) {
			var userstring = userlist.toString();
			var exempt = ["John", "NDKilla", "Reception123", "Revi", "Southparkfan", "Abuse filter", "Void", "Zppix", "RhinosF1", "MediaWiki message delivery", "MediaWiki default", "Babel AutoCreate", "Dmehus", "Revibot", "Delete page script", "Move page script", "Flow talk page manager", "Universal Omega", "HeartsDo", "MacFan4000"];

			for ( i = 0; i < exempt.length; i++ ) {
				userstring = userstring.replace( exempt[i] + ",", "" );
			}

			checkList = userstring.split( "," );
			total = checkList.length;
			checkUser( checkList.pop() );
		}

		function checkUser( user ) {
			$.getJSON(
		        mw.util.wikiScript( 'api' ),
		        {
		            format: 'json',
		            action: 'query',
		            list: 'logevents|usercontribs',
		            leprop: 'timestamp',
		            ledir: 'older',
		            leuser: user,
		            lelimit: 1, //We only need the most recent log action/edit
		            uclimit: 1,
		            ucuser: user,
		            ucdir: 'older',
		            ucprop: 'timestamp|ids'
		        }
		    ).done( function ( data ) {
		        try {
		        	var tribsData = data.query.usercontribs;
		        	var logsData = data.query.logevents;
		           	var activeLogs, activeTribs, active, tribsInfo;

		           	if( typeof( logsData[0] ) != "undefined" ) {
		           		activeLogs = compareDates( logsData[0].timestamp, "logs" );
		           	} else {
		           		activeLogs = false;
		           	}

		           	if( typeof( tribsData[0] ) != "undefined" ) {
		           		tribsInfo = tribsData[0].revid + "|" + tribsData[0].timestamp;
		           		activeTribs = compareDates( tribsInfo, "tribs" );
		           	} else {
		           		activeTribs = false;
		           	}

		           	if( activeLogs === false && activeTribs === false ) {
		           		inactive.push([user, tribsData, logsData]);
		           	}

		           	checked++;
		           	progressBar.setProgress( parseInt( (checked/total) * 100 ) );

		           	if( checkList.length > 0 ) {
		           		checkUser( checkList.pop() );
		           	} else {
		           		listInactiveUsers();
		           	}
		        } catch ( e ) {
		        	console.log( "Content request error: " + e.message );
		        	console.log( "Content request response: " + JSON.stringify( data ) );
		    	}
		    } );
		}
		
		function compareDates ( data, dataType ) {
			//Gets current date in yyyymmdd
			var today = new Date();
			var dd = today.getDate();
			var mm = today.getMonth() + 1; //January is 0!
			var yyyy = today.getFullYear();

			//Set back 3 months
			mm -= 3;
			if( mm < 0 ) {
				mm += 12;
				yyyy -= 1;
			}

			if( dd < 10 ) {
		    	dd = '0' + dd;
			}

			if( mm<10 ) {
			    mm = '0' + mm;
			}

			today = '' + yyyy + mm + dd; //This is a string
		
			var date;
			var isActive;

			if( dataType === "logs" ) {
				date = data.slice( 0, data.indexOf('T') );
				date = date.replace( /-/g, "" );
			} else if( dataType === "tribs" ) {
				date = data.slice( data.indexOf('|') + 1, data.indexOf('T') );
				date = date.replace( /-/g, "" );
			}

			return date >= today;
		}

		function listInactiveUsers() {
			sorted = inactive.sort( function( a, b ) {
				return a[0].localeCompare( b[0] );
			} );

			for( var i in sorted ) {
				var userName = sorted[i][0];
				var tribsArray = sorted[i][1];
				var logsArray = sorted[i][2];
				var userLink = "[[User:<a href=\"https://publictestwiki.com/wiki/Special:Contribs/" + userName + "\">" + userName + "</a>|" + userName + "]]";

				var tribsInfo;
				if( tribsArray[0] !== undefined ) {
					tribsInfo = tribsArray[0].timestamp;
					tribsInfo = tribsInfo.slice( 0, tribsInfo.indexOf("T") );
					tribsInfo = tribsArray[0].revid + "|" + tribsInfo;
					tribsInfo = "[[Special:PermanentLink/" + tribsInfo + "]]";
				} else {
					tribsInfo = 'None';
				}

				var logsInfo;
				if( logsArray[0] !== undefined ) {
					logsInfo = logsArray[0].timestamp;
					logsInfo = logsInfo.slice( 0, logsInfo.indexOf("T") );
					logsInfo = "[[Special:Log/" + userName + "|" + logsInfo + "]]";
				} else {
					logsInfo = 'None';
				}

				textPanel.$element.append( "<li>" + userLink + " || " + tribsInfo + " || " + logsInfo + "</li>" );
			}
			inactiveUsersProc.content.clearItems();
			inactiveUsersProc.content.addItems([textPanel]);
			inactiveUsersProc.updateSize();
			canSave = true;
		}
		
		function updList() {
			var list = textPanel.$element[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 );
			}

			// Get contents of TestWiki:Inactivity/Inactive administrators
			$.getJSON(
				mw.util.wikiScript( 'api' ),
		        {
		            format: 'json',
		            action: 'query',
		            pageids: 238,
		            prop: 'revisions',
		            rvprop: 'content',
		            rvslots: 'main'
		        }
		    ).done( function ( data ) {
		        try {
		           	var wtext = data.query.pages[238].revisions[0].slots.main['*'];
		           	wtext = wtext.substr( 0, wtext.indexOf("|-") ) + list + '\n' + 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: '[[User:Void/findInactiveSysops.js|Automatically]] updating list',
				            token: mw.user.tokens.get( 'csrfToken' ),
				        }
		   			} ).done( function() {
		   				alert( "Updated TestWiki:Inactivity/Inactive administrators" );
		   			} ).fail( function ( e, data ) {
		   				console.log( e.message );
		   				console.log( JSON.stringify( data ) );
		   			} );
		        }
		        catch( e ) {
		          	// ignore
		        }
		    } ).fail( function ( e, data ) {
		    	console.log( e.message );
		    	console.log( JSON.stringify( data ) );
		    } );
		}
	} );
});
//</nowiki>