From 0556bf7618639e598c006b11b460995117d23cc2 Mon Sep 17 00:00:00 2001 From: andrew Date: Thu, 11 May 2023 10:47:30 -0400 Subject: [PATCH] Solution for http --- Templates/OpenBench/test.html | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/Templates/OpenBench/test.html b/Templates/OpenBench/test.html index e26bd19..bb376d7 100644 --- a/Templates/OpenBench/test.html +++ b/Templates/OpenBench/test.html @@ -9,10 +9,31 @@ {% block scripts %} function copy_statblock() { + var text = document.getElementById("long-statblock").innerHTML; text = text.replace(/
/g, "\n"); text += "\n" + window.location.href; - navigator.clipboard.writeText(text); + + // navigator.clipboard.writeText(text); // Optimal solution + + // Suboptimal, HTTP solution + + var area = document.createElement("textarea"); + area.value = text; + document.body.append(area); + + area.focus(); + area.select(); + + try { + document.execCommand("copy"); + document.body.removeChild(area); + } + + catch (err) { + document.body.removeChild(area); + console.error("Unable to copy to Clipboard"); + } } {% endblock %}