Jump to content

User:DannyS712/errors.js

From Wikipedia, the free encyclopedia
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

/*** Only add if "Main Page" is in page title, and not already on errors (or errors talk) page ***/
if( mw.config.get( "wgPageName" ).indexOf( "Main_Page" ) > -1
	&& mw.config.get( "wgPageName" ).indexOf("Main_Page/Errors") == -1
) {
	console.log(mw.config.get( "wgPageName" ));
	mw.loader.using( 'mediawiki.util',
		function () {
			var $link = $( "<a>" )
				.text( "Errors" )
				.attr( "title", "Wikipedia:Main Page/Errors" )
				.attr( "href", mw.util.getUrl( "Wikipedia:Main Page/Errors" ) );
			var isNewVector = mw.config.get('skin') == 'vector-2022';
			if ( !isNewVector ) {
				$link = $( "<span>" ).append( $link );
			}
			$link = $( "<li>" ).append( $link )
						.attr( "id", "ca-errors" );
			if ( isNewVector ) {
				$link.addClass( "vector-tab-noicon" ).addClass( "mw-list-item" );
			}
			$( "#ca-talk" ).after( $link );
		}
	);
}