Skip to content

Instantly share code, notes, and snippets.

@johnmurch
Last active August 6, 2018 12:47
Show Gist options
  • Save johnmurch/172de04f8c1e8ac48424af3edca7f26c to your computer and use it in GitHub Desktop.
Save johnmurch/172de04f8c1e8ac48424af3edca7f26c to your computer and use it in GitHub Desktop.
Twitter Follower Parse on-page
// Twitter URL
// document.querySelectorAll('.ProfileCard-avatarLink')[2].href
// Twitter Handle
// document.querySelectorAll('.ProfileCard-avatarLink')[2].href.replace("https://twitter.com/","")
// Twitter Name
// document.querySelectorAll('.ProfileNameTruncated-link')[3].innerHTML.trim()
// Twitter Profile Image
// document.querySelectorAll('.ProfileCard-avatarLink img')[2].src
// BIO - Notice count is off by 1 (e.g. starts at 0)
// document.querySelectorAll('.ProfileCard-bio')[2].innerHTML
// Background Image
// document.querySelectorAll('.ProfileCard-bg')[2].style.backgroundImage.replace('url("','').replace(')','')
var users = [];
for(var i=1;i<document.querySelectorAll('.ProfileCard-avatarLink').length;i++){
if(document.querySelectorAll('.ProfileCard-avatarLink')[i].href){
users.push({
url: document.querySelectorAll('.ProfileCard-avatarLink')[i].href,
username: document.querySelectorAll('.ProfileCard-avatarLink')[i].href.replace("https://twitter.com/",""),
name: document.querySelectorAll('.ProfileNameTruncated-link')[i].innerHTML.trim(),
bio: document.querySelectorAll('.ProfileCard-bio')[(i-1)].innerHTML,
image:{
profile: document.querySelectorAll('.ProfileCard-avatarLink img')[i].src,
background: document.querySelectorAll('.ProfileCard-bg')[i].style.backgroundImage.replace('url("','').replace(')','')
}
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment