Understand the snippets library
What are snippets?
Snippets are pieces of JavaScript code, injected by the Ad-Filtering Solution, that execute within the context of a website and combat advanced ads that circumvent ordinary blocking.
How snippets work
A snippet is typically a JavaScript function. It may optionally take arguments.
Snippets are stored in a snippet library and selected for execution based on the content of a filter list. The filter list also specifies any arguments passed to snippets on a given website.
Multiple snippets with various arguments may be executed on a single website. For more on snippet functionality, view the Snippets Overview.
Requirements for using snippets
In order to execute snippets on websites, the following are required:
the snippet library of a sufficiently recent version must be built into the browser
the Anti-CV filter list must be subscribed
Verify the Anti-CV filter subscription
The Anti-CV filter list is subscribed by default.
If it isn't in your configuration, you can subscribe to it the same way as you subscribe to any other filter list, through FilteringConfiguration
or any of the platform-specific APIs.
Keeping the snippets library up to date
The version of the snippets library built into the Browser Ad-Filtering Solution is defined in the DEPS file.
The snippet library may sometimes be updated separately from the remainder of the Solution by changing the tagged version.
Some changes to the snippets library may require alignment of the Solution. Consult the following compatibility matrix to see if a Solution version is compatible with a snippet library version:
0.5.1
105+
0.8.1
117+
1.2.0
123+
Update the snippets library
Set the new desired version in the DEPS file.
Run
gclient sync
to pull the new version of the library to your local repository.Rebuild the browser (
ninja -C out/...
)
Remember to consult the compatibility matrix to avoid mismatches between the snippets library content and the Solution's expectations.
Last updated