Last active
January 26, 2023 06:02
-
-
Save itsjavi/8912169c0781defd8079404255fc5074 to your computer and use it in GitHub Desktop.
Bookmark to download ChatGPT chat as Markdown
This file contains 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
// Copy the following line of code, and paste it prefixed with "javascript:" (without the quotes), in a browser bookmark | |
function h(html) { return html.replace(/<p>/g, '\n\n').replace(/<\/p>/g, '').replace(/<b>/g, '**').replace(/<\/b>/g, '**').replace(/<i>/g, '_').replace(/<\/i>/g, '_').replace(/<code[^>]*>/g, (match) => { const lm = match.match(/class="[^"]*language-([^"]*)"/); return lm ? %27\n```%27 + lm[1] + %27\n%27 : %27```%27; }).replace(/<\/code[^>]*>/g, %27```%27).replace(/<[^>]*>/g, %27%27).replace(/Copy code/g, %27%27).replace(/This content may violate our content policy. If you believe this to be in error, please submit your feedback — your input will aid our research in this area./g, %27%27).trim(); } (()=>{ const e=document.querySelectorAll(".text-base");let t="";for(const s of e)s.querySelector(".whitespace-pre-wrap")&&(t+=`**${s.querySelector(%27img%27)?%27You%27:%27ChatGPT%27}**: \n${h(s.querySelector(".whitespace-pre-wrap").innerHTML)}\n\n`);const o=document.createElement("a");o.download=window.document.title+".chat.md",o.href=URL.createObjectURL(new Blob([t])),o.style.display="none",document.body.appendChild(o),o.click()})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment