Skip to content

Instantly share code, notes, and snippets.

@seldo
Last active November 20, 2022 20:03
Show Gist options
  • Save seldo/8601ad146420ae53a4be2568a747a300 to your computer and use it in GitHub Desktop.
Save seldo/8601ad146420ae53a4be2568a747a300 to your computer and use it in GitHub Desktop.
How to find your top tweets in your twitter archive

Get your top tweets

  1. Get your archive from twitter
  2. Find tweets.js; if you have a lot of tweets you may also have a tweets-part1, part2 etc.
  3. Modify the first line of each of those files to:
let data = [

and add this to the last line

module.exports = data

Then use toptweets.mjs

import part0 from "./tweets.js"
import part1 from "./tweets-part1.js"
import part2 from "./tweets-part2.js"
let tweets = part0.concat(part1).concat(part2)
let likes = tweets.map( (o) => {
let tweet = o.tweet
return {
link: "https://twitter.com/seldo/status/" + tweet.id,
text: tweet.full_text,
likes: parseInt(tweet.favorite_count),
retweets: parseInt(tweet.retweet_count),
total: parseInt(tweet.favorite_count) + parseInt(tweet.retweet_count)
}
})
likes.sort( (a,b) => {
return b.total - a.total
})
console.log(likes.slice(0,10))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment