User:Sophiedp/global.js

/* Link to report thread on suwiki */ $('', {id: 'report'}) .html('Report Thread') .prependTo('.toolbar .tools');

/* Show removed replies on threads */ $(".message-removed.hide").removeClass("hide");

/* Remove the part of the url that opens the editor on redlinks */ var head = $('a[href$="?action=edit&redlink=1"]'); if ($('a[href$="?action=edit&redlink=1"]').attr("href")) { //if ?action=edit&redlink=1 is in the url head.attr("href", head.attr("href").replace("?action=edit&redlink=1", "")); //remove it }

/* Link to subpages in my tools menu */ $('', {id: 'subpages'}) .html('Subpages') .prependTo('#my-tools-menu');

/* Disable user js */ $('', {id: 'nouserjs'}) .html('No User JS') .prependTo('#my-tools-menu');

/* Add option to make code pages use different font */ if ($("#theme-solarized-light").length||$("#theme-solarized-dark").length) { $('', {id: 'codefont',}) .html('Code Font') //create the link .prependTo('#my-tools-menu') //attach the link .click(function {       mw.util.addCSS('#theme-solarized-light, #theme-solarized-dark { font-family: Fira !important; }');    }); }

/* Make page take the full width of the screen */ $('', {id: 'screenwidth',}) .html('Full Screen') //create the link .prependTo('#my-tools-menu') //attach the link .click(function {   mw.util.addCSS('.WikiaPage {\ border: none !important;\ padding: 0 8px;\ width: calc(100% - 16px);\ }\   #WikiaRail {\ display: none;\ }\   #WikiaMainContent {\ width: 100%;\ }'); });

/* Code to create userpage or message wall greeting by clicking on a link */ //Userpage $('', {id: 'qcup',}) .html('Create user page</a>') //create the link .prependTo('.toolbar .tools') //put it in the toolbar .click(function { //when clicked   $.ajax( { //create the userpage type: 'POST', url: mw.util.wikiScript( 'api' ), dataType: 'json', data: { action: 'edit', title: 'User:Sophiedp', //at this page summary: 'Creating user page (script)', //with this edit summary text: '', //using this tempalte format: 'json', token: mw.user.tokens.get( 'editToken' ) }   } ).done( function ( data ) { if ( data.edit.result === 'Success' ) { new BannerNotification("Successfully created user page!","confirm").show; //say we created the page } else { new BannerNotification("An error occurred while creating user page.","error").show; //say we didn't create the page }   } ).fail( function ( data ) { new BannerNotification("An error occurred while creating user page.","error").show; //say we didn't create the page } ); }); //Message wall greeting $.ajax({   type: 'HEAD', //see if    url: wgServer + '/wiki/Message_Wall:Sophiedp', //my message wall exists    success: function { //if it exists        $('<li>', {id: 'qcmwg',})        .html('Create Greeting</a>') //create the link        .prependTo('#my-tools-menu') //put it in the my tools menu on the toolbar        .click(function { //when clicked $.ajax( { //create the message wall greeting           type: 'POST',            url: mw.util.wikiScript( 'api' ),            dataType: 'json',            data: {                action: 'edit',                title: 'Message_Wall_Greeting:Sophiedp', //at this page                summary: 'Creating message wall greeting (script)', //with this edit summary                text: '', //using this template                format: 'json',                token: mw.user.tokens.get( 'editToken' )            }            } ).done( function ( data ) {                if ( data.edit.result === 'Success' ) {                    new BannerNotification("Successfully created message wall greeting!","confirm").show; //say we created the page                } else {                    new BannerNotification("An error occurred creating while message wall greeting.","error").show; //say we didn't create the page }           } ).fail( function ( data ) { new BannerNotification("An error occurred while creating message wall greeting.","error").show; //say we didn't create the page } );       });    },    error: function { //if it doesn't exist return; //do nothing } });

/** * Name:       UnhideUserWikis * Description: Unhides hidden user wikis in masthead and appends the edit count * Author:     KockaAdmiralac <1405223@gmail.com> */ $(function {   if($('#UserProfileMasthead').length === 0) {        return;    }    $.getJSON(mw.util.wikiScript('api'), { action: 'query', list: 'users', ususers: $('.masthead-info hgroup h1').text, format: 'json' }, function(d) { var u = d.query.users; if(u && u[0] && u[0].userid) { $.getJSON(mw.util.wikiScript('wikia'), {               controller: 'UserProfilePageController',                method: 'renderLightbox',                userId: u[0].userid,                format: 'json'            }, function(da) {                if(da && da.user && da.user.topWikis && da.user.topWikis.length > 0) {                    $('.masthead-info-lower .wikis').remove;                    var el = $('<ul>'),                        tw = da.user.topWikis;                    for(var i in tw) {                        if(tw.hasOwnProperty(i)) {                            var w = tw[i];                            el.append( $('<li>') .append(                                       $('')                                            .attr('href', w.wikiUrl)                                            .text(w.wikiName + ' (' + w.edits + ')')                                    ) );                       }                    }                    $('.masthead-info-lower').append( $('<ul>') .attr('class', 'wikis') .append(                               $(' ')                                    .text('My favorite wikis')                            ) .append(el) );               }            });        }    }); });

/* Add gender tag to global masterhead */ $(function {   if($("#UserProfileMasthead").length === 0) {        return;    }    mw.loader.using('mediawiki.api').then(function { new mw.Api.get({           action: 'parse',            text: ''        }).done(function(d) {            if(d.parse.text['*'].indexOf('thisisjustsomethingstupid') === -1) {                $('.masthead-info hgroup').append(' ' + d.parse.text['*'] + ' ');            }        }); }); });

/* Staff/VSTF/Bot/Helper highlights */ importStylesheetPage('Highlight/code.css', 'dev');

/* WLB highlights */ importStylesheetPage('MediaWiki:WLBhighlight.css', 'wlb');

/* Imports */ importArticles({   type: "script",    articles: [        'u:dev:MediaWiki:CacheCheck/code.js',        'u:dev:MediaWiki:MarkBlocked.js',        'u:dev:MediaWiki:AjaxRC/code.js',        'u:dev:MediaWiki:LastEdited/code.js',        'u:dev:MediaWiki:AjaxUndo/code.js',        'u:dev:MediaWiki:ToggleSideBar/code.js',        'u:dev:MediaWiki:HoverEditCount/code.js',        'u:dev:MediaWiki:QuickDiff/code.js',        'u:dev:MediaWiki:ContribsLink/code.js',        'u:dev:MediaWiki:DupImageList/code.js',        'u:dev:MediaWiki:DisplayTimer/code.js',        'u:dev:MediaWiki:Linksweeper/code.js',        'u:dev:MediaWiki:RecentChangesMultiple/code.2.js'    ] });