Files
webextensions-examples/selection-to-clipboard
rebloor 82217a05bc Replace var with let in examples (#484)
* Replace var with let in examples

store-collected-images/webextension-plain/deps/uuidv4.js

* Reverted third–party code
2022-08-11 04:27:28 +12:00
..
2016-11-03 14:30:44 -07:00
2017-11-14 18:51:37 -08:00

selection-to-clipboard

This add-on injects JavaScript into web pages. The addons.mozilla.org domain disallows this operation, so this add-on will not work properly when it's run on pages in the addons.mozilla.org domain.

What it does

This extension includes:

  • a content script, "content-script.js", that is injected into all pages

The content script listens for text selections in the page it's attached to and copies the text to the clipboard on mouse-up.

What it shows

  • how to inject content scripts declaratively using manifest.json
  • how to write to the clipboard

Note

  • If the copySelection function was in a browser event clipboardWrite permissions would be required e.g.
"permissions": ["clipboardWrite"]

See Interact with the clipboard.