Jump to content

User:DannyS712 test/errors.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by DannyS712 test (talk | contribs) at 05:03, 5 January 2019 (+heading). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
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.
// Install with:
// <code><nowiki>		{{subst:Iusc|User:DannyS712/errors.js}}																	</nowiki></code>
// or with
// <code><nowiki>		importScript( 'User:DannyS712/errors.js' ); // Backlink: [[User:DannyS712/errors.js]] 				</nowiki></code> 
//
// Special thanks to User:Enterprisey and their script, [[User:Enterprisey/user-tabs-on-contribs.js]], which I partially forked.
// If forking this script, please note my contributions / give me credit

if( mw.config.get( "wgPageName" ).indexOf( "Main_Page" ) > -1 ) {
	if ( !( mw.config.get( "wgPageName" ).indexOf("Main_Page/Errors") > -1 )) {
		console.log(mw.config.get( "wgPageName" ));
	    $.when(
	        mw.loader.using( [ "mediawiki.api", "mediawiki.util", "jquery.accessKeyLabel" ] ),
	        $.ready
	    ).then( function () {
	    	$( "#ca-talk" ).after( utocMakeTab( "Errors", "Wikipedia:Main Page/Errors", null, "ca-errors" ) );
	    } );
	}
}
function utocMakeTab( label, pageName, accesskey, id ) {
    var tab = $( "<li>" ).append( $( "<span>" ).append( $( "<a>" )
                .text( label )
                .attr( "accesskey", accesskey )
                .attr( "title", pageName + " (access key " + accesskey + ")" )
                .attr( "href", mw.util.getUrl( pageName ) ) ) )
            .attr( "id", id );
    return tab;
}