26

It's common that I read a question and say, "OK, I don't need to see it again."
Then I always think, "Hmm... maybe there is a 'hide' button on the question, so that I won't see it again in my favourite tag list so that I'll be able to focus on the remaining questions which are either new or known by me and interesting to me?" But, unfortunately, the button is never there.

Request: Let's implement that button! No need to clutter the database with it: It looks to me like a perfect candidate for HTML5 local storage. Purely client side.

The fun part is, it can be implemented separately from SO, as a bookmarklet or just an addon for PersonalizedWeb / GreaseMonkey. But I believe it would be indeed useful to have it there available for everyone.

Do you like the idea?

3
  • 4
    I like it, but I would also recommend to keep a datetimestamp and remove them after so many hours, for two reasons (decrease the size of localstorage // re-show them to you after so long a period of time, when the frontlist should've updated anyways)
    – jcolebrand
    Jan 2, 2011 at 18:01
  • OMG stop leaving fruit on your desk! and, no, it's not a toaster.
    – Mazura
    Sep 12, 2014 at 5:49

4 Answers 4

11

It's an interesting idea. Sort of like "Archive" in Gmail.

I disagree about doing it client side being the best approach, though. I access SO from multiple computers, so having the "hide" data stored locally would be annoying as each computer (really, each browser) would have a different set of hidden questions.

On the other hand, doing it client side does make it possible for "anyone" to go and implement it, which certainly increases the chance that there'll actually be an implementation.

Another approach would be to use a feed reader (like Google Reader) that'll let you hide "read" items. This would work better if the feeds on SO were better. For example, if I go to my "interesting" tab on SO, autodiscovery shows a feed available, but the feed isn't for my "interesting" questions -- it appears to just be the recent questions feed. Anyway, once you have a feed you can just use your feed reader to keep track of which questions you're already done with.

10

This is a working prototype using LocalStorage. Good enough for my needs- maybe anyone would want to start from here and extend?

I'm using it under Chrome Personalized Web extension, but it should be easy to incorprate anywhere.

<style>
    .kos-hide-button {
        color: #666;
    }
    .kos-hide-button:hover {
        color: red;
        cursor: pointer;
    }   
    .kos-hide-button-hide {
        display: block;
        width: 2em;
        float: right;
        text-align: right;
    }
    .kos-hide-hidden-question {
        display: none;
    }

</style>
<script>
$(document).ready(function() {

    var keyPrefix = "stackoverflow.hiddenquestion.";

    function hideElem(elem) {
        elem.addClass('kos-hide-hidden-question');
    }
    function clearHidden() {

        var toRemove = [];
        for (var i=0; i<localStorage.length; ++i) {
            var key = localStorage.key(i);
            if (key.substr(0, keyPrefix.length) == keyPrefix) {
                toRemove.push(key);
            }
        }
        for (var i=0; i<toRemove.length; ++i) {
            localStorage.removeItem(toRemove[i]);
        }
        $('.kos-hide-hidden-question').removeClass('kos-hide-hidden-question');
    }

    if (!('localStorage' in window && window['localStorage'] !== null)) {
        return;
    }
    $('.question-summary').each(function() {

        var that = $(this);
        var id = keyPrefix + $(this).attr('id');

        $('<span>(-)</span>')
            .addClass('kos-hide-button')
            .addClass('kos-hide-button-hide')
            .attr('title','Hide this question')
            .insertBefore($(this).find('h3'))
            .click(function() {
                hideElem(that);
                var tab = $
                localStorage[id] = 1;
            })
            ;

        var hidden = localStorage[id];          
        if (hidden) {
            hideElem($(this));
        }
    });

    $('<div>Reset hidden questions</div>')
        .addClass('kos-hide-button')
        .appendTo($('#sidebar'))
        .click(function() {
            clearHidden();
        })
        ;
});
</script>
1
  • To use this, install the Personalized Web extension, go to the extension's options page, click "Add a new rule", and paste the above in the "Add HTML" box. You may also want to change the "Match URLs" regexp to only apply to Stack Exchange sites. Apr 1, 2012 at 18:27
1

For those using Firefox instead of Chrome, here's a Greasemonkey version of @Kos extension:

// ==UserScript==
// @name        SO Hide Questions
// @namespace   http://stackoverflow.com/
// @include     http://stackoverflow.com/
// @version     1
// @grant       none
// ==/UserScript==

(function() {

    var head = document.getElementsByTagName('head')[0];
    var style = document.createElement('style');
    style.type = 'text/css';
    style.innerHTML = "[CSS style from @Kos answer]"
    head.appendChild(style);

    [content of $(document).ready(function() from @Kos answer]

})();

Disclaimer: I am new to both Greasemonkey and JavaScript, but the above seems to work. If not, please comment.

4
  • This won't work. Greasemonkey creates a sandboxed environment which basically renames the global scope to unsafeWindow and creates a new global scope for the script. A quick workaround is to stringify the function you want to run in the global scope and add it as a script tag to the document. Jun 27, 2013 at 10:59
  • @JanDvorak Can you elaborate? The above seems to work for me. I can hide a few questions, hit refresh, close and restart Firefox, and the questions are still hidden, and reappear when I click the unhide link. Which aspect won't work then? PS.: Feel free to edit/extend my answer!
    – tobias_k
    Jun 27, 2013 at 11:04
  • Weird... I thought it wouldn't, because $ would not be visible from the userscript scope. Can you test in Chrome/Tampermonkey? If it breaks there, I think I've got a compatibility report to fill. If it doesn't, I'll need to reevaluate my previous tests. Jun 27, 2013 at 11:08
  • @JanDvorak Sorry, I don't have Chrome installed -- that's why I derived this Firefox version. ;-)
    – tobias_k
    Jun 27, 2013 at 11:18
1

Yet another greasemonkey script with an UI to select questions to hide manually.

2
  • Thanks for the script. The 'userscripts' site does not open and it says its under heavy load. Would you please upload the script some where else so that it can be accessed. Thanks again.
    – talegari
    Jul 22, 2014 at 3:11
  • @talegari, thank you for notification. Link is updated. Please ping me again if need arise.
    – Basilevs
    Sep 12, 2014 at 8:03

You must log in to answer this question.

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