Using webrequest api with event page
Asked Answered
M

2

44

When using webrequest api with event page, get the error :

The 'webRequest' API cannot be used with event pages.

Looking on the net, I found this topic : http://code.google.com/p/chromium/issues/detail?id=119613

My questions : why can't (or how can) we use both ?

Malmo answered 10/11, 2012 at 21:9 Comment(0)
M
21

Found declarativeWebRequest API, that would be the solution.

Avalaible now in dev and beta channels.

Malmo answered 10/11, 2012 at 23:29 Comment(8)
In the manual Google states they would rather have extensions use content pages rather than background pages, but that isn't going to happen for any plugins that need webRequest access until declarativeWebRequest is stable.Paymaster
I'd just like everyone to notice that this post was created in 2012. It's now 2015 and the declarativeWebRequest page reads: "Note: this API is currently on hold, without concrete plans to move to stable." So... what are we supposed to do?Hipparchus
declarativeWebRequest may be removed bugs.chromium.org/p/chromium/issues/detail?id=586636Patagium
@KyawTun, Actually that means that it may not be removed too. Wtf now? Chrome really loves making its devs be sitting ducks.Holozoic
2017...still waitingLoaves
2019 is there any solution?Homozygote
2020 the world is collapsing, and still no solution?Jupon
@CharlesJeremyColnet The pandemic has ended and there is the brand new shining declarativeNetRequest API now 🥳Lownecked
H
77

For those who don't want to use the new Event Pages and would prefer to stick with Background Pages, make sure to set "persistent": true in your manifest file's background property.

"background": {
    "scripts": ["bootstrap.js"],
    "persistent": true
  },
Haiti answered 31/7, 2013 at 19:21 Comment(1)
"persistent":true is the default value; it can be omitted.Gladden
M
21

Found declarativeWebRequest API, that would be the solution.

Avalaible now in dev and beta channels.

Malmo answered 10/11, 2012 at 23:29 Comment(8)
In the manual Google states they would rather have extensions use content pages rather than background pages, but that isn't going to happen for any plugins that need webRequest access until declarativeWebRequest is stable.Paymaster
I'd just like everyone to notice that this post was created in 2012. It's now 2015 and the declarativeWebRequest page reads: "Note: this API is currently on hold, without concrete plans to move to stable." So... what are we supposed to do?Hipparchus
declarativeWebRequest may be removed bugs.chromium.org/p/chromium/issues/detail?id=586636Patagium
@KyawTun, Actually that means that it may not be removed too. Wtf now? Chrome really loves making its devs be sitting ducks.Holozoic
2017...still waitingLoaves
2019 is there any solution?Homozygote
2020 the world is collapsing, and still no solution?Jupon
@CharlesJeremyColnet The pandemic has ended and there is the brand new shining declarativeNetRequest API now 🥳Lownecked

© 2022 - 2024 — McMap. All rights reserved.