Guest User

Untitled

a guest
May 25th, 2025
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. javascript:(function() {
  2.     console.log("Nc5 based on Nc6v3.4-2 code");
  3.  
  4.     var tweets = Array.from(document.querySelectorAll('.timeline-item'));
  5.     var tweetTexts = [];
  6.     var userTweets = [];
  7.     var imgCounter = 0;
  8.     var globalTweetCount = 0;
  9.     var totalTweetCount = 0;
  10.     var outputChains = [];
  11.  
  12.    
  13.    
  14.    
  15.    
  16.     tweets.forEach(function(tweet) {
  17.        
  18.        
  19.         var tweetLinkElement = tweet.querySelector('a.tweet-link[href*="/status/"], a[href*="/status/"][title]');
  20.  
  21.         if (tweetLinkElement && tweetLinkElement.href) {
  22.             var fullTweetUrl = tweetLinkElement.href;
  23.            
  24.             fullTweetUrl = fullTweetUrl.replace('nitter.poast.org', 'twitter.com').replace('xcancel.com', 'twitter.com');
  25.             if (fullTweetUrl.includes('/status/')) {
  26.                 fullTweetUrl = fullTweetUrl.split('?')[0];
  27.             }
  28.             userTweets.push(fullTweetUrl);
  29.         }
  30.     });
  31.  
  32.  
  33.     tweets.forEach(function(tweet) {
  34.         var tweetAuthor = tweet.querySelector('.username');
  35.         if (tweetAuthor) {
  36.             var tweetText = tweet.querySelector('.tweet-content').innerHTML;
  37.  
  38.            
  39.             tweetText = tweetText.replace(/<a[^>]+href="([^"]+)"[^>]*>@<[^<]+<\/a>/g, (match, p1) => `[U][URL]${p1}[/URL][/U]`);
  40.             tweetText = tweetText.replace(/<a[^>]+href="([^"]+)"[^>]*>[^<]+<\/a>/g, (match, p1) => `[U][URL]${p1}[/URL][/U]`);
  41.             tweetText = tweetText.replace(/<br>/g, '\n');
  42.             tweetText = tweetText.replace(/<span[^>]+data-sanitized-url="([^"]+)"[^>]*>[^<]+<\/span>/g, (match, p1) => `[U][URL]${p1}[/URL][/U]`);
  43.             tweetText = tweetText.replace(/<span[^>]+data-url="([^"]+)"[^>]*>[^<]+<\/span>/g, (match, p1) => `[U][URL]${p1}[/URL][/U]`);
  44.             tweetText = tweetText.replace(/<span[^>]+data-expanded-url="([^"]+)"[^>]*>[^<]+<\/span>/g, (match, p1) => `[U][URL]${p1}[/URL][/U]`);
  45.             tweetText = tweetText.replace(/<span[^>]+title="([^"]+)"[^>]*>[^<]+<\/span>/g, (match, p1) => `[U][URL]${p1}[/URL][/U]`);
  46.             tweetText = tweetText.replace(/<a[^>]+href="([^"]+)"[^>]*>[^<]+<\/a>/g, (match, p1) => `[U][URL]${p1}[/URL][/U]`);
  47.             tweetText = tweetText.replace(/]*>/g, '\n');
  48.             tweetText = tweetText.replace(/<[^>]+>/g, '');
  49.             tweetText = tweetText.replace(/Β /g, ' ');
  50.  
  51.             var images = Array.from(tweet.querySelectorAll('.attachment.image img'));
  52.             var imageUrlsForThisTweet = images.map(img => {
  53.                 var src = decodeURIComponent(img.src);
  54.                 var url = new URL(src, window.location.href);
  55.                 url.hostname = 'pbs.twimg.com';
  56.                
  57.                
  58.                 url.pathname = url.pathname
  59.                     .replace('/pic/', '/media/')
  60.                     .replace('/media/media/', '/media/')
  61.                     .replace(/\/media\/.*\/media\//, '/media/');
  62.                 url.search = '';
  63.                 return `[img]${url.href}[/img]`;
  64.             }).join('\n');
  65.             imgCounter += images.length;
  66.             if (imageUrlsForThisTweet) {
  67.                 tweetText += `\n\n${imageUrlsForThisTweet}`;
  68.             }
  69.  
  70.             var videos = Array.from(tweet.querySelectorAll('video'));
  71.             var videoUrlsForThisTweet = videos.map(video => {
  72.                 var source = video.querySelector('source');
  73.                 if (source && source.src) {
  74.                     var src = source.src;
  75.                     if (src && (src.startsWith('https://video') && (src.includes('twimg.com/ext_tw_video/') || src.includes('twimg.com/amplify_video/')))) {
  76.                         src = src.split('?')[0];
  77.                         return `[U][URL]${src}[/URL][/U]`;
  78.                     }
  79.                 }
  80.                 return '';
  81.             }).filter(url => url !== '').join('\n');
  82.             if (videoUrlsForThisTweet) {
  83.                 tweetText += `\n\n${videoUrlsForThisTweet}`;
  84.             }
  85.  
  86.             globalTweetCount++;
  87.             totalTweetCount++;
  88.             tweetTexts.push({ text: tweetText, author: tweetAuthor.textContent.slice(1), index: globalTweetCount });
  89.  
  90.            
  91.             if (imgCounter >= 20 || tweet === tweets[tweets.length - 1]) {
  92.                 if (userTweets.length > 0) {
  93.                     var firstNewChainUrl = userTweets.shift();
  94.                     var formattedText = `\n` + [
  95.                         firstNewChainUrl,
  96.                         `[SPOILER="thread continued"]\n${userTweets.map(url => {
  97.                            
  98.                            
  99.                             if (url && url.includes('/status/')) {
  100.                                 return url.split('?')[0];
  101.                             }
  102.                             return url;
  103.                         }).join('\n')}\n[/SPOILER]`,
  104.                         `[SPOILER="full text & large images"]\n\n${tweetTexts.map((tweet, index) => `${globalTweetCount - tweetTexts.length + index + 1}/${globalTweetCount}\n@${tweet.author}\n${tweet.text}\n`).join('\n')}\n\n[COLOR=rgb(184, 49, 47)][B][SIZE=5]To post tweets in this format, more info here: [URL]https://www.thecoli.com/threads/tips-and-tricks-for-posting-the-coli-megathread.984734/post-52211196[/URL][/SIZE][/B][/COLOR]\n[/SPOILER]`
  105.                     ].join('\n');
  106.  
  107.                     formattedText = formattedText.replace(/(\d+\/\d+)\s@/g, '$1\n@');
  108.                     outputChains.push(formattedText);
  109.                     userTweets = [];
  110.                     imgCounter = 0;
  111.                     tweetTexts = [];
  112.                     totalTweetCount = 0;
  113.                 }
  114.             }
  115.         }
  116.     });
  117.  
  118.     var finalFormattedText = '';
  119.     if (outputChains.length > 0) {
  120.         finalFormattedText = outputChains.join('\n\n');
  121.     }
  122.  
  123.    
  124.    
  125.     if (userTweets.length > 0) {
  126.         var remainingFormattedText = `\n` + [
  127.             userTweets[0],
  128.             `[SPOILER="thread continued"]\n${userTweets.slice(1).map(url => {
  129.                 if (url && url.includes('/status/')) {
  130.                     return url.split('?')[0];
  131.                 }
  132.                 return url;
  133.             }).join('\n')}\n[/SPOILER]`,
  134.             `[SPOILER="full text & large images"]\n\n${tweetTexts.map((tweet, index) => `${globalTweetCount - tweetTexts.length + index + 1}/${globalTweetCount}\n@${tweet.author}\n${tweet.text}\n`).join('\n')}\n\n[COLOR=rgb(184, 49, 47)][B][SIZE=5]To post tweets in this format, more info here: [URL]https://www.thecoli.com/threads/tips-and-tricks-for-posting-the-coli-megathread.984734/post-52211196[/URL][/SIZE][/B][/COLOR]\n[/SPOILER]`
  135.         ].join('\n');
  136.  
  137.         remainingFormattedText = remainingFormattedText.replace(/(\d+\/\d+)\s@/g, '$1\n@');
  138.         if (finalFormattedText) {
  139.             finalFormattedText += '\n\n[threads continued]\n\n' + remainingFormattedText;
  140.         } else {
  141.             finalFormattedText = remainingFormattedText;
  142.         }
  143.     } else if (tweetTexts.length > 0) {
  144.        
  145.        
  146.         var remainingFormattedText = `\n` + [
  147.             window.location.href.replace('nitter.poast.org', 'twitter.com').replace('xcancel.com', 'twitter.com').split('?')[0],
  148.             `[SPOILER="full text & large images"]\n\n${tweetTexts.map((tweet, index) => `${globalTweetCount - tweetTexts.length + index + 1}/${globalTweetCount}\n@${tweet.author}\n${tweet.text}\n`).join('\n')}\n\n[COLOR=rgb(184, 49, 47)][B][SIZE=5]To post tweets in this format, more info here: [URL]https://www.thecoli.com/threads/tips-and-tricks-for-posting-the-coli-megathread.984734/post-52211196[/URL][/SIZE][/B][/COLOR]\n[/SPOILER]`
  149.         ].join('\n');
  150.  
  151.         remainingFormattedText = remainingFormattedText.replace(/(\d+\/\d+)\s@/g, '$1\n@');
  152.         finalFormattedText = remainingFormattedText;
  153.     }
  154.  
  155.    
  156.     var textArea = document.createElement('textarea');
  157.     textArea.value = finalFormattedText;
  158.     document.body.appendChild(textArea);
  159.     textArea.select();
  160.     document.execCommand('copy');
  161.     document.body.removeChild(textArea);
  162.  
  163.     var notificationBox = document.createElement('div');
  164.     notificationBox.style.position = 'fixed';
  165.     notificationBox.style.bottom = '20px';
  166.     notificationBox.style.left = '20px';
  167.     notificationBox.style.padding = '10px';
  168.     notificationBox.style.backgroundColor = 'white';
  169.     notificationBox.style.border = '1px solid black';
  170.     notificationBox.innerText = `Copied: ${globalTweetCount} tweets`;
  171.     document.body.appendChild(notificationBox);
  172.  
  173.     setTimeout(function() {
  174.         notificationBox.style.opacity = '0';
  175.         setTimeout(function() {
  176.             document.body.removeChild(notificationBox);
  177.         }, 1000);
  178.     }, 2000);
  179.  
  180.     console.log('Tweet collection process completed and copied to clipboard.');
  181. })();
Advertisement
Add Comment
Please, Sign In to add comment