How to read the Clipboard text in google chrome extension
11,148
Once upon a time there was an experimental API chrome.experimental.clipboard, but there is no more http://code.google.com/chrome/extensions/trunk/experimental.clipboard.html
Maybe you should try: How do I copy to the clipboard in JavaScript?
UPDATE: I was wrong - there is a possibility. As permissions page says there are "clipboardRead" and "clipboardWrite" permissions. So maybe they will work for you.
Author by
Exception
Updated on June 04, 2022Comments
-
Exception almost 2 years
I am trying to read clipboard text in Google chrome extension. As of now I have tried with tis code and it is returning me undefined. Please help me on this.
In background.html my code is
chrome.extension.onRequest.addListener(function(request, sender, sendResponse) { if (request.method == "getClipData") sendResponse({data: document.execCommand('paste')}); else sendResponse({}); // snub them. });
In My content script my code is
chrome.extension.sendRequest({method: "getClipData"}, function(response) { alert(response.data); });