User:Sophiedp/global.js

/* Alert if global.js loads in chat */ if ( wgCanonicalSpecialPageName == 'Chat' ) { alert('Global.js is loaded in chat!'); }

/* Cache check settings */ window.topLevelCat = '';

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

/* FastDelete settings */ var fdButtons = []; fdButtons.push({   'summary': 'Housekeeping',    'label': 'HK' });

/* Anchored rollback */ if (!$('.mw-rollback-link a').length) return; $('.mw-rollback-link a').click(function(e) {	e.preventDefault;	var href = $(this).attr('href');	$.get(href);	$(this).css({'color':'grey','text-decoration':'line-through'}).removeAttr('href title').text('rollbacked'); }); }) (this.jQuery, this.mediaWiki);
 * (function($, mw) {

/* Always show bot edits on RecentChanges */ //@author-Foodbandlt var url = window.location.href; if (wgPageName == "Special:RecentChanges") { //Change the URL if (url.indexOf("hidebots=") == -1 && url.indexOf("?") == -1) { window.location.href = url + "?hidebots=0"; } else if (url.indexOf("hidebots=") == -1 && url.indexOf("?") != -1) { window.location.href = url + "&hidebots=0"; }   //Change the "hide/show bot edits" link if (url.search(/hidebots=0/) != -1) { $('.hideBotsButton a').attr("href", url.replace("hidebots=0", "hidebots=1")); $('.hideBotsButton a').html("Hide bots"); } else if (url.search(/hidebots=1/) != -1) { $('.hideBotsButton a').attr("href", url.replace("hidebots=1", "hidebots=0")); $('.hideBotsButton a').html("Show bots"); } }

/* AjaxUndo */ if (wgAction !== 'history') { jQuery(document).ready(function($) {       "use strict";        function createUndoLink(diffUndoUrl) {            var $ajaxUndoLink = $('').text('AJAX Undo').attr('href', '#').click(function { var $ajaxUndoLinkob = $(this), undoIdRegex = /&undo=([^&]*)/, undoId = undoIdRegex.exec(diffUndoUrl)[1], editToken, etUrl = wgServer + wgScriptPath + '/api.php?action=query&prop=info|revisions&intoken=edit&titles=' + encodeURIComponent(wgPageName) + '&format=json', usrUnd = $('#mw-diff-ntitle2 .mw-userlink').html, smry = prompt('Undo summary', 'Undo revision ' + undoId + ' by ' + usrUnd + ' (talk)'); if (smry === null) return; else if (!smry) smry = 'Undo revision ' + undoId + ' by ' + usrUnd + ' (talk)'; $ajaxUndoLinkob.html(' '); $.getJSON(etUrl, function(data) {                   editToken = data.query.pages[wgArticleId].edittoken;                    $.ajax({ url: wgScriptPath + '/api.php?', data: 'action=edit&format=json&title=' + encodeURIComponent(wgPageName) + '&undo=' + encodeURIComponent(undoId) + '&bot=1&summary=' + encodeURIComponent(smry) + '&token=' + encodeURIComponent(editToken), dataType: 'json', type: 'POST', success: function(data) { if (data.edit && data.edit.result === 'Success') { $ajaxUndoLinkob.text('(undone)'); } else if (data.error && data.error.code === 'undofailure') { $ajaxUndoLinkob.text('(error)'); alert(data.error.info); } else { $ajaxUndoLinkob.text('(error)'); alert('Error: Unknown result from API.'); }                       },                        error: function { $ajaxUndoLinkob.text('(error)'); }                   });                });            });            return $ajaxUndoLink;        }        if ($('.mw-history-undo > a').length && wgAction === 'history') {            $('.mw-history-undo > a').each(function { var diffUndoUrl = $(this).attr('href'), $ajaxUndoLink = createUndoLink(diffUndoUrl); $(this).replaceWith($ajaxUndoLink); });       } else if ($('table.diff').length && typeof $.getUrlVar('diff') !== 'undefined') {            var $diffUndoLink = $('table.diff').find('.diff-ntitle > #mw-diff-ntitle1 a:last'),                diffUndoUrl = $diffUndoLink.attr('href'),                $ajaxDiffUndoLink = createUndoLink(diffUndoUrl);            $diffUndoLink.replaceWith($ajaxDiffUndoLink);        }    }); } else { importScriptPage('MediaWiki:AjaxUndo/code.js', 'dev'); }

/* Remove some items from the global nav menu */ $('#AccountNavigation > li > ul.subnav > li:has(a[data-id="help"])').remove; $('#AccountNavigation > li > ul.subnav > li:has(a[data-id="mytalk"])').remove;

/* Add some items to the global nav menu */ function AddNavigationLinks { $('My contributionsMy watchlistFollowed pages').insertBefore($('.AccountNavigation .subnav li a[data-id="preferences"]').parent); } addOnloadHook(AddNavigationLinks);

/* Fix global master head on AT and SP wiki */ if (wgCityId === "7553" || wgCityId === "95") { mw.util.addCSS('.UserProfileMasthead .masthead-info { margin-left: 165px; }'); mw.util.addCSS('.discussion-details.tally { margin: 0 0 5px 0 !important; }'); }

/* Make the edit sub-menu expand on hover */ $(document.head).append('#WikiHeader nav.wikia-menu-button .drop:hover ~ ul,#WikiHeader nav.wikia-menu-button ul.WikiaMenuElement:hover,#WikiaMainContent nav.wikia-menu-button .drop:hover ~ ul,#WikiaMainContent nav.wikia-menu-button ul.WikiaMenuElement:hover{min-width:100%;display:block;} ');

/* Pseudo-Vector */ (function ($, mw) {   'use strict';    // double-run protection + only run in monobook    if (window.pseudoVectorLoaded || mw.config.get('skin') !== 'monobook') {        return;    }    window.pseudoVectorLoaded = true;    // Load the style    importStylesheetPage('Pseudo-Vector/code.css', 'dev');    // JS-based tweaks    $(function  { // add 'Search' box text placeholder $('#searchInput').attr('placeholder', $('#mw-searchButton').val);

// add 'Read' tab if (mw.config.get('wgArticleId')) { var $readTab = $('').append(               $('', { 'href': mw.util.getUrl(mw.config.get('wgRelevantPageName')), 'text': 'Read' })           );            // is another action tab selected already? if (!$('#p-cactions li.selected').not(':nth-child(1), :nth-child(2)').length) { $readTab.addClass('selected'); }

$('#ca-edit, #ca-viewsource').before($readTab); }   }); }(jQuery, mediaWiki));

/* ColoredColors */ //@author-Curiouscrab //Fixed by Dorumin (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] = '<span style="color:' + brokened[j].substring(0, 7) + '">' + brokened[j].substring(0, 7) + ' ';					}				}				tags[i].innerHTML = brokened.join(';');			}		}	} });

/* Clock */ $(function liveClock {	var link = wgServer + wgScriptPath + '/wiki/' + encodeURIComponent(wgPageName) + '?action=purge';	$('#WikiaPage #WikiHeader div.buttons').prepend(' <a href="'+link+'"></a> ');	// Make clock not load on AT and SP	if (wgCityId != "7553" && wgCityId != "95") { showTime; } }); function showTime { var now    = new Date, hh     = now.getUTCHours, mm     = now.getUTCMinutes, ss     = now.getUTCSeconds, dd     = now.getUTCDate, months = 'Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec'.split(' '), month  = months[now.getUTCMonth], year   = now.getUTCFullYear, time   = ( hh < 10 ? '0' + hh : hh ) + ':' + ( mm < 10 ? '0' + mm : mm ) + ':' + ( ss < 10 ? '0' + ss : ss ) + ', ' + ( dd < 10 ? '0' + dd : dd ) + ' ' + month + ' ' + year + ' (UTC)'; $('#utcdate a').text(time); window.setTimeout(showTime, 1000); }

/* QuickCreateUserPage */ /* Modified version of QuickCreateUserPage */ if (wgCityId != "621556") { ( function( $, mw, window ) {       'use strict';        var QuickCreateUserPage = {            init: function {                $('ul.tools li:last-child:not(.tools-menu li)').after(' <a style="cursor:pointer;">Create user page</a></li>');                $(".qcup").click( ( QuickCreateUserPage.createUserPage ) );            },            langConfig: {                en: {                    'cup-reason': 'Creating user page',                    'cup-success-text': 'Successfully created page!',                    'cup-error-exists': 'Page already exists!',                    'cup-error-failed': 'Creating page failed!'                }            },            langMsg: function ( name, userLang ) {                QuickCreateUserPage.langConfig.en[name];            },            createUserPage: function {                var	userPageContent = '',                    pageName = 'User:Sophiedp', overwriteUserPage = true; if ( overwriteUserPage === true ) { QuickCreateUserPage.makeEdit( pageName, userPageContent ); return; }               $.getJSON( mw.util.wikiScript( 'api' ), {                    action: 'query',                    prop: 'revisions',                    titles: pageName,                    format: 'json'                } ).done( function ( data ) {                    var	pageIds = Object.keys( data.query.pages ),                        pageId = pageIds[0];                    if ( pageId !== '-1' ) {                        QuickCreateUserPage.showResult( 'error', 'Page already exists!' );                    } else {                        QuickCreateUserPage.makeEdit( pageName, userPageContent );                    }                } ); },           makeEdit: function( pageName, pageContent ) { $.ajax( {                   type: 'POST',                    url: mw.util.wikiScript( 'api' ),                    dataType: 'json',                    data: {                        action: 'edit',                        title: pageName,                        summary: 'Creating user page',                        text: pageContent,                        format: 'json',                        token: mw.user.tokens.get( 'editToken' )                    }                } ).done( function ( data ) {                    if ( data.edit.result === 'Success' ) {                    QuickCreateUserPage.showResult( 'ok', 'Successfully created page!' );                    } else {                        QuickCreateUserPage.showResult( 'error', 'Creating page failed!' );                    }                } ).fail( function ( data ) {                    QuickCreateUserPage.showResult( 'error', 'Creating page failed!' ); } );           },            showResult: function( result, message ) {                var resultClass = ( result === 'error' ? 'error' : 'confirm' );               new BannerNotification( QuickCreateUserPage.langMsg( message, true ), resultClass ).show;            }        };        $( QuickCreateUserPage.init );    }( jQuery, mediaWiki, this ) ); }

//—————————————————————————————— ! ! ! ———————————————————————————————// /* Place imports below this line. Place everything else above this line. */

/* Imports */ $(window).load(function {   importArticles({ type: "script", articles: [ 'u:dev:MediaWiki:MarkForDeletion/code.js', 'u:dev:MediaWiki:CacheCheck/code.js', 'u:dev:MediaWiki:HoverEditCount/code.js', 'u:dev:MediaWiki:QuoteComments/code.js', 'u:dev:MediaWiki:GlobalEditcount/code.js', 'u:dev:MediaWiki:NoImageLightbox/code.js', 'u:dev:MediaWiki:Rollback/code.js', 'u:dev:MediaWiki:Wikimarks/code.js', 'u:dev:MediaWiki:WallGreetingButton/code.js', 'u:dev:MediaWiki:PurgeButton/code.js', 'u:dev:MediaWiki:DupImageList/code.js', 'u:dev:MediaWiki:NullEditButton/code.js', 'u:dev:MediaWiki:FastDelete/code.js', 'u:dev:MediaWiki:Linksweeper/code.js', 'u:dev:MediaWiki:RecentChangesMultiple/code.2.js' ]   }); });