Expand all comments and replies on Facebook

Alec Jacobson

October 10, 2014

weblog/

A couple times I've been frustrated that Facebook announces "So and so replied to a comment on this." above a post with 100K comments. If I want to see what So and so wrote then I'm stuck clicking "View more comments" and "View more replies" until I can find So and so.

This bookmarklet will expand all replies and comments:

javascript:function find_more_and_click(){function i(e){if(e.length<=0){return}e[0].click();window.setTimeout(function(){i(e.splice(1))},800)}var e=document.getElementsByClassName("UFIPagerLink");var t=[];for(var n=0;n<e.length;n++){if(e[n]&&(e[n].text=="View more replies"||e[n].text=="View more comments")){t.push(e[n])}}var r=t.length;i(t);if(r>0){window.setTimeout(function(){find_more_and_click()},800)}}find_more_and_click()

Here's the source

function find_more_and_click()
{
  var buttons = document.getElementsByClassName('UFIPagerLink');
  var more = [];

  // Select only the View more ... buttons.
  for (var i = 0; i < buttons.length; i++) {
      if (buttons[i] && (buttons[i].text == 'View more replies' || buttons[i].text == 'View more comments')) {
          more.push(buttons[i]);
      }
  }
  var more_length = more.length;

  function clickFn(more) {
      if (more.length <= 0) {
          return;
      }
      more[0].click();

      // Wait for each Like to be processed before trying the next.
      // Facebook enforces this requirement.
      window.setTimeout(function() {
          clickFn(more.splice(1));
      }, 800);
  }
  clickFn(more);
  if(more_length>0)
  {
    window.setTimeout(function(){find_more_and_click();},800);
  }
}
find_more_and_click();

Source