4

The following script for Tampermonkey (multi browser) or Greasemonkey (Firefox) automatically expands all comments which are normally hidden behind the "show ... more comments" link:

pic of "show more comments" link

The code is based on the fantastic, but unfortunately deleted, answer from Brock Adams (screenshot for users below 10k) - Thank you!

// ==UserScript==
// @name        StackExchange, Expand All Comments
// @author      Taken from https://webapps.stackexchange.com/a/119439/192282
// @description Automatically shows all comments for questions and answers
// @match       *://*.askubuntu.com/*
// @match       *://*.mathoverflow.net/*
// @match       *://*.serverfault.com/*
// @match       *://*.stackapps.com/*
// @match       *://*.stackexchange.com/*
// @match       *://*.stackoverflow.com/*
// @match       *://*.superuser.com/*
// @exclude     *://api.stackexchange.com/*
// @exclude     *://blog.stackexchange.com/*
// @exclude     *://blog.stackoverflow.com/*
// @exclude     *://chat.stackexchange.com/*
// @exclude     *://chat.stackoverflow.com/*
// @exclude     *://data.stackexchange.com/*
// @exclude     *://elections.stackexchange.com/*
// @exclude     *://openid.stackexchange.com/*
// @exclude     *://stackexchange.com/*
// @exclude     *://*/review
// @grant       none
// @version     1.1
// @history     1.1 Avoid clicking on disabled "add a comment" links.
// @history     1.0 Initial release.
// ==/UserScript==
try {
    //--- This is a utility function that SE currently provides on its pages.
    StackExchange.ready (function () {
        $('.js-show-link').not (".dno").trigger ('click');
    } );
}
catch (e) {
    console.error (
      "***Userscript error: StackExchange.ready() is no longer defined!"
    , e);
}



Known issues:

  • May not expand comments if cookies are disabled (side effect of SE's anonymous user handling).
7
  • 2
    Just a few days ago, I decided to write a script to do this, today I find you've prepared one for me. Thank you. It works perfectly. +1
    – 3D1T0R
    Aug 6, 2018 at 22:33
  • 1
    @3D1T0R You'll have to thank @ BrockAdams -- it's all his magic doing! Aug 7, 2018 at 14:44
  • @BrockAdams & @​samcarter: Thanks. Sorry I didn't get back to you sooner, but it really is working perfect for me now. I do have to wonder though about the coding style. I find it very weird to have spaces between function-name and parenthesis. Is there a particular reason for this?
    – 3D1T0R
    Aug 20, 2018 at 21:58
  • Also: You can use // @exclude *://blog.* & // @exclude *://chat.*.
    – 3D1T0R
    Aug 24, 2018 at 21:21
  • This script, may it be beautifully short and concise as it is, has one issue: compared to StackExchange – Expand Hidden Comments it doesn't scroll to the (textual) point on the page were you initially were after expansion. And, BTW, the link to Brock Adam's answer that you mention is dead now. Dec 1, 2019 at 1:03
  • @GeroldBroserreinstatesMonica Scrolling to the textual point on the page does indeed not work, but the colour highlighting of the comment/answer still works, so I usually just pay attention to the colour highlighting and then scroll myself. I added screenshot of Brock Adam's answer for the below 10k users, thanks for pointing this out! Dec 1, 2019 at 11:41
  • At the moment it also doesn't work for just-added comments (the site can automatically load posted comments with JavaScript)
    – user202729
    Jan 25, 2021 at 3:40

0

You must log in to answer this question.

Browse other questions tagged .