-
-
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
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
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