Skip to content

Instantly share code, notes, and snippets.

@gornostay25
Created October 29, 2025 11:24
Show Gist options
  • Select an option

  • Save gornostay25/cbf9de4cc5e9c749099181a430c8cdae to your computer and use it in GitHub Desktop.

Select an option

Save gornostay25/cbf9de4cc5e9c749099181a430c8cdae to your computer and use it in GitHub Desktop.
Telegram Chat Export HTML to Text
let msg = '';
[...document.querySelector('.history').children].forEach(elm =>{
if (elm.classList.contains("service")) return;
if (elm.classList.contains("joined")) {
const text = elm.querySelector(".text")?.textContent?.trim();
if (!text) return;
msg += `${text}\n`;
return
}
const from = elm.querySelector(".from_name")?.textContent?.trim();
const text = elm.querySelector(".text")?.textContent?.trim();
if (!from || !text) return;
msg += `${from}: ${text}\n`;
})
console.log(msg);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment