declarativeNetRequest redirect rule to extension's internal page not working

67 views Asked by At

I want to redirect certain domains to an extension's internal page. This is my manifest:

{
    "manifest_version": 3,
    "default_locale": "en",

    "name": "__MSG_extension_name__",
    "description": "__MSG_extension_description__",
    "version": "1.0",

    "icons": {
        "48": "images/icon-48.png",
        "96": "images/icon-96.png",
        "128": "images/icon-128.png",
        "256": "images/icon-256.png",
        "512": "images/icon-512.png"
    },

    "background": {
        "service_worker": "background.js"
    },

    "content_scripts": [{
        "js": [ "content.js" ],
        "matches": [ "*://example.com/*" ]
    }],

    "action": {
        "default_popup": "popup.html",
        "default_icon": {
            "16": "images/toolbar-icon-16.png"
        }
    },
    
    "web_accessible_resources": [
        {
          "resources": ["locked.html"],
          "matches": ["<all_urls>"]
        }
    ],
    "declarative_net_request" : {
        "rule_resources" : [{
          "id": "ruleset_1",
          "enabled": true,
          "path": "declarative-net-request-rules.json"
        }]
      },

    "permissions": ["tabs", "webNavigation", "declarativeNetRequest", "declarativeNetRequestWithHostAccess"]
}

My rules file (declarative-net-request-rules.json):

[
    {
   "id": 1,
   "action": {
      "type": "redirect",
      "redirect": {
          "extensionPath": "/locked.html?type=1"
      }
   },
   "condition": {
      "requestDomains": [
         "test-redir.app",
         "reddit.com",
         "example.net"
      ],
      "resourceTypes": [
         "main_frame",
         "sub_frame"
      ]
   }
}
]

But nothing happens when I navigate to those pages. Am I missing something in the condition part? No errors are shown

0

There are 0 answers