content-scope-scripts
content-scope-scripts copied to clipboard
[PROTOTYPE] web interference detection
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
WebInterferenceDetectioncontent feature prototype + example usages - working integration in the
BrokerProtectioncontent 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
observeDOMChangesflag 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 detectorsbot-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), emittinginterferenceDetected/interferenceChanged.features/broker-protection.js: Integrates detection viacreateWebInterferenceService, addsdetectInterferencehandler and emitsinterferenceDetected/interferenceDetectionError.- Utilities:
error-utils.js: AddssafeCallhelper.- 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.
Temporary Branch Update
The temporary branch has been updated with the latest changes. Below are the details:
- Branch Name: pr-releases/pr-2048
- Commit Hash: a0b8a36c5acbbeb38af7582f64d96734741e4745
- Last Updated: November 6, 2025 at 4:43:00 PM UTC
- Install Command:
npm i github:duckduckgo/content-scope-scripts#a0b8a36c5acbbeb38af7582f64d96734741e4745
Please use the above install command to update to the latest version.
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 |
[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