Skip to content

Instantly share code, notes, and snippets.

@tregoning
Created October 15, 2012 22:03
Show Gist options
  • Save tregoning/3895864 to your computer and use it in GitHub Desktop.
Save tregoning/3895864 to your computer and use it in GitHub Desktop.
Expand all comments on a Facebook page
(function(){
'use strict';
var digCounter = 0,
numberOfDigTries = 3,
bodyHeight = window.getComputedStyle(document.body).height;
var scroll = function(){
window.scrollBy(0, 10000);
};
var areWeLoading = function(){
var loading = false;
[].forEach.call(document.querySelectorAll(".loadingIndicator"), function(it){
if(window.getComputedStyle(it).display !== "none"){
loading = true;
}
});
return loading;
};
var areWeIncreasingContent = function(){
var retVal = false,
currentBodyHeight = window.getComputedStyle(document.body).height;
if(currentBodyHeight > bodyHeight){
retVal = true;
}
return retVal;
};
var reportDigCompleted = function(){
alert("Done!");
};
var expandComments = function(){
[].forEach.call(document.querySelectorAll(".UFIPagerLink"), function(it){
if( !it.querySelector(".ufiPagerLoading") ){
it.click();
}
});
if( document.querySelectorAll(".UFIPagerLink").length ){
window.setTimeout(expandComments, 3000);
}else{
[].forEach.call(document.querySelectorAll(".fbTimelineFeedbackComments a"), function(it){
it.click();
});
window.setTimeout(reportDigCompleted, 5000);
}
};
var dig = function(){
if(digCounter > numberOfDigTries){
expandComments();
return;
}
scroll();
if( areWeIncreasingContent() || areWeLoading() ){
digCounter = 0;
window.setTimeout(dig, 1000);
}else{
digCounter++;
window.setTimeout(dig, 1000);
}
};
dig();
}());
@Zuhayer
Copy link

Zuhayer commented Aug 8, 2016

Kindly guide me how to use this?

I am familiar with javascript, but how to use this script?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment