Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Twitter Data Export reFollower Script (save and run from the root of your unzipped Twitter data export)
<!DOCTYPE html>
<!-- This script is for people who have exported their data from Twitter,
and want to mass add their followers and followees to a new twitter account.
It will open up the accounts as new tabs in chunks defined by you.
Save and run from the root of your unzipped Twitter data export.
-->
<html>
<head>
<title>Twitter Data Export reFollower Script</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<script type="text/javascript">
window.YTD = {};
window.YTD.following = {};
window.YTD.follower = {};
</script>
<script src="data/following.js"></script>
<script src="data/follower.js"></script>
</head>
<body>
<div class="container">
<div class="row py-5">
<div class="col-12 col-md-4 py-3">
Chunk Size: <input id="chunk_size" name="chunk_size" size="6" type="text" value="25" style="text-align:right;"/><button class="btn btn-outline-danger ml-2" id="chunk_info" style="padding: .04rem .32rem; font-size: 0.6rem; line-height: 1.5; border-radius: 1rem;">?</button>
</div>
<div class="col-12 col-md-4 py-3">
<button class="btn btn-sm btn-success" id="following">Open - Followings</button>
</div>
<div class="col-12 col-md-4 py-3">
<button class="btn btn-sm btn-success" id="follower">Open - Followers</button>
</div>
</div>
</div>
<script type="text/javascript">
(function() {
document.getElementById('following').innerHTML =
"Open " + window.YTD.following.part0.length +" Followings";
document.getElementById('follower').innerHTML =
"Open " + window.YTD.follower.part0.length +" Followers";
function processEntries(type){
var chunk_size = parseInt(document.getElementById('chunk_size').value,10);
var total_counter = 0;
var interval_counter = 0;
var left = window.YTD[type].part0.length;
for (i=0; i<window.YTD[type].part0.length;i++){
window.open(window.YTD[type].part0[i][type].userLink,'_blank');
total_counter++;
interval_counter++;
left = window.YTD[type].part0.length - total_counter;
if (left === 0){
alert ('Done!');
break;
}
if (interval_counter == chunk_size)
{
if (!confirm("Keep going? You have " + left + " left."))
{
break;
}
interval_counter = 0;
}
};
}
document.getElementById('chunk_info').addEventListener("click", function() {
alert("\"Chunk Size\" refers to how many tabs should open at a time, before you get the chance to cancel.");
}, false);
document.getElementById('following').addEventListener("click", function() {
processEntries('following');
}, false);
document.getElementById('follower').addEventListener("click", function() {
processEntries('follower');
}, false);
})();
alert('Please be sure that you are logged into Twitter before user this script! Otherwise you will have to individually refresh every tab that this script opens before being able to click the follow button, which will be super annoying for you. \n\nAlso, be careful when setting the "chunk size", as it may freeze your browser to have so a ton of tabs open at once! Also Twitter may rate-limit you temporarily. !ALSO! This script won\'t work unless you tell your browser to allow this script to open as many tabs as it wants.');
</script>
</body>
</html>
@HeathMorrisCode

This comment has been minimized.

Copy link
Owner Author

@HeathMorrisCode HeathMorrisCode commented Sep 11, 2020

Weirdly specific script, hope it is helpful for someone. I made it because I junked my old account and started fresh, but wanted to re-add about half of the accounts that I had previously followed, and some that had followed me. Any comments on how to clean it up, or general pointers on code design are appreciated!

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