Hacker News new | ask | show | jobs
by coopsmgoops 2085 days ago
Maybe, but I'm pretty sure browsers block the clipboard functions unless they were triggered via user input. I don't know if a page load counts as a valid trigger.
1 comments

`document.execCommand("copy")` works without user input - https://developer.mozilla.org/en-US/docs/Web/API/Document/ex....
Nope.

> Conditions of having this behavior enabled vary from one browser to another, and have evolved over time.

If you're not running based on a click event, you'll certainly fail.

Perhaps extension code gets different rules. This code works in Firefox without needing interaction from the user: https://github.com/tridactyl/tridactyl/blob/5e8f94ff06bd5f14...
Extensions get different rules.