4

I've developed a Firefox Addon which has a feature of copying some text automatically when the popup window is open. This works fine on Chrome, but it doesn't work in Firefox, and gives me this error message.

uncaught (in promise) DOMException: clipboard write was blocked due to lack of user activation.

I use the clipboard API to do this.

navigator.clipboard.writeText(data).then(()=>{
    console.log('copied')
})

Any thoughts to bypass this or fix this?

pbarney
  • 2,529
  • 4
  • 35
  • 49
ChethiyaKD
  • 726
  • 2
  • 7
  • 13

1 Answers1

4

You extensions needs to have the clipboardWrite permission to write to the clipboard without user interaction. https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions#clipboard_access

evilpie
  • 2,718
  • 20
  • 21
  • I am writing a little single-usage-hack for myself to execute in the Firefox console and get the same error message when I try to write data to the clipboard. How do I get around that? – d-b Jun 06 '23 at 19:15