MediaWiki:Common.js

/* Spoilers */ (function {   if ($('.hidden.on').length) {    if ($('.UserProfileActionButton').length) {        $('.UserProfileActionButton .wikia-menu-button').before( $(' ', {               class: 'wikia-menu-button',                id: 'toggle-hidden',                title: 'Show all hiddens on page',                text: 'Show Hiddens',                css: {'padding': '0 6px', 'margin-right': '5px'},            }) );   } else if (wgCanonicalNamespace === 'MediaWiki') {        return;    } else {        $('', { class: 'wds-button wds-is-squished', id: 'toggle-hidden', title: 'Show all hiddens on page', text: 'Show Spoilers', css: {'float': 'right', 'margin-bottom': '5px'}, }).prependTo($('#mw-content-text'));       }    }

$('#toggle-hidden').click(function {       if ($('.hidden.on, .hidden.off').length) {            $('.hidden').attr('class', 'hidden').removeAttr('title');            $('.wds-button#toggle-hidden').attr('title', 'Hide all hiddens on the page').html('Hide Spoilers');        } else {            $('.hidden').attr('class', 'hidden on').attr('title', 'click to show the hiddens');            $('.wds-button#toggle-hidden').attr('title', 'Show all hiddens on page').html('Show Spoilers');        }    }); var hiddenConfig = function(i, el) { var $el = $(el); $el.attr('title', 'Click to show the hiddens'); $el.click(function {           var $this = $(this);            if ($this.hasClass('on'))                $this.attr('class', 'hidden off').removeAttr('title');            else                $this.attr('class', 'hidden on').attr('title', 'Click to show the hiddens');        }); };   $('.hidden.on').each(hiddenConfig); }) ;