1

I see that Google wants Chrome Extension developers to migrate from chrome.webRequest to chrome.declarativeNetRequest. I see static rules, but the trouble there is that how do we allow a user to toggle individual rules on or off per website? Most users want whitelisting overrides. This is why we used chrome.webRequest to look at network connections on any given web page, and if any of those URLs matched a regexp ruleset, we could deny the request, and that Javascript could look to see if the user wanted to toggle that off on a given website to whitelist it.

Is there a way with declarativeNetRequest to look at any website and load in static rules that a user could toggle off (whitelist) for a given website if they desire from their options panel?

Volomike
  • 23,743
  • 21
  • 113
  • 209
  • Not implemented: https://crbug.com/1225229. Could you elaborate on the problem with using the dynamic rules? – wOxxOm Apr 30 '22 at 04:36
  • Edited. Changed "dynamic" to "static". So, let's say we have example.com as the website the user browses to, and on it a script from evil.com to block in a static rule. But a user says no, they want to prevent all the static rules from running on example.com, allowing evil.com to run. He might have a panel with an enabled/disabled toggle. How, in code, do we turn off the static rules on example.com for this user, yet block the evil.com script on other websites he browses to? – Volomike Apr 30 '22 at 04:45
  • You'll have to use dynamic rules. Or add a new dynamic rule that overrides the "disabled" static one. – wOxxOm Apr 30 '22 at 04:52
  • When the user browses to example.com (`chrome.tabs` API check) and he's whitelisted this domain, would I be using `chrome.declarativeNetRequest.updateEnabledRulesets` to disable ruleset id 1? Or does that disable it for all tabs? – Volomike Apr 30 '22 at 05:14
  • I guess you would use updateDynamicRules and supply tabId. – wOxxOm Apr 30 '22 at 05:30

0 Answers0