0

When blocking pages with a pattern like so:

chrome.declarativeNetRequest.updateDynamicRules({
  addRules: [
    {
      "id": 1,
      "priority": 1,
      "action": {"type": "block"},
      "condition": {
        "urlFilter": "*://*/*lala.js",
        "resourceTypes": ["main_frame"]
      }
    }
  ]
})

i get a page error:

ERR_BLOCKED_BY_CLIENT

What would be the best way to tell the user that my extension blocked this page?

mandano
  • 31
  • 4
  • You can redirect to an html file in your extension that says it. See `extensionPath` in documentation. It must be also listed in [web_accessible_resources](https://developer.chrome.com/docs/extensions/mv3/manifest/web_accessible_resources/). – wOxxOm Mar 24 '23 at 16:57
  • ah ok, that means if one wants to make visible that it is its own extension is blocking, one blocks by redirecting? like so: `"action": { "type": "redirect", "redirect": { "extensionPath": "/a.jpg" } }` – mandano Mar 24 '23 at 17:13
  • would there be any way to state in the Pop-Up that it was your extension blocking/redirecting? – mandano Mar 24 '23 at 17:15
  • No, use an html file. Inside it put the text/images you want to show. – wOxxOm Mar 24 '23 at 18:00
  • if i block assets by using `"resourceTypes" : ["script"]`, there is also no way to notify the user that the asset was blocked? – mandano Mar 25 '23 at 07:03
  • You can increase the number on the badge, see chrome.declarativeNetRequest.setExtensionActionOptions. – wOxxOm Mar 25 '23 at 10:10

0 Answers0