Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
<!DOCTYPE html>
<meta charset="utf-8">
<title>Twitter Archive Viewer</title>
<script>window.YTD = { tweet: {}, account: {} }</script>
<script src="tweet.js"></script><!-- this is loading a file from the archive -->
<script src="account.js"></script><!-- this is loading a file from the archive -->
.tweet { border: 1px solid #eee; margin: 8px }
.full_text { padding: 8px }
.created_at { padding: 8px; color: #777 }
<div id="root"></div>
const tweets = []
let account = {}
for (const part of Object.values(window.YTD.tweet)) {
for (const part of Object.values(window.YTD.account)) {
account = part[0].account
const newestFirst = (a, b) => new Date(b.created_at) - new Date(a.created_at)
const buildURL = (screenName, id) => `${screenName}/status/${id}`
const renderTweet = tweet => `
<div class="tweet">
<div class="full_text">${tweet.full_text}</div>
<div class="created_at"><a href="${buildURL(account.username, tweet.id_str)}">${tweet.created_at}</a></div>
document.getElementById('root').innerHTML = tweets.sort(newestFirst).map(renderTweet).join('\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment