23

When there are lots of comments under a post, they're automatically collapsed, and if you want to find (Ctrl + F) a specific word/phrase on the page, you have to look for and click the show (n) more comments link under each post separately. Here's a feature request: add an Expand all comments button above all posts.

12
  • 1
    Just asking, what purpose will it serve in broad sense? Jan 1, 2017 at 12:12
  • 8
    It makes searching on a web page through all the answers and comments easier. I especially find it useful when you look for specific words -- just for instance for English Language Learners.
    – Mori
    Jan 1, 2017 at 12:15
  • 4
    Also , in general, lots of comments != lots of value. Jan 1, 2017 at 12:17
  • 2
    @SouravGhosh, Perhaps, but selected comments by software algorithm or the community also != lots of value. Jan 2, 2017 at 5:33
  • @tgm1024 sorry, is that a question? Jan 2, 2017 at 5:35
  • @Mori, I wholeheartedly agree. In fact, if there were a setting to automatically expand (read as "put the @#$% back") all comments, I would use it. Jan 2, 2017 at 5:35
  • 7
    @SouravGhosh, I want to follow the conversation, which often has many people answering prior messages that have no upvote. Even if I had no interest in searching, what selectively removing messages does is make it ever more likely that someone will produce a message that sounds like a non sequitur. That's a nonstarter. Scrolling is easier than trying to piece together a conversation with needless holes in it. Jan 2, 2017 at 5:39
  • 2
    When I've wanted this, it's been to find a comment of my own that I remember leaving on one of those many answers. Searching comments would be useful more broadly. Are there non-search use cases for this feature? Jan 3, 2017 at 19:21
  • 1
    There is at least one Tampermonkey/Greasemonkey/Userscript for this. Aug 8, 2018 at 20:22
  • 1
    Just wanted to post an up-to-date response: If you have the keyboard-shortcuts script enabled in your preferences, press C to show all comments on a post, or to post a new one.
    – Ollie
    Nov 7, 2020 at 14:27
  • @Ollie: Good point! It seems to work only for one post, though. It doesn't expand all the comments throughout a thread.
    – Mori
    Nov 8, 2020 at 15:00
  • @Mori It's not supposed to. You can expand the comments on a each post in a thread by clicking J to go to the next post, then clicking C. As we have that, to quote ShadowWizard: "Most people aren't going to use it".
    – Ollie
    Nov 8, 2020 at 16:55

2 Answers 2

11

That would be a nice-to-have feature, but doubt it will be done. Most people are not going to use it.

So as alternative, in a page where you want to expand all the comments you can do that by following those steps:

  1. Open the browser developer console. (e.g. in Chrome CTRL+SHIFT+I)

  2. Copy and paste the following:

    function TriggerSingleLink(links, index) {
        if (index >= links.length) {
            console.log("All done.");
            return;
        }
        var oLink = links[index];
        oLink.trigger('click');
        window.setTimeout(function() {
            TriggerSingleLink(links, index + 1)
        }, 500);
    }
    var links = [];
    $('.js-show-link').each(function() {
        var oLink = $(this);
        if ($.trim(oLink.text()).length > 0)
            links.push(oLink);
    });
    if (links.length > 0) {
        console.log("Expanding " + links.length + " link" + ((links.length > 1) ? "s" : "") +"...");
        TriggerSingleLink(links, 0);
    } else {
        console.log("No valid expand links found.");
    }
    
  3. Press ENTER. All comments will be expanded in all posts.

You can then close the console, e.g. F12 in Chrome.

14
  • 4
    I believe that most people would use it. However, thanks for the js. Very useful......will greasemonkey a variant out later on FF to see. Jan 2, 2017 at 5:41
  • @tgm1024 voting ratio on the request is 6/4 but still... doubt the team will spend time on this. Jan 2, 2017 at 7:25
  • 1
    I wonder what the rationale is for not wanting it? At the very least a setting for it to be the default would be completely innocuous to the naysayers. Jan 3, 2017 at 4:04
  • @tgm1024 personally I do want it because I read all the comments sometimes, and would like to be able to search them too. However, being here enough time, I believe many users consider comments as "noise" and prefer to see as little of them as possible. For them, "expand all" will be just pointless. Jan 3, 2017 at 9:12
  • 3
    Well in that case, an option to fold away all comments under a "+" button would be what they want. What I understand are 1. All comments, and 2. No comments. Seeing Partial Comments picked behind my back makes no sense to me: If comments are there at all, I want to be able to follow the conversation. Not sit there and guess about what may be missing. Jan 11, 2017 at 14:35
  • 1
    I second @tgm1024's suggestion of adding a single "Expand All" link on pages that contain hidden comments; being able to quickly search through all answers and comments is very useful. In the meantime, thanks very much for the JavaScript. Rather than opening the Developer Console and pasting the code in each time, a bookmarklet can be created by 1. opening the Bookmark Manager, 2. clicking the More (⋮) icon > "Add new bookmark", 3. entering a name for the bookmarklet, and 4. pasting your JavaScript snippet into the URL field like so: javascript:$('.js-show-link').trigger('click'); Mar 27, 2018 at 16:57
  • 1
    @Miles I also support the request, I upvoted and said it in my answer, I just give something small that can be used in the meantime. Your suggestion sounds good, you can turn this into a new answer IMO. Mar 28, 2018 at 7:09
  • @MilesWolbe, well to fully clarify, what I actually do want is a single option within the settings for the entire site: "Show all comments, and not ones hand-picked by algorithm", or less clumsy wording to that effect. May 3, 2018 at 12:34
  • Not sure whether this is the right place to ask—if it's not, I'll happily delete—but when I do this, I get the following message in the console: 2D22Fd9oftH.js:108 Uncaught Error: <![EX[["Tried to get element with id of \"%s\" but it is not present on the page",".js-show-link"]]]> TAAL[1] at g (2D22Fd9oftH.js:108) at a (2D22Fd9oftH.js:108) at <anonymous>:1:1 g @ 2D22Fd9oftH.js:108 a [from $-core] @ 2D22Fd9oftH.js:108 (anonymous) @ VM2184:1 Service Worker termination by a timeout timer was canceled because DevTools is attached. Any idea how I can fix this? Nov 4, 2018 at 16:05
  • @JoelDerfner thanks for the heads up, I fixed the code. Nov 5, 2018 at 7:03
  • @Joel sorry can't see any error with my code this time. Looks like you try to run this as extension, which it's not. You must run it as plain code in the JS console of Chrome on SE page. Nov 6, 2018 at 11:53
  • Thanks—I realized what I was doing wrong. I appreciate it! Nov 6, 2018 at 22:49
  • 2
    This answer is better served with a warning. We don't actually keep all the comments on the page pre-loaded. Every time you click the show more comments button, it sends a request to the server to fetch the full list of comments. This code without any delays has the potential to send 31 requests to the server immediately, which could result in the user getting rate limited for a short time.
    – animuson StaffMod
    Jul 10, 2020 at 15:11
  • @animuson thanks, I wasn't aware of that. I've added a delay of half a second between each "click", is that enough? Jul 11, 2020 at 9:39
7

Create a bookmarklet for @ShadowWizard's handy JavaScript snippet:

Chrome:

  1. Bookmarks > Bookmark Manager
  2. Click the More (vertical ellipsis) icon then "Add new bookmark"
  3. Enter a name for the bookmarklet (e.g., "Expand All") and paste this into the URL field: javascript:$('.js-show-link').trigger('click');

Firefox:

  1. Right click Bookmarks Bar > New Bookmark...
  2. Enter a name for the bookmarklet and paste this into the URL Location field: javascript:(function(){$('.js-show-link').trigger('click');})();

Safari:

  1. Cmd + D
  2. Enter a name for the bookmarklet and click Add
  3. Right click the bookmark > Edit Address...
  4. Replace the existing location with javascript:$('.js-show-link').trigger('click');
2
  • 5
    This answer is better served with a warning. We don't actually keep all the comments on the page pre-loaded. Every time you click the show more comments button, it sends a request to the server to fetch the full list of comments. This code without any delays has the potential to send 31 requests to the server immediately, which could result in the user getting rate limited for a short time.
    – animuson StaffMod
    Jul 10, 2020 at 15:12
  • I've edited the code to add a delay. Jul 11, 2020 at 9:40

You must log in to answer this question.

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