I'm having a hard time finding any recent info on how to add a listener for "Ctrl+C", fetching clipboard data, and then writing back to clipboard all in a Chrome Extension. All of the old code that i found was for the older versions that are now deprecated.
To find it, open a new tab, paste chrome://flags into Chrome's Omnibox and then press the Enter key. Search for “Clipboard” in the search box.
clipboard API is provided to allow users to access data of the clipboard. This is a temporary solution for chromeos platform apps until open-web alternative is available.
2. Right click and select "Copy" or press on CTRL+C (Windows) / CMD+C (MAC). 3. Click on the Easy Clipboard extension to view saved text snippets!
Basically you can manipulate clipboard using document.execCommand('paste|copy|cut')
.
You'll need to specify "clipboardWrite"
and/or "clipboardRead"
permissions in manifest.
"clipboardRead" Required if the extension or app uses document.execCommand('paste').
"clipboardWrite" Indicates the extension or app uses document.execCommand('copy') or document.execCommand('cut'). This permission is required for hosted apps; it's recommended for extensions and packaged apps.
Create <input>
element (or <textarea>
)
document.execCommand('paste')
<input>
value
attribute.This worked for me to copy data to clipboard.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With