I've developed a Firefox Addon which has a feature of copying some text automatically when the popup window is open. But it doesn't work and gives me this error message.
uncaught (in promise) DOMException: clipboard write was blocked due to lack of user activation.
this works fine on Chrome.
I used clipboard API to do this.
navigator.clipboard.writeText(data).then(()=>{
console.log('copied')
})
Any thoughts to bypass this or fix this?
CodePudding user response:
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