S058: Pie-style ad removal animation (port of the original zapper)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
astar76 2026-11-14 07:42:50 -06:00
commit f90134bda6
3 changed files with 10 additions and 6 deletions

View file

@ -36,8 +36,8 @@ Port the original, which is the spec: `~/Documents/Apps/Nacre/nacre/services.py`
- [x] Port `ZAP_JS` detection + overlay + collapse into the cosmetic script (keep the class/id → selectors round trip), options (animate, ms, bg, badge, off) from the browser per page; badge SVG built in Rust from theme colours.
- [x] Safety rules (players, sizes, off-screen, max 12, paused sites) and Motion off / setting off → plain hide.
- [x] Test page `tests/smoke/pages/ads.html` (a few visible ad boxes matching local cosmetic rules, one inside a fake player, one tiny, one off-screen) + smoke: shots mid-animation (overlay + badge visible) and after (slots collapsed, layout closed), player untouched, Motion off = instant; dark and light.
- [ ] Visible run on a real ad-heavy page (e.g. a news site) on DP-1 (D-045): watch it, read the shots; note anything that flickers or jumps.
- [ ] PROGRESS entry, INDEX line, tracker, commit `S058: …`, push.
- [x] Visible run on a real ad-heavy page (e.g. a news site) on DP-1 (D-045): watch it, read the shots; note anything that flickers or jumps.
- [x] PROGRESS entry, INDEX line, tracker, commit `S058: …`, push.
## End criteria
- The smoke shows the overlay with the cookie shield mid-animation and the closed layout after; player element intact.
@ -49,6 +49,3 @@ Port the original, which is the spec: `~/Documents/Apps/Nacre/nacre/services.py`
## Handoff (→ PROGRESS.md)
What differs from the original, if anything.
## Resume
Boxes 1–2 done (src/inject.rs `COSMETIC_JS`, `App::zap_options` in src/app.rs, `theme::zap_badge`). Box 3 in
progress: `tests/smoke/pages/ads.html` + `tests/smoke/zap.txt` (`SMOKE_SIZE=1280x900 tools/smoke.sh tests/smoke/zap.txt`).

View file

@ -10,7 +10,7 @@ Dropped with Servo (D-032): S011, S029, S030, S032, S033, S037, S038.
## 08 WebKit engine (in this order)
- [x] [S053 — Remove Servo: vendor crates, gst-mse, Servo-only tests/tools, docs and texts](08%20WebKit%20engine/S053-servo-removal.md) · Sonnet high
- [x] [S057 — Small UI bugs: Customize panel scroll, site colour from the favicon, colour picker glyphs, beforeunload on quit](08%20WebKit%20engine/S057-small-ui-bugs.md) · Sonnet high
- [ ] [S058 — Ads vanish before your eyes: Pie-style cookie shield removal animation (port of the original)](08%20WebKit%20engine/S058-ad-removal-animation.md) · Opus medium
- [x] [S058 — Ads vanish before your eyes: Pie-style cookie shield removal animation (port of the original)](08%20WebKit%20engine/S058-ad-removal-animation.md) · Opus medium
- [ ] [S051 — Profile folder, sealed cookies, site data, incognito, media source](08%20WebKit%20engine/S051-profile-cookies-media.md) · Opus medium
- [ ] [S052 — WebKit tuning defaults, background tabs, memory check](08%20WebKit%20engine/S052-tuning-defaults.md) · Sonnet high
- [ ] [S054 — Site pass on WebKit vs Chromium reference](08%20WebKit%20engine/S054-site-pass.md) · Opus high

View file

@ -439,6 +439,13 @@ Later: S010 list: user checks the Discord icon with their own client (the Discor
- Not done: a Stay answer on a tab that closed in a quit leaves it reloaded (state of form fields lost); no visible run.
- Later: other Areas that only paint (none found) would repeat the Customize bug.
## S058 — Ad removal animation: Pie-style cookie shield, port of the original zapper (2026-11-14)
- Done: `COSMETIC_JS` (src/inject.rs) ports `ZAP_JS`: the class/id → selectors round trip stays; selectors now get a 1 ms `__nz_detect` animation and `animationstart` hands over each rendered match (WebKit fires it). Visible ads get an overlay (primaryContainer 92 % + cookie shield badge, `theme::zap_badge` in the window's theme colours) that squishes and spins away while the ad fades, then the slot collapses (340 ms) and gets `display:none`. Options per `cosmetic.hide(selectors, opts)` call from `App::zap_options` (animate, ms = 900 × Motion scale, min 0.3; bg; badge).
- Safety: `<video>`/`<audio>` and their holders never touched (also with plain hiding: `:is(sel):not(video,audio,:has(video,audio))`); ad bits in known players, tiny (< 24 px), huge (> 60 % viewport), off-screen hidden quietly; at most 12 at once. Setting off, Motion off or still mode → plain `display:none`, counted when selectors arrive.
- Differs from the original: no `off` option in the page (Nacre doesn't send selectors to paused sites, as before); script options no longer baked into the injected script (no reinstall on setting change); one count per detected element, batched.
- Verified: `cargo test` 81 + webext 1; hidden `zap.txt` (new, `tests/smoke/pages/ads.html`) exit 0: overlay + badge mid-animation dark and light, slots closed, player and video box intact, Motion off = no overlay; `net-adblock.txt`, `crash-adblock.txt` exit 0. Visible DP-1 (Independent, AccuWeather, Speedtest, Guardian): Guardian header slot squished then collapsed (content moves up once, no flicker seen); pages render as before.
- Later: `hidden_elements` counts matches in frames and ones the page later removes (Guardian 27 vs 3 left in the top document); an element whose `__nz_gone` class a page re-render strips shows again (as the original).
## Later
- A link followed inside a frame still goes through the tab's navigation policy (WebKit's GTK API has no frame info; S050).
- file:// media outside the XDG user folders doesn't play (WebKit sandbox, D-043).