Skip to content

Instantly share code, notes, and snippets.

@MOOOWOOO
Created April 12, 2023 04:10
Show Gist options
  • Save MOOOWOOO/b9ef6bf854729856287876489c997f7c to your computer and use it in GitHub Desktop.
Save MOOOWOOO/b9ef6bf854729856287876489c997f7c to your computer and use it in GitHub Desktop.
save chatGPT conversion to a markdown file
javascript: (function () { 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 ? '\n```' + lm[1] + '\n' : '```'; }).replace(/<\/code[^>]*>/g, '```').replace(/<[^>]*>/g, '').replace(/Copy code/g, '').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, '').trim(); } (() => { const e = document.querySelectorAll(".text-base"); let t = ""; for (const s of e) s.querySelector(".whitespace-pre-wrap") && (t += `**${s.querySelector('img') ? 'You' : 'ChatGPT'}**: ${h(s.querySelector(".whitespace-pre-wrap").innerHTML)}\n\n`); const now = new Date(); const formattedTime = now.getFullYear().toString() + (now.getMonth() + 1).toString().padStart(2, '0') + now.getDate().toString().padStart(2, '0') + now.getHours().toString().padStart(2, '0') + now.getMinutes().toString().padStart(2, '0') + now.getSeconds().toString().padStart(2, '0') + now.getMilliseconds().toString().padStart(3, '0');const o = document.createElement("a"); o.download = `Conversation.with.ChatGPT-${formattedTime}.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