Skip to content

Instantly share code, notes, and snippets.

@Uvacoder
Forked from insin/followers.js
Created June 21, 2024 18:47
Show Gist options
  • Save Uvacoder/3d31a9c24ef34778c40aaa23bc3c7903 to your computer and use it in GitHub Desktop.
Save Uvacoder/3d31a9c24ef34778c40aaa23bc3c7903 to your computer and use it in GitHub Desktop.
Run this while viewing someone's Twitter /following list to get the handles of everyone they follow
let $follows = document.querySelector('div[data-testid="primaryColumn"] section > h1 + div[aria-label] > div')
let handles = new Set()
let finishTimeout
let observer
function finish() {
if (finishTimeout) {
clearTimeout(finishTimeout)
}
finishTimeout = setTimeout(() => {
console.log(Array.from(handles).join(', '))
observer.disconnect()
}, 10000)
}
function processFollows() {
for (let $follow of $follows.children) {
if ($follow.firstElementChild.style.display === 'none') {
continue
}
let $handle = $follow.querySelector('a:not([aria-hidden])[tabindex]')
if ($handle) {
handles.add($handle.innerText)
$follow.firstElementChild.style.display = 'none'
}
}
console.log(handles.size)
finish()
}
observer = new MutationObserver(processFollows)
observer.observe($follows, {childList: true})
processFollows()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment