Chrome's Manifest V3 is often said to be the end of ad blockers as we know them. We decided to check that and we're now publishing the first ad blocker that is built on the new platform. Check it out and see what awaits us in the future.
Hello, hunters!
As you probably know, Google decided to switch from Manifest V2 to Manifest V3. And we put a lot of effort into developing the first browser extension that could meet all the requirements of Manifest V3 and block ads properly within its tight confines. The task was not an easy one: the new API is still raw, some things are being finalized and do not work as intended. But we coped with it.
🚀 The first prototype
While developing the first MV3 extension prototype, we faced a lot of problems. Let us tell you briefly what these problems were and how we dealt with them.
✋ Rule limits
Google has set such limits: 5,000 for dynamic rules per extension, and a total limit of 330,000 static rules for all extensions installed by a single user. These limits also include caps for rules that use regular expression - no more than 1000 rules for static (built-in) and dynamic rules each.
📕 Declarative rules
With the release of Manifest V3, ad-blocking extensions are no longer allowed to handle network requests themselves. Now Chrome does it, using declarative rules pre-installed in the extension.
The declarative rule syntax is very different from the syntax traditional content blockers were using for years. So we had to figure out a way to convert our rules into the syntax imposed by the browser developers. Most of the rules will convert correctly, but, unfortunately, some functionality will be lost because of various restrictions.
📜 Rulesets
According to the new API, declarative rules must be combined into rulesets. They are specified in the extension's "manifest" and are loaded only when the extension is installed or updated. And this is a big problem.
Now to update filters it is necessary to upload a new version of the extension to Chrome Store daily (or more often), because there is no other way to provide users with updated filters. We sincerely hope that it will be possible to update filters quickly after all.
⏳ Service worker
With the advent of Manifest V3, the background page that allowed the extension to run in the background has been replaced by the service worker. Its work is often interrupted by the browser, which causes the extension to go into a kind of sleep mode: declarative rules are functional, but the cosmetic rules that we load dynamically are not.
When the service worker comes back online, the extension starts to process the filter rules from the repository so that it can then find them quickly. During this time — for 1.5-2 seconds (about 3 seconds during the initial installation) — the extension does not block ads cosmetically. Then the engine starts and the ads disappear.
We plan to reduce the wake-up time of the service worker and to move the application of most of the cosmetic rules to the "content script", but for some cases we will still need the service worker.
💚 Conclusion
By presenting you today an experimental extension built with Manifest V3, we can say that we've met the challenge presented to us by Google. Yes, there is still a lot of work to do, but we can already say that even after the cancellation of Manifest V2, Google Chrome users will be able to protect themselves from ads and trackers with AdGuard MV3.
🙋♂️ We will be around here all day, should you have any questions!
ℹ️ If you want more technical details about the extension and what issues we had to deal with, check out our blog: https://agrd.io/blogpost_mv3
AdGuard MV3
AdGuard MV3