javascript:(function() { console.log('Starting tweet collection process...'); var tweets = Array.from(document.querySelectorAll('.timeline-item')); console.log('Found', tweets.length, 'tweets on the page.'); if (tweets.length === 0) { console.log('No tweets found. Exiting...'); return; } var username = document.querySelector('.username'); if (username) { username = username.textContent.slice(1); console.log('Identified username:', username); } else { console.log('Username not found. Exiting...'); return; } var userTweets = []; var tweetTexts = []; tweets.forEach(tweet => { var tweetLink = tweet.querySelector('.tweet-link'); var tweetAuthor = tweet.querySelector('.username'); if (tweetAuthor && tweetAuthor.textContent.slice(1) === username) { if (tweetLink) { var tweetLinkHref = new URL(tweetLink.href, window.location.href); var newUrl = tweetLinkHref.href.replace(tweetLinkHref.hostname, 'twitter.com'); if (newUrl && newUrl.includes(`/${username}/status/`) && !userTweets.includes(newUrl)) { userTweets.push(newUrl); } } } }); console.log('Collecting tweet texts...'); tweets.forEach((tweet, index) => { var tweetAuthor = tweet.querySelector('.username'); if (tweetAuthor && tweetAuthor.textContent.slice(1) === username) { var tweetContent = tweet.querySelector('.tweet-content'); if (tweetContent) { var tweetText = tweetContent.innerHTML; tweetText = tweetText.replace(/[^<]+<\/a>/g, (match, p1) => `[U][URL]${p1}[/URL][/U]`); tweetText = tweetText.replace(/]*>/g, '\n'); tweetText = tweetText.replace(/<[^>]+>/g, ''); tweetText = tweetText.replace(/ /g, ' '); console.log('Tweet', index + 1, 'text:', tweetText); tweetTexts.push(tweetText); } else { console.log('Tweet text not found for tweet', index + 1); } } }); console.log('Collected', tweetTexts.length, 'tweet texts.'); var imageUrls = tweets.flatMap(tweet => { var tweetAuthor = tweet.querySelector('.username'); if (tweetAuthor && tweetAuthor.textContent.slice(1) === username) { var images = Array.from(tweet.querySelectorAll('.attachment.image img')); return images.map(img => { var src = decodeURIComponent(img.src); var url = new URL(src, window.location.href); url.hostname = 'pbs.twimg.com'; url.pathname = url.pathname.replace('/pic/', '/media/').replace('/media/media/', '/media/'); url.search = ''; return `[img]${url.href}[/img]`; }); } else { return []; } }); console.log('Collected', imageUrls.length, 'image URLs.'); var originalUrl = window.location.href; var originalUrlObj = new URL(originalUrl); originalUrlObj.hostname = 'twitter.com'; originalUrl = originalUrlObj.href; var threadContinuedUrls = userTweets.slice(0); var tweetText = ''; tweetTexts.forEach((body, index) => { body = body.replace(/@(\w+)\n/, `@$1 `); tweetText += `\n${index + 1}/${tweetTexts.length}\n${body}\n`; }); var formattedText = `\n` + [ originalUrl, `[SPOILER="thread continued"]\n${threadContinuedUrls.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'); var textArea = document.createElement('textarea'); textArea.value = formattedText; 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 and copied to clipboard.'); })();