Last active
February 17, 2023 18:02
-
-
Save cshanejennings/f52bc772c49a095e8838db09d88e9826 to your computer and use it in GitHub Desktop.
Save ChatGPT script as Markdown file
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
(function (CONFIG) { | |
const make_headlines = (toc, q) => [...toc, q.replace(/----\n###(.*)\n----/g,'* [[#$1]]')]; | |
const post_process = (str) => { | |
const with_headers = str.replace(/\*\*You\*\*:(.*)(\n\n\*\*ChatGPT)/g, "----\n###$1\n----$2") | |
.replace(/\*\*ChatGPT\*\*\:[\s]*/g, "#unconfirmed-chatgpt\n"); | |
const body_text = with_headers.split(/----\n### .*\n----/g).reduce((body, ans) => (ans) | |
? body.replace(ans, ans + '\n[[#Questions asked|Back to Questions]]\n\n') | |
: body, with_headers); | |
const toc = with_headers.match(/----\n\#\#\#.*\n----/g).reduce(make_headlines, ['## Questions asked to GPT', '----']).join('\n'); | |
return [toc, body_text].join('\n\n').trim(); | |
} | |
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 body = (CONFIG.encodeHTMLCHARS)? post_process(t.replace(/\>\;/g, ">").replace(/\<\;/g, "<")): post_process(t); | |
const o = document.createElement("a"); (o.download = CONFIG.DOC_TITLE + ".md"),(o.href = URL.createObjectURL(new Blob([body]))),(o.style.display = "none"),document.body.appendChild(o),o.click(); | |
})(); | |
})({ | |
DOC_TITLE: "ChatGPT: Laravel Queue and jobs", | |
encodeHTMLCHARS: false, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ChatGPT: is replaced with #unconfirmed-chatgpt for confirmation tracking via tagging