I'm new to chrome-extension. I'm trying to inject a frame-content.js to an iframe inside my website and I'm succeeded in injecting the frame-content. But after injecting the frame content and again when I try to communicate with the frame-content (from my website), I fails to connect with the frame-content. I think it's because I'm trying to inject the frame-content again which I already injected. so how to fix it? what should be the code inside the else condition?
if(!contentFrameInjected) {
chrome.tabs.query({ active: true }, (tabs) => {
chrome.tabs.executeScript(tabs[0].id, {
frameId: <id of the frame>,
file: 'frame-content.js'
});
});
} else {
/* how to execute already injected frame-content.js*/
}