Copy to clipboard

I’m trying to have the copy example from Github working on Nigthlly.

I keep having the msg An unexpected error occurred in the console…

I tried to add

“content_scripts”: [

{

  "matches": ["<all_urls>"],

 "js": ["clipboard-helper.js"]

}],

In the manifest without success.

Could someone explains me in practical terms how I can get see this example
at work ?

Thanks

François

Firefox blocks tabs.executeScript on certain locations like addons.mozilla.org, about:* pages etc.

Is that where you are testing the code?

Depending on the code, you may also need "clipboardWrite" in the "permissions"

  • I run web-ext in the directory where the manifest.json is
  • In Nightly, I open this page http://www.unifr.ch/dokpe
  • I select a link and right click on Copy link to clipboard

In the console window I see “Failed to copy text: Error: An unexpected error occurred” and I can see that the clipboard content has not changed.

The permissions are
"permissions": [
“activeTab”,
“contextMenus”,
“clipboardWrite”
]
}

Thanks
François

There is an error in your code. It is not possible to say where without seeing the code.

But the code comes from github.com/mdn/webextensions-examples/tree/master/context-menu-copy-link-with-types

https://github.com/mdn/webextensions-examples/tree/master/context-menu-copy-link-with-types

It’s not mine!
F.

There could be an error elsewhere.
You can also try asking Rob who wrote the code.