I wanted to create very small extension for website that will automatically copy some value to the clipboard.
The problem is that I want it to copy the value even if browser is not focused e.g.:
- I open the website, my extension listens to the change on the page
- I open different application
- If something changes on the page then the extension should copy some value
- Main application that I'm working with is still focused but I can CTRL+V paste value copied from the website without alt+tab
I tried to use Clipboard API:
navigator.clipboard.writeText(...)
but I don't think it will work because browser have to be focused(I think).
When page is focused then copying works fine. If I try to switch to different application I get an exception when my extension tries to copy the value:
DOMException: Document is not focused.
Is there any way to do this?