Break long text into chunks
In the past, websites used a hacky, synchronous command called document.execCommand('copy') to copy text.
This worked by programmatically creating an invisible text input on the screen, dumping the text into it, focusing the input, selecting all the text, and then simulating a Ctrl+C keystroke. It was unreliable, blocked the main UI thread, and lacked proper security checks.
Modern applications (like this tool) use the navigator.clipboard.writeText() API.
It is asynchronous (returns a Promise), meaning it doesn't freeze the webpage while it waits for the underlying operating system to confirm the copy operation.
The ability to silently read or write to a user's clipboard is a massive security risk, so modern browsers restrict it heavily:
NotAllowedError unless the copy was triggered directly by a real user gesture (like a click or touch event).Why will a script fail if it tries to copy text to the clipboard exactly 10 seconds after the page loads?