developer.chrome.com icon indicating copy to clipboard operation
developer.chrome.com copied to clipboard

Docs: webRequestBlocking in Manifest V3 ?

Open tf42src opened this issue 4 years ago • 7 comments

I assume this documentation is for Manifest v3. It does mention webRequestBlocking which when added to the manifest file results in 'webRequestBlocking' requires manifest version of 2 or lower.

Screen Shot 2021-08-15 at 10 51 44 am

manifest.json

{
    "name": "",
    "manifest_version": 3,
    ...
    "permissions": [
        ...
        "webRequest",
        "webRequestBlocking"
    ]
...
}

Version 1.28.105 Chromium: 92.0.4515.131 (Official Build) (x86_64)

tf42src avatar Aug 15 '21 00:08 tf42src

@awfuchs did you have a chance to look at it? Would be much appreciated!

tf42src avatar Aug 24 '21 10:08 tf42src

@tf42src The new declarativeNetRequestWithHostAccess permission allows extensions to use the chrome.declarativeNetRequest API on sites the extension has host permissions for. This also enables existing Manifest V2 extensions that use webRequest, webRequestBlocking, and site-specific host permission to migrate to the chrome.declarativeNetRequest API without requiring the user to approve new permissions.

via official docs: https://developer.chrome.com/docs/extensions/whatsnew/

Does this help?

Rononoa13 avatar Mar 20 '22 02:03 Rononoa13

CC: @dotproto, as I believe @awfuchs is no longer working on Chrome Extensions.

jeffposnick avatar Mar 21 '22 14:03 jeffposnick

I try to use declarativeNetRequest to instead of webRequestBlocking.

In manifest.json

  "manifest_version": 3,
   "permissions": [
      "declarativeNetRequest",
   ]

In background.js or devtool.js

chrome.declarativeNetRequest.updateDynamicRules({
  addRules: [{
    'id': 1001,
    'priority': 1,
    'action': {
      'type': 'block'
    },
    'condition': {
      'urlFilter': 'twitter.com',
      'resourceTypes': [
        'csp_report', 'font', 'image', 'main_frame', 'media', 'object', 'other', 'ping', 'script',
        'stylesheet', 'sub_frame', 'webbundle', 'websocket', 'webtransport', 'xmlhttprequest'
      ]
    }
  }],
  removeRuleIds: [1001]
})

femvc avatar Apr 11 '22 15:04 femvc

I assume this documentation is for Manifest v3.

yeah that page doesn't mention anything about the changes in manifest v3. it needs a big red warning like the one here.

DetachHead avatar Apr 26 '22 23:04 DetachHead

webRequest blocking for MV3 policy installed extensions is being tracked in crbug.com/1024211.

solomonkinard avatar Jul 26 '22 23:07 solomonkinard

@solomonkinard I think you meant to link to a different issue.

ghostwords avatar Jul 27 '22 14:07 ghostwords

Fixed in new Migration guide and PR's https://github.com/GoogleChrome/developer.chrome.com/pull/5473 and https://github.com/GoogleChrome/developer.chrome.com/pull/4603

AmySteam avatar Jun 02 '23 17:06 AmySteam