Following Copy/Paste code not working in Chrome Extension, I need to write Chrome Extension that copy and paste data using clipboard.
I write following code in Backgrou
To eliminate the obvious; have you added the "experimental" permission to your manifest and are you using the latest dev build of Chrome as listed in the official documentation?
Otherwise, I'm not sure what may help you as I don't use the experimental API due to them not being usable in production. There is a workaround for copying without using the experimental API (using an input field and document.execCommand) but I'm not sure how to paste without it.
EDIT:
I've just noticed that experimental.clipboard
is not longer listed on the experimental API page. It may be that this namespace has been deprecated/abandoned as can happen when using the experimental API. A simple test for this would be inserting;
console.log(typeof chrome.experimental.clipboard);
console.log(typeof chrome.experimental.clipboard.executeCopy);
console.log(typeof chrome.experimental.clipboard.executePaste);
Which should output the following the console for your background page;
> object
> function
> function
As of Chrome 13, clipboard access is no longer experimental.
The commands are now document.execCommand('paste')
, document.execCommand('copy')
and document.execCommand('cut')
.
However, permissions need to be added to your manifest: "clipboardRead"
and "clipboardWrite"
.
Try implementing the above and see how you get on.