Add core ad blocking capabilities#8622
Conversation
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
There was a problem hiding this comment.
Pull request overview
This PR introduces the core plumbing to inject “ad blocking extension” scriptlets into pages (currently targeting YouTube domains), sourcing the scriptlet payload from the local Room store and gating injection behind feature toggles.
Changes:
- Add
AdBlockingExtensionJsInjectorPluginto build and inject a combined JS payload ononPageStarted. - Extend
AdBlockingExtensionRepositorywith ascriptletsFlow()API and introduce aScriptletmodel. - Add tests for injection gating (feature flags, domain matching) and payload behavior (sorting, updates); add
AndroidX.core.ktxdependency fortoUri.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| ad-blocking/ad-blocking-impl/src/main/java/com/duckduckgo/adblocking/impl/AdBlockingExtensionJsInjectorPlugin.kt | New JS injector plugin that gates and injects scriptlets on page start for configured domains. |
| ad-blocking/ad-blocking-impl/src/main/java/com/duckduckgo/adblocking/impl/AdBlockingExtensionRepository.kt | Adds a flow-based API to observe scriptlets and maps DB entities into Scriptlet. |
| ad-blocking/ad-blocking-impl/src/main/java/com/duckduckgo/adblocking/impl/Scriptlet.kt | Introduces a Scriptlet data model (name + JS content). |
| ad-blocking/ad-blocking-impl/src/test/java/com/duckduckgo/adblocking/impl/AdBlockingExtensionJsInjectorPluginTest.kt | Adds unit tests covering injection conditions and payload composition. |
| ad-blocking/ad-blocking-impl/build.gradle | Adds AndroidX.core.ktx dependency required by the plugin. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
3b6160c to
f23bf2f
Compare
ca28c5a to
e3ccd58
Compare
cmonfortep
left a comment
There was a problem hiding this comment.
LGTM
I need to test on a real device, but not blocker. When testing this on the emulators I noticed few seconds of loading on every video, I don't remember seeing that when I did the hackphase. if we see this happening, when we are doing pixels, we should check if we have something we can use to track this.
| ?.sortedBy { it.name } | ||
| ?.joinToString(separator = "\n") { it.content } | ||
|
|
||
| private val domains = listOf( |
There was a problem hiding this comment.
is this expected to be local list or provided from the remote config?
There was a problem hiding this comment.
Yes, expected to be local. Discussed over zoom
e241c58 to
71544f4
Compare
f23bf2f to
5142d91
Compare
71544f4 to
e4d29da
Compare
5142d91 to
8a3a2a0
Compare
e4d29da to
ca5bcf7
Compare

Task/Issue URL: https://app.asana.com/1/137249556945/project/1212227266948491/task/1213078401808051?focus=true
Description
Add core ad blocking capabilities
Steps to test this PR
Feature 1
Feature not discoverableandStatus checker rejected injection, skippingadBlockingExtension.isDiscoverableFeature not operationalandStatus checker rejected injection, skippingadBlockingExtensionEmpty payload, skippingFeature 2
Feature not discoverableandStatus checker rejected injection, skippingadBlockingExtension, andadBlockingExtension.isDiscoverableInjecting scriptPatches
Patch 1: Update RC URL
UI changes
n/a
Note
Medium Risk
Injects dynamically-sourced JavaScript into
WebViewon page start; mistakes could impact page behavior/performance or unintentionally run on the wrong domains, though it’s gated by feature toggles and domain checks.Overview
Adds a new
JsInjectorPluginthat, ononPageStarted, conditionally injects ad-blocking “scriptlets” into YouTube pages (youtube.com/youtube-nocookie.comand subdomains) viaevaluateJavascript.Introduces a
AdBlockingStatusCheckergate (kill-switch + contingency-mode toggle) and extendsAdBlockingExtensionRepositorywith ascriptletsFlow()so the injector can use the latest stored scriptlets, plus unit tests covering gating, domain matching, ordering, and update behavior.Reviewed by Cursor Bugbot for commit ca5bcf7. Bugbot is set up for automated code reviews on this repo. Configure here.