I have a product that opens 3rd party customer sites using window.open in an additional window.(For doing some WSIWYG type editing on the site). I need to remove a few headers (eg Cross-Origin-Opener-Policy) from the clients sites in order for it to open and work like I need it to.
In MV2 it was easy as we would maintain an array of myProductTabs, when I open a new tab append tabId in myProductTabs. and in webRequest.onHeadersReceived I would check if current request is coming from one of the tabs in myProductTabs using details.tabId and then remove header right there.
But in MV3 the issues is the first time new tab is opened using window.open I have to now add a new declarative netrequest rule where tabs property will be myProductTabs as new tab is added to array. (Remove old rule ofc).
Now this doesn’t work . Probably because registering a new rule doesn’t immediately add the rule and by the time its in effect main document has loaded.
If I refresh the tab , then it would work as rule has already been set.
Now I can set the rule to all tabs by default but that would be a security risk for the user. So is there any other way to do it?