Created
September 16, 2016 16:38
-
-
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
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 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