Skip to content
11 changes: 11 additions & 0 deletions injected/entry-points/extension-mv3.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/
import { load, init, update } from '../src/content-scope-features.js';
import { computeLimitedSiteObject } from '../src/utils.js';
import { getSharedMessagingTransport } from '../src/sendmessage-transport.js';

const secret = (crypto.getRandomValues(new Uint32Array(1))[0] / 2 ** 32).toString().replace('0.', '');

Expand Down Expand Up @@ -34,6 +35,16 @@ window.addEventListener(secret, ({ detail: encodedMessage }) => {
init(message.argumentsObject);
}
break;
default:
// Messages with messageType are subscription responses from the extension.
// Route them to the shared transport so all subscribed features receive them.
if (message.messageType) {
const transport = getSharedMessagingTransport();
if (transport?.onResponse) {
transport.onResponse(message);
}
}
break;
}
});

Expand Down
1 change: 0 additions & 1 deletion injected/src/detectors/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ detectors/
│ └── fraud-detection.js # fraud/phishing warning utility
├── utils/
│ └── detection-utils.js # DOM helpers (selectors, text matching, visibility)
└── default-config.js # fallback detector settings
```

## How It Works
Expand Down
48 changes: 0 additions & 48 deletions injected/src/detectors/default-config.js

This file was deleted.

2 changes: 1 addition & 1 deletion injected/src/features.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const platformSupport = {
'pageContext',
'duckAiDataClearing',
],
firefox: ['cookie', ...baseFeatures, 'clickToLoad'],
firefox: ['cookie', ...baseFeatures, 'clickToLoad', 'webInterferenceDetection', 'breakageReporting'],
chrome: ['cookie', ...baseFeatures, 'clickToLoad', 'webInterferenceDetection', 'breakageReporting'],
'chrome-mv3': ['cookie', ...baseFeatures, 'clickToLoad', 'webInterferenceDetection', 'breakageReporting'],
integration: [...baseFeatures, ...otherFeatures],
Expand Down
1 change: 1 addition & 0 deletions injected/src/features/breakage-reporting.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export default class BreakageReporting extends ContentFeature {
}

// Only run detectors if explicitly configured
// Fetch interferenceTypes from webInterferenceDetection feature settings
const detectorSettings = this.getFeatureSetting('interferenceTypes', 'webInterferenceDetection');
if (detectorSettings) {
result.detectorData = {
Expand Down
22 changes: 20 additions & 2 deletions injected/src/sendmessage-transport.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,30 @@ import { TestTransportConfig } from '../../messaging/index.js';
* @typedef {import('@duckduckgo/messaging').MessagingTransport} MessagingTransport
*/

/**
* Singleton transport shared across all features. Without this, each feature would
* have its own transport/queue and wouldn't receive messages meant for other features.
* @type {SendMessageMessagingTransport | null}
*/
let sharedTransport = null;

/**
* @deprecated - A temporary constructor for the extension to make the messaging config
*/
export function extensionConstructMessagingConfig() {
const messagingTransport = new SendMessageMessagingTransport();
return new TestTransportConfig(messagingTransport);
return new TestTransportConfig(getSharedMessagingTransport());
}

/**
* Used by entry-points to route incoming extension messages to onResponse().
* Ensures a singleton transport exists.
* @returns {SendMessageMessagingTransport}
*/
export function getSharedMessagingTransport() {
if (!sharedTransport) {
sharedTransport = new SendMessageMessagingTransport();
}
return sharedTransport;
}

/**
Expand Down
Loading