User:AntiCompositeNumber/CentralAuthLWCULink.js
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/**
Adds a link to LWCU from CentralAuth, with a staleness indicator
@license Apache-2.0
@author AntiCompositeNumber
*/
if ( mw.config.get("wgCanonicalSpecialPageName") === "CentralAuth" ) {
mw.loader.using( "moment", function () {
var $reg = $( "#mw-centralauth-info>ul>li:nth-child(2)" );
$reg.append( " " );
var reg_date = moment.utc(
$reg.text().match( /: (.*) \(/ )[1],
[ 'HH:mm, DD MMMM YYYY', 'HH:mm, MMMM DD, YYYY' ]
);
var stale_date = moment.utc().subtract( 90, 'days' );
if ( reg_date.isBefore( stale_date ) ) {
$( '<span></span>' ).text( "(Stale)" ).appendTo( $reg );
$reg.css( "background-color", "#d33" ).css( "color", "white" );
} else {
$(
'<a></a>',
{ href: "https://login.wikimedia.org/wiki/Special:CheckUser/" + mw.config.get( "wgRelevantUserName" ) }
)
.text( "(Fresh)" )
.css( "color", "#14866d" )
.appendTo( $reg );
}
} );
}