feat(goto): widen autoconsent heuristics and fix consent fallback inj…#827
Merged
Conversation
…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>
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ 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.
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

…ection
Maximize @duckduckgo/autoconsent coverage:
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: trueand 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), andenablePopupMutationObserverfor late-mounted banners. The post-navigationrunAutoConsentfallback re-runs the stored nonce guard + script (page._autoconsentScript) so init messages are not dropped whenevaluateOnNewDocumentnever ran.New
dismisshelper (also gated onadblock: 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.