WebExtension - Read From Clipboard

I started to develop an addon for Firefox recently. The addon is just a toolbar button (browser_action). When it clicked, it will do simple changes on current page. But I couldn’t able to read the clipboard. Can you tell me how can read text from system’s clipboard?

Hi there,

I suggest you read this post and tell us if it helps you out.

https://discourse.mozilla-community.org/t/webextensions-adding-something-to-the-clipboard/9890/5

Best regards,
Larry P.

I could not do it myself. I don’t have sufficient knowledge to do. I need ready-to-use apis or documentation. I see now WebExtension very new technology and it’s not fully developed yet. So I decided to use Addon SDK to develop my addon. There is many high and low level apis with it.

This has nothing to do with WebExtensions not being not fully developed.
After specifying the permissions in the manifest, you can read/write the clipboard the same way websites so. I don’t think that will ever change.

The way websites interact with the clipboard is admittedly quite ugly. Here is a working wrapper that writes to the clipboard:

Regarding reading, I find it least invasive to simply prompt() the user to paste their data. That way a user can be sure the possibly privacy sensitive content of the clipboard is only read when they explicitly want it.