User:Burgereater/dropdownAddon.js

/*jshint browser:true, jquery:true*/ /*global mediaWiki*/ /* @author Burgereater * @notes pure ripoff of Purge xD * To use this script, add * importScriptPage('User:Burgereater/dropdownAddon.js', 'fake'); * to your global.js ( http://c.wikia.com/wiki/User:YourNameHere/global.js ) */ ( function ( $, mw ) {   'use strict';    var nsNr = mw.config.get( 'wgNamespaceNumber' ),        translations = {            en: 'Undelete',            es: 'Actualizar',            de: 'Neu laden',            hu: 'Frissítés',            nl: 'Herladen',            pl: 'Odswiez'        },        theText = (typeof window.UndeleteButtonText === 'string' && window.UndeleteButtonText) ||            translations[mw.config.get('wgContentLanguage')] || translations.en;    if ( nsNr < 0 || window.UndeleteButtonsLoaded || document.getElementById( 'control_Undelete' ) ) {        return;    }    window.UndeleteButtonsLoaded = true; // prevent duplicate running (but not dupe buttons from outside this code)    $( addUndeleteButton );    function UndeletePage  {        var page = encodeURIComponent( mw.config.get( 'wgPageName' ) );        $.get( '/index.php?title=Special%3AUndelete' + '&target=' + page + '', function  { location.reload( true ); } );       window.location = "/index.php?title=Special%3AUndelete&target=" + page + '';     function addOasisUndeleteButton  {        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 addUndeleteButton  {        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': addOasisUndeleteButton; break; }       $( '#Undelete' ).click( UndeletePage ); }   } ( jQuery, mediaWiki ) ); //