Greasy Fork 还支持 简体中文。

Puzzling.SE Empuzzler

Hide answers and comments on Puzzling.SE questions until you want to see them.

Ajankohdalta 8.10.2014. Katso uusin versio.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name        Puzzling.SE Empuzzler
// @namespace   https://greasyfork.org/users/5615-doppelgreener
// @description Hide answers and comments on Puzzling.SE questions until you want to see them.
// @grant       none
// @include     http://puzzling.stackexchange.com/questions/*
// @version     0.1
// ==/UserScript==


// CSS styles needed
var styles = [];
styles.push("body:not(.show-comments) #question .comments { display: none; }");
styles.push("body:not(.show-comments) #question .comments-link { display: none; }");
styles.push("body:not(.show-comments) #question .bounty-link { display: none; }");
styles.push("body:not(.show-answers) #answers { display: none; }");


var main = function () {

    function makeButton(buttonText, classToAdd) {
        return $('<button>')
            .prop('type', 'button')
            .text(buttonText)
            .click(function() {
                $('body').addClass(classToAdd);
                $(this).remove();
            });
    }

    $(window).load(function() {
        var rev = $('<div>')
            .prop('id', 'empuzzler-revealers');

        rev.append(makeButton("Show comments on question", 'show-comments'));
        rev.append(makeButton("Show answers", 'show-answers'));

        rev.insertAfter('#question');
    });

};

//
// Inject content into the page
//

// JavaScript
var script = document.createElement('script');
script.type = 'text/javascript';
script.id = 'empuzzler-script'
script.textContent = '(' + main.toString() + ')();';
document.body.appendChild(script);

// CSS styles, borrowed from Stack Overflow Unofficial Patch:
var styleElem = document.createElement('style');
styleElem.id = 'empuzzler-styles';
styleElem.type = 'text/css';
var code = "";
for (var id in styles) {
  code += styles[id] + "\n";
}
styleElem.textContent = code.replace( /[}] */g, "}\n" )
var head = document.head || document.documentElement;
head.appendChild(styleElem);