User:Burgereater/dropdownDebug.js

/*jshint browser:true, jquery:true*/ /*global mediaWiki*/ /* @author Burgereater * @notes pure ripoff of Undelete xD * To use this script, add * importScriptPage('User:Burgereater/dropdownDebug.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: 'Debug',            es: 'Debug',            de: 'Debug',            hu: 'Debug',            nl: 'Debug',            pl: 'Debug'        },        theText = (typeof window.DebugButtonText === 'string' && window.DebugButtonText) ||            translations[mw.config.get('wgContentLanguage')] || translations.en;    if ( nsNr < 0 || window.DebugButtonsLoaded || document.getElementById( 'control_Debug' ) ) {        return;    }    window.DebugButtonsLoaded = true;     $( addDebugButton );    function DebugPage  {        var page = encodeURIComponent( mw.config.get( 'wgPageName' ) );        $.get( '/index.php?title=' + page + '&uselang=qqx', function  { location.reload( true ); } );        window.location = "/index.php?title=" + page + '&uselang=qqx&debug=1';

function addOasisDebugButton { 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 addDebugButton  { 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': addOasisDebugButton; break; }       $( '#Debug' ).click( DebugPage ); }   } ( jQuery, mediaWiki ) ); //