User:Divon23/common.js

javascript:(function{const paragraphs = document.querySelectorAll('p'); let touchTimeout; for (const paragraph of paragraphs) { paragraph.addEventListener('touchstart', function(event) { const target = event.target; if (target.classList.contains('double-tap')) { clearTimeout(touchTimeout); copyToClipboard(target.textContent); target.classList.remove('double-tap'); } else { target.classList.add('double-tap'); touchTimeout = setTimeout(function { target.classList.remove('double-tap'); }, 500); } }); } function copyToClipboard(text) { const textarea = document.createElement('textarea'); textarea.value = text; document.body.appendChild(textarea); textarea.select; document.execCommand('copy'); document.body.removeChild(textarea);} });