blob: 368f712dc19294a19c4b42e6a29f3c7f048ff117 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
window.onload = () => {
document.querySelectorAll(".copy").forEach((element) => {
const tooltip = document.createElement("span");
tooltip.textContent = " [copy]";
element.appendChild(tooltip);
element.addEventListener("click", () => {
try {
navigator.clipboard.writeText(element.attributes["copy-text"]?.value);
tooltip.textContent = " [copied]";
} catch (error) {
tooltip.textContent = " [error]";
}
setTimeout(() => (tooltip.textContent = " [copy]"), 1000);
});
});
};
|