Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop using XRay in Firefox #2852

Merged
merged 11 commits into from
Jan 9, 2025
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ chrome-release-zip:
.PHONY: chrome-release-zip

chrome-beta-zip: prepare-chrome-beta chrome-release-zip


.PHONY: chrome-beta-zip

Expand Down Expand Up @@ -231,12 +231,12 @@ CONTENT_SCOPE_SCRIPTS = node_modules/@duckduckgo/content-scope-scripts
CONTENT_SCOPE_SCRIPTS_DEPS =
CONTENT_SCOPE_SCRIPTS_LOCALES_DEPS =
ifneq ("$(wildcard $(CONTENT_SCOPE_SCRIPTS)/.git/)","")
CONTENT_SCOPE_SCRIPTS_DEPS += $(shell find $(CONTENT_SCOPE_SCRIPTS)/src $(CONTENT_SCOPE_SCRIPTS)/inject $(CONTENT_SCOPE_SCRIPTS)/scripts -type f -not -name "*~")
CONTENT_SCOPE_SCRIPTS_DEPS += $(shell find $(CONTENT_SCOPE_SCRIPTS)/injected/src $(CONTENT_SCOPE_SCRIPTS)/injected/entry-points $(CONTENT_SCOPE_SCRIPTS)/injected/scripts -type f -not -name "*~")
CONTENT_SCOPE_SCRIPTS_DEPS += $(CONTENT_SCOPE_SCRIPTS)/package.json
CONTENT_SCOPE_SCRIPTS_DEPS += $(CONTENT_SCOPE_SCRIPTS)/node_modules
CONTENT_SCOPE_SCRIPTS_DEPS += $(CONTENT_SCOPE_SCRIPTS)/build/locales

CONTENT_SCOPE_SCRIPTS_LOCALES_DEPS += $(shell find $(CONTENT_SCOPE_SCRIPTS)/src/locales $(CONTENT_SCOPE_SCRIPTS)/scripts)
CONTENT_SCOPE_SCRIPTS_LOCALES_DEPS += $(shell find $(CONTENT_SCOPE_SCRIPTS)/injected/src/locales $(CONTENT_SCOPE_SCRIPTS)/injected/scripts)
CONTENT_SCOPE_SCRIPTS_LOCALES_DEPS += $(CONTENT_SCOPE_SCRIPTS)/package.json
CONTENT_SCOPE_SCRIPTS_LOCALES_DEPS += $(CONTENT_SCOPE_SCRIPTS)/node_modules
endif
Expand All @@ -246,11 +246,11 @@ $(CONTENT_SCOPE_SCRIPTS)/node_modules: $(CONTENT_SCOPE_SCRIPTS)/package.json
touch $@

$(CONTENT_SCOPE_SCRIPTS)/build/locales: $(CONTENT_SCOPE_SCRIPTS_LOCALES_DEPS)
cd $(CONTENT_SCOPE_SCRIPTS); npm run build-locales
cd $(CONTENT_SCOPE_SCRIPTS)/injected; npm run build-locales
touch $@

$(CONTENT_SCOPE_SCRIPTS)/build/$(LEGACY_BROWSER)/inject.js: $(CONTENT_SCOPE_SCRIPTS_DEPS)
cd $(CONTENT_SCOPE_SCRIPTS); npm run build-$(LEGACY_BROWSER)
cd $(CONTENT_SCOPE_SCRIPTS)/injected; npm run build-$(LEGACY_BROWSER)

$(BUILD_DIR)/public/js/inject.js: $(CONTENT_SCOPE_SCRIPTS)/build/$(LEGACY_BROWSER)/inject.js shared/data/bundled/tracker-lookup.json shared/data/bundled/extension-config.json
node scripts/bundleContentScopeScripts.mjs $@ $^
Expand All @@ -277,7 +277,7 @@ $(BUILD_DIR)/public/font/%: $(INTERMEDIATES_DIR)/%

# Fetch fonts from the webserver to be included in the generated build
.SECONDARY:
$(INTERMEDIATES_DIR)/%:
$(INTERMEDIATES_DIR)/%:
curl -s -o $@ https://duckduckgo.com/font/all/`basename $@`

## Other
Expand Down
17 changes: 16 additions & 1 deletion browsers/firefox/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,21 @@
],
"match_about_blank": true,
"all_frames": true,
"world": "ISOLATED",
"js": ["public/js/content-scripts/content-scope-messaging.js"],
"run_at": "document_start"
},
{
"matches": [
"<all_urls>"
],
"exclude_matches": [
"*://localhost/*",
"*://*.localhost/*"
],
"match_about_blank": true,
"all_frames": true,
"world": "MAIN",
"js": [
"public/js/inject.js"
],
Expand Down Expand Up @@ -106,4 +121,4 @@
"/public/css/autofill.css",
"/public/font/*"
]
}
}
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
},
"dependencies": {
"@duckduckgo/autofill": "github:duckduckgo/duckduckgo-autofill#15.1.0",
"@duckduckgo/content-scope-scripts": "github:duckduckgo/content-scope-scripts#6.44.0",
"@duckduckgo/content-scope-scripts": "github:duckduckgo/content-scope-scripts#7.3.0",
"@duckduckgo/ddg2dnr": "file:packages/ddg2dnr",
"@duckduckgo/jsbloom": "^1.0.2",
"@duckduckgo/privacy-dashboard": "github:duckduckgo/privacy-dashboard#7.5.0",
Expand Down
15 changes: 8 additions & 7 deletions shared/js/content-scripts/content-scope-messaging.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ async function init() {
// Init the content-scope-scripts with the argumentsObject.
window.dispatchEvent(
new CustomEvent(secret, {
detail: {
detail: JSON.stringify({
type: 'register',
argumentsObject,
},
}),
}),
);
},
Expand All @@ -68,20 +68,21 @@ async function init() {
// response.
// Note: This event listener is only for Chrome MV3 builds of the extension,
// the equivalent Chrome MV2 event listener lives in
// content-scope-scripts/inject/chrome.js.
// content-scope-scripts/entry-points/chrome.js.
window.addEventListener('sendMessageProxy' + secret, (event) => {
event.stopImmediatePropagation();

if (!(event instanceof CustomEvent) || !event?.detail) {
return console.warn('no details in sendMessage proxy', event);
}

const messageType = event.detail?.messageType;
const eventDetail = JSON.parse(event.detail);
const messageType = eventDetail.messageType;
if (!allowedMessages.includes(messageType)) {
return console.warn('Ignoring invalid sendMessage messageType', messageType);
}

chrome.runtime.sendMessage(event.detail, (response) => {
chrome.runtime.sendMessage(eventDetail, (response) => {
const message = {
type: 'update',
messageType: 'response',
Expand All @@ -91,7 +92,7 @@ async function init() {

window.dispatchEvent(
new CustomEvent(secret, {
detail: message,
detail: JSON.stringify(message),
}),
);
});
Expand All @@ -100,7 +101,7 @@ async function init() {
chrome.runtime.onMessage.addListener((message) => {
window.dispatchEvent(
new CustomEvent(secret, {
detail: message,
detail: JSON.stringify(message),
}),
);
});
Expand Down
Loading