brave-experiments / ad-block

Ad block engine used in the Brave browser for ABP filter syntax based lists like EasyList.
https://www.brave.com
Mozilla Public License 2.0
240 stars 95 forks source link

Add support for tagging ad-block rules #191

Closed bbondy closed 5 years ago

bbondy commented 5 years ago

We'd like to conditionally exclude matching for certain filters based on options in Brave. To do this the idea is to have a conditional tag which can be added to a filter.

The AdBlockClient instance which is in use must have the same added tag to match a tagged filter.

The idea is for example if the user checks a checkbox like "Allow Facebook login buttons" then we'd match filters with an option of tag=fb-login.

Serialization and deserialization is backwards compatible so no new version bump is needed. It does still serialize and deserialize the tags though.

It does this in the filter's serialize'd block where it stores the domain list. If it sees a # character, it knows that it is a tag first. # is not a valid character for a domain. Existing live versions of the lib would just deserialize any such rule as as a domain and not consider it.