Guest User

Untitled

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