I have an event for paste in a BrowserAction and I need to send either the Event object or its clipboardData.items property to a Background Script.
I've tried extracting the contents, but it doesn't retain the properties / methods.
Any normal object works, but Event objects do not retain their values.
I've also tried deep copies using Object.assign, but the contents are never passed to the Background script when using chrome.runtime.sendMessage().
Really appreciate the help as all my work goes to the trash if I can't get this to work.
My goal is to read an image file from the clipboard and then upload it to a website. Here's the relevant code to the problem I have:
const body = document.querySelector('body');
body.addEventListener('paste', (event) => {
const item = [...event.clipboardData.items].pop();
const message = {
fn: 'pasteEvent',
text: item
}
chrome.runtime.sendMessage(message);
});