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);
});
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…