User:GerritH/global.js

/* Buttons */ if (mwCustomEditButtons) { mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://static2.wikia.nocookie.net/monsterhunternews/de/images/d/d3/Button_Weiterleitung.png", "speedTip": "Weiterleitung", "tagOpen": "#REDIRECT ",   "tagClose": "", "sampleText": "R" }; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/en/f/fd/Button_blockquote.png", "speedTip": "Anführungszeichen", "tagOpen": "„", "tagClose": "“", "sampleText": "M" }; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/en/f/fd/Button_blockquote.png", "speedTip": "Magic", "tagOpen": "__", "tagClose": "__", "sampleText": "NOEDITSECTION" }; }

/* chat hacks */ importScriptPage('User:Monchoman45/ChatHacks.js', 'c');

// From http://dev.wikia.com/wiki/QuickCreateUserPage (english version)

( function( $, mw, window ) {	'use strict';	var QuickCreateUserPage = {		init: function {			var $qcLink = $( ' ' ).attr( 'id', 'quick-cup' ).html( $( '' ).attr( 'title', QuickCreateUserPage.langMsg( 'button-tooltip', true ) ) .attr( 'style', 'cursor: pointer' ).text( QuickCreateUserPage.langMsg( 'button-link-text', true ) ) .click( QuickCreateUserPage.createUserPage ) );			if ( mw.config.get( 'skin' ) === 'oasis' ) {				$( '#AccountNavigation' ).find( 'li > ul.subnav' ).prepend( $qcLink );			} else {				$( '#column-one' ).find( '#p-personal > .pBody > ul' ).prepend( $qcLink );			}		},		langConfig: {			//Lang			en: {				'button-link-text': 'User page (en)',				'button-tooltip': 'User page (en)',				'buttontalk-link-text': 'Create user talk page',				'buttontalk-tooltip': 'Create your user talk page',				'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 ) {			if ( userLang && mw.config.get( 'wgUserLanguage' ) in QuickCreateUserPage.langConfig && name in QuickCreateUserPage.langConfig[mw.config.get( 'wgUserLanguage' )] ) {				return QuickCreateUserPage.langConfig[mw.config.get( 'wgUserLanguage' )][name]; }			if ( !userLang && mw.config.get( 'wgContentLanguage' ) in QuickCreateUserPage.langConfig && name in QuickCreateUserPage.langConfig[mw.config.get( 'wgContentLanguage' )] ) { return QuickCreateUserPage.langConfig[mw.config.get( 'wgContentLanguage' )][name]; }			return QuickCreateUserPage.langConfig.en[name]; },		createUserPage: function { var	userPageContent = window.qtUserPageTemplate2 || '', pageName = 'User:' + mw.config.get( 'wgUserName' ), overwriteUserPage = window.qtEnableUserPageOverwrite || 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( 'ok', 'cup-error-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: QuickCreateUserPage.langMsg( 'cup-reason', false ),					text: pageContent,					format: 'json',					token: mw.user.tokens.get( 'editToken' )				}			} ).done( function ( data ) {				if ( data.edit.result === 'Success' ) {					QuickCreateUserPage.showResult( 'ok', 'cup-success-text' );				} else {					QuickCreateUserPage.showResult( 'error', 'cup-error-failed' );				}			} ).fail( function ( data ) {				QuickCreateUserPage.showResult( 'error', 'cup-error-failed' );			} ); },		showResult: function( result, message ) { if ( mw.config.get( 'skin' ) === 'monobook' ) { mw.util.$content.prepend(					'  ' + QuickCreateUserPage.langMsg( message, true ) + ' ' +					' '				); } else { var resultClass = ( result === 'error' ? 'error' : 'confirm' ); window.GlobalNotification.show( QuickCreateUserPage.langMsg( message, true ), resultClass ); }		}	};	$( QuickCreateUserPage.init ); }( jQuery, mediaWiki, this ) );

/** * Ajax Message Wall Greeting Creation * Attempts to create your message wall greeting * Adapted from Grunny's QuickCreateUserPage tool */ ( function( $, mw, window ) {	'use strict';	var QuickCreateMessageWallGreeting = {		init: function {			var $qcLink = $( ' ' ).attr( 'id', 'quick-cup' ).html( $( '' ).attr( 'title', QuickCreateMessageWallGreeting.langMsg( 'button-tooltip', true ) ) .attr( 'style', 'cursor: pointer' ).text( QuickCreateMessageWallGreeting.langMsg( 'button-link-text', true ) ) .click( QuickCreateMessageWallGreeting.createMessageWallGreeting ) );			if ( mw.config.get( 'skin' ) === 'oasis' ) {				$( '#AccountNavigation' ).find( 'li > ul.subnav' ).prepend( $qcLink );			} else {				$( '#column-one' ).find( '#p-personal > .pBody > ul' ).prepend( $qcLink );			}		},		langConfig: {			//English			en: {				'button-link-text': 'Greeting (en)',				'button-tooltip': 'Greeting (en)',				'buttontalk-link-text': 'Greeting (en)',				'buttontalk-tooltip': 'Greeting (en)',				'cup-reason': 'Creating message wall greeting',				'cup-success-text': 'Successfully created greeting!',				'cup-error-exists': 'Greeting already exists!',				'cup-error-failed': 'Creating greeting failed!'			}		},		langMsg: function ( name, userLang ) {			if ( userLang && mw.config.get( 'wgUserLanguage' ) in QuickCreateMessageWallGreeting.langConfig && name in QuickCreateMessageWallGreeting.langConfig[mw.config.get( 'wgUserLanguage' )] ) { return QuickCreateMessageWallGreeting.langConfig[mw.config.get( 'wgUserLanguage' )][name]; }			if ( !userLang && mw.config.get( 'wgContentLanguage' ) in QuickCreateMessageWallGreeting.langConfig && name in QuickCreateMessageWallGreeting.langConfig[mw.config.get( 'wgContentLanguage' )] ) { return QuickCreateMessageWallGreeting.langConfig[mw.config.get( 'wgContentLanguage' )][name]; }			return QuickCreateMessageWallGreeting.langConfig.en[name]; },		createMessageWallGreeting: function { var	MessageWallGreetingContent = window.qtMessageWallGreetingTemplate2 || '', pageName = 'Message_Wall_Greeting:' + mw.config.get( 'wgUserName' ), overwriteMessageWallGreeting = window.qtEnableMessageWallGreetingOverwrite || false; if ( overwriteMessageWallGreeting === true ) { QuickCreateMessageWallGreeting.makeEdit( pageName, MessageWallGreetingContent ); 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' ) {					QuickCreateMessageWallGreeting.showResult( 'ok', 'cup-error-exists' );				} else {					QuickCreateMessageWallGreeting.makeEdit( pageName, MessageWallGreetingContent );				}			} ); },		makeEdit: function( pageName, MessageWallGreetingContent ) { $.ajax( {				type: 'POST',				url: mw.util.wikiScript( 'api' ),				dataType: 'json',				data: {					action: 'edit',					title: pageName,					summary: QuickCreateMessageWallGreeting.langMsg( 'cup-reason', false ),					text: MessageWallGreetingContent,					format: 'json',					token: mw.user.tokens.get( 'editToken' )				}			} ).done( function ( data ) {				if ( data.edit.result === 'Success' ) {					QuickCreateMessageWallGreeting.showResult( 'ok', 'cup-success-text' );				} else {					QuickCreateMessageWallGreeting.showResult( 'error', 'cup-error-failed' );				}			} ).fail( function ( data ) {				QuickCreateMessageWallGreeting.showResult( 'error', 'cup-error-failed' );			} ); },		showResult: function( result, message ) { if ( mw.config.get( 'skin' ) === 'monobook' ) { mw.util.$content.prepend(					'  ' + QuickCreateMessageWallGreeting.langMsg( message, true ) + ' ' +					' '				); } else { var resultClass = ( result === 'error' ? 'error' : 'confirm' ); window.GlobalNotification.show( QuickCreateMessageWallGreeting.langMsg( message, true ), resultClass ); }		}	};	$( QuickCreateMessageWallGreeting.init ); }( jQuery, mediaWiki, this ) );

/* changing "Start a wikia" in RC */ $('.start-wikia').attr('href','/wiki/Special:RecentChanges?hidebots=0').attr('title','Special:RecentChanges').text('Änderungen');

/* Other stuff */ window.AdvancedOasisUI = { accountNavFollowedPages: false, accountNavWatchlist: false, categoryRedlink: true, RCHeader: false, DefaultSourceMode: true, lightbox: false, randomPageLimitedTo: 'Help', activity2RC: false, userLang: true, };

window.AutoEditDropdownConfig = { expandedAreaContribute: true, expandedAreaEdit: true };

var qtUserPageTemplate = ''; var qtEnableUserPageOverwrite = true;

var qtMessageWallGreetingTemplate = ''; var qtEnableMessageWallGreetingOverwrite = true;

importArticles({   type: 'script',    articles: [         'u:dev:AjaxDiff/code.js',         'u:dev:ViewRemoved/code.js',         'u:dev:AnchoredRollback/code.js',         'u:dev:View_Source/code.js',         'u:dev:MiniComplete/code.js',         'u:dev:PortableCSSPad/code.js',         'u:dev:AutoEditDropdown/code.js',         'u:dev:AjaxPatrol/code.js',         'u:dev:AdvancedOasisUI/code.js',         'u:dev:WHAM/code.2.js',         'u:dev:RedirectManagement/code.js',         'u:dev:QuickCreateUserPage/code.js',         'u:dev:QuickCreateMessageWallGreeting/code.js',         'u:dev:FileUsageAuto-update/code.js',         'u:dev:ColoredColors/code.js'    ] }); ( function ( $, mw ) {   'use strict';    var nsNr = mw.config.get( 'wgNamespaceNumber' ),        translations = {            en: 'Refresh',            es: 'Actualizar',            de: 'Neu laden',            fr: 'Actualiser',            hu: 'Frissítés',            nl: 'Herladen',            pl: 'Odśwież',            ru: 'Обновить'        },        theText = (typeof window.PurgeButtonText === 'string' && window.PurgeButtonText) ||            translations[mw.config.get('wgContentLanguage')] || translations.en;    if ( nsNr < 0 || window.PurgeButtonsLoaded || document.getElementById( 'control_purge' ) ) {        return;    }    window.PurgeButtonsLoaded = true; // prevent duplicate running (but not dupe buttons from outside this code)    $( addPurgeButton );    function purgePage  {        var page = encodeURIComponent( mw.config.get( 'wgPageName' ) );        $.get( '/index.php?title=' + page + '&action=purge', function  { location.reload( true ); } );       $('html,body').css( { display: 'block', overflow: 'hidden' } );       $( ' ' ).appendTo( document.body )        .css( 'height', $( window ).height );    }    function addOasisPurgeButton  {        var selector;        switch (nsNr) {            case 500:            case 502:                selector = $( '#WikiaUserPagesHeader' );                break;            case 2:            case 3:                selector = $( '.UserProfileActionButton' );                if ( selector.length ) break;            default:                selector = $( '#WikiaPageHeader' );        }        selector.find('.wikia-menu-button').first.find('ul')        .append(''+ theText + '');    }    function addPurgeButton  { switch( mw.config.get( 'skin' ) ) { case 'uncyclopedia': /* monobook clone, pass to monobook */ case 'wowwiki': /* monobook clone, pass to monobook */ case 'lostbook': /* monobook clone, pass to monobook */ case 'monobook': $('#p-cactions > .pBody > ul').append(''+ theText + ''); break; case 'oasis': case 'wikia': addOasisPurgeButton; break; }       $( '#purge' ).click( purgePage ); }   } ( jQuery, mediaWiki ) );

var c = mw.config.get( [   'wgPageName',    'wgCanonicalSpecialPageName',    'wgTitle',    'wgAction',    'wgCanonicalNamespace',    'wgNamespaceNumber',    'wgUserGroups',    'wgSiteName',    'skin' ] ), escapedPage = encodeURIComponent(c.wgPageName), href, link; /* Import CacheCheck not for Special:WantedFiles */ if (c.wgCanonicalSpecialPageName != "Wantedfiles") importScriptPage('CacheCheck/code.js','dev'); /* IP lookup on contribs */ if (c.wgCanonicalSpecialPageName == "Contributions" && c.wgTitle.split('.').length == 4) { href = 'http://myip.ms/info/whois/' + page.split('/')[1], link = ' (lookup)</a>'; $('.masthead-info').find('h2').html(link); } /* Create an edit link on Special:MovePage for easy redirecting */ if (c.wgCanonicalSpecialPageName == "Movepage") { href = $('fieldset').find('a').attr('href') + '?action=edit', link = ' <a href="'+href+'">(edit)</a>'; $('#mw-movepage-table').find('a').first.after(link); }
 * (function($, mw) {

/* Import AjaxRC for just Special:RecentChanges */ if (c.wgCanonicalSpecialPageName == "Recentchanges") importScriptPage('AjaxRC/code.js','dev'); /* Unchecks redirects when moving files */ if (c.wgPageName.indexOf("Special:MovePage/File:") !== -1) $('#wpLeaveRedirect').removeAttr('checked'); /* Show abuse log entries in Special:Log/newusers */ if ("Special:Log/newusers".indexOf(c.wgPageName) !== -1) { $('li.mw-logline-newusers').each(function {   href = '/wiki/Special:AbuseLog?wpSearchUser=' + $(this).children('a.new.mw-userlink,a.mw-userlink').attr('href').substring(11),    link = ' | <a href="'+href+'">abuse</a>';    $(this).children('span.mw-usertoollinks').find('a:last-child').after(link);  }); } /* Create move link on Special:ListFiles for users' files listed */ if (c.wgCanonicalSpecialPageName == "Listfiles" && c.wgPageName.split('/').length === 2) { $('.TablePager_col_img_name').each(function {   link = ' (<a href="/wiki/Special:MovePage/File:' + $(this).find('a').first.text + '">move</a>)';     $(this).append(link);  }); } /* Automatic broken redirect delete summary */ if (c.wgAction == "delete" && $('#wpReason').val.slice(0,23) == 'content was: \"#REDIRECT' ) $('#wpReason').val('Broken redirect'); /* Revision delete */ if (c.wgAction == 'revisiondelete' || c.wgCanonicalSpecialPageName == 'Revisiondelete') {  $('#wpHidePrimary,#wpHideComment,#wpHideUser').attr('checked','checked');  $('#wpReason').val('spam'); } /* Thread history return to thread */ if (c.wgPageName.split(':')[0] == "Thread" && c.wgAction == "history")  $('.SortingBar').after('<a href="/wiki/'+page+'" style="font-size:14px">Back to thread</a>'); /* Make Visual Editor links load the regular editor instead */ if ($.getUrlVar('veaction') == 'edit')  location.replace(document.URL.replace('veaction','action')); /* Special:WhatLinksHere on redirect page */ var h2header = $('#WikiaPageHeader').find('h2'); if (h2header && h2header.text.split('Redirected from').length == 2) { link = ' <a href="/wiki/Special:WhatLinksHere/'+h2header.children('a').attr('title')+'">(links)</a> <a href="/wiki/'+h2header.children('a').attr('title')+'?action=history">(history)</a>'; h2header.append(link); } /* Special:SearchDigest better functionality */ if (c.wgCanonicalSpecialPageName == "SearchDigest") { $('#mw-content-text ul li').each(function {   var attrTitle = $(this).children('a').attr('title');    if (attrTitle && attrTitle.split('(page does not exist)').length == 1)      $(this).remove;  }); } /* Add history button to diffs */ if ($('strong:contains("Changes:")').length) $('#WikiaPageHeader').find('p').children('a').after(' <a href="?action=history">(history)</a>'); /* Always go to IP contributions, not userpage */ if (c.wgNamespaceNumber == 2 && title.split('.').length == 4) location.replace("/wiki/Special:Contributions/"+mw.config.get('wgPageName').split(':')[1]);

}) (this.jQuery, this.mediaWiki);

/* Easily see removed messages on threads */ if ($('.removed-info.speech-bubble-message-removed').length && mw.config.get('wgCanonicalNamespace') == "Thread") { $('.removed-info.speech-bubble-message-removed').each(function {   var id = $(this).parent.attr('id');    $(this).append(' (<a href="#'+id+'">see message</a>)')  }); }