The scenario is that on a given page, I want to block the browser from redirecting the user to a different page via a chrome extension on manifest v3.
I am listening to redirect events via onBeforeRedirect, but the blocking version of webRequest seems to be deprecated in manifest v3. Chrome seems to recommend declarativeNetRequest instead, but the rules seem much more rigid.
For example, if I wanted to stop a redirect to google.com, I could add a rule like:
{
"id" : 1,
"priority": 1,
"action" : { "type" : "block" },
"condition" : {
"urlFilter" : "abc",
"domains" : ["google.com"],
"resourceTypes" : ["script"]
}
}
but I still wanted the user to be able visit google.com if they weren't being redirected there. This will block all attempts to go to google.com.
How can I block only redirect events to a given site?