content-scope-scripts icon indicating copy to clipboard operation
content-scope-scripts copied to clipboard

[PROTOTYPE] web interference detection

Open madblex opened this issue 4 weeks ago • 3 comments

Asana Task/Github Issue: https://app.asana.com/1/137249556945/project/1206054067224240/task/1211804981097440

Description

This PR builds a prototype for the WebInterferenceDetection system:

  • the service with the detection logic
  • the associated WebInterferenceDetection content feature prototype + example usages
  • working integration in the BrokerProtection content feature

Goals

  • Keep all interference detection logic in one place (services/web-interference-detection/) to avoid duplication across features while maintaining flexibility for future detector types.
  • All detectors use common utilities from detection-utils.js (selector checking, visibility detection, pattern matching) to maximise code reuse and consistency.
  • The service architecture intentionally avoids over-constraining detector implementations. We will revisit this based on what patterns emerge.
  • Unsure about this: Each interference type has an independent configuration with observeDOMChanges flag controlling whether continuous monitoring is enabled per-detector.

Caveats

Current implementation creates new observers for each detect() call when observeDOMChanges: true. Multiple detections may create redundant observers. Future iterations should consider observer pooling/reuse, debouncing detection calls, or centralised DOM observation.

Testing Steps

n/a

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] Introduces a config-driven Web Interference Detection service (bot/fraud/YouTube ads) with messaging APIs, a new feature entry point, and BrokerProtection integration.

  • Services:
    • injected/src/services/web-interference-detection/: New detection service with detectors bot-detection, fraud-detection, youtube-ads-detection, shared utils (detection-utils, result-factory), default config, and type definitions.
    • detector-service.js: Orchestrates detections per request and optional continuous monitoring via callbacks.
  • Features:
    • features/web-interference-detection.js: New content feature enabling on-demand detection (detectInterference) and continuous monitoring (startInterferenceMonitoring), emitting interferenceDetected/interferenceChanged.
    • features/broker-protection.js: Integrates detection via createWebInterferenceService, adds detectInterference handler and emits interferenceDetected/interferenceDetectionError.
  • Utilities:
    • error-utils.js: Adds safeCall helper.
  • Config/Types:
    • default-config.js: Default interference configuration (bot, fraud, YouTube ads).
    • types/*.js: API and detection type definitions.

Written by Cursor Bugbot for commit 5e9d02fbfbb713def7cac3c5171633d8b0212657. This will update automatically on new commits. Configure here.

madblex avatar Nov 06 '25 16:11 madblex

Temporary Branch Update

The temporary branch has been updated with the latest changes. Below are the details:

Please use the above install command to update to the latest version.

github-actions[bot] avatar Nov 06 '25 16:11 github-actions[bot]

Deploy Preview for content-scope-scripts failed.

Name Link
Latest commit 5e9d02fbfbb713def7cac3c5171633d8b0212657
Latest deploy log https://app.netlify.com/projects/content-scope-scripts/deploys/690ccfe85521e10008df863b

netlify[bot] avatar Nov 06 '25 16:11 netlify[bot]

[Beta] Generated file diff

Time updated: Thu, 06 Nov 2025 16:43:18 GMT

Android
    - android/autofillImport.js
  • android/brokerProtection.js

File has changed

Apple
    - apple/contentScopeIsolated.js

File has changed

Integration
    - integration/contentScope.js

File has changed

Windows
    - windows/contentScope.js

File has changed

github-actions[bot] avatar Nov 06 '25 16:11 github-actions[bot]