@duckduckgo/autoconsent 14.93.0 → 14.95.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/data/coverage.json +1424 -1485
- package/dist/addon-firefox/background.bundle.js +2 -1
- package/dist/addon-firefox/compact-rules.json +1 -1
- package/dist/addon-firefox/content.bundle.js +23 -12
- package/dist/addon-firefox/manifest.json +1 -1
- package/dist/addon-firefox/popup.bundle.js +2 -1
- package/dist/addon-firefox/rules.json +1 -1
- package/dist/addon-mv3/background.bundle.js +2 -1
- package/dist/addon-mv3/compact-rules.json +1 -1
- package/dist/addon-mv3/content.bundle.js +23 -12
- package/dist/addon-mv3/manifest.json +1 -1
- package/dist/addon-mv3/popup.bundle.js +2 -1
- package/dist/addon-mv3/rules.json +1 -1
- package/dist/autoconsent.cjs.js +23 -12
- package/dist/autoconsent.esm.js +23 -12
- package/dist/autoconsent.extra.cjs.js +23 -12
- package/dist/autoconsent.extra.esm.js +23 -12
- package/dist/autoconsent.playwright.js +23 -12
- package/dist/types/heuristics.d.ts +1 -1
- package/dist/types/types.d.ts +1 -0
- package/lib/cmps/base.ts +4 -2
- package/lib/heuristics.ts +13 -8
- package/lib/types.ts +1 -0
- package/lib/utils.ts +1 -0
- package/lib/web.ts +8 -3
- package/package.json +1 -1
- package/rules/autoconsent/aws-amazon.json +23 -13
- package/rules/autoconsent/didomi.json +1 -1
- package/rules/autoconsent/yachtclubgames.json +35 -0
- package/rules/compact-rules.json +1 -1
- package/rules/rules.json +1 -1
- package/tests/didomi.spec.ts +1 -2
- package/tests/yachtclubgames.spec.ts +9 -0
- package/tests-wtr/lifecycle/find-cmp.ts +3 -1
|
@@ -708,7 +708,8 @@
|
|
|
708
708
|
messages: false,
|
|
709
709
|
waits: false
|
|
710
710
|
},
|
|
711
|
-
performanceLoggingEnabled: false
|
|
711
|
+
performanceLoggingEnabled: false,
|
|
712
|
+
heuristicPopupSearchTimeout: 100
|
|
712
713
|
};
|
|
713
714
|
const updatedConfig = copyObject(defaultConfig);
|
|
714
715
|
for (const key of Object.keys(defaultConfig)) {
|
|
@@ -1460,6 +1461,7 @@
|
|
|
1460
1461
|
// lib/heuristics.ts
|
|
1461
1462
|
var BUTTON_LIKE_ELEMENT_SELECTOR = 'button, input[type="button"], input[type="submit"], a, [role="button"], [class*="button"]';
|
|
1462
1463
|
var TEXT_LIMIT = 1e5;
|
|
1464
|
+
var POPUP_SEARCH_MAX_TIME = 100;
|
|
1463
1465
|
function checkHeuristicPatterns(allText, detectPatterns = DETECT_PATTERNS) {
|
|
1464
1466
|
allText = allText.slice(0, TEXT_LIMIT);
|
|
1465
1467
|
const patterns = [];
|
|
@@ -1473,8 +1475,8 @@
|
|
|
1473
1475
|
}
|
|
1474
1476
|
return { patterns, snippets: snippets2 };
|
|
1475
1477
|
}
|
|
1476
|
-
function getActionablePopups() {
|
|
1477
|
-
const popups = getPotentialPopups();
|
|
1478
|
+
function getActionablePopups(timeout = POPUP_SEARCH_MAX_TIME) {
|
|
1479
|
+
const popups = getPotentialPopups(timeout);
|
|
1478
1480
|
const result = popups.reduce((acc, popup) => {
|
|
1479
1481
|
const popupText = popup.text?.trim();
|
|
1480
1482
|
if (popupText) {
|
|
@@ -1528,17 +1530,17 @@
|
|
|
1528
1530
|
result = result.trim();
|
|
1529
1531
|
return result;
|
|
1530
1532
|
}
|
|
1531
|
-
function getPotentialPopups() {
|
|
1533
|
+
function getPotentialPopups(timeout = POPUP_SEARCH_MAX_TIME) {
|
|
1532
1534
|
const isFramed = !isTopFrame();
|
|
1533
1535
|
if (isFramed && window.parent && window.parent !== window.top) {
|
|
1534
1536
|
return [];
|
|
1535
1537
|
}
|
|
1536
|
-
return collectPotentialPopups(isFramed);
|
|
1538
|
+
return collectPotentialPopups(isFramed, timeout);
|
|
1537
1539
|
}
|
|
1538
|
-
function collectPotentialPopups(isFramed) {
|
|
1540
|
+
function collectPotentialPopups(isFramed, timeout = POPUP_SEARCH_MAX_TIME) {
|
|
1539
1541
|
let elements = [];
|
|
1540
1542
|
if (!isFramed) {
|
|
1541
|
-
elements = getPopupLikeElements();
|
|
1543
|
+
elements = getPopupLikeElements(timeout);
|
|
1542
1544
|
} else {
|
|
1543
1545
|
const doc = document.body || document.documentElement;
|
|
1544
1546
|
if (doc && isElementVisible(doc) && doc.innerText) {
|
|
@@ -1566,7 +1568,8 @@
|
|
|
1566
1568
|
}
|
|
1567
1569
|
return false;
|
|
1568
1570
|
}
|
|
1569
|
-
function getPopupLikeElements() {
|
|
1571
|
+
function getPopupLikeElements(timeout = POPUP_SEARCH_MAX_TIME) {
|
|
1572
|
+
const startTime = performance.now();
|
|
1570
1573
|
const walker = document.createTreeWalker(
|
|
1571
1574
|
document.documentElement,
|
|
1572
1575
|
NodeFilter.SHOW_ELEMENT,
|
|
@@ -1585,6 +1588,9 @@
|
|
|
1585
1588
|
return NodeFilter.FILTER_ACCEPT;
|
|
1586
1589
|
}
|
|
1587
1590
|
}
|
|
1591
|
+
if (performance.now() - startTime > timeout) {
|
|
1592
|
+
return NodeFilter.FILTER_REJECT;
|
|
1593
|
+
}
|
|
1588
1594
|
return NodeFilter.FILTER_SKIP;
|
|
1589
1595
|
}
|
|
1590
1596
|
}
|
|
@@ -1988,9 +1994,10 @@
|
|
|
1988
1994
|
get isCosmetic() {
|
|
1989
1995
|
return false;
|
|
1990
1996
|
}
|
|
1991
|
-
detectCmp() {
|
|
1997
|
+
async detectCmp() {
|
|
1998
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
1992
1999
|
this.autoconsent.config.performanceLoggingEnabled && performance.mark("heuristicDetectorStart");
|
|
1993
|
-
this.popups = getActionablePopups();
|
|
2000
|
+
this.popups = getActionablePopups(this.autoconsent.config.heuristicPopupSearchTimeout);
|
|
1994
2001
|
this.autoconsent.config.performanceLoggingEnabled && performance.mark("heuristicDetectorEnd");
|
|
1995
2002
|
this.autoconsent.config.performanceLoggingEnabled && performance.measure("heuristicDetector", "heuristicDetectorStart", "heuristicDetectorEnd");
|
|
1996
2003
|
if (this.popups.length > 0) {
|
|
@@ -3490,7 +3497,7 @@
|
|
|
3490
3497
|
}
|
|
3491
3498
|
}
|
|
3492
3499
|
});
|
|
3493
|
-
const heuristicRules = isTop && this.config.enableHeuristicAction ? [new AutoConsentHeuristicCMP(this)] : [];
|
|
3500
|
+
const heuristicRules = isTop && this.config.enableHeuristicAction && this.state.findCmpAttempts % 2 === 0 ? [new AutoConsentHeuristicCMP(this)] : [];
|
|
3494
3501
|
const rulesPriorityStages = [
|
|
3495
3502
|
["site-specific", siteSpecificRules],
|
|
3496
3503
|
["generic", genericRules],
|
|
@@ -3530,8 +3537,12 @@
|
|
|
3530
3537
|
}
|
|
3531
3538
|
this.detectHeuristics();
|
|
3532
3539
|
if (foundCMPs.length === 0 && retries > 0) {
|
|
3540
|
+
const waitFor2 = [this.domActions.wait(500)];
|
|
3541
|
+
if (this.state.findCmpAttempts > 1) {
|
|
3542
|
+
waitFor2.push(mutationObserver);
|
|
3543
|
+
}
|
|
3533
3544
|
try {
|
|
3534
|
-
await Promise.all(
|
|
3545
|
+
await Promise.all(waitFor2);
|
|
3535
3546
|
} catch (e) {
|
|
3536
3547
|
return [];
|
|
3537
3548
|
}
|
|
@@ -539,7 +539,8 @@
|
|
|
539
539
|
messages: false,
|
|
540
540
|
waits: false
|
|
541
541
|
},
|
|
542
|
-
performanceLoggingEnabled: false
|
|
542
|
+
performanceLoggingEnabled: false,
|
|
543
|
+
heuristicPopupSearchTimeout: 100
|
|
543
544
|
};
|
|
544
545
|
const updatedConfig = copyObject(defaultConfig);
|
|
545
546
|
for (const key of Object.keys(defaultConfig)) {
|