WebExtensions: Adding something to the clipboard

Can a WebExtension do that? I am working an an addon to get something from the page and, preferably, put it in the clipboard so the user can paste it somewhere.

Thanks

You can do it with Javascript. I cannot remember details but I have seen WYSYWIG editor (not sure if I have it written correctly) which enables to copy from clipboard so I think it should be possible by nature from browser. Try google - Javascript copy and paste.

It will be possible, you need special permissions for it (see clipboardRead and clipboardWrite on https://developer.chrome.com/extensions/declare_permissions). However it is not implemented yet in Firefox (see https://bugzilla.mozilla.org/show_bug.cgi?id=1197451).

1 Like

I see that I have not express myself correctly. I don’t want to copy from the page (I will be reading data from the DOM). Rather, I want to place a generated result onto the clipboard. Sorry about the confusion.

I know I can fake it by popping up a dialog box and asking the user to copy, but that’s not convenient for the user.

Thanks

The API I linked is exactly for that: so you can write arbitrary data to the clipboard (clipboardWrite). WebExtensions just have their own “background” page their run in, that’s why it looks like a website.

I see it now. The discussion appears to be covering multiple issues.

Short answer is not yet. Oh well, back to creating a dialog box.

Thanks