0

I am writing a Chrome Extension. Every time the user copies something, my extension should capture the copied text. I read that access to the clipboard is a security concern. However there is a clipboardRead and clipboardWrite permission according to https://developer.chrome.com/extensions/declare_permissions

Is it possible in any way?

Kevin Desai
  • 317
  • 3
  • 22

3 Answers3

2

It says in the link you posted that the permission is used with document.execCommand('paste'), you could easily write a function to monitor changes in the clipboard, and then do more when you find it was modified since the last check.

Anonymous
  • 46
  • 1
1

You can use

document.execCommand('paste');
document.execCommand('copy');
document.execCommand('cut');

to interact with the clipboard.

I think you can find the documentation here (for firefox, at least): https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand

Clément Berthou
  • 1,928
  • 1
  • 13
  • 12
0

You need to trap the copy action event, and then read the clipboard in a background page. These answers should help:

Google Chrome Extensions: How to detect Copy action (Ctrl-C and Edit-Copy)?

How to read the Clipboard text in google chrome extension

Community
  • 1
  • 1
David Jeske
  • 2,306
  • 24
  • 29