Sorry, I didn't look at urlFilter. Indeed declarativeNetRequest shouldn't work for extension's own scripts because these are local files that don't go through the network process.
You can try self.onfetch handler in the background script:
self.onfetch = e => {
e.respondWith(Response.redirect("chrome-extension://${
chrome.runtime.id}/scriptB.js"));
}
};
On Tuesday, June 11, 2024 at 5:08:11 PM UTC+3 woxxom wrote:
Assuming you know that this code should be used in an extension script such as the background script and web_accessible_resources properly declares scriptB.js, the problem is likely that you need to add resourceTypes: ['script'] to condition. There's also a bug with redirecting from pages without an origin such as a local file:// and probably sandboxed pages/frames.