I am developing a chrome extension, which injects two separate content scripts…
- User
I am developing a chrome extension, which injects two separate content scripts (topFrame.js and aboutBlank.js) into the same targeted page. The two content scripts work together to hide/show certain UI elements on the page, depending on certain conditions.
I am trying to issue a Custom DOM Event from the aboutBlank.js script and have it be received by the topFrame.js script. However, it doesn't seem to be working. In the chrome extension platform, is such a thing not possible?
I know that there are other ways for content scripts to communicate with one another (e.g. chrome.runtime.sendMessage and then using the Extension Service Worker to relay the message to the other content script via chrome.tabs.sendMessage), but I am specifically trying to understand whether or not sending/receiving custom DOM events is possible between two content scripts within the same chrome extension.
Here are the relevant sections of my code...
// aboutBlank.js
setTimeout(() => { console.log(`About to dispatch "test-event-from-about". (ts: ${ts()})`) window.dispatchEvent(new Event("test-event-from-about")); }, 1000); }// topFrame.js
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.