Can someone explain how I can write to clipboard please? I've seen a lot of ways but I cant seem to understand how. Currently using manifest v3 and no background.js script.
popup.js (action: download)
-> contentscript.js (see below)
function listener(info) {
chrome.runtime.onMessage.addListener(
function (request, sender, sendResponse) {
if (!request.action) return sendResponse({
err: 'Error: No Request Action'
});
switch (request.action) {
case "copy":
var textCopy = info.links.join(', ').replace(/"/g, '') // Text to Copy (String)
navigator.clipboard.writeText(textCopy).then(() => {
sendResponse('success')
}, () => {
sendResponse('failed')
});
break;
// Other Requests
}
}
);
}