-
Notifications
You must be signed in to change notification settings - Fork 73
Description
Typically, when a content blocker is disabled on a specific site, an allowAllRequests DNR rule is in effect in the top-most frame. When a content blocker is disabled on a given site, users expect a different visual for the toolbar icon as an important visual hint.
I had numerous requests[1] to implement the different visual for when the content blocker was disabled (through an allowAllRequests rule), but I resisted for a long while because I didn't want to have the service worker wake up on navigation events just for the sake of 1) verifying that filtering is meant to be disabled on the navigated-to site, and 2) that the toolbar icon should be modified from default one to reflect the disabled state of the content blocker.
Eventually we figured out that the service worker could be woken up only for those sites for which the content blocker is meant to be disabled by using the optional filter property in webNavigation.onCommitted.addListener; such that only navigation to URLs matching the sites for which filtering is disabled would cause the service worker to wake up -- hence the need for webNavigation permission.
Using this approach however means installing an event listener in an asynchronous manner, which means that when the service worker is woken up on a navigation event, the listener has (most likely) not been executed, which then means that the extension must go through all existing tabs to ensure that the toolbar icon is properly reflecting the disabled status of the content blocker -- hence the need for tabs permission.
This work well as far as I can tell, however this approach requires:
- two new permissions in the manifest just for that one single purpose:
tabsandwebNavigation[2] - the code required to accomplish this [3]
If there was a way to set an alternative toolbar icon for when an allowAllRequests is in effect in the top-most frame in a tab, this would save content blocker authors from having to declare two new permissions, and remove all the code necessary to deal with this common case (all reputable content blockers show a different toolbar icon when disabled on a given sites -- uBO Lite was the exception for a long while).
The declarativeNetRequest.setExtensionActionOptions method seems to be a good place to support such capability, though I am not sure how the optional property under extensionActionOptions should look like, but just to illustrate let's say:
allowAllRequestsActionIcon
An object containing theimageDataorpathproperty (as defined inaction.setIcon()) to use for tab where anallowAllRequestsDNR rule is in effect in the top-most frame.
[1] uBlockOrigin/uBOL-home#198
[2] https://github.com/uBlockOrigin/uBOL-home/blob/uBOLite_2025.4.27.1394/chromium/manifest.json#L309-L316
[3] https://github.com/uBlockOrigin/uBOL-home/blob/uBOLite_2025.4.27.1394/chromium/js/action.js