Jump to content

User:Writ Keeper/Scripts/cuStaleness.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Writ Keeper (talk | contribs) at 19:38, 27 June 2017 (start). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
//<nowiki>
/*
	Checkuser staleness checker, written by Writ Keeper. Checks contribs, deleted contribs, and user creation date, and determines whether the account has activity past the 90-day checkuser staleness mark.
 */
mw.hook( 'wikipage.content' ).add(function(){
	var titleRegex = /Wikipedia:Sockpuppet_investigations\/[^\/]+/;
	if(titleRegex.test(mw.config.get("wgPageName")))
	{
		//initialize some variables
		var currentTimestamp = new Date().getTime();
		var timestampDifference = 90*24*60*60*1000; //90 days in milliseconds
		var contribsData = {"action":"query","list":"usercontribs","ucprop":"timestamp","ucuser":"","uclimit":"1","ucdir":"older", "format":"json"};
		var deletedData = {"action":"query","list":"alldeletedrevisions","adrprop":"timestamp","adruser":"","adrlimit":"1","adrdir":"older", "format":"json"};
		
		//for each cu entry (as defined by use of the {{checkuser}} template)...
		$("span.cuEntry").each(function(index) 
		{
			//first, retrieve the current iteration's user name from the text of the template
			var sockName = $(this).children(":first").text();
			//insert it into the API data packages
			var contribsData.ucuser = sockName;
			var deletedData.adruser = sockName;
			//initialize values
			var lastWasDeleted = false;
			var lastTimestamp = -1;
			//first search standard contribs
			$.post("/w/api.php", contribsData, function(response){
				if(typeof results.query !== "undefined" && response.query.usercontribs.length >0)
				{
					//retrieve the current stamp
					lastTimestamp = new Date(results.query.alldeletedrevisions[0].revisions[0].timestamp).getTime();
					if(currentTimestamp - lastTimestamp < timestampDifference)
					{
						
					}
				}
				else
				{
					
				}
			})
		});
	}
});
//</nowiki>

$.post("/w/api.php", )

				if(typeof results.query !== "undefined" && response.query.alldeletedrevisions.length >0)
					new Date(results.query.alldeletedrevisions[0].revisions[0].timestamp).getTime();