Last active
November 18, 2022 05:03
-
-
Save olexpono/81dad9990b6779f0f589d3cb66d46bfe to your computer and use it in GitHub Desktop.
Get your follower list / following out of Twitter
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
/* DIRECTIONS: | |
* go to twitter.com/username/following | |
* also works on go to twitter.com/username/followers | |
* paste the script, it'll start collecting ALL USERS you scroll past in a list | |
* into a variable called "allUsers". | |
* | |
* Use this to stop when you're done: | |
* doneCapturing(); | |
*/ | |
if (!window.allUsers) { | |
window.allUsers = []; | |
} else { | |
allUsers = []; | |
} | |
const slurp = () => {// Meant to run on `*/following` | |
if (!location.href.endsWith('/followers') && !location.href.endsWith('/following')) { | |
console.log("WARNING: Maybe not the right page? this is meant to be run on /following") | |
} | |
let users = document.querySelectorAll('[data-testid="UserCell"]'); | |
users.forEach((userCell) => { | |
const spl = userCell.innerText.split("\n"); | |
if (allUsers.findIndex((el) => el.handle === spl[1]) > 0 ){ | |
console.log("K"); | |
return; | |
} | |
allUsers.push({ | |
name: spl[0], | |
handle: spl[1], | |
description: spl.slice(3).join(' ') | |
}); | |
console.log("."); | |
}); | |
window.scrollTo({ top: window.scrollY + window.innerHeight * 0.75 }); | |
}; | |
console.log("CAPTURING USERS!") | |
console.log("WHEN YOU'RE DONE, CALL / PASTE:") | |
console.log("doneCapturing()") | |
console.log("doneCapturing()") | |
console.log("doneCapturing()") | |
console.log("WHEN YOU'RE DONE SCROLLING!") | |
const inty = setInterval(slurp, 750); | |
const doneCapturing = () => { | |
clearInterval(inty); | |
console.log("All the users you scrolled past, right-click & copy:") | |
console.log(allUsers); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment