How can I access a page's window variable through Manifest v3.
In V2, I could have a content script access the window variable of a page by injecting javascript into the main page. However, appendChild() for javascript code does not work on V3.
I tried using scripting.executeScript but this still has no effect in being able to access the window variable (the DOM is accessible).
For example the following code supposedly injects on frameid 0 but the window of the top javascript context is still not readable:
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
// since only one tab should be active and in the current window at once
// the return variable should only have one entry
const activeTab = tabs[0];
const activeTabId = activeTab.id; // or do whatever you need
chrome.scripting.executeScript({
target: { tabId: activeTabId, frameIds: [0] },
files: [filePath],
});
});