Skip to content

Commit

Permalink
Update raw.js
Browse files Browse the repository at this point in the history
  • Loading branch information
ulrischa authored Dec 18, 2024
1 parent 9e11cc8 commit a634705
Showing 1 changed file with 2 additions and 27 deletions.
29 changes: 2 additions & 27 deletions raw.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
<head>
<meta charset="UTF-8">
<title>Chat Export</title>
<link rel="stylesheet" href="https://unpkg.com/mvp.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/styles/default.min.css">
<style>
.w-fit {
width: fit-content;
Expand Down Expand Up @@ -127,31 +126,7 @@
// Close HTML content
htmlContent += `
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/highlight.min.js"></script>
<script>
hljs.highlightAll();
document.querySelectorAll("button.flex.gap-1.items-center.select-none.py-1").forEach(btn => {
btn.addEventListener("click", function () {
var pre = btn.closest("pre");
if (pre) {
var code = pre.querySelector("code");
if (code) {
var textarea = document.createElement("textarea");
textarea.value = code.innerText;
document.body.appendChild(textarea);
textarea.select();
try {
document.execCommand("copy");
alert("Code copied to clipboard.");
} catch (e) {
alert("Failed to copy code.");
}
document.body.removeChild(textarea);
}
}
});
});
</script>
</body>
</html>
`;
Expand Down

0 comments on commit a634705

Please sign in to comment.