Last active
April 1, 2020 14:42
-
-
Save tomcritchlow/c685818efd120594a5e62e59eb86693c to your computer and use it in GitHub Desktop.
A bookmarklet to grab the URLs in a tweet thread and copy all the embed code to the clipboard
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
javascript: (function() { | |
var username = document.location.href.split("/")[3]; | |
var urls = document.querySelectorAll("a"); | |
var tweets = "<blockquote class='twitter-tweet' data-conversation='none'><a href='https://twitter.com"+document.location.href+"'></a></blockquote><script async src='https://platform.twitter.com/widgets.js' charset='utf-8'></script>\n\n";; | |
var count = 1; | |
urls.forEach(myFunction); | |
function myFunction(item, index) { | |
if(item.getAttribute("href").includes(username+"/status/") && !(item.getAttribute("href").includes("/retweets")) && !(item.getAttribute("href").includes("/likes"))){ | |
tweets += "<blockquote class='twitter-tweet' data-conversation='none'><a href='https://twitter.com"+item.getAttribute('href')+"'></a></blockquote><script async src='https://platform.twitter.com/widgets.js' charset='utf-8'></script>\n\n"; | |
count++; | |
}; | |
}; | |
var dummy = document.createElement("textarea"); | |
document.body.appendChild(dummy); | |
dummy.value = tweets; | |
dummy.select(); | |
document.execCommand("copy"); | |
document.body.removeChild(dummy); | |
alert("Copied "+count+" tweets from "+username); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Instructions: load up a twitter URL, scroll down so all the tweets load and then run the bookmarklet.
Bugs: unfortunately for threads longer than about 15 tweets Twitter starts deleting the tweets out of scroll view so it stops working. Can anyone figure out how to make it work?