Skip to content

Commit 5d65eb4

Browse files
Release build 11.14.0 [ci release]
1 parent 8d591b8 commit 5d65eb4

File tree

10 files changed

+1635
-478
lines changed

10 files changed

+1635
-478
lines changed

CHANGELOG.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
- ntp: support empty strings in persistent storage (#1932)
2-
- ntp: allow visibility menu items to be disabled (#1930)
3-
- Update dark search icon (#1915)
4-
- build(deps-dev): bump the eslint group across 1 directory with 2 updates (#1925)
1+
- Page context follow up work (#1931)

build/apple/contentScope.js

Lines changed: 304 additions & 78 deletions
Large diffs are not rendered by default.

build/apple/contentScopeIsolated.js

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2028,6 +2028,15 @@
20282028
createCustomEvent("sendMessageProxy" + messageSecret, { detail: JSON.stringify({ messageType, options }) })
20292029
);
20302030
}
2031+
function isDuckAi() {
2032+
const tabUrl = getTabUrl();
2033+
const domains = ["duckduckgo.com", "duck.ai", "duck.co"];
2034+
if (tabUrl?.hostname && domains.includes(tabUrl?.hostname)) {
2035+
const url = new URL(tabUrl?.href);
2036+
return url.searchParams.has("duckai");
2037+
}
2038+
return false;
2039+
}
20312040

20322041
// src/features.js
20332042
init_define_import_meta_trackerLookup();
@@ -15398,7 +15407,7 @@ ul.messages {
1539815407
__publicField(this, "listenForUrlChanges", true);
1539915408
}
1540015409
init() {
15401-
if (this.isDuckAi()) {
15410+
if (isDuckAi()) {
1540215411
return;
1540315412
}
1540415413
this.setupMessageHandlers();
@@ -15409,16 +15418,9 @@ ul.messages {
1540915418
window.addEventListener("hashchange", () => {
1541015419
this.handleContentCollectionRequest({});
1541115420
});
15412-
}
15413-
isDuckAi() {
15414-
if (window?.top?.location?.hostname === "duckduckgo.com") {
15415-
return true;
15416-
}
15417-
if (window.location.hostname === "duckduckgo.com") {
15418-
const url = new URL(window.location.href);
15419-
return url.searchParams.has("duckai");
15420-
}
15421-
return false;
15421+
window.addEventListener("pageshow", () => {
15422+
this.handleContentCollectionRequest({});
15423+
});
1542215424
}
1542315425
/**
1542415426
* @param {NavigationType} _navigationType
@@ -15477,6 +15479,7 @@ ul.messages {
1547715479
}
1547815480
}
1547915481
const content = {
15482+
favicon: getFaviconList(),
1548015483
title: this.getPageTitle(),
1548115484
metaDescription: this.getMetaDescription(),
1548215485
content: this.getMainContent(options),

build/integration/contentScope.js

Lines changed: 309 additions & 89 deletions
Large diffs are not rendered by default.

injected/integration-test/extension/contentScope.js

Lines changed: 309 additions & 89 deletions
Large diffs are not rendered by default.

injected/integration-test/test-pages/build/contentScope.js

Lines changed: 309 additions & 89 deletions
Large diffs are not rendered by default.

injected/src/features/duck-ai-listener.js

Lines changed: 371 additions & 105 deletions
Large diffs are not rendered by default.

injected/src/features/favicon.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ function monitor(changeObservedCallback) {
8787
/**
8888
* @returns {import('../types/favicon.js').FaviconAttrs[]}
8989
*/
90-
function getFaviconList() {
90+
export function getFaviconList() {
9191
const selectors = [
9292
"link[href][rel='favicon']",
9393
"link[href][rel*='icon']",

injected/src/features/page-context.js

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import ContentFeature from '../content-feature.js';
2+
import { getFaviconList } from './favicon.js';
3+
import { isDuckAi } from '../utils.js';
24
const MSG_PAGE_CONTEXT_COLLECT = 'collect';
35
const MSG_PAGE_CONTEXT_RESPONSE = 'collectionResult';
46
const MSG_PAGE_CONTEXT_ERROR = 'collectionError';
@@ -9,7 +11,7 @@ export default class PageContext extends ContentFeature {
911
listenForUrlChanges = true;
1012

1113
init() {
12-
if (this.isDuckAi()) {
14+
if (isDuckAi()) {
1315
return;
1416
}
1517
this.setupMessageHandlers();
@@ -20,17 +22,9 @@ export default class PageContext extends ContentFeature {
2022
window.addEventListener('hashchange', () => {
2123
this.handleContentCollectionRequest({});
2224
});
23-
}
24-
25-
isDuckAi() {
26-
if (window?.top?.location?.hostname === 'duckduckgo.com') {
27-
return true;
28-
}
29-
if (window.location.hostname === 'duckduckgo.com') {
30-
const url = new URL(window.location.href);
31-
return url.searchParams.has('duckai');
32-
}
33-
return false;
25+
window.addEventListener('pageshow', () => {
26+
this.handleContentCollectionRequest({});
27+
});
3428
}
3529

3630
/**
@@ -106,6 +100,7 @@ export default class PageContext extends ContentFeature {
106100
}
107101

108102
const content = {
103+
favicon: getFaviconList(),
109104
title: this.getPageTitle(),
110105
metaDescription: this.getMetaDescription(),
111106
content: this.getMainContent(options),

injected/src/utils.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,3 +835,13 @@ export function withExponentialBackoff(fn, maxAttempts = 4, delay = 500) {
835835
tryFn();
836836
});
837837
}
838+
839+
export function isDuckAi() {
840+
const tabUrl = getTabUrl();
841+
const domains = ['duckduckgo.com', 'duck.ai', 'duck.co'];
842+
if (tabUrl?.hostname && domains.includes(tabUrl?.hostname)) {
843+
const url = new URL(tabUrl?.href);
844+
return url.searchParams.has('duckai');
845+
}
846+
return false;
847+
}

0 commit comments

Comments
 (0)