2

i want to create a chrome extension that read what's currently on the clipboard. i tried the Chrome Clipboard API, but it didn't work for me.

var clipboardData = navigator.clipboard.readText('text');
alert(clipboardData);

1 Answers1

1

readText returns a Promise. You have to wait for it to resolve:

navigator.clipboard.readText().then(function (clipboardData) {
  alert(clipboardData);
});
Ates Goral
  • 126,894
  • 24
  • 129
  • 188