Skip to content

Instantly share code, notes, and snippets.

@milesflo
Last active February 11, 2020 21:41
Show Gist options
  • Save milesflo/bf1c8c117e14a9c7b1327038ecc2c0d3 to your computer and use it in GitHub Desktop.
Save milesflo/bf1c8c117e14a9c7b1327038ecc2c0d3 to your computer and use it in GitHub Desktop.
A tiny GUI-automation script for following accounts on Twitter
/**
Why?:
This script is useful for following a large list of accounts straight from your browser.
There are many reasons to use this... Maybe you want to follow everyone in a community but you
can't be bothered to click on all those buttons... Maybe you want to follow all these accounts
in the hopes that they'll follow you back, giving you lots of free followers for doing nothing
How:
1. Navigate to a twitter page with multiple [Follow] buttons visible...
- Scrolling to the bottom of a page may list more... Do this for maximum efficiency
2. Open your browser's command prompt
- Chrome: https://developers.google.com/web/tools/chrome-devtools/console/
- Firefox: https://developer.mozilla.org/en-US/docs/Tools/Web_Console/Opening_the_Web_Console
3. Paste the script below into the line and run
*/
var targetUsers = [...document
.getElementsByClassName('EdgeButton EdgeButton--secondary EdgeButton--small button-text follow-text')]
.filter(button => button.innerText.startsWith('Follow\nFollow'))
for (var i = 0; i < targetUsers.length; i++) {
let button = targetUsers[i]
// Twitter will get mad if you spam this... Clicking buttons on a 1-second cooldown
setTimeout(() => {
button.click()
}, 1000 * i)
}
@rvvvt
Copy link

rvvvt commented Feb 10, 2020

howdy sir - i tried your snippet but it did not work for me. here is a quick revision using a portion of your code. thanks!

//define our button 
 but = $$('[data-testid*="-follow"]')

// uncomment and run below line -only- for what i like to call yolo mode 
// for (i in but) {but[i].click()}
// the above line will click all detected "follow" buttons at once so use with caution or whatever

// for the timid, the below will sanely click one follow button per 1000ms and isnt as fun
for (var i = 0; i < but.length; i++) {
  let button = but[i]
  setTimeout(() => {
    button.click()
  }, 1000 * i)
}; 

@milesflo
Copy link
Author

@architekco What?? 😄

@rvvvt
Copy link

rvvvt commented Feb 11, 2020

@architekco What?? 😄

sorry 😂your snippet didnt work for me so i just rejiggled it a bit and posted my revision/version. i will add some additional comments for clarification

@milesflo
Copy link
Author

@architekco Sounds good to me! I wasn’t planning on this being a living document, but the logic could/will break any time they do a UI overhaul.

Appreciate the contribution, and best of luck “stimulating growth” 😂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment