Created
June 19, 2025 13:18
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(() => { | |
const threads = document.querySelectorAll('[data-qa="slack_kit_list"]'); | |
if (!threads || threads.length < 3) { | |
// note: when you click view thread, there are three "slack_kit_list" items: sidebar, main channel, thread | |
return console.error('Thread container not found (need at least 3)'); | |
} | |
const thread = threads[2]; | |
const msgs = thread.querySelectorAll('.c-message_kit__thread_message'); | |
const result = Array.from(msgs) | |
.map(msg => { | |
const sender = msg.querySelector('[data-qa="message_sender"]')?.innerText.trim() || 'Unknown'; | |
const time = msg.querySelector('.c-timestamp__label')?.innerText.trim() || ''; | |
const bodyEl = msg.querySelector('div[data-qa="message-text"]'); | |
const body = bodyEl?.innerText.trim() || ''; | |
// prefix each line for GitHub quoting | |
const quotedBody = body | |
.split('\n') | |
.map(line => `> ${line}`) | |
.join('\n'); | |
return `> **${sender} [${time}]**\n${quotedBody}`; | |
}) | |
.filter(Boolean) | |
.join('\n\n'); | |
console.log(result); | |
return result; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment