Copy-Paste Hack using JavaScript

How to reproduce

Step 1 - Copy this line of code:

echo "This code looks safe!"

Step 2 - Paste it in a bash terminal or (to stay safe) in the box below:

How it works behind the scenes

Using plain JavaScript we detect every time there is a "copy" event on that text.
When it happens, we set the clipboard content of the user with a different code, as we wish.
We also add a "\n" to simulate the Enter key and execute the code right away.
Sounds scary, right?

The full JavaScript script is less than 10 lines.
You can find more details about the exploit on my repository on GitHub.