-
-
Save thoragio/04b138bd5144f78f065d4f46ae4e4ac6 to your computer and use it in GitHub Desktop.
Nuke Your Twitter History
This file contains hidden or 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
# Grab the keys from Twitter Apps: https://apps.twitter.com/ | |
CONSUMER_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | |
CONSUMER_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | |
ACCESS_TOKEN=xxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | |
ACCESS_TOKEN_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
This file contains hidden or 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
require('dotenv').config(); | |
module.exports = { | |
consumer_key: process.env.CONSUMER_KEY, | |
consumer_secret: process.env.CONSUMER_SECRET, | |
access_token: process.env.ACCESS_TOKEN, | |
access_token_secret: process.env.ACCESS_TOKEN_SECRET | |
}; |
This file contains hidden or 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
/* | |
Nuke the history of tweets and favorites | |
Run the script a few times if you have a lot of history | |
This runs with node and the following dependencies: | |
"dotenv": "^4.0.0" | |
"twit": "^2.2.5" | |
*/ | |
const Twit = require('twit'); | |
const config = require('./config'); | |
const bot = Twit(config); | |
/* | |
Nuke all tweets... | |
*/ | |
const deleteTweet = id => { | |
bot.post( | |
'statuses/destroy', | |
{ | |
id | |
}, | |
(err, data, response) => { | |
if (err) { | |
console.log(err); | |
} else { | |
console.log('destroyed ' + id); | |
} | |
} | |
); | |
} | |
bot.get( | |
'statuses/user_timeline', | |
{ | |
count: 1000, | |
screen_name: '[YOUR_SCREEN_NAME]' | |
}, | |
(err, data, response) => { | |
if (err) { | |
console.log(err); | |
} else { | |
data.forEach(t => { | |
console.log(t.id_str); | |
deleteTweet(t.id_str); | |
}); | |
} | |
} | |
); | |
/* | |
And favorites... | |
*/ | |
const deleteFavorite = id => { | |
bot.post( | |
'favorites/destroy', | |
{ | |
id | |
}, | |
(err, data, response) => { | |
if (err) { | |
console.log(err); | |
} else { | |
console.log('destroyed ' + id); | |
} | |
} | |
); | |
} | |
bot.get( | |
'favorites/list', | |
{ | |
count: 200, | |
screen_name: '[YOUR_SCREEN_NAME]' | |
}, | |
(err, data, response) => { | |
if (err) { | |
console.log(err); | |
} else { | |
data.forEach(t => { | |
console.log(t.id_str); | |
deleteFavorite(t.id_str); | |
}); | |
} | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment