StackExchange hide closed questions

Hide closed questions on the home page and in other lists of questions. Put a link showing the number of closed questions that have been hidden that shows the closed questions again.

Versione datata 16/06/2017. Vedi la nuova versione l'ultima versione.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name StackExchange hide closed questions
// @namespace http://ostermiller.org/
// @version 1.10
// @description Hide closed questions on the home page and in other lists of questions.   Put a link showing the number of closed questions that have been hidden that shows the closed questions again.
// @include /https?\:\/\/([a-z\.]*\.)?stackexchange\.com\/.*/
// @include /https?\:\/\/([a-z\.]*\.)?askubuntu\.com\/.*/
// @include /https?\:\/\/([a-z\.]*\.)?superuser\.com\/.*/
// @include /https?\:\/\/([a-z\.]*\.)?serverfault\.com\/.*/
// @include /https?\:\/\/([a-z\.]*\.)?stackoverflow\.com\/.*/
// @include /https?\:\/\/([a-z\.]*\.)?answers.onstartups\.com\/.*/
// @grant none
// ==/UserScript==
function closedQuestionVisibility(show){
    var numberOfClosed=0;
    $('.question-summary').each(function(){
        var e = $(this);
        var t = e.find('h3 a').text();
        if (t.match(/\]$/)){
            e.addClass('closed');
            if(show){
                e.show();
            } else {
                e.hide();
            }
            numberOfClosed++;
        }
    });
    return numberOfClosed;
}

if (/\.com\/(questions)?([\?\#].*)?$/.exec(window.document.location.href)){ // only on pages with questions
    var numberHidden=closedQuestionVisibility(false);
    if (numberHidden > 0){
        $('#mainbar h1').append(" <a href='#' id='unhideclosedlink'>(" + numberHidden + " hidden closed)</a>");
        $('#unhideclosedlink').click(function(){
            closedQuestionVisibility(true);
            $('#unhideclosedlink').hide();
            return false;
        });
        $('html > head').append("<style>.question-summary.closed .status * { text-decoration: line-through; }</style>");
    }
}