@duckduckgo/autoconsent 14.91.0 → 14.93.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 +30 -0
- package/dist/addon-firefox/background.bundle.js +5 -1
- package/dist/addon-firefox/compact-rules.json +1 -1
- package/dist/addon-firefox/content.bundle.js +33 -2
- package/dist/addon-firefox/manifest.json +1 -1
- package/dist/addon-firefox/popup.bundle.js +5 -1
- package/dist/addon-firefox/rules.json +1 -1
- package/dist/addon-mv3/background.bundle.js +5 -1
- package/dist/addon-mv3/compact-rules.json +1 -1
- package/dist/addon-mv3/content.bundle.js +33 -2
- package/dist/addon-mv3/manifest.json +1 -1
- package/dist/addon-mv3/popup.bundle.js +5 -1
- package/dist/addon-mv3/rules.json +1 -1
- package/dist/autoconsent.cjs.js +33 -2
- package/dist/autoconsent.esm.js +33 -2
- package/dist/autoconsent.extra.cjs.js +33 -2
- package/dist/autoconsent.extra.esm.js +33 -2
- package/dist/autoconsent.playwright.js +33 -2
- package/dist/types/messages.d.ts +4 -1
- package/dist/types/types.d.ts +2 -0
- package/dist/types/web.d.ts +8 -0
- package/lib/cmps/base.ts +4 -0
- package/lib/messages.ts +11 -1
- package/lib/types.ts +2 -0
- package/lib/utils.ts +1 -0
- package/lib/web.ts +31 -2
- package/package.json +1 -1
- package/rules/autoconsent/vivenu.json +31 -0
- package/rules/compact-rules.json +1 -1
- package/rules/rules.json +1 -1
- package/tests/vivenu.spec.ts +5 -0
package/dist/autoconsent.cjs.js
CHANGED
|
@@ -742,7 +742,8 @@ function normalizeConfig(providedConfig) {
|
|
|
742
742
|
errors: true,
|
|
743
743
|
messages: false,
|
|
744
744
|
waits: false
|
|
745
|
-
}
|
|
745
|
+
},
|
|
746
|
+
performanceLoggingEnabled: false
|
|
746
747
|
};
|
|
747
748
|
const updatedConfig = copyObject(defaultConfig);
|
|
748
749
|
for (const key of Object.keys(defaultConfig)) {
|
|
@@ -2023,7 +2024,10 @@ var AutoConsentHeuristicCMP = class extends AutoConsentCMPBase {
|
|
|
2023
2024
|
return false;
|
|
2024
2025
|
}
|
|
2025
2026
|
detectCmp() {
|
|
2027
|
+
this.autoconsent.config.performanceLoggingEnabled && performance.mark("heuristicDetectorStart");
|
|
2026
2028
|
this.popups = getActionablePopups();
|
|
2029
|
+
this.autoconsent.config.performanceLoggingEnabled && performance.mark("heuristicDetectorEnd");
|
|
2030
|
+
this.autoconsent.config.performanceLoggingEnabled && performance.measure("heuristicDetector", "heuristicDetectorStart", "heuristicDetectorEnd");
|
|
2027
2031
|
if (this.popups.length > 0) {
|
|
2028
2032
|
return Promise.resolve(true);
|
|
2029
2033
|
}
|
|
@@ -3647,6 +3651,8 @@ var AutoConsent = class {
|
|
|
3647
3651
|
});
|
|
3648
3652
|
}
|
|
3649
3653
|
parseDeclarativeRules(declarativeRules) {
|
|
3654
|
+
const perfEnabled = __privateGet(this, _config)?.performanceLoggingEnabled;
|
|
3655
|
+
perfEnabled && performance.mark("parseDeclarativeRulesStart");
|
|
3650
3656
|
if (declarativeRules.consentomatic) {
|
|
3651
3657
|
for (const [name, rule] of Object.entries(declarativeRules.consentomatic)) {
|
|
3652
3658
|
this.addConsentomaticCMP(name, rule);
|
|
@@ -3662,9 +3668,11 @@ var AutoConsent = class {
|
|
|
3662
3668
|
const rules = decodeRules(declarativeRules.compact);
|
|
3663
3669
|
rules.forEach(this.addDeclarativeCMP.bind(this));
|
|
3664
3670
|
} catch (e) {
|
|
3665
|
-
this
|
|
3671
|
+
__privateGet(this, _config)?.logs.errors && console.error(e);
|
|
3666
3672
|
}
|
|
3667
3673
|
}
|
|
3674
|
+
perfEnabled && performance.mark("parseDeclarativeRulesEnd");
|
|
3675
|
+
perfEnabled && performance.measure("parseDeclarativeRules", "parseDeclarativeRulesStart", "parseDeclarativeRulesEnd");
|
|
3668
3676
|
}
|
|
3669
3677
|
addDeclarativeCMP(ruleset) {
|
|
3670
3678
|
if ((ruleset.minimumRuleStepVersion || 1) <= SUPPORTED_RULE_STEP_VERSION) {
|
|
@@ -3684,6 +3692,9 @@ var AutoConsent = class {
|
|
|
3684
3692
|
this.updateState({ lifecycle: "started" });
|
|
3685
3693
|
const foundCmps = await this.findCmp(this.config.detectRetries);
|
|
3686
3694
|
this.updateState({ detectedCmps: foundCmps.map((c) => c.name) });
|
|
3695
|
+
if (this.config.performanceLoggingEnabled) {
|
|
3696
|
+
this.updateState({ performance: this.measurePerformance() });
|
|
3697
|
+
}
|
|
3687
3698
|
if (foundCmps.length === 0) {
|
|
3688
3699
|
logsConfig.lifecycle && console.log("no CMP found", location.href);
|
|
3689
3700
|
if (this.shouldPrehide) {
|
|
@@ -3777,7 +3788,10 @@ var AutoConsent = class {
|
|
|
3777
3788
|
`Trying ${stageName} rules`,
|
|
3778
3789
|
ruleGroup.map((r) => r.name)
|
|
3779
3790
|
);
|
|
3791
|
+
this.config.performanceLoggingEnabled && performance.mark(`findCmpStage_${stageName}`);
|
|
3780
3792
|
await Promise.all(ruleGroup.map(runDetectCmp));
|
|
3793
|
+
this.config.performanceLoggingEnabled && performance.mark(`findCmpStageEnd_${stageName}`);
|
|
3794
|
+
this.config.performanceLoggingEnabled && performance.measure(`findCmp_${stageName}`, `findCmpStage_${stageName}`, `findCmpStageEnd_${stageName}`);
|
|
3781
3795
|
if (foundCMPs.length > 0) {
|
|
3782
3796
|
break;
|
|
3783
3797
|
}
|
|
@@ -3795,11 +3809,14 @@ var AutoConsent = class {
|
|
|
3795
3809
|
}
|
|
3796
3810
|
detectHeuristics() {
|
|
3797
3811
|
if (this.config.enableHeuristicDetection) {
|
|
3812
|
+
this.config.performanceLoggingEnabled && performance.mark("detectHeuristicsStart");
|
|
3798
3813
|
const { patterns, snippets: snippets2 } = checkHeuristicPatterns(document.documentElement?.innerText || "");
|
|
3799
3814
|
if (patterns.length > 0 && (patterns.length !== this.state.heuristicPatterns.length || this.state.heuristicPatterns.some((p, i) => p !== patterns[i]))) {
|
|
3800
3815
|
this.config.logs.lifecycle && console.log("Heuristic patterns found", patterns, snippets2);
|
|
3801
3816
|
this.updateState({ heuristicPatterns: patterns, heuristicSnippets: snippets2 });
|
|
3802
3817
|
}
|
|
3818
|
+
this.config.performanceLoggingEnabled && performance.mark("detectHeuristicsEnd");
|
|
3819
|
+
this.config.performanceLoggingEnabled && performance.measure("detectHeuristics", "detectHeuristicsStart", "detectHeuristicsEnd");
|
|
3803
3820
|
}
|
|
3804
3821
|
}
|
|
3805
3822
|
/**
|
|
@@ -4061,8 +4078,22 @@ var AutoConsent = class {
|
|
|
4061
4078
|
case "evalResp":
|
|
4062
4079
|
resolveEval(message.id, message.result);
|
|
4063
4080
|
break;
|
|
4081
|
+
case "measurePerformance":
|
|
4082
|
+
this.updateState({ performance: this.measurePerformance() });
|
|
4083
|
+
break;
|
|
4064
4084
|
}
|
|
4065
4085
|
}
|
|
4086
|
+
measurePerformance() {
|
|
4087
|
+
const getRoundedPerformanceEntries = (name) => performance.getEntriesByName(name).map((m) => Number(m.duration.toFixed(3)));
|
|
4088
|
+
return {
|
|
4089
|
+
detectHeuristics: getRoundedPerformanceEntries("detectHeuristics"),
|
|
4090
|
+
heuristicDetector: getRoundedPerformanceEntries("heuristicDetector"),
|
|
4091
|
+
findCmpSiteSpecific: getRoundedPerformanceEntries("findCmp_site-specific"),
|
|
4092
|
+
findCmpGeneric: getRoundedPerformanceEntries("findCmp_generic"),
|
|
4093
|
+
findCmpHeuristic: getRoundedPerformanceEntries("findCmp_heuristic"),
|
|
4094
|
+
parseDeclarativeRules: getRoundedPerformanceEntries("parseDeclarativeRules")
|
|
4095
|
+
};
|
|
4096
|
+
}
|
|
4066
4097
|
};
|
|
4067
4098
|
_config = new WeakMap();
|
|
4068
4099
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/autoconsent.esm.js
CHANGED
|
@@ -712,7 +712,8 @@ function normalizeConfig(providedConfig) {
|
|
|
712
712
|
errors: true,
|
|
713
713
|
messages: false,
|
|
714
714
|
waits: false
|
|
715
|
-
}
|
|
715
|
+
},
|
|
716
|
+
performanceLoggingEnabled: false
|
|
716
717
|
};
|
|
717
718
|
const updatedConfig = copyObject(defaultConfig);
|
|
718
719
|
for (const key of Object.keys(defaultConfig)) {
|
|
@@ -1993,7 +1994,10 @@ var AutoConsentHeuristicCMP = class extends AutoConsentCMPBase {
|
|
|
1993
1994
|
return false;
|
|
1994
1995
|
}
|
|
1995
1996
|
detectCmp() {
|
|
1997
|
+
this.autoconsent.config.performanceLoggingEnabled && performance.mark("heuristicDetectorStart");
|
|
1996
1998
|
this.popups = getActionablePopups();
|
|
1999
|
+
this.autoconsent.config.performanceLoggingEnabled && performance.mark("heuristicDetectorEnd");
|
|
2000
|
+
this.autoconsent.config.performanceLoggingEnabled && performance.measure("heuristicDetector", "heuristicDetectorStart", "heuristicDetectorEnd");
|
|
1997
2001
|
if (this.popups.length > 0) {
|
|
1998
2002
|
return Promise.resolve(true);
|
|
1999
2003
|
}
|
|
@@ -3617,6 +3621,8 @@ var AutoConsent = class {
|
|
|
3617
3621
|
});
|
|
3618
3622
|
}
|
|
3619
3623
|
parseDeclarativeRules(declarativeRules) {
|
|
3624
|
+
const perfEnabled = __privateGet(this, _config)?.performanceLoggingEnabled;
|
|
3625
|
+
perfEnabled && performance.mark("parseDeclarativeRulesStart");
|
|
3620
3626
|
if (declarativeRules.consentomatic) {
|
|
3621
3627
|
for (const [name, rule] of Object.entries(declarativeRules.consentomatic)) {
|
|
3622
3628
|
this.addConsentomaticCMP(name, rule);
|
|
@@ -3632,9 +3638,11 @@ var AutoConsent = class {
|
|
|
3632
3638
|
const rules = decodeRules(declarativeRules.compact);
|
|
3633
3639
|
rules.forEach(this.addDeclarativeCMP.bind(this));
|
|
3634
3640
|
} catch (e) {
|
|
3635
|
-
this
|
|
3641
|
+
__privateGet(this, _config)?.logs.errors && console.error(e);
|
|
3636
3642
|
}
|
|
3637
3643
|
}
|
|
3644
|
+
perfEnabled && performance.mark("parseDeclarativeRulesEnd");
|
|
3645
|
+
perfEnabled && performance.measure("parseDeclarativeRules", "parseDeclarativeRulesStart", "parseDeclarativeRulesEnd");
|
|
3638
3646
|
}
|
|
3639
3647
|
addDeclarativeCMP(ruleset) {
|
|
3640
3648
|
if ((ruleset.minimumRuleStepVersion || 1) <= SUPPORTED_RULE_STEP_VERSION) {
|
|
@@ -3654,6 +3662,9 @@ var AutoConsent = class {
|
|
|
3654
3662
|
this.updateState({ lifecycle: "started" });
|
|
3655
3663
|
const foundCmps = await this.findCmp(this.config.detectRetries);
|
|
3656
3664
|
this.updateState({ detectedCmps: foundCmps.map((c) => c.name) });
|
|
3665
|
+
if (this.config.performanceLoggingEnabled) {
|
|
3666
|
+
this.updateState({ performance: this.measurePerformance() });
|
|
3667
|
+
}
|
|
3657
3668
|
if (foundCmps.length === 0) {
|
|
3658
3669
|
logsConfig.lifecycle && console.log("no CMP found", location.href);
|
|
3659
3670
|
if (this.shouldPrehide) {
|
|
@@ -3747,7 +3758,10 @@ var AutoConsent = class {
|
|
|
3747
3758
|
`Trying ${stageName} rules`,
|
|
3748
3759
|
ruleGroup.map((r) => r.name)
|
|
3749
3760
|
);
|
|
3761
|
+
this.config.performanceLoggingEnabled && performance.mark(`findCmpStage_${stageName}`);
|
|
3750
3762
|
await Promise.all(ruleGroup.map(runDetectCmp));
|
|
3763
|
+
this.config.performanceLoggingEnabled && performance.mark(`findCmpStageEnd_${stageName}`);
|
|
3764
|
+
this.config.performanceLoggingEnabled && performance.measure(`findCmp_${stageName}`, `findCmpStage_${stageName}`, `findCmpStageEnd_${stageName}`);
|
|
3751
3765
|
if (foundCMPs.length > 0) {
|
|
3752
3766
|
break;
|
|
3753
3767
|
}
|
|
@@ -3765,11 +3779,14 @@ var AutoConsent = class {
|
|
|
3765
3779
|
}
|
|
3766
3780
|
detectHeuristics() {
|
|
3767
3781
|
if (this.config.enableHeuristicDetection) {
|
|
3782
|
+
this.config.performanceLoggingEnabled && performance.mark("detectHeuristicsStart");
|
|
3768
3783
|
const { patterns, snippets: snippets2 } = checkHeuristicPatterns(document.documentElement?.innerText || "");
|
|
3769
3784
|
if (patterns.length > 0 && (patterns.length !== this.state.heuristicPatterns.length || this.state.heuristicPatterns.some((p, i) => p !== patterns[i]))) {
|
|
3770
3785
|
this.config.logs.lifecycle && console.log("Heuristic patterns found", patterns, snippets2);
|
|
3771
3786
|
this.updateState({ heuristicPatterns: patterns, heuristicSnippets: snippets2 });
|
|
3772
3787
|
}
|
|
3788
|
+
this.config.performanceLoggingEnabled && performance.mark("detectHeuristicsEnd");
|
|
3789
|
+
this.config.performanceLoggingEnabled && performance.measure("detectHeuristics", "detectHeuristicsStart", "detectHeuristicsEnd");
|
|
3773
3790
|
}
|
|
3774
3791
|
}
|
|
3775
3792
|
/**
|
|
@@ -4031,8 +4048,22 @@ var AutoConsent = class {
|
|
|
4031
4048
|
case "evalResp":
|
|
4032
4049
|
resolveEval(message.id, message.result);
|
|
4033
4050
|
break;
|
|
4051
|
+
case "measurePerformance":
|
|
4052
|
+
this.updateState({ performance: this.measurePerformance() });
|
|
4053
|
+
break;
|
|
4034
4054
|
}
|
|
4035
4055
|
}
|
|
4056
|
+
measurePerformance() {
|
|
4057
|
+
const getRoundedPerformanceEntries = (name) => performance.getEntriesByName(name).map((m) => Number(m.duration.toFixed(3)));
|
|
4058
|
+
return {
|
|
4059
|
+
detectHeuristics: getRoundedPerformanceEntries("detectHeuristics"),
|
|
4060
|
+
heuristicDetector: getRoundedPerformanceEntries("heuristicDetector"),
|
|
4061
|
+
findCmpSiteSpecific: getRoundedPerformanceEntries("findCmp_site-specific"),
|
|
4062
|
+
findCmpGeneric: getRoundedPerformanceEntries("findCmp_generic"),
|
|
4063
|
+
findCmpHeuristic: getRoundedPerformanceEntries("findCmp_heuristic"),
|
|
4064
|
+
parseDeclarativeRules: getRoundedPerformanceEntries("parseDeclarativeRules")
|
|
4065
|
+
};
|
|
4066
|
+
}
|
|
4036
4067
|
};
|
|
4037
4068
|
_config = new WeakMap();
|
|
4038
4069
|
export {
|
|
@@ -11305,7 +11305,8 @@ function normalizeConfig(providedConfig) {
|
|
|
11305
11305
|
errors: true,
|
|
11306
11306
|
messages: false,
|
|
11307
11307
|
waits: false
|
|
11308
|
-
}
|
|
11308
|
+
},
|
|
11309
|
+
performanceLoggingEnabled: false
|
|
11309
11310
|
};
|
|
11310
11311
|
const updatedConfig = copyObject(defaultConfig);
|
|
11311
11312
|
for (const key of Object.keys(defaultConfig)) {
|
|
@@ -13253,7 +13254,10 @@ var AutoConsentHeuristicCMP = class extends AutoConsentCMPBase {
|
|
|
13253
13254
|
return false;
|
|
13254
13255
|
}
|
|
13255
13256
|
detectCmp() {
|
|
13257
|
+
this.autoconsent.config.performanceLoggingEnabled && performance.mark("heuristicDetectorStart");
|
|
13256
13258
|
this.popups = getActionablePopups();
|
|
13259
|
+
this.autoconsent.config.performanceLoggingEnabled && performance.mark("heuristicDetectorEnd");
|
|
13260
|
+
this.autoconsent.config.performanceLoggingEnabled && performance.measure("heuristicDetector", "heuristicDetectorStart", "heuristicDetectorEnd");
|
|
13257
13261
|
if (this.popups.length > 0) {
|
|
13258
13262
|
return Promise.resolve(true);
|
|
13259
13263
|
}
|
|
@@ -14645,6 +14649,8 @@ var AutoConsent = class {
|
|
|
14645
14649
|
});
|
|
14646
14650
|
}
|
|
14647
14651
|
parseDeclarativeRules(declarativeRules) {
|
|
14652
|
+
const perfEnabled = __privateGet(this, _config)?.performanceLoggingEnabled;
|
|
14653
|
+
perfEnabled && performance.mark("parseDeclarativeRulesStart");
|
|
14648
14654
|
if (declarativeRules.consentomatic) {
|
|
14649
14655
|
for (const [name, rule] of Object.entries(declarativeRules.consentomatic)) {
|
|
14650
14656
|
this.addConsentomaticCMP(name, rule);
|
|
@@ -14660,9 +14666,11 @@ var AutoConsent = class {
|
|
|
14660
14666
|
const rules = decodeRules(declarativeRules.compact);
|
|
14661
14667
|
rules.forEach(this.addDeclarativeCMP.bind(this));
|
|
14662
14668
|
} catch (e) {
|
|
14663
|
-
this
|
|
14669
|
+
__privateGet(this, _config)?.logs.errors && console.error(e);
|
|
14664
14670
|
}
|
|
14665
14671
|
}
|
|
14672
|
+
perfEnabled && performance.mark("parseDeclarativeRulesEnd");
|
|
14673
|
+
perfEnabled && performance.measure("parseDeclarativeRules", "parseDeclarativeRulesStart", "parseDeclarativeRulesEnd");
|
|
14666
14674
|
}
|
|
14667
14675
|
addDeclarativeCMP(ruleset) {
|
|
14668
14676
|
if ((ruleset.minimumRuleStepVersion || 1) <= SUPPORTED_RULE_STEP_VERSION) {
|
|
@@ -14682,6 +14690,9 @@ var AutoConsent = class {
|
|
|
14682
14690
|
this.updateState({ lifecycle: "started" });
|
|
14683
14691
|
const foundCmps = await this.findCmp(this.config.detectRetries);
|
|
14684
14692
|
this.updateState({ detectedCmps: foundCmps.map((c) => c.name) });
|
|
14693
|
+
if (this.config.performanceLoggingEnabled) {
|
|
14694
|
+
this.updateState({ performance: this.measurePerformance() });
|
|
14695
|
+
}
|
|
14685
14696
|
if (foundCmps.length === 0) {
|
|
14686
14697
|
logsConfig.lifecycle && console.log("no CMP found", location.href);
|
|
14687
14698
|
if (this.shouldPrehide) {
|
|
@@ -14775,7 +14786,10 @@ var AutoConsent = class {
|
|
|
14775
14786
|
`Trying ${stageName} rules`,
|
|
14776
14787
|
ruleGroup.map((r) => r.name)
|
|
14777
14788
|
);
|
|
14789
|
+
this.config.performanceLoggingEnabled && performance.mark(`findCmpStage_${stageName}`);
|
|
14778
14790
|
await Promise.all(ruleGroup.map(runDetectCmp));
|
|
14791
|
+
this.config.performanceLoggingEnabled && performance.mark(`findCmpStageEnd_${stageName}`);
|
|
14792
|
+
this.config.performanceLoggingEnabled && performance.measure(`findCmp_${stageName}`, `findCmpStage_${stageName}`, `findCmpStageEnd_${stageName}`);
|
|
14779
14793
|
if (foundCMPs.length > 0) {
|
|
14780
14794
|
break;
|
|
14781
14795
|
}
|
|
@@ -14793,11 +14807,14 @@ var AutoConsent = class {
|
|
|
14793
14807
|
}
|
|
14794
14808
|
detectHeuristics() {
|
|
14795
14809
|
if (this.config.enableHeuristicDetection) {
|
|
14810
|
+
this.config.performanceLoggingEnabled && performance.mark("detectHeuristicsStart");
|
|
14796
14811
|
const { patterns, snippets: snippets2 } = checkHeuristicPatterns(document.documentElement?.innerText || "");
|
|
14797
14812
|
if (patterns.length > 0 && (patterns.length !== this.state.heuristicPatterns.length || this.state.heuristicPatterns.some((p, i) => p !== patterns[i]))) {
|
|
14798
14813
|
this.config.logs.lifecycle && console.log("Heuristic patterns found", patterns, snippets2);
|
|
14799
14814
|
this.updateState({ heuristicPatterns: patterns, heuristicSnippets: snippets2 });
|
|
14800
14815
|
}
|
|
14816
|
+
this.config.performanceLoggingEnabled && performance.mark("detectHeuristicsEnd");
|
|
14817
|
+
this.config.performanceLoggingEnabled && performance.measure("detectHeuristics", "detectHeuristicsStart", "detectHeuristicsEnd");
|
|
14801
14818
|
}
|
|
14802
14819
|
}
|
|
14803
14820
|
/**
|
|
@@ -15059,8 +15076,22 @@ var AutoConsent = class {
|
|
|
15059
15076
|
case "evalResp":
|
|
15060
15077
|
resolveEval(message.id, message.result);
|
|
15061
15078
|
break;
|
|
15079
|
+
case "measurePerformance":
|
|
15080
|
+
this.updateState({ performance: this.measurePerformance() });
|
|
15081
|
+
break;
|
|
15062
15082
|
}
|
|
15063
15083
|
}
|
|
15084
|
+
measurePerformance() {
|
|
15085
|
+
const getRoundedPerformanceEntries = (name) => performance.getEntriesByName(name).map((m) => Number(m.duration.toFixed(3)));
|
|
15086
|
+
return {
|
|
15087
|
+
detectHeuristics: getRoundedPerformanceEntries("detectHeuristics"),
|
|
15088
|
+
heuristicDetector: getRoundedPerformanceEntries("heuristicDetector"),
|
|
15089
|
+
findCmpSiteSpecific: getRoundedPerformanceEntries("findCmp_site-specific"),
|
|
15090
|
+
findCmpGeneric: getRoundedPerformanceEntries("findCmp_generic"),
|
|
15091
|
+
findCmpHeuristic: getRoundedPerformanceEntries("findCmp_heuristic"),
|
|
15092
|
+
parseDeclarativeRules: getRoundedPerformanceEntries("parseDeclarativeRules")
|
|
15093
|
+
};
|
|
15094
|
+
}
|
|
15064
15095
|
};
|
|
15065
15096
|
_config = new WeakMap();
|
|
15066
15097
|
|
|
@@ -11239,7 +11239,8 @@ function normalizeConfig(providedConfig) {
|
|
|
11239
11239
|
errors: true,
|
|
11240
11240
|
messages: false,
|
|
11241
11241
|
waits: false
|
|
11242
|
-
}
|
|
11242
|
+
},
|
|
11243
|
+
performanceLoggingEnabled: false
|
|
11243
11244
|
};
|
|
11244
11245
|
const updatedConfig = copyObject(defaultConfig);
|
|
11245
11246
|
for (const key of Object.keys(defaultConfig)) {
|
|
@@ -13187,7 +13188,10 @@ var AutoConsentHeuristicCMP = class extends AutoConsentCMPBase {
|
|
|
13187
13188
|
return false;
|
|
13188
13189
|
}
|
|
13189
13190
|
detectCmp() {
|
|
13191
|
+
this.autoconsent.config.performanceLoggingEnabled && performance.mark("heuristicDetectorStart");
|
|
13190
13192
|
this.popups = getActionablePopups();
|
|
13193
|
+
this.autoconsent.config.performanceLoggingEnabled && performance.mark("heuristicDetectorEnd");
|
|
13194
|
+
this.autoconsent.config.performanceLoggingEnabled && performance.measure("heuristicDetector", "heuristicDetectorStart", "heuristicDetectorEnd");
|
|
13191
13195
|
if (this.popups.length > 0) {
|
|
13192
13196
|
return Promise.resolve(true);
|
|
13193
13197
|
}
|
|
@@ -14579,6 +14583,8 @@ var AutoConsent = class {
|
|
|
14579
14583
|
});
|
|
14580
14584
|
}
|
|
14581
14585
|
parseDeclarativeRules(declarativeRules) {
|
|
14586
|
+
const perfEnabled = __privateGet(this, _config)?.performanceLoggingEnabled;
|
|
14587
|
+
perfEnabled && performance.mark("parseDeclarativeRulesStart");
|
|
14582
14588
|
if (declarativeRules.consentomatic) {
|
|
14583
14589
|
for (const [name, rule] of Object.entries(declarativeRules.consentomatic)) {
|
|
14584
14590
|
this.addConsentomaticCMP(name, rule);
|
|
@@ -14594,9 +14600,11 @@ var AutoConsent = class {
|
|
|
14594
14600
|
const rules = decodeRules(declarativeRules.compact);
|
|
14595
14601
|
rules.forEach(this.addDeclarativeCMP.bind(this));
|
|
14596
14602
|
} catch (e) {
|
|
14597
|
-
this
|
|
14603
|
+
__privateGet(this, _config)?.logs.errors && console.error(e);
|
|
14598
14604
|
}
|
|
14599
14605
|
}
|
|
14606
|
+
perfEnabled && performance.mark("parseDeclarativeRulesEnd");
|
|
14607
|
+
perfEnabled && performance.measure("parseDeclarativeRules", "parseDeclarativeRulesStart", "parseDeclarativeRulesEnd");
|
|
14600
14608
|
}
|
|
14601
14609
|
addDeclarativeCMP(ruleset) {
|
|
14602
14610
|
if ((ruleset.minimumRuleStepVersion || 1) <= SUPPORTED_RULE_STEP_VERSION) {
|
|
@@ -14616,6 +14624,9 @@ var AutoConsent = class {
|
|
|
14616
14624
|
this.updateState({ lifecycle: "started" });
|
|
14617
14625
|
const foundCmps = await this.findCmp(this.config.detectRetries);
|
|
14618
14626
|
this.updateState({ detectedCmps: foundCmps.map((c) => c.name) });
|
|
14627
|
+
if (this.config.performanceLoggingEnabled) {
|
|
14628
|
+
this.updateState({ performance: this.measurePerformance() });
|
|
14629
|
+
}
|
|
14619
14630
|
if (foundCmps.length === 0) {
|
|
14620
14631
|
logsConfig.lifecycle && console.log("no CMP found", location.href);
|
|
14621
14632
|
if (this.shouldPrehide) {
|
|
@@ -14709,7 +14720,10 @@ var AutoConsent = class {
|
|
|
14709
14720
|
`Trying ${stageName} rules`,
|
|
14710
14721
|
ruleGroup.map((r) => r.name)
|
|
14711
14722
|
);
|
|
14723
|
+
this.config.performanceLoggingEnabled && performance.mark(`findCmpStage_${stageName}`);
|
|
14712
14724
|
await Promise.all(ruleGroup.map(runDetectCmp));
|
|
14725
|
+
this.config.performanceLoggingEnabled && performance.mark(`findCmpStageEnd_${stageName}`);
|
|
14726
|
+
this.config.performanceLoggingEnabled && performance.measure(`findCmp_${stageName}`, `findCmpStage_${stageName}`, `findCmpStageEnd_${stageName}`);
|
|
14713
14727
|
if (foundCMPs.length > 0) {
|
|
14714
14728
|
break;
|
|
14715
14729
|
}
|
|
@@ -14727,11 +14741,14 @@ var AutoConsent = class {
|
|
|
14727
14741
|
}
|
|
14728
14742
|
detectHeuristics() {
|
|
14729
14743
|
if (this.config.enableHeuristicDetection) {
|
|
14744
|
+
this.config.performanceLoggingEnabled && performance.mark("detectHeuristicsStart");
|
|
14730
14745
|
const { patterns, snippets: snippets2 } = checkHeuristicPatterns(document.documentElement?.innerText || "");
|
|
14731
14746
|
if (patterns.length > 0 && (patterns.length !== this.state.heuristicPatterns.length || this.state.heuristicPatterns.some((p, i) => p !== patterns[i]))) {
|
|
14732
14747
|
this.config.logs.lifecycle && console.log("Heuristic patterns found", patterns, snippets2);
|
|
14733
14748
|
this.updateState({ heuristicPatterns: patterns, heuristicSnippets: snippets2 });
|
|
14734
14749
|
}
|
|
14750
|
+
this.config.performanceLoggingEnabled && performance.mark("detectHeuristicsEnd");
|
|
14751
|
+
this.config.performanceLoggingEnabled && performance.measure("detectHeuristics", "detectHeuristicsStart", "detectHeuristicsEnd");
|
|
14735
14752
|
}
|
|
14736
14753
|
}
|
|
14737
14754
|
/**
|
|
@@ -14993,8 +15010,22 @@ var AutoConsent = class {
|
|
|
14993
15010
|
case "evalResp":
|
|
14994
15011
|
resolveEval(message.id, message.result);
|
|
14995
15012
|
break;
|
|
15013
|
+
case "measurePerformance":
|
|
15014
|
+
this.updateState({ performance: this.measurePerformance() });
|
|
15015
|
+
break;
|
|
14996
15016
|
}
|
|
14997
15017
|
}
|
|
15018
|
+
measurePerformance() {
|
|
15019
|
+
const getRoundedPerformanceEntries = (name) => performance.getEntriesByName(name).map((m) => Number(m.duration.toFixed(3)));
|
|
15020
|
+
return {
|
|
15021
|
+
detectHeuristics: getRoundedPerformanceEntries("detectHeuristics"),
|
|
15022
|
+
heuristicDetector: getRoundedPerformanceEntries("heuristicDetector"),
|
|
15023
|
+
findCmpSiteSpecific: getRoundedPerformanceEntries("findCmp_site-specific"),
|
|
15024
|
+
findCmpGeneric: getRoundedPerformanceEntries("findCmp_generic"),
|
|
15025
|
+
findCmpHeuristic: getRoundedPerformanceEntries("findCmp_heuristic"),
|
|
15026
|
+
parseDeclarativeRules: getRoundedPerformanceEntries("parseDeclarativeRules")
|
|
15027
|
+
};
|
|
15028
|
+
}
|
|
14998
15029
|
};
|
|
14999
15030
|
_config = new WeakMap();
|
|
15000
15031
|
|
|
@@ -714,7 +714,8 @@
|
|
|
714
714
|
errors: true,
|
|
715
715
|
messages: false,
|
|
716
716
|
waits: false
|
|
717
|
-
}
|
|
717
|
+
},
|
|
718
|
+
performanceLoggingEnabled: false
|
|
718
719
|
};
|
|
719
720
|
const updatedConfig = copyObject(defaultConfig);
|
|
720
721
|
for (const key of Object.keys(defaultConfig)) {
|
|
@@ -1995,7 +1996,10 @@
|
|
|
1995
1996
|
return false;
|
|
1996
1997
|
}
|
|
1997
1998
|
detectCmp() {
|
|
1999
|
+
this.autoconsent.config.performanceLoggingEnabled && performance.mark("heuristicDetectorStart");
|
|
1998
2000
|
this.popups = getActionablePopups();
|
|
2001
|
+
this.autoconsent.config.performanceLoggingEnabled && performance.mark("heuristicDetectorEnd");
|
|
2002
|
+
this.autoconsent.config.performanceLoggingEnabled && performance.measure("heuristicDetector", "heuristicDetectorStart", "heuristicDetectorEnd");
|
|
1999
2003
|
if (this.popups.length > 0) {
|
|
2000
2004
|
return Promise.resolve(true);
|
|
2001
2005
|
}
|
|
@@ -3387,6 +3391,8 @@
|
|
|
3387
3391
|
});
|
|
3388
3392
|
}
|
|
3389
3393
|
parseDeclarativeRules(declarativeRules) {
|
|
3394
|
+
const perfEnabled = __privateGet(this, _config)?.performanceLoggingEnabled;
|
|
3395
|
+
perfEnabled && performance.mark("parseDeclarativeRulesStart");
|
|
3390
3396
|
if (declarativeRules.consentomatic) {
|
|
3391
3397
|
for (const [name, rule] of Object.entries(declarativeRules.consentomatic)) {
|
|
3392
3398
|
this.addConsentomaticCMP(name, rule);
|
|
@@ -3402,9 +3408,11 @@
|
|
|
3402
3408
|
const rules = decodeRules(declarativeRules.compact);
|
|
3403
3409
|
rules.forEach(this.addDeclarativeCMP.bind(this));
|
|
3404
3410
|
} catch (e) {
|
|
3405
|
-
this
|
|
3411
|
+
__privateGet(this, _config)?.logs.errors && console.error(e);
|
|
3406
3412
|
}
|
|
3407
3413
|
}
|
|
3414
|
+
perfEnabled && performance.mark("parseDeclarativeRulesEnd");
|
|
3415
|
+
perfEnabled && performance.measure("parseDeclarativeRules", "parseDeclarativeRulesStart", "parseDeclarativeRulesEnd");
|
|
3408
3416
|
}
|
|
3409
3417
|
addDeclarativeCMP(ruleset) {
|
|
3410
3418
|
if ((ruleset.minimumRuleStepVersion || 1) <= SUPPORTED_RULE_STEP_VERSION) {
|
|
@@ -3424,6 +3432,9 @@
|
|
|
3424
3432
|
this.updateState({ lifecycle: "started" });
|
|
3425
3433
|
const foundCmps = await this.findCmp(this.config.detectRetries);
|
|
3426
3434
|
this.updateState({ detectedCmps: foundCmps.map((c) => c.name) });
|
|
3435
|
+
if (this.config.performanceLoggingEnabled) {
|
|
3436
|
+
this.updateState({ performance: this.measurePerformance() });
|
|
3437
|
+
}
|
|
3427
3438
|
if (foundCmps.length === 0) {
|
|
3428
3439
|
logsConfig.lifecycle && console.log("no CMP found", location.href);
|
|
3429
3440
|
if (this.shouldPrehide) {
|
|
@@ -3517,7 +3528,10 @@
|
|
|
3517
3528
|
`Trying ${stageName} rules`,
|
|
3518
3529
|
ruleGroup.map((r) => r.name)
|
|
3519
3530
|
);
|
|
3531
|
+
this.config.performanceLoggingEnabled && performance.mark(`findCmpStage_${stageName}`);
|
|
3520
3532
|
await Promise.all(ruleGroup.map(runDetectCmp));
|
|
3533
|
+
this.config.performanceLoggingEnabled && performance.mark(`findCmpStageEnd_${stageName}`);
|
|
3534
|
+
this.config.performanceLoggingEnabled && performance.measure(`findCmp_${stageName}`, `findCmpStage_${stageName}`, `findCmpStageEnd_${stageName}`);
|
|
3521
3535
|
if (foundCMPs.length > 0) {
|
|
3522
3536
|
break;
|
|
3523
3537
|
}
|
|
@@ -3535,11 +3549,14 @@
|
|
|
3535
3549
|
}
|
|
3536
3550
|
detectHeuristics() {
|
|
3537
3551
|
if (this.config.enableHeuristicDetection) {
|
|
3552
|
+
this.config.performanceLoggingEnabled && performance.mark("detectHeuristicsStart");
|
|
3538
3553
|
const { patterns, snippets: snippets2 } = checkHeuristicPatterns(document.documentElement?.innerText || "");
|
|
3539
3554
|
if (patterns.length > 0 && (patterns.length !== this.state.heuristicPatterns.length || this.state.heuristicPatterns.some((p, i) => p !== patterns[i]))) {
|
|
3540
3555
|
this.config.logs.lifecycle && console.log("Heuristic patterns found", patterns, snippets2);
|
|
3541
3556
|
this.updateState({ heuristicPatterns: patterns, heuristicSnippets: snippets2 });
|
|
3542
3557
|
}
|
|
3558
|
+
this.config.performanceLoggingEnabled && performance.mark("detectHeuristicsEnd");
|
|
3559
|
+
this.config.performanceLoggingEnabled && performance.measure("detectHeuristics", "detectHeuristicsStart", "detectHeuristicsEnd");
|
|
3543
3560
|
}
|
|
3544
3561
|
}
|
|
3545
3562
|
/**
|
|
@@ -3801,8 +3818,22 @@
|
|
|
3801
3818
|
case "evalResp":
|
|
3802
3819
|
resolveEval(message.id, message.result);
|
|
3803
3820
|
break;
|
|
3821
|
+
case "measurePerformance":
|
|
3822
|
+
this.updateState({ performance: this.measurePerformance() });
|
|
3823
|
+
break;
|
|
3804
3824
|
}
|
|
3805
3825
|
}
|
|
3826
|
+
measurePerformance() {
|
|
3827
|
+
const getRoundedPerformanceEntries = (name) => performance.getEntriesByName(name).map((m) => Number(m.duration.toFixed(3)));
|
|
3828
|
+
return {
|
|
3829
|
+
detectHeuristics: getRoundedPerformanceEntries("detectHeuristics"),
|
|
3830
|
+
heuristicDetector: getRoundedPerformanceEntries("heuristicDetector"),
|
|
3831
|
+
findCmpSiteSpecific: getRoundedPerformanceEntries("findCmp_site-specific"),
|
|
3832
|
+
findCmpGeneric: getRoundedPerformanceEntries("findCmp_generic"),
|
|
3833
|
+
findCmpHeuristic: getRoundedPerformanceEntries("findCmp_heuristic"),
|
|
3834
|
+
parseDeclarativeRules: getRoundedPerformanceEntries("parseDeclarativeRules")
|
|
3835
|
+
};
|
|
3836
|
+
}
|
|
3806
3837
|
};
|
|
3807
3838
|
_config = new WeakMap();
|
|
3808
3839
|
|
package/dist/types/messages.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { snippets } from './eval-snippets';
|
|
2
2
|
import { Config, ConsentState, RuleBundle } from './types';
|
|
3
|
-
export type BackgroundMessage = InitResponseMessage | EvalResponseMessage | OptOutMessage | OptInMessage | SelfTestMessage;
|
|
3
|
+
export type BackgroundMessage = InitResponseMessage | EvalResponseMessage | OptOutMessage | OptInMessage | SelfTestMessage | MeasurePerformanceMessage;
|
|
4
4
|
export type ContentScriptMessage = InitMessage | EvalMessage | DelayMessage | DetectedMessage | FoundMessage | OptOutResultMessage | OptInResultMessage | SelfTestResultMessage | DoneMessage | ErrorMessage | ReportMessage;
|
|
5
5
|
export type BackgroundDevtoolsMessage = DevtoolsAuditMessage | InstanceTerminatedMessage | InitResponseMessage;
|
|
6
6
|
export type DevtoolsMessage = DevtoolsInitMessage;
|
|
@@ -99,3 +99,6 @@ export type DevtoolsInitMessage = {
|
|
|
99
99
|
type: 'init';
|
|
100
100
|
tabId: number;
|
|
101
101
|
};
|
|
102
|
+
export type MeasurePerformanceMessage = {
|
|
103
|
+
type: 'measurePerformance';
|
|
104
|
+
};
|
package/dist/types/types.d.ts
CHANGED
|
@@ -72,6 +72,7 @@ export type Config = {
|
|
|
72
72
|
messages: boolean;
|
|
73
73
|
waits: boolean;
|
|
74
74
|
};
|
|
75
|
+
performanceLoggingEnabled: boolean;
|
|
75
76
|
};
|
|
76
77
|
export type LifecycleState = 'loading' | 'initialized' | 'waitingForInitResponse' | 'started' | 'nothingDetected' | 'cosmeticFiltersDetected' | 'cmpDetected' | 'openPopupDetected' | 'runningOptOut' | 'runningOptIn' | 'optOutSucceeded' | 'optOutFailed' | 'optInSucceeded' | 'optInFailed' | 'done';
|
|
77
78
|
export type ConsentState = {
|
|
@@ -88,6 +89,7 @@ export type ConsentState = {
|
|
|
88
89
|
clicks: number;
|
|
89
90
|
startTime: number;
|
|
90
91
|
endTime: number;
|
|
92
|
+
performance?: Record<string, number[]>;
|
|
91
93
|
};
|
|
92
94
|
export interface ButtonData {
|
|
93
95
|
text: string;
|
package/dist/types/web.d.ts
CHANGED
|
@@ -57,4 +57,12 @@ export default class AutoConsent {
|
|
|
57
57
|
filterListFallback(): boolean;
|
|
58
58
|
updateState(change: Partial<ConsentState>): void;
|
|
59
59
|
receiveMessageCallback(message: BackgroundMessage): Promise<void>;
|
|
60
|
+
measurePerformance(): {
|
|
61
|
+
detectHeuristics: number[];
|
|
62
|
+
heuristicDetector: number[];
|
|
63
|
+
findCmpSiteSpecific: number[];
|
|
64
|
+
findCmpGeneric: number[];
|
|
65
|
+
findCmpHeuristic: number[];
|
|
66
|
+
parseDeclarativeRules: number[];
|
|
67
|
+
};
|
|
60
68
|
}
|
package/lib/cmps/base.ts
CHANGED
|
@@ -442,7 +442,11 @@ export class AutoConsentHeuristicCMP extends AutoConsentCMPBase {
|
|
|
442
442
|
}
|
|
443
443
|
|
|
444
444
|
detectCmp(): Promise<boolean> {
|
|
445
|
+
this.autoconsent.config.performanceLoggingEnabled && performance.mark('heuristicDetectorStart');
|
|
445
446
|
this.popups = getActionablePopups();
|
|
447
|
+
this.autoconsent.config.performanceLoggingEnabled && performance.mark('heuristicDetectorEnd');
|
|
448
|
+
this.autoconsent.config.performanceLoggingEnabled &&
|
|
449
|
+
performance.measure('heuristicDetector', 'heuristicDetectorStart', 'heuristicDetectorEnd');
|
|
446
450
|
if (this.popups.length > 0) {
|
|
447
451
|
return Promise.resolve(true);
|
|
448
452
|
}
|
package/lib/messages.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { snippets } from './eval-snippets';
|
|
2
2
|
import { Config, ConsentState, RuleBundle } from './types';
|
|
3
3
|
|
|
4
|
-
export type BackgroundMessage =
|
|
4
|
+
export type BackgroundMessage =
|
|
5
|
+
| InitResponseMessage
|
|
6
|
+
| EvalResponseMessage
|
|
7
|
+
| OptOutMessage
|
|
8
|
+
| OptInMessage
|
|
9
|
+
| SelfTestMessage
|
|
10
|
+
| MeasurePerformanceMessage;
|
|
5
11
|
|
|
6
12
|
export type ContentScriptMessage =
|
|
7
13
|
| InitMessage
|
|
@@ -130,3 +136,7 @@ export type DevtoolsInitMessage = {
|
|
|
130
136
|
type: 'init';
|
|
131
137
|
tabId: number;
|
|
132
138
|
};
|
|
139
|
+
|
|
140
|
+
export type MeasurePerformanceMessage = {
|
|
141
|
+
type: 'measurePerformance';
|
|
142
|
+
};
|
package/lib/types.ts
CHANGED
|
@@ -76,6 +76,7 @@ export type Config = {
|
|
|
76
76
|
messages: boolean;
|
|
77
77
|
waits: boolean;
|
|
78
78
|
};
|
|
79
|
+
performanceLoggingEnabled: boolean;
|
|
79
80
|
};
|
|
80
81
|
|
|
81
82
|
export type LifecycleState =
|
|
@@ -109,6 +110,7 @@ export type ConsentState = {
|
|
|
109
110
|
clicks: number; // Number of clicks the script has made.
|
|
110
111
|
startTime: number; // The time the script started.
|
|
111
112
|
endTime: number; // The time the script ended.
|
|
113
|
+
performance?: Record<string, number[]>;
|
|
112
114
|
};
|
|
113
115
|
|
|
114
116
|
export interface ButtonData {
|
package/lib/utils.ts
CHANGED