Skip to content

feat(goto): widen autoconsent heuristics and fix consent fallback inj…#827

Merged
Kikobeats merged 4 commits into
masterfrom
feat/autoconsent-heuristics
Jul 9, 2026
Merged

feat(goto): widen autoconsent heuristics and fix consent fallback inj…#827
Kikobeats merged 4 commits into
masterfrom
feat/autoconsent-heuristics

Conversation

@Kikobeats

@Kikobeats Kikobeats commented Jul 9, 2026

Copy link
Copy Markdown
Member

…ection

Maximize @duckduckgo/autoconsent coverage:

  • heuristicMode 'reject' -> 'tier2': when no reject button exists, click the acknowledge button (ok/got it), else a lone accept button. All tiers stay gated on consent-text detection, so this only affects cookie banners.
  • enablePopupMutationObserver: react to DOM mutations instead of only polling, catching banners mounted late by SPAs.
  • heuristicPopupSearchTimeout 100 -> 500ms: avoid truncating the popup DOM scan on heavy pages.

Fix runAutoConsent fallback: it re-evaluated the autoconsent script without the nonce guard, so on documents where the new-document injection never ran (the only case the fallback exists for) every message was dropped by the nonce check and autoconsent stayed dead. The full injection (guard + script) is now stored on the page and reused by the fallback.


Note

Medium Risk
In-page auto-clicks affect real page DOM during navigation; guards limit scope but mis-clicks on unusual modals remain possible, and tier2 heuristics change consent-banner button choice when reject is absent.

Overview
Improves cookie-banner handling under adblock: true and adds a separate path for non-consent announcement modals.

Autoconsent now uses heuristicMode: 'tier2' (prefer reject, else acknowledge / lone accept), a longer heuristic DOM scan (heuristicPopupSearchTimeout: 500), and enablePopupMutationObserver for late-mounted banners. The post-navigation runAutoConsent fallback re-runs the stored nonce guard + script (page._autoconsentScript) so init messages are not dropped when evaluateOnNewDocument never ran.

New dismiss helper (also gated on adblock: true) injects a narrow in-page scanner for ARIA/<dialog> announcements without consent copy, clicking only safe acknowledge/close buttons (skipping consent-themed and most form dialogs). It runs at setup and again after navigation alongside autoconsent; README documents the behavior.

Unit tests cover heuristic banners, the autoconsent fallback handshake, and dismiss edge cases.

Reviewed by Cursor Bugbot for commit 02e2552. Bugbot is set up for automated code reviews on this repo. Configure here.

Kikobeats and others added 2 commits July 9, 2026 13:36
…ection

Maximize @duckduckgo/autoconsent coverage:

- heuristicMode 'reject' -> 'tier2': when no reject button exists, click
  the acknowledge button (ok/got it), else a lone accept button. All
  tiers stay gated on consent-text detection, so this only affects
  cookie banners.
- enablePopupMutationObserver: react to DOM mutations instead of only
  polling, catching banners mounted late by SPAs.
- heuristicPopupSearchTimeout 100 -> 500ms: avoid truncating the popup
  DOM scan on heavy pages.

Fix runAutoConsent fallback: it re-evaluated the autoconsent script
without the nonce guard, so on documents where the new-document
injection never ran (the only case the fallback exists for) every
message was dropped by the nonce check and autoconsent stayed dead.
The full injection (guard + script) is now stored on the page and
reused by the fallback.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
autoconsent only handles cookie-consent popups. Sites also ship legal notices, maintenance banners, and takedown announcements as ARIA dialogs with no consent language, so autoconsent leaves them on screen (e.g. the Important Notice modal on wetriedtls.com bleeds into PDF/screenshot output).

Add a narrowly-scoped dismisser, injected at document start and re-run after navigation, enabled together with adblock: true:

- targets only ARIA dialogs: role=dialog, role=alertdialog, aria-modal, dialog[open]. Never arbitrary fixed-position elements.
- clicks a single acknowledge-style button (ok / got it / i understand / dismiss / close / continue / x), or an aria-label close button.
- dialogs with form fields are skipped unless they expose an explicit close button outside a form, so login / newsletter / paywall modals are left alone.
- only button elements, never anchors, so a dismissal cannot navigate.
- idempotent, capped at 3 clicks, observer self-disconnects after 15s.

Verified end-to-end: the wetriedtls chapter now renders clean to PDF.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 6a55988. Configure here.

Comment thread packages/goto/src/dismiss.js
Comment thread packages/goto/src/dismiss.js Outdated
Kikobeats and others added 2 commits July 9, 2026 14:05
…ost-nav

- dismissOverlays returns its click count, so dismiss.run reads it from the same evaluate instead of a second CDP round-trip and a 3-link promise chain.
- run autoconsent and dismiss fallbacks with Promise.all: they touch different page globals and were needlessly serialized on the post-navigation path.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Address PR review (Cursor Bugbot):

- Consent guard: dismiss now skips any ARIA dialog whose copy mentions
  cookies/consent/privacy, leaving the opt-out decision to autoconsent.
  Previously a consent banner styled as a dialog with an 'OK'/'Got it'
  button could be clicked by dismiss, which may mean accept and undermine
  autoAction: 'optOut'.
- Re-scan on re-entry: the post-navigation run fallback now triggers a
  fresh scan even when the script is already initialized, so dialogs
  mounted only once goto settles (e.g. after networkidle, past the 15s
  observer window) are still caught.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Kikobeats Kikobeats merged commit 797bbea into master Jul 9, 2026
11 of 12 checks passed
@Kikobeats Kikobeats deleted the feat/autoconsent-heuristics branch July 9, 2026 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant