Guest User

Untitled

a guest
Nov 8th, 2025
8
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-universal');
  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.     function universalizeUrl(url) {
  13.         if (!url) return url;
  14.        
  15.        
  16.         var urlStr = url.toString();
  17.         var urlObj;
  18.        
  19.         try {
  20.             urlObj = new URL(urlStr);
  21.            
  22.            
  23.             if (urlObj.pathname.includes('/status/')) {
  24.                
  25.                 urlObj.hostname = 'twitter.com';
  26.                 urlObj.protocol = 'https:';
  27.                
  28.                 urlObj.search = '';
  29.                 return urlObj.href.split('?')[0];
  30.             }
  31.            
  32.            
  33.             return urlObj.href.split('?')[0];
  34.            
  35.         } catch (e) {
  36.            
  37.             if (urlStr.includes('/status/')) {
  38.                
  39.                 var statusMatch = urlStr.match(/(\/status\/\d+)/);
  40.                 if (statusMatch) {
  41.                     return 'https://twitter.com' + statusMatch[1];
  42.                 }
  43.             }
  44.             return urlStr;
  45.         }
  46.     }
  47.    
  48.    
  49.     var originalAuthor = null;
  50.     var firstTweet = tweets[0];
  51.     if (firstTweet) {
  52.         var firstAuthor = firstTweet.querySelector('.username');
  53.         if (firstAuthor) {
  54.             originalAuthor = firstAuthor.textContent.slice(1);
  55.             console.log('Original author identified:', originalAuthor);
  56.         }
  57.     }
  58.    
  59.    
  60.     var originalAuthorTweetUrls = [];
  61.     tweets.forEach(function(tweet) {
  62.         var tweetAuthor = tweet.querySelector('.username');
  63.         if (tweetAuthor && tweetAuthor.textContent.slice(1) === originalAuthor) {
  64.             var tweetLink = tweet.querySelector('.tweet-link a') ||
  65.                            tweet.querySelector('.tweet-avatar + a') ||
  66.                            tweet.querySelector('a.tweet-link') ||
  67.                            tweet.querySelector('a[href*="/status/"]:not([href*="/photo/"])');
  68.            
  69.             if (tweetLink) {
  70.                 var tweetUrl = universalizeUrl(tweetLink.href);
  71.                 originalAuthorTweetUrls.push(tweetUrl);
  72.             }
  73.         }
  74.     });
  75.    
  76.     console.log('Original author tweet URLs:', originalAuthorTweetUrls);
  77.    
  78.    
  79.     tweets.forEach(function(tweet, tweetIndex) {
  80.         var tweetAuthor = tweet.querySelector('.username');
  81.         if (tweetAuthor) {
  82.             var currentAuthor = tweetAuthor.textContent.slice(1);
  83.             var tweetText = tweet.querySelector('.tweet-content').innerHTML;
  84.            
  85.            
  86.             tweetText = tweetText.replace(/<a[^>]+href="([^"]+)"[^>]*>@<[^<]+<\/a>/g, (match, p1) => {
  87.                 var cleanUrl = universalizeUrl(p1);
  88.                 return `[U][URL]${cleanUrl}[/URL][/U]`;
  89.             });
  90.            
  91.             tweetText = tweetText.replace(/<a[^>]+href="([^"]+)"[^>]*>[^<]+<\/a>/g, (match, p1) => {
  92.                 var cleanUrl = universalizeUrl(p1);
  93.                 return `[U][URL]${cleanUrl}[/URL][/U]`;
  94.             });
  95.            
  96.             tweetText = tweetText.replace(/<br>/g, '\n');
  97.            
  98.            
  99.             tweetText = tweetText.replace(/<span[^>]+data-sanitized-url="([^"]+)"[^>]*>[^<]+<\/span>/g, (match, p1) => {
  100.                 var cleanUrl = universalizeUrl(p1);
  101.                 return `[U][URL]${cleanUrl}[/URL][/U]`;
  102.             });
  103.            
  104.             tweetText = tweetText.replace(/<span[^>]+data-url="([^"]+)"[^>]*>[^<]+<\/span>/g, (match, p1) => {
  105.                 var cleanUrl = universalizeUrl(p1);
  106.                 return `[U][URL]${cleanUrl}[/URL][/U]`;
  107.             });
  108.            
  109.             tweetText = tweetText.replace(/<span[^>]+data-expanded-url="([^"]+)"[^>]*>[^<]+<\/span>/g, (match, p1) => {
  110.                 var cleanUrl = universalizeUrl(p1);
  111.                 return `[U][URL]${cleanUrl}[/URL][/U]`;
  112.             });
  113.            
  114.             tweetText = tweetText.replace(/<span[^>]+title="([^"]+)"[^>]*>[^<]+<\/span>/g, (match, p1) => {
  115.                 var cleanUrl = universalizeUrl(p1);
  116.                 return `[U][URL]${cleanUrl}[/URL][/U]`;
  117.             });
  118.            
  119.             tweetText = tweetText.replace(/]*>/g, '\n');
  120.             tweetText = tweetText.replace(/<[^>]+>/g, '');
  121.             tweetText = tweetText.replace(/ /g, ' ');
  122.            
  123.             var images = Array.from(tweet.querySelectorAll('.attachment.image img'));
  124.             var imageUrlsForThisTweet = images.map(img => {
  125.                 var src = decodeURIComponent(img.src);
  126.                 var url = new URL(src, window.location.href);
  127.                 url.hostname = 'pbs.twimg.com';
  128.                 url.pathname = url.pathname.replace('/pic/', '/media/').replace('/media/media/', '/media/');
  129.                 url.pathname = url.pathname.replace(/\/media\/.*\/media\//, '/media/');
  130.                 url.search = '';
  131.                 return `[img]${url.href}[/img]`;
  132.             }).join('\n');
  133.             imgCounter += images.length;
  134.            
  135.             if (imageUrlsForThisTweet) {
  136.                 tweetText += `\n\n${imageUrlsForThisTweet}`;
  137.             }
  138.            
  139.             var videos = Array.from(tweet.querySelectorAll('video'));
  140.             var videoUrlsForThisTweet = videos.map(video => {
  141.                 var source = video.querySelector('source');
  142.                 if (source && source.src) {
  143.                     var src = source.src;
  144.                     if (src && (src.startsWith('https://video') && (src.includes('twimg.com/ext_tw_video/') || src.includes('twimg.com/amplify_video/')))) {
  145.                         src = src.split('?')[0];
  146.                         return `[U][URL]${src}[/URL][/U]`;
  147.                     }
  148.                 }
  149.                 return '';
  150.             }).filter(url => url !== '').join('\n');
  151.            
  152.             if (videoUrlsForThisTweet) {
  153.                 tweetText += `\n\n${videoUrlsForThisTweet}`;
  154.             }
  155.            
  156.             globalTweetCount++;
  157.             totalTweetCount++;
  158.             tweetTexts.push({
  159.                 text: tweetText,
  160.                 author: currentAuthor,
  161.                 index: globalTweetCount,
  162.                 isOriginalAuthor: (currentAuthor === originalAuthor)
  163.             });
  164.            
  165.             if (imgCounter >= 20 || tweetIndex === tweets.length - 1) {
  166.                 if (tweetTexts.length > 0) {
  167.                    
  168.                     var batchOriginalAuthorUrls = [];
  169.                     var currentBatchStartIndex = globalTweetCount - tweetTexts.length;
  170.                    
  171.                    
  172.                     tweetTexts.forEach((tweetObj, batchIndex) => {
  173.                         if (tweetObj.isOriginalAuthor) {
  174.                             var absoluteIndex = currentBatchStartIndex + batchIndex;
  175.                             if (originalAuthorTweetUrls[absoluteIndex]) {
  176.                                 batchOriginalAuthorUrls.push(originalAuthorTweetUrls[absoluteIndex]);
  177.                             }
  178.                         }
  179.                     });
  180.                    
  181.                     var formattedText = '';
  182.                     var currentPageUrl = universalizeUrl(window.location.href);
  183.                    
  184.                     if (batchOriginalAuthorUrls.length > 1) {
  185.                        
  186.                         var firstTweetUrl = batchOriginalAuthorUrls[0];
  187.                         var remainingTweetUrls = batchOriginalAuthorUrls.slice(1);
  188.                        
  189.                         formattedText = `\n` + [
  190.                             firstTweetUrl,
  191.                             `[SPOILER="thread continued"]\n${remainingTweetUrls.join('\n')}\n[/SPOILER]`,
  192.                             `[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]`
  193.                         ].join('\n');
  194.                     } else if (batchOriginalAuthorUrls.length === 1) {
  195.                        
  196.                         formattedText = `\n` + [
  197.                             batchOriginalAuthorUrls[0],
  198.                             `[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]`
  199.                         ].join('\n');
  200.                     } else {
  201.                        
  202.                         formattedText = `\n` + [
  203.                             currentPageUrl,
  204.                             `[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]`
  205.                         ].join('\n');
  206.                     }
  207.                    
  208.                     formattedText = formattedText.replace(/(\d+\/\d+)\s@/g, '$1\n@');
  209.                     outputChains.push(formattedText);
  210.                    
  211.                     imgCounter = 0;
  212.                     tweetTexts = [];
  213.                 }
  214.             }
  215.         }
  216.     });
  217.    
  218.     var finalFormattedText = outputChains.join('\n\n');
  219.    
  220.     var textArea = document.createElement('textarea');
  221.     textArea.value = finalFormattedText;
  222.     document.body.appendChild(textArea);
  223.     textArea.select();
  224.     document.execCommand('copy');
  225.     document.body.removeChild(textArea);
  226.    
  227.     var notificationBox = document.createElement('div');
  228.     notificationBox.style.position = 'fixed';
  229.     notificationBox.style.bottom = '20px';
  230.     notificationBox.style.left = '20px';
  231.     notificationBox.style.padding = '10px';
  232.     notificationBox.style.backgroundColor = 'white';
  233.     notificationBox.style.border = '1px solid black';
  234.     notificationBox.innerText = `Copied: ${globalTweetCount} tweets (Original: ${originalAuthor})`;
  235.     document.body.appendChild(notificationBox);
  236.    
  237.     setTimeout(function() {
  238.         notificationBox.style.opacity = '0';
  239.         setTimeout(function() {
  240.             document.body.removeChild(notificationBox);
  241.         }, 1000);
  242.     }, 2000);
  243.    
  244.     console.log('Tweet collection process completed and copied to clipboard.');
  245.     console.log('Original author tweet URLs found:', originalAuthorTweetUrls.length);
  246. })();
Advertisement
Add Comment
Please, Sign In to add comment