Hide answers and comments on Puzzling.SE questions until you want to see them.
Ajankohdalta
// ==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);