Skip to content

Instantly share code, notes, and snippets.

@SgtPooki
Last active July 29, 2025 16:41
Show Gist options
  • Save SgtPooki/59fc5b888c999389b7fdf6b117b75332 to your computer and use it in GitHub Desktop.
Save SgtPooki/59fc5b888c999389b7fdf6b117b75332 to your computer and use it in GitHub Desktop.
get slack thread discussion for posting to github issues as quoted by each user.
  1. Open a comment thread and scroll to the top
  2. copy this whole script and paste into the console
  3. scroll slowly to the bottom of the comment thread
  4. run getSlackTranscript() in the console
(() => {
const threads = document.querySelectorAll('[data-qa="slack_kit_list"]');
if (!threads || threads.length < 3) {
console.error('Thread container not found (need at least 3)');
return;
}
const thread = threads[2];
const messagesMap = new Map(); // key: unique, value: { ts, formatted }
function extractMessageInfo(msg) {
const senderEl = msg.querySelector('[data-qa="message_sender_name"]'); // FIXED
const timeAnchor = msg.querySelector('a[data-ts]');
const timeLabelEl = msg.querySelector('.c-timestamp__label');
const bodyEl = msg.querySelector('div[data-qa="message-text"]');
if (!senderEl || !timeAnchor || !timeLabelEl || !bodyEl) return null;
const sender = senderEl.textContent.trim(); // Now safe – just one copy
const timeText = timeLabelEl.textContent.trim();
const ts = timeAnchor.getAttribute('data-ts');
const bodyText = bodyEl.textContent.trim();
const quotedBody = bodyText
.split('\n')
.map(line => `> ${line}`)
.join('\n');
const formatted = `> **${sender} [${timeText}]**\n${quotedBody}`;
const key = `${sender}::${ts}::${bodyText}`;
return { key, ts, formatted };
}
function scanMessages() {
const msgs = thread.querySelectorAll('.c-message_kit__thread_message');
msgs.forEach(msg => {
const info = extractMessageInfo(msg);
if (info && !messagesMap.has(info.key)) {
messagesMap.set(info.key, { ts: parseFloat(info.ts), formatted: info.formatted });
}
});
}
// Initial scan
scanMessages();
const observer = new MutationObserver(() => {
scanMessages();
});
observer.observe(thread, {
childList: true,
subtree: true
});
window.getSlackTranscript = function () {
const sorted = Array.from(messagesMap.values())
.sort((a, b) => a.ts - b.ts)
.map(entry => entry.formatted)
.join('\n\n');
console.log(sorted);
return sorted;
};
console.info('✅ Slack thread tracker active. Run `getSlackTranscript()` to export the full, sorted, clean transcript.');
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment