Skip to content

Pass login state with youtube detection event - #2677

Merged
jdorweiler merged 1 commit into
mainfrom
youtube-detection-login-state
Apr 30, 2026
Merged

Pass login state with youtube detection event#2677
jdorweiler merged 1 commit into
mainfrom
youtube-detection-login-state

Conversation

@jdorweiler

@jdorweiler jdorweiler commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Asana Task/Github Issue:
https://app.asana.com/1/137249556945/project/72649045549333/task/1214157598747980

Description

Adding login state to the youtube detection events

Testing Steps

cd injected && npm run test-unit
cd injected && npx playwright test web-interference-detection-events --reporter list

Checklist

Please tick all that apply:

  • I have tested this change locally
  • I have tested this change locally in all supported browsers
  • This change will be visible to users
  • I have added automated tests that cover this change
  • I have ensured the change is gated by config
  • This change was covered by a ship review
  • This change was covered by a tech design
  • Any dependent config has been merged

Note

Medium Risk
Changes the runtime payload shape for webEvent notifications (adds data.loginState), which may affect downstream consumers expecting an empty object; logic is otherwise small and covered by tests.

Overview
YouTube interference detection events now include a data payload with the detector’s current loginState (defaulting to 'unknown') when firing youtube_* web events.

This threads an optional data argument through YouTubeAdDetector’s onEvent callback and WebInterferenceDetection’s webEvents.fireEvent call, and updates unit/integration tests to assert the new event shape.

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

@github-actions github-actions Bot added the semver-patch Bug fix / internal — no release needed label Apr 29, 2026
@github-actions

github-actions Bot commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

[Beta] Generated file diff

Time updated: Wed, 29 Apr 2026 17:26:57 GMT

Android
    - android/adsjsContentScope.js
  • android/contentScope.js

File has changed

Apple
    - apple/contentScopeIsolated.js

File has changed

Chrome-mv3
    - chrome-mv3/inject.js

File has changed

Firefox
    - firefox/inject.js

File has changed

Integration
    - integration/contentScope.js

File has changed

Windows
    - windows/contentScope.js

File has changed

Made-with: Cursor
@jdorweiler
jdorweiler force-pushed the youtube-detection-login-state branch from 1a451fb to fe9afc7 Compare April 29, 2026 14:47
@github-actions

Copy link
Copy Markdown
Contributor

Build Branch

Branch pr-releases/youtube-detection-login-state
Commit 75c5e42358
Updated April 29, 2026 at 2:48:39 PM UTC

Static preview entry points

QR codes (mobile preview)
Entry point QR code
Docs QR for docs preview
Static pages QR for static pages preview
Integration pages QR for integration pages preview

Integration commands

npm (Android / Extension):

npm i github:duckduckgo/content-scope-scripts#pr-releases/youtube-detection-login-state

Swift Package Manager (Apple):

.package(url: "https://github.com/duckduckgo/content-scope-scripts.git", branch: "pr-releases/youtube-detection-login-state")

git submodule (Windows):

git -C submodules/content-scope-scripts fetch origin pr-releases/youtube-detection-login-state
git -C submodules/content-scope-scripts checkout origin/pr-releases/youtube-detection-login-state
Pin to exact commit

npm (Android / Extension):

npm i github:duckduckgo/content-scope-scripts#75c5e423583c63f388f4128b0d076b2e9c8cc5db

Swift Package Manager (Apple):

.package(url: "https://github.com/duckduckgo/content-scope-scripts.git", revision: "75c5e423583c63f388f4128b0d076b2e9c8cc5db")

git submodule (Windows):

git -C submodules/content-scope-scripts fetch origin pr-releases/youtube-detection-login-state
git -C submodules/content-scope-scripts checkout 75c5e423583c63f388f4128b0d076b2e9c8cc5db

@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.

Web Compatibility Assessment

No findings. The PR does not add or modify browser API wrappers/shims, prototype patches, DOM mutation behavior, iframe access, or timing-sensitive load-time code. The changed detector event path preserves the existing webEvents.fireEvent contract and continues to send a structured { type, data } payload.

Security Assessment

No findings. The new loginState payload is constructed explicitly from detector state as { loginState: ... }, with no object spreading or forwarding of incoming/native payloads. It still flows through webEvents.fireEvent, which constructs notify params explicitly and avoids nativeData leakage.

Risk Level

Medium Risk: this changes an injected runtime event payload sent to native/webEvents consumers, but it is narrowly scoped, config-gated through the existing YouTube detection event settings, and does not touch message transports, bridge security checks, captured globals, or API overrides.

Recommendations

No blocking recommendations. Optional cleanup: update the stale runYoutubeAdDetection JSDoc callback type to include the data argument so future callsites match the new detector callback contract.

Validation: npm run test-unit -- --filter='YouTubeAdDetector|WebEvents' passed (30 specs, 0 failures).

Open in Web View Automation 

Sent by Cursor Automation: Web compat and sec

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Cursor review was not successful.

This PR requires a manual review and approval from a member of one of the following teams:

  • @duckduckgo/content-scope-scripts-owners
  • @duckduckgo/apple-devs
  • @duckduckgo/android-devs
  • @duckduckgo/team-windows-development
  • @duckduckgo/extension-owners
  • @duckduckgo/config-aor
  • @duckduckgo/breakage-aor
  • @duckduckgo/breakage

@jdorweiler
jdorweiler marked this pull request as ready for review April 29, 2026 17:25
@jdorweiler
jdorweiler requested review from a team and GuiltyDolphin as code owners April 29, 2026 17:25

@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.

Web Compatibility Assessment

No findings.

The change only extends the existing webEvent payload for YouTube detection events with an internally derived data.loginState string. It does not add or modify browser API overrides, prototype patches, DOM mutations, event listeners, timers, or iframe access patterns.

Security Assessment

No findings.

The outgoing message remains explicitly constructed as { type, data }; there is no spread of page-controlled objects and no nativeData forwarding path. The new loginState value is synthesized from detector state and constrained to the detector's known state strings or unknown.

Risk Level

Medium Risk: this changes an injected runtime event payload sent through native messaging on supported platforms, but the behavior is narrowly scoped, config-gated by existing YouTube detection event settings, and does not touch wrapper utilities, captured globals, message bridge security checks, or API shims.

Recommendations

No blocking recommendations. Consider adding fixture coverage for non-unknown login states (logged-in, logged-out, premium) if native consumers depend on those exact values.

Validation run:

  • npm run test-unit -- unit-test/youtube-ad-detection.js
  • npx playwright test integration-test/web-interference-detection-events.spec.js --reporter list
Open in Web View Automation 

Sent by Cursor Automation: Web compat and sec

@GuiltyDolphin GuiltyDolphin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Haven't tested (assuming you've tested and this is a simple enough change). Let me know if you need manual testing and I can look into it tomorrow.

Overall looks good. Main ask is can we add tests for the non-unknown cases? It'd be great to have integration/e2e tests covering this such that we can check the correct login state is being sent when appropriate indicators are on the page.

Maybe see if Cursor can build a couple of those. If it's a lot of work we can skip.

@jdorweiler
jdorweiler added this pull request to the merge queue Apr 30, 2026
Merged via the queue into main with commit 5329eae Apr 30, 2026
50 of 51 checks passed
@jdorweiler
jdorweiler deleted the youtube-detection-login-state branch April 30, 2026 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

semver-patch Bug fix / internal — no release needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants