MV3 declarativeNetRequest not replacing webRequest properly

69 views
Skip to first unread message

ZW

unread,
Sep 27, 2022, 5:15:49 AM9/27/22
to Chromium-dev
I have a very simple webRequest blocking operation that works perfectly on MV3 but by migrating to MV3 declarativeNetRequestit doesn't work

What is the equivalent of the  webRequest  on the declarativeNetRequest for this simple operation:

chrome.webRequest.onBeforeRequest.addListener(
  function(){ return {cancel: true}; },
  {
    urls: ["*://*.example.com/mwlite/service-worker.js", "*://*.example.com/mwlite/manifest.json"]
  },
  ["blocking"]
);

On MV3 I have:
    chrome.declarativeNetRequest.updateSessionRules(
        {addRules:[{
            "id": id,
            "priority": 1,
            "action": {     "type": "block"
            },
            "condition": {"urlFilter": "*://*.example.com/mwlite/service-worker.js", "resourceTypes": ["image",
            "media",
            "main_frame",
            "sub_frame",
            "stylesheet",
            "script",
            "font",
            "xmlhttprequest",
            "ping",
            "websocket",
            "other"], "tabIds" : tabMultiId }}    
            ],
            removeRuleIds: [id]
        },
    );

I have tried this and it simply doesn't work!
Greetings and thank you very much for anyone that try to help.
Reply all
Reply to author
Forward
0 new messages