Jump to content

User:Enterprisey/user-tabs-on-contribs.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Enterprisey (talk | contribs) at 06:08, 6 December 2018 (fix). 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.
$( function () {
    if( mw.config.get( "wgPageName" ).indexOf( "Special:Contributions/" ) === 0 ) {
        mw.loader.using( [ "mediawiki.api", "mediawiki.util" ], function () {
            var username = mw.config.get( "wgTitle" ).substring( 14 );
            new mw.Api().get( {
                 action: "query",
                 titles: "User:" + username + "|User talk:" + username
            } ).done( console.log );

            /** Makes a tab linking to the given page name. redlink is a boolean indicating
             * whether the page exists or not. */
            function tab( label, target, redlink ) {
                return $( "<li>" ).append( $( "<a>" ) )
                        //.
                        }
            $( "#ca-nstab-special" );
        } );
    }
} );