Created
September 22, 2017 16:33
-
-
Save phillmv/caa6d522603a28cc01f426e8d56e8f8a to your computer and use it in GitHub Desktop.
Mass embed twitter threads
This file contains 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
// 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>— 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. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?