Auto-publish on Fri 8 Aug 18:27:52 BST 2025
This commit is contained in:
21
output/assets/script.js
Normal file
21
output/assets/script.js
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
// COPY BUTTON:
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
document.querySelectorAll("pre.src").forEach(function (block) {
|
||||
const button = document.createElement("button");
|
||||
button.innerText = "Copy";
|
||||
button.className = "copy-btn";
|
||||
|
||||
// Append button inside <pre>
|
||||
block.appendChild(button);
|
||||
|
||||
button.addEventListener("click", function () {
|
||||
const text = block.innerText.replace(button.innerText, ""); // exclude button text
|
||||
navigator.clipboard.writeText(text.trim()).then(() => {
|
||||
button.innerText = "Copied!";
|
||||
setTimeout(() => (button.innerText = "Copy"), 1500);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user