Last active
March 21, 2025 23:38
-
-
Save kojp/f51d9e11bf818ab1336abef153398219 to your computer and use it in GitHub Desktop.
Retrieve all tweets of a tree
This file contains hidden or 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(){function extractTweetInfo(tweet){var tweetText=tweet.querySelector('div[lang]').innerText.replace(/\n/g,' ');var tweetUrls=Array.from(tweet.querySelectorAll('a')).map(a=>a.href).filter(href=>href.includes('https://t.co'));var tweetTime=new Date(tweet.querySelector('time').getAttribute('datetime')).toISOString().replace(/\.\d+Z$/,'').replace('T',' ');var tweetUrl=tweet.querySelector('a[href*="/status/"]').href;var fullTweetText=tweetText+' '+tweetUrls.join(' ');return{text:fullTweetText,time:tweetTime,url:tweetUrl};}var tweets=document.querySelectorAll('article[role="article"]');var tweetInfos=[];tweets.forEach(function(tweet){var tweetInfo=extractTweetInfo(tweet);tweetInfos.push(tweetInfo);});console.log(tweetInfos);var output=tweetInfos.map(function(info){return info.text+' '+info.time+' '+info.url;}).join('\n');function copyToClipboard(text){if(navigator.clipboard){navigator.clipboard.writeText(text).then(function(){alert('Tweet information copied to clipboard!');}).catch(function(err){fallbackCopyToClipboard(text);});}else{fallbackCopyToClipboard(text);}}function fallbackCopyToClipboard(text){var textArea=document.createElement('textarea');textArea.value=text;document.body.appendChild(textArea);textArea.focus();textArea.select();try{var successful=document.execCommand('copy');var msg=successful?%27successful%27:%27unsuccessful%27;alert(%27Fallback:%20Copying%20text%20command%20was%20%27+msg);}catch(err){alert(%27Fallback:%20Oops,%20unable%20to%20copy%27,err);}document.body.removeChild(textArea);}copyToClipboard(output);})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment