Skip to content

Instantly share code, notes, and snippets.

@tomcritchlow
Last active April 1, 2020 14:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomcritchlow/c685818efd120594a5e62e59eb86693c to your computer and use it in GitHub Desktop.
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
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);
})();
@tomcritchlow
Copy link
Author

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?

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