Created
October 15, 2012 22:03
-
-
Save tregoning/3895864 to your computer and use it in GitHub Desktop.
Expand all comments on a Facebook page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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(); | |
}()); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Kindly guide me how to use this?
I am familiar with javascript, but how to use this script?