Skip to content

Instantly share code, notes, and snippets.

@scr2em
Last active January 12, 2021 21:24
Show Gist options
  • Save scr2em/d82e663f152b275b2b44a6c48d04aed7 to your computer and use it in GitHub Desktop.
Save scr2em/d82e663f152b275b2b44a6c48d04aed7 to your computer and use it in GitHub Desktop.
Facebook random comment picker
// open the post in a new tap
var commentPicker= function(){
var comments =[];
document.querySelectorAll("li div div div div div div div div div div a").forEach(x=>{
try{
var link = x.href
if(link.match('profile.php')){
link = link.split("&")[0]
}else{
link = link.split("?")[0]
}
comments.push({name: x.firstElementChild.firstElementChild.innerHTML,profile:link})
}catch{
}
})
var {name,profile} = comments[Math.floor(Math.random()*comments.length)]
console.log(`YAY ${name} has won!!! check his profile at ${profile} `)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment