User:Sophiedp/global.js

/* Toolbar */ importStylesheetURI('https://rawgit.com/LunarTwilight/cb84225e1edad24b81d7d460e7771d34/raw/26c226a8feed3993de133b0584b4cdc0ad9a1c9d/toolbar.css'); $('.WikiaBarWrapper .toolbar .tools > li:has(a[class="sprite gear"])').remove; $('.WikiaBarWrapper .toolbar .tools > li:has(a[class="tools-customize"])').remove; $('.WikiaBarWrapper .toolbar .tools > li:has(a[class="global-shortcuts-help-entry-point"])').remove;

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

/* 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('.toolbar .tools');

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

/* Disable site js */ $('', {id: 'nositejs'}) .html('No Site 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('.toolbar .tools') //attach the link .click(function {       mw.util.addCSS('#theme-solarized-light, #theme-solarized-dark { font-family: Fira !important; }');    }); }

/* ColoredColors */ (function {	var isHexCode = function(h) {		var a = parseInt(h, 16);		return (a.toString(16) === h);	};	var tags = document.getElementsByClassName('re0');	if (wgAction == 'view' && wgPageName.split('.')[wgPageName.split('.').length - 1] == 'css') {		for (i = 0; i < tags.length; i++) {			var html = tags[i].innerHTML;			if (html.charAt(0) == '#' && html.length == 7 && isHexCode(html.slice(1).toLowerCase)) {				var brokened = html.split(';');				for (j = 0; j < html.split('#').length - 1; j++) {					if (brokened[j][0] == '#') {						brokened[j] = '' + brokened[j].substring(0, 7) + ' ';					}				}				tags[i].innerHTML = brokened.join(';');			}		}	} });

/* Make page take the full width of the screen */ $('<li>', {id: 'screenwidth',}) .html('Full Screen</a>') //create the link .prependTo('.toolbar .tools') //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%;\ }'); });

/* Disable 5 sec edit save delay */ GlobalTriggers.bind("WikiaEditorReady", function(point) { if (point.controls) {    point.controls.editform.off("submit").on("submit", function { point.setState(3); }); } });

/** * 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');

/* BotoneraPopups */ importArticles({   type: "script",    articles: [        "u:dev:MediaWiki:BotoneraPopups/BotoneraPopups.js",        "u:dev:MediaWiki:BotoneraPopups/WikiArticle.js",        "u:dev:MediaWiki:BotoneraPopups/UILang/en.js",        "u:dev:MediaWiki:BotoneraPopups/code.js"    ] }); importStylesheetPage('BotoneraPopups/code.css', 'dev');

/* 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:PageCreator/code2.js',        'u:dev:MediaWiki:HoverEditCount/code.js',        'u:dev:MediaWiki:QuickDiff/code.js',        'u:dev:MediaWiki:GlobalEditcount/code.js',        'u:dev:MediaWiki:UserAccountAge/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'    ] });