var buttons = document.querySelectorAll("[role='copy']");

buttons.forEach(button => {
    button.addEventListener('click',(e)=>{
        button = e.target;
		var textToCopy = button.previousElementSibling?.innerHTML;
		var $temp = $("<input>");
		$("body").append($temp);
		$temp.val(textToCopy).select();
		document.execCommand("copy");
		$temp.remove();
		
        button.innerHTML = "Copied!"

        setTimeout(() => {
            button.innerHTML = "Copy"
        },2000)
    }, false)
});