Hi guys,
I finally made it!
The Clipboard API allows access from a background script, but cannot listen to change events. To listen for change events, we need to use a content script and add an event to the page. In my case, I didn’t want to inject content.js on every page just for this purpose, so I adopted the setInterval() approach which, unlike content.js, will allow me to get a new clipboard entry from any origin.
The goal of all this was to share the clipboard remotely, here’s the extension I made, tell me what you think.
Another thing I really wanted was to use WebRTC on the local network, which is possible in Chrome, but not yet in Firefox.
I think Firefox is asking for a use case according to this topic.
So, Firefox team, please allow us to do this without needing internet. My use case is often that I need to be offline on a virtual machine and copy and paste with the host or file sharing doesn’t work, so in that case I have no choice other than activating the internet and then share over it via other means that I may not trust for confidential documents.
And I use peerJs as a dependency in order to stabilize a WebRTC connection, it would be very nice if Firefox itself handled this pairing process natively.