Guest User

Untitled

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