javascript:(function() { console.log('Starting tweet collection process...'); var tweets = Array.from(document.querySelectorAll('article[data-testid="tweet"]')); console.log('Found', tweets.length, 'tweets on the page.'); if (tweets.length === 0) { console.log('No tweets found. Exiting...'); return; } var firstTweetUrl = tweets[0].querySelector('a[href*="/status/"]').href; var username = firstTweetUrl.split('/')[3]; console.log('Identified username:', username); var userTweets = []; var tweetTexts = []; tweets.forEach(tweet => { var tweetUrl = tweet.querySelector('a[href*="/status/"]').href; if (tweetUrl.includes(`/${username}/status/`) && !userTweets.includes(tweetUrl)) { userTweets.push(tweetUrl); } }); console.log('Collecting tweet texts...'); userTweets.forEach((tweetUrl, index) => { var tweetText = tweets.find(tweet => tweet.querySelector('a[href*="/status/"]').href === tweetUrl)?.querySelector('div[data-testid="tweetText"]')?.innerText || ''; if (tweetText) { tweetText = tweetText.replace(/https?:\/\/[^\s]+/g, function(url) { var truncatedUrl = url.replace(/…$/, ''); return `[U][URL]${truncatedUrl}[/URL][/U]`; }); var youtubeLinks = tweetText.match(/https?:\/\/(?:www\.)?youtube\.com\/watch\?v=\w+/g); if (youtubeLinks) { youtubeLinks.forEach(link => { tweetText = tweetText.replace(link, `[U][URL]${link}[/URL][/U]`); }); } console.log('Tweet', index + 1, 'text:', tweetText); tweetTexts.push(tweetText); } else { console.log('Tweet text not found for tweet', index + 1); return; } }); console.log('Collected', tweetTexts.length, 'tweet texts.'); var imageUrls = tweets.flatMap(tweet => { var images = Array.from(tweet.querySelectorAll('img[src^="https://pbs.twimg.com/media/"]')); return images.map(img => { var src = img.src; var match = src.match(/https:\/\/pbs\.twimg\.com\/media\/([^?]+)\?format=([^&]+)/); if (match) { var filename = match[1]; var format = match[2]; return `[img]https://pbs.twimg.com/media/${filename}.${format}[/img]`; } return ''; }).filter(Boolean); }); console.log('Collected', imageUrls.length, 'image URLs.'); var textArea = document.createElement('textarea'); var tweetText = ''; tweetTexts.forEach((body, index) => { body = body.replace(/@(\w+)\n/, `@$1 `); tweetText += `\n${index + 1}/${tweetTexts.length}\n${body}\n`; }); textArea.value = `\n` + [ window.location.href, `[SPOILER="thread continued"]\n${userTweets.slice(1).join('\n')}\n[/SPOILER]`, `[SPOILER="full text"]\n\n${tweetText}\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]`, `[SPOILER="larger images"]\n${imageUrls.join('\n')}\n[/SPOILER]` ].join('\n'); document.body.appendChild(textArea); textArea.select(); document.execCommand('copy'); document.body.removeChild(textArea); var notificationBox = document.createElement('div'); notificationBox.style.position = 'fixed'; notificationBox.style.bottom = '20px'; notificationBox.style.left = '20px'; notificationBox.style.padding = '10px'; notificationBox.style.backgroundColor = 'white'; notificationBox.style.border = '1px solid black'; notificationBox.innerText = 'Copied: ' + imageUrls.length + ' links and ' + tweetTexts.length + ' tweets'; document.body.appendChild(notificationBox); setTimeout(function() { notificationBox.style.opacity = '0'; setTimeout(function() { document.body.removeChild(notificationBox); }, 1000); }, 2000); console.log('Tweet collection process completed.'); })();