User:Technical 13/Scripts/ACCHelp/CentralAuth.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
This user script seems to have a documentation page at User:Technical 13/Scripts/ACCHelp/CentralAuth. |
if(mw.config.get("wgCanonicalSpecialPageName") === "CentralAuth"){
function checkActive(){
var existsAgoDate = new Date($('fieldset#mw-centralauth-info').find('li:nth-child(3)').html().slice($('fieldset#mw-centralauth-info').find('li:nth-child(3)').html().indexOf('</strong>')+9, $('fieldset#mw-centralauth-info').find('li:nth-child(3)').html().indexOf('(')).trim());
var existsAgoTime = Date.now() - existsAgoDate;
var existsEditsEn = 0;
if($('td a:contains("en.wikipedia.org")').length ){
existsEditsEn = parseInt($('td a:contains("en.wikipedia.org")').closest('tr').find('td').eq(4).html().replace(/<\/?a(.*?)>/gi, ''),10);
}
var existsEditsGlobal = $('fieldset#mw-centralauth-info').find('li:nth-child(5)').html().substr(34);
var existsNotActive = true;
if(existsEditsEn > 0){
var aYearAgo = new Date();
var aYearAgoDay = aYearAgo.getUTCDate();
var aYearAgoMonth = aYearAgo.getUTCMonth();
var aYearAgoYear = aYearAgo.getUTCFullYear() - 1;
aYearAgo = new Date(aYearAgoYear, aYearAgoMonth, aYearAgoDay);
if(existsAgoTime < aYearAgo){
if(existsEditsGlobal < 15){ existsNotActive = "SUL";/* Assume active (will need to check for activity) */ }
else { existsNotActive = false;/* More than 15 global edits. */ }
} else { existsNotActive = false;/* More than a year old. */ }
} else {
var sixMonthsAgo = new Date();
var sixMonthsAgoDay = sixMonthsAgo.getUTCDate();
var sixMonthsAgoMonth = sixMonthsAgo.getUTCMonth() - 6;
var sixMonthsAgoYear = sixMonthsAgo.getUTCFullYear();
if(sixMonthsAgoMonth < 0){
sixMonthsAgoYear -= 1;
sixMonthsAgoMonth += 6;
}
sixMonthsAgo = new Date(sixMonthsAgoYear, sixMonthsAgoMonth, sixMonthsAgoDay);
if(existsAgoTime < sixMonthsAgo){
if(existsEditsGlobal > 15){ existsNotActive = false;/* Too many global edits */ }
} else { existsNotActive = "SUL";/* Assume active (will need to check for activity) */ }
}
return existsNotActive;
}
if(typeof($("div#mw-content-text div.error:contains('There is no global account for')").html()) === "undefined"){
var existsInactive = checkActive();
var existsName = '"' + $('fieldset#mw-centralauth-info').find('li:nth-child(1)').html().substr(27).replace(' ', '_') + '"';
var existsAgo = $('fieldset#mw-centralauth-info').find('li:nth-child(3)').html().substr($('fieldset#mw-centralauth-info').find('li:nth-child(3)').html().indexOf('(')).replace(/[\(\)]/g, '');
var existsEditsGlobal = $('fieldset#mw-centralauth-info').find('li:nth-child(5)').html().substr(34);
if(existsEditsGlobal === "0"){ existsEditsGlobal = 'no global edits'; }
else if(existsEditsGlobal === "1"){ existsEditsGlobal = '1 global edit'; }
else { existsEditsGlobal = existsEditsGlobal + ' global edits'; }
if (!existsInactive || existsInactive === "SUL"){
if (existsInactive === "SUL"){
var existsInactiveCheckSUL = confirm("WARNING!\n\t\t" + existsName + ' may be an ACTIVE account that was created ' + existsAgo + ' and has ' + existsEditsGlobal + ',\n\t\tbut you will need to check https://tools.wmflabs.org/quentinv57-tools/tools/sulinfo.php?showinactivity=1&showblocks=1&username=' + existsName + ' to be sure.');
if (existsInactiveCheckSUL === false/* change this back to null when switched back to prompt when read to send in date to test */){
$('fieldset#mw-centralauth-info').find('li:nth-child(3)').html($('fieldset#mw-centralauth-info').find('li:nth-child(3)').html().replace('(' + existsAgo + ')', '(' + existsName + ' is an <b class="error">ACTIVE</b> account that was created ' + existsAgo + ' and has ' + existsEditsGlobal + '.)'));
} else {
$('fieldset#mw-centralauth-info').find('li:nth-child(3)').html($('fieldset#mw-centralauth-info').find('li:nth-child(3)').html().replace('(' + existsAgo + ')', '(' + existsName + ' is an <b style="color: #0A0;">INACTIVE</b> account that was created ' + existsAgo + ' and has ' + existsEditsGlobal + '.)'));
}
} else {
$('fieldset#mw-centralauth-info').find('li:nth-child(3)').html($('fieldset#mw-centralauth-info').find('li:nth-child(3)').html().replace('(' + existsAgo + ')', '(' + existsName + ' is an <b class="error">ACTIVE</b> account that was created ' + existsAgo + ' and has ' + existsEditsGlobal + '.)'));
}
$("h1#firstHeading").html(tickBad + " " + $("h1#firstHeading").html());
document.title = Ucross + document.title;
} else {
$('fieldset#mw-centralauth-info').find('li:nth-child(3)').html($('fieldset#mw-centralauth-info').find('li:nth-child(3)').html().replace('(' + existsAgo + ')', '(' + existsName + ' is an <b style="color: #0A0;">INACTIVE</b> account that was created ' + existsAgo + ' and has ' + existsEditsGlobal + '.)'));
$("h1#firstHeading").html(tickGood + " " + $("h1#firstHeading").html());
document.title = Ucheck + document.title;
}
} else {
$("h1#firstHeading").html(tickGood + " " + $("h1#firstHeading").html());
document.title = Ucheck + document.title;
}
}