I want to redirect visits to a particular URL (in some format, so it’s not one static one, so I need to analyze the URL format) to a different one.
Now, obviously, I see I can do so with webRequest.onBeforeRequest
. However, this is fired for loaded assets, images, etc., which I obviously don’t care about and also do not want to accidentally redirect.
So I found the webNavigation API, which seems to be exactly what i want, i.e. only catch the real “navigations” a user does, e.g. when clicking on a link/button, opening a new tab or so, basically everytime the URL in the address bar changes (if I understand it correctly).
But the webNavigation
API has no way to redirect or modify anything of the loading request, as it seems. It’s purely static to give you information.
So what is the best way to only redirect some web navigation requests? Can the webRequests be filtered by “onlyNavigation”? Or can one redirect the webNavigation
in a clever way?