8
\$\begingroup\$

Description

As it appears the sandbox on meta is here to stay, I've written a very simple userscript that will allow you to collapse sandbox answers to reduce clutter. (This may be able to be replaced when the fancy sandbox viewer thingy is finished, but for now it'll make navigating the sandbox a little easier.)

Screenshot

screenshot

Code

stackexchange-codegolf-sandbox-collapse.user.js:

// ==UserScript==
// @name stackexchange-codegolf-sandbox-collapse
// @namespace http://keyboardfire.com/
// @license MIT
// @description A simple userscript for collapsing sandbox answers
// @version 1.0.0
// @match *://meta.codegolf.stackexchange.com/*
// ==/UserScript==

if ($('#question-header a').text().indexOf('Proposed Question Sandbox') > -1) {
    $('.answer').each(function() {
        var ans = $(this);
        var ansPosted = $('.post-text', ans).children().length === 1;
        var btnMessage = '(' + (ansPosted ? 'challenge posted; ' : '') + 'click to toggle view)';
        $('table', ans).wrap($('<div>').addClass('posted-challenge').css('display', ansPosted ? 'none' : ''));
        ans.prepend($('<input>').attr('type', 'button').css('margin-bottom', '20px').val(btnMessage).click(function() {
            $(this).parent().find('.posted-challenge').toggle('slow');
        }));
    });
}

Issues

| |
\$\endgroup\$
5
\$\begingroup\$

If I click on the "show N more comments" link, comments do not show up with the userscript enabled.

Sandbox comments with userscript enabled

| |
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .