Skip to content

Instantly share code, notes, and snippets.

@phillmv
Created September 22, 2017 16:33
Show Gist options
  • Save phillmv/caa6d522603a28cc01f426e8d56e8f8a to your computer and use it in GitHub Desktop.
Save phillmv/caa6d522603a28cc01f426e8d56e8f8a to your computer and use it in GitHub Desktop.
Mass embed twitter threads
// Open the Chrome inspector, and select the topmost div containing the twitter thread.
// You might want to open the first tweet in the thread, scroll down to load every item in the thread, then select the parent container
var foo = document.createElement("div");
var str = ""
$($0).find(".tweet").each(function(i, t) {
var tweet = $(t);
var turl = "https://twitter.com" + tweet.data("permalink-path")
var tdate = tweet.find(".tweet-timestamp").attr("title")
var tcontent = tweet.find(".tweet-text").html()
str += '<blockquote class="twitter-tweet" data-conversation="none" data-lang="en"><p lang="en" dir="ltr">' + tcontent + '</p>&mdash; Better Toronto (@betteryyz) <a href="' + turl + '">' + tdate + '</a></blockquote>\n\n';
});
foo.innerHTML = str
// type foo and right click to select. Congrats! Don't forget to add a
// <script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>
// at the bottom of wherever you post it.
@floriandierickx
Copy link

Thanks for this script! It served it's purpose at floriandierickx.github.com :) Some additional question: would there be an easy way to retrieve the author for each tweet and adjust it?

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