mirror of
https://github.com/mdn/webextensions-examples.git
synced 2026-04-24 02:02:53 +02:00
b1154b6caf
* selection-to-text example * update icon * update icon * use clipboard icon * update with requested changes * updated strict version and wrapped clipboard copy in setTimeout to force permissions * add note about clipboardWrite permissions inside browser event. removed permissions and setTimeout
22 lines
757 B
Markdown
22 lines
757 B
Markdown
# selection-to-clipboard
|
|
|
|
## 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](https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Interact_with_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](https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Interact_with_the_clipboard.)
|