Skip to content

Instantly share code, notes, and snippets.

@DanH42
Created September 16, 2016 16:38
Show Gist options
  • Save DanH42/dbb5b69dccadbd8d153d6e3a4675f0ed to your computer and use it in GitHub Desktop.
Save DanH42/dbb5b69dccadbd8d153d6e3a4675f0ed to your computer and use it in GitHub Desktop.
Expands collapsed threads and then likes every comment on the current Facebook page
(function expandThreads(){
var count = 0;
var els = document.querySelectorAll('.UFIReplySocialSentenceLinkText, .UFIPagerLink');
console.log("Expanding", els.length, "threads");
for(var i = 0; i < els.length; i++){
if(els[i].innerText.indexOf("Hide") === -1){
els[i].click();
count++;
}
}
if(count)
setTimeout(expandThreads, 250);
else{
els = document.querySelectorAll('.UFILikeLink');
var delay = els.length < 50 ? 100 : 1000; // TODO: Find more accurate numbers to use here
console.log("Liking", els.length, "comments");
(function likeComment(i){
if(els[i].innerText === "Like")
els[i].click();
if(i < els.length - 1)
setTimeout(likeComment.bind(this, i + 1), delay);
else
console.log("Done");
})(0);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment