feat: block ad and tracker hosts in Edition WebViews, hide newsletter sign-ups #190

Closed
midas wants to merge 0 commits from feat/169-edition-webview-blocking into dev
Owner

Closes #169

What the app has (Het Parool 7.55.0 decompile; class names checked in the dex of Volkskrant 7.54.0/7.55.0 and Trouw 7.55.0)

  • nl.persgroep.edition.component.web.ui.DefaultWebViewClient (extends WebViewClient): the in-app browser (WebViewContent -> InjectWebView: links, "Kijk verder", "Mijn omgeving").
  • nl.persgroep.edition.embed.webview.ui.EmbedWebViewViewModel$EmbedWebViewClient (extends androidx.webkit.WebViewClientCompat): article embeds (YouTube, X, Instagram, Facebook, other HTML/iframes).
  • Neither overrides shouldInterceptRequest (nor does WebViewClientCompat). Both are unobfuscated.
  • Left alone: SubscriptionWebViewClient (purchase), Temptation PaywallWebView, the privacy gate SDK's WebView, games, year review, the ad SDKs' own WebViews.

Change

  • shared/util/WebViewClients.kt: hookShouldInterceptRequest(clientType, hook) adds a shouldInterceptRequest(WebView, WebResourceRequest) override that returns super's result when the class has none, then puts the hook in front (non-null response = returned). Hide ads and Disable tracking each add their own hook. Checked with dexdump on the patched Volkskrant 7.55.0: both clients get the method with both hooks before invoke-super.
  • Extension: nl.midasvo.extension.web.WebRequestBlocker (host rules, main frame never blocked, empty response), used by the new edition.EditionWebRequests and by NrcWebContent (NRC hosts and behaviour unchanged: exact hosts only). Hooks have the never-throw wrapper; JVM tests in WebRequestBlockerTest, EditionWebRequestsTest.
  • Hosts (all from SDKs the app ships, see docs/apps/edition.md): Hide ads: securepubads.g.doubleclick.net, googleads.g.doubleclick.net, pagead2.googlesyndication.com, ib.adnxs.com, msft-ssp.adnxs.com, prebid-server.dpgmedia.net, advertising-cdn.dpgmedia.cloud. Disable tracking: hit.gemius.pl and subdomains, t.contentsquare.net. Never blocked (pinned by a test): privacy gate hosts, the publishers' sites, the embeds' own hosts, www.googletagmanager.com.
  • No toggle for these (ads and tracking, per AGENTS.md).
  • Newsletter iframe (separate commit): new named patch Hide newsletter sign-ups, toggle hide_newsletter_signups (default on, "Advertenties en promotie"): ContentFilters drops a Block.EmbedBlock whose HTML contains /optiext/optiextension.dll. Stub Block.EmbedBlock.getContent() added; check-stubs.sh OK on Het Parool 7.55.0 and Volkskrant 7.53.1.
  • docs/HOSTS.md does not exist on dev yet, so the hosts are listed in docs/apps/edition.md.

Verification

Check Result
buildAndroid (incl. contract check) pass
:extensions:extension:testDebugUnitTest pass
check-patches.sh Volkskrant 7.55.0 exit 0, all 14 Applied, class check 0 to fix
check-patches.sh Trouw 7.55.0 exit 0, all 14 Applied, class check 0 to fix
check-patches.sh Volkskrant 7.54.0 exit 0, all 14 Applied, class check 0 to fix
check-patches.sh NRC 5.12.24 exit 0, all 5 Applied, class check 0 to fix

Not verified

  • Not device-tested.
  • Which hosts the pages in these WebViews really request: a plain fetch of volkskrant.nl only reaches the privacy gate; no device capture.
  • That the newsletter form arrives as an EmbedBlock (and whether Trouw/Het Parool have the same form): the URL comes with the article, not the APK.
  • That blocking googleads.g.doubleclick.net in a YouTube embed leaves playback alone.

🤖 Generated with Claude Code

Closes #169 ## What the app has (Het Parool 7.55.0 decompile; class names checked in the dex of Volkskrant 7.54.0/7.55.0 and Trouw 7.55.0) - `nl.persgroep.edition.component.web.ui.DefaultWebViewClient` (extends `WebViewClient`): the in-app browser (`WebViewContent` -> `InjectWebView`: links, "Kijk verder", "Mijn omgeving"). - `nl.persgroep.edition.embed.webview.ui.EmbedWebViewViewModel$EmbedWebViewClient` (extends `androidx.webkit.WebViewClientCompat`): article embeds (YouTube, X, Instagram, Facebook, other HTML/iframes). - Neither overrides `shouldInterceptRequest` (nor does `WebViewClientCompat`). Both are unobfuscated. - Left alone: `SubscriptionWebViewClient` (purchase), Temptation `PaywallWebView`, the privacy gate SDK's WebView, games, year review, the ad SDKs' own WebViews. ## Change - `shared/util/WebViewClients.kt`: `hookShouldInterceptRequest(clientType, hook)` adds a `shouldInterceptRequest(WebView, WebResourceRequest)` override that returns `super`'s result when the class has none, then puts the hook in front (non-null response = returned). Hide ads and Disable tracking each add their own hook. Checked with `dexdump` on the patched Volkskrant 7.55.0: both clients get the method with both hooks before `invoke-super`. - Extension: `nl.midasvo.extension.web.WebRequestBlocker` (host rules, main frame never blocked, empty response), used by the new `edition.EditionWebRequests` and by `NrcWebContent` (NRC hosts and behaviour unchanged: exact hosts only). Hooks have the never-throw wrapper; JVM tests in `WebRequestBlockerTest`, `EditionWebRequestsTest`. - Hosts (all from SDKs the app ships, see `docs/apps/edition.md`): Hide ads: `securepubads.g.doubleclick.net`, `googleads.g.doubleclick.net`, `pagead2.googlesyndication.com`, `ib.adnxs.com`, `msft-ssp.adnxs.com`, `prebid-server.dpgmedia.net`, `advertising-cdn.dpgmedia.cloud`. Disable tracking: `hit.gemius.pl` and subdomains, `t.contentsquare.net`. Never blocked (pinned by a test): privacy gate hosts, the publishers' sites, the embeds' own hosts, `www.googletagmanager.com`. - No toggle for these (ads and tracking, per AGENTS.md). - Newsletter iframe (separate commit): new named patch **Hide newsletter sign-ups**, toggle `hide_newsletter_signups` (default on, "Advertenties en promotie"): `ContentFilters` drops a `Block.EmbedBlock` whose HTML contains `/optiext/optiextension.dll`. Stub `Block.EmbedBlock.getContent()` added; `check-stubs.sh` OK on Het Parool 7.55.0 and Volkskrant 7.53.1. - `docs/HOSTS.md` does not exist on dev yet, so the hosts are listed in `docs/apps/edition.md`. ## Verification | Check | Result | | --- | --- | | `buildAndroid` (incl. contract check) | pass | | `:extensions:extension:testDebugUnitTest` | pass | | `check-patches.sh` Volkskrant 7.55.0 | exit 0, all 14 Applied, class check 0 to fix | | `check-patches.sh` Trouw 7.55.0 | exit 0, all 14 Applied, class check 0 to fix | | `check-patches.sh` Volkskrant 7.54.0 | exit 0, all 14 Applied, class check 0 to fix | | `check-patches.sh` NRC 5.12.24 | exit 0, all 5 Applied, class check 0 to fix | ## Not verified - **Not device-tested.** - Which hosts the pages in these WebViews really request: a plain fetch of volkskrant.nl only reaches the privacy gate; no device capture. - That the newsletter form arrives as an `EmbedBlock` (and whether Trouw/Het Parool have the same form): the URL comes with the article, not the APK. - That blocking `googleads.g.doubleclick.net` in a YouTube embed leaves playback alone. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Hide ads and Disable tracking now hook shouldInterceptRequest of Edition's
DefaultWebViewClient (in-app browser) and EmbedWebViewClient (article
embeds). Neither overrides it, so the hook adds an override that calls
super. Subresources on the ad and tracker hosts of the SDKs the app ships
get an empty response; consent, login, paywall and payment hosts stay.

The host check moves to WebRequestBlocker, shared with NRC (NRC's hosts
and behaviour unchanged).

Refs #169

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
feat: hide the newsletter sign-up form in Edition articles
All checks were successful
CI / Build (pull_request) Successful in 1m16s
CI / Patch check (pull_request) Successful in 3m2s
4001e92272
New patch Hide newsletter sign-ups (toggle hide_newsletter_signups,
default on): the article block filter drops an embed whose HTML loads the
newsletter form handler (ims.volkskrant.nl/optiext/optiextension.dll).

Refs #169

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
midas closed this pull request 2026-11-17 15:33:57 +01:00
Author
Owner

Merged into dev through the integration PR #195 (same commits), released as v1.11.0-dev.10.

Merged into dev through the integration PR #195 (same commits), released as v1.11.0-dev.10.
All checks were successful
CI / Build (pull_request) Successful in 1m16s
Required
Details
CI / Patch check (pull_request) Successful in 3m2s

Pull request closed

Sign in to join this conversation.
No description provided.