Wednesday, March 21, 2012

Google Chrome Extension: Reddit All Comments Viewer (Expand all comments in Reddit)

Ever noticed those "load more comments" button, this extension expands all those links.

Please note that use this feature judiciously as it increases the load on reddit servers and that was the primary reason not all comments are displayed by default. 

The idea behind developing:- It was a top-post with more than 2000 comments. I had read a comment earlier but later when I reopend the link to search for that comment with the keyword (Yes, I remembered the keywork to search for the comment), it wasn't on the page. The sole reason for this was it being not shown due to "load more comments".



Content Script used:

function runAgain(){
    //Run every one second
    window.setTimeout(addButton,1e3)
    }
    
function addButton(){
    //All buttons have class as "button"
    var first_button = document.getElementsByClassName("button")[0];
    if (first_button == null){
        alert("Sorry, no comments to expand");
        return;
    }

    if (first_button.innerHTML == "loading..."){
        first_button.className = ""; //To fix later
    }
    else{
       var theEvent = document.createEvent("MouseEvent");
       theEvent.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
       first_button.dispatchEvent(theEvent);
    }

    if(first_button.id) 
        runAgain();
    };

//Link created and added as child to "pane"
var pane = document.getElementsByClassName("panestack-title")[0];
var newlink = document.createElement("a");
newlink.appendChild(document.createTextNode("Load all comments"));
newlink.id = "loadmorecomments";
newlink.href = "javascript:void(0)";
newlink.className="title-button ";
newlink.title = 'Opens all "load more comments" link every 1 second';
newlink.addEventListener('click', runAgain, false);
pane.appendChild(newlink);


10 comments:

  1. Is there any way to port this extension over to Firefox?

    ReplyDelete
  2. This can be done. Even I need it myself as I stopped using Chrome long ago. Will probably do it in the weekend and update here.

    ReplyDelete
  3. This is awesome, thank you! Any chance you could give it a drop down type option to have it grab the last 'load more comments' from the bottom of the page to only load comments made to OP?

    ReplyDelete
  4. I didn't try implementing it. Should be easy, it's just that I haven't got time to do it.

    ReplyDelete
  5. I hope you get a conversion to Firefox going soon. I really need this extension.

    ReplyDelete
  6. I ended up here when looking for this functionality for firefox.

    ReplyDelete
  7. me too, sadpanda I don't have programming skillz

    ReplyDelete
  8. I want something like this for Disqus. I want to "show all" comments, like clicking on all the "load more comments" and "show more" and "this comment is awaiting moderation / show comment" links. The resulting (possibly huge) page could them be saved (or printed to PDF) to make a record of all the comments on an article.

    Has anyone written such a beast?

    ReplyDelete