I'm trying to achieve a simple action on a Google Chrome extension: when user is on a tab, it could click on the extension icon, and something (like a string) will be copied into its clipboard.
The only thing that I don't know how to deal with in this process is the copy action to the clipboard. Can you help me on this?
What I've done so far:
- added the clipboardWrite
permission to my manifest.json
- added the browser_action
section to my manifest.json
to handle click on the icon extension
- added something like this into my background.js
file:
chrome.browserAction.onClicked.addListener((tab) => {
console.log(tab.url);
const string = "something";
// Here I need to add code to copy `string` to clipboard, looking for a way to do it
});
Any help on this would be useful :)