User:Void/common.js: Difference between revisions
Content deleted Content added
m oops |
currently just logs usernames and timestamps + revisionids |
||
Line 5: | Line 5: | ||
//mw.loader.load('//publictestwiki.com/w/index.php?title=User:Void/testing.js&action=raw&ctype=text/javascript'); |
//mw.loader.load('//publictestwiki.com/w/index.php?title=User:Void/testing.js&action=raw&ctype=text/javascript'); |
||
//Testing js to automate finding inactive sysops |
//Testing js to automate finding inactive sysops. Currently logs usernames, logevent timestamps, and revision ids|timestamps. |
||
var testlink = mw.util.addPortletLink( |
|||
'p-personal', |
'p-personal', |
||
'#', |
'#', |
||
Line 36: | Line 36: | ||
userlist.push(object.name); |
userlist.push(object.name); |
||
}); |
}); |
||
console.log(userlist); |
//console.log(userlist); |
||
filterUsers(userlist); |
|||
} |
} |
||
catch ( e ) { |
catch ( e ) { |
||
Line 43: | Line 44: | ||
} |
} |
||
} ).fail( function () { |
} ).fail( function () { |
||
console.log( "While getting the |
console.log( "While getting the userlist, there was an AJAX error." ); |
||
} ); |
} ); |
||
} |
} |
||
} ); |
} ); |
||
*/ |
|||
function filterUsers (userlist){ |
|||
var userstring = userlist.toString(); |
|||
var exempt = ["John","Pup","Void","NDKilla","Reception123","Revi","Southparkfan","Abuse filter"]; |
|||
for (i = 0; i < exempt.length; i++){ |
|||
userstring = userstring.replace(exempt[i]+",",""); |
|||
} |
|||
var reducedList = userstring.split(","); |
|||
//console.log(reducedList); |
|||
var tribsInfo = []; |
|||
var tribsData; |
|||
var logsInfo = []; |
|||
var logsData; |
|||
for (x = 0; x < reducedList.length; x++){ |
|||
$.getJSON( |
|||
//Get contribs and log entries |
|||
mw.util.wikiScript('api'), |
|||
{ |
|||
format: 'json', |
|||
action: 'query', |
|||
list: 'logevents|usercontribs', |
|||
leprop: 'timestamp', |
|||
ledir: 'older', |
|||
leuser: reducedList[x], |
|||
lelimit: 1, //We only need the most recent log action/edit |
|||
uclimit: 1, |
|||
ucuser: reducedList[x], |
|||
ucdir: 'older', |
|||
ucprop: 'timestamp|ids' |
|||
} |
|||
).done( function ( data ) { |
|||
try { |
|||
tribsData = data.query.usercontribs; |
|||
//console.log(tribsData[0].timestamp); |
|||
logsData = data.query.logevents; |
|||
//console.log(logsData[0].timestamp); |
|||
if(typeof(logsData[0].timestamp) != "undefined") { |
|||
logsInfo.push(logsData[0].timestamp); |
|||
} |
|||
else { |
|||
logsInfo.push(null); |
|||
} |
|||
if( typeof(tribsData[0]) != "undefined" ) { |
|||
tribsInfo.push(tribsData[0].revid+"|"+tribsData[0].timestamp); |
|||
} |
|||
else { |
|||
tribsInfo.push(null); |
|||
} |
|||
} |
|||
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." )*/); |
|||
} |
|||
console.log(reducedList); |
|||
console.log(logsInfo); |
|||
console.log(tribsInfo); |
|||
} |
Revision as of 18:59, 8 November 2016
mw.loader.load('//en.wikipedia.org/w/index.php?action=raw&ctype=text/javascript&title=User:Writ_Keeper/Scripts/massRevdel.js');
mw.loader.load('//en.wikipedia.org/w/index.php?action=raw&ctype=text/javascript&title=User:Writ_Keeper/Scripts/massRollback.js');
mw.loader.load('//www.mediawiki.org/w/index.php?title=MediaWiki:Gadget-DotsSyntaxHighlighter.js&action=raw&ctype=text/javascript');
mw.loader.load('//tools-static.wmflabs.org/meta/scripts/pathoschild.templatescript.js');
//mw.loader.load('//publictestwiki.com/w/index.php?title=User:Void/testing.js&action=raw&ctype=text/javascript');
//Testing js to automate finding inactive sysops. Currently logs usernames, logevent timestamps, and revision ids|timestamps.
var testlink = mw.util.addPortletLink(
'p-personal',
'#',
'Test Script',
'pt-testscript',
'Test this piece of JS',
null,
'#pt-adminlinks'
);
$( testlink ).click( function () {
var doThis = confirm('Do you want to run the script?');
if( doThis ){
$.getJSON(
//Get userlist
mw.util.wikiScript('api'),
{
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);
});
//console.log(userlist);
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","Pup","Void","NDKilla","Reception123","Revi","Southparkfan","Abuse filter"];
for (i = 0; i < exempt.length; i++){
userstring = userstring.replace(exempt[i]+",","");
}
var reducedList = userstring.split(",");
//console.log(reducedList);
var tribsInfo = [];
var tribsData;
var logsInfo = [];
var logsData;
for (x = 0; x < reducedList.length; x++){
$.getJSON(
//Get contribs and log entries
mw.util.wikiScript('api'),
{
format: 'json',
action: 'query',
list: 'logevents|usercontribs',
leprop: 'timestamp',
ledir: 'older',
leuser: reducedList[x],
lelimit: 1, //We only need the most recent log action/edit
uclimit: 1,
ucuser: reducedList[x],
ucdir: 'older',
ucprop: 'timestamp|ids'
}
).done( function ( data ) {
try {
tribsData = data.query.usercontribs;
//console.log(tribsData[0].timestamp);
logsData = data.query.logevents;
//console.log(logsData[0].timestamp);
if(typeof(logsData[0].timestamp) != "undefined") {
logsInfo.push(logsData[0].timestamp);
}
else {
logsInfo.push(null);
}
if( typeof(tribsData[0]) != "undefined" ) {
tribsInfo.push(tribsData[0].revid+"|"+tribsData[0].timestamp);
}
else {
tribsInfo.push(null);
}
}
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." )*/);
}
console.log(reducedList);
console.log(logsInfo);
console.log(tribsInfo);
}