@duckduckgo/autoconsent 14.97.0 → 15.1.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/build.sh +3 -0
- package/dist/addon-firefox/background.bundle.js +10 -1
- package/dist/addon-firefox/compact-rules.json +1 -1
- package/dist/addon-firefox/content.bundle.js +157 -40
- package/dist/addon-firefox/manifest.json +1 -1
- package/dist/addon-firefox/popup.bundle.js +190 -14
- package/dist/addon-firefox/popup.html +93 -8
- package/dist/addon-firefox/rule-index.json +1 -0
- package/dist/addon-firefox/rules.json +1 -1
- package/dist/addon-mv3/background.bundle.js +10 -1
- package/dist/addon-mv3/compact-rules.json +1 -1
- package/dist/addon-mv3/content.bundle.js +157 -40
- package/dist/addon-mv3/manifest.json +1 -1
- package/dist/addon-mv3/popup.bundle.js +190 -14
- package/dist/addon-mv3/popup.html +93 -8
- package/dist/addon-mv3/rule-index.json +1 -0
- package/dist/addon-mv3/rules.json +1 -1
- package/dist/autoconsent.cjs.js +157 -40
- package/dist/autoconsent.esm.js +157 -40
- package/dist/autoconsent.extra.cjs.js +157 -40
- package/dist/autoconsent.extra.esm.js +157 -40
- package/dist/autoconsent.playwright.js +157 -40
- package/dist/autoconsent.standalone.js +4138 -0
- package/dist/types/cmps/base.d.ts +4 -2
- package/dist/types/cmps/trustarc-top.d.ts +1 -1
- package/dist/types/eval-handler.d.ts +3 -3
- package/dist/types/heuristic-patterns.d.ts +3 -0
- package/dist/types/heuristics.d.ts +4 -7
- package/dist/types/types.d.ts +18 -2
- package/lib/cmps/base.ts +20 -7
- package/lib/cmps/conversant.ts +7 -4
- package/lib/cmps/trustarc-top.ts +1 -1
- package/lib/cmps/uniconsent.ts +4 -4
- package/lib/eval-handler.ts +6 -3
- package/lib/heuristic-patterns.ts +68 -1
- package/lib/heuristics.ts +76 -27
- package/lib/types.ts +20 -2
- package/lib/utils.ts +13 -6
- package/lib/web.ts +3 -1
- package/package.json +1 -1
- package/rules/autoconsent/twitch.json +1 -1
- package/rules/build.ts +4 -0
- package/rules/compact-rules.json +1 -1
- package/rules/rule-index-builder.ts +63 -0
- package/rules/rule-index.json +1 -0
- package/rules/rules.json +1 -1
- package/standalone/content.ts +103 -0
- package/tests-wtr/heuristics/get-actionable-popups.html +16 -0
- package/tests-wtr/heuristics/get-actionable-popups.ts +85 -6
- package/tests-wtr/heuristics/heuristic-cmp.html +69 -0
- package/tests-wtr/heuristics/heuristic-cmp.ts +178 -0
- package/tests-wtr/heuristics/heuristics-utils.test.ts +96 -28
- package/tests-wtr/lifecycle/find-cmp.html +14 -0
- package/tests-wtr/lifecycle/find-cmp.ts +44 -2
|
@@ -19,6 +19,20 @@
|
|
|
19
19
|
<button>Accept All</button>
|
|
20
20
|
<button>Reject All</button>
|
|
21
21
|
</div>
|
|
22
|
+
<div
|
|
23
|
+
id="heuristic-popup-acknowledge-only"
|
|
24
|
+
style="position: fixed; top: 0; left: 0; width: 300px; height: 200px; background: white; display: none"
|
|
25
|
+
>
|
|
26
|
+
<p>We use cookies to improve your experience.</p>
|
|
27
|
+
<button>OK</button>
|
|
28
|
+
</div>
|
|
29
|
+
<div
|
|
30
|
+
id="heuristic-popup-accept-only"
|
|
31
|
+
style="position: fixed; top: 0; left: 0; width: 300px; height: 200px; background: white; display: none"
|
|
32
|
+
>
|
|
33
|
+
<p>We use cookies to improve your experience.</p>
|
|
34
|
+
<button>Accept All</button>
|
|
35
|
+
</div>
|
|
22
36
|
<div id="onetrust-pc-sdk" style="display: none">Cookie Preference Center</div>
|
|
23
37
|
</body>
|
|
24
38
|
</html>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { expect } from '@esm-bundle/chai';
|
|
2
2
|
import Autoconsent from '../../lib/web';
|
|
3
3
|
import Onetrust from '../../lib/cmps/onetrust';
|
|
4
|
+
import { PopupHandlingModes } from '../../lib/types';
|
|
4
5
|
|
|
5
6
|
describe('Autoconsent.findCmp', () => {
|
|
6
7
|
let autoconsent: Autoconsent;
|
|
@@ -145,7 +146,12 @@ describe('Autoconsent.findCmp', () => {
|
|
|
145
146
|
});
|
|
146
147
|
|
|
147
148
|
afterEach(() => {
|
|
148
|
-
document.getElementById('heuristic-popup')
|
|
149
|
+
const heuristicPopup = document.getElementById('heuristic-popup');
|
|
150
|
+
if (heuristicPopup) {
|
|
151
|
+
heuristicPopup.style.display = '';
|
|
152
|
+
}
|
|
153
|
+
document.getElementById('heuristic-popup-acknowledge-only')!.style.display = 'none';
|
|
154
|
+
document.getElementById('heuristic-popup-accept-only')!.style.display = 'none';
|
|
149
155
|
});
|
|
150
156
|
|
|
151
157
|
it('returns heuristic CMP when no declarative rules match', async () => {
|
|
@@ -161,7 +167,7 @@ describe('Autoconsent.findCmp', () => {
|
|
|
161
167
|
const found = await autoconsent.findCmp(1);
|
|
162
168
|
|
|
163
169
|
expect(found).to.have.length(1);
|
|
164
|
-
expect(found[0].name).to.equal('HEURISTIC');
|
|
170
|
+
expect(found[0].name).to.equal('HEURISTIC-TIER0');
|
|
165
171
|
});
|
|
166
172
|
|
|
167
173
|
it('prefers declarative rules over heuristic CMP', async () => {
|
|
@@ -178,5 +184,41 @@ describe('Autoconsent.findCmp', () => {
|
|
|
178
184
|
expect(found).to.have.length(1);
|
|
179
185
|
expect(found[0].name).to.equal('test');
|
|
180
186
|
});
|
|
187
|
+
|
|
188
|
+
it('returns HEURISTIC-TIER1 for acknowledge-only popup when mode is Tier1', async () => {
|
|
189
|
+
document.getElementById('heuristic-popup')!.style.display = 'none';
|
|
190
|
+
document.getElementById('heuristic-popup-acknowledge-only')!.style.display = 'block';
|
|
191
|
+
|
|
192
|
+
autoconsent = new Autoconsent((msg) => Promise.resolve(), {
|
|
193
|
+
enabled: false,
|
|
194
|
+
autoAction: null,
|
|
195
|
+
enableHeuristicAction: true,
|
|
196
|
+
heuristicMode: PopupHandlingModes.Tier1,
|
|
197
|
+
});
|
|
198
|
+
autoconsent.state.findCmpAttempts = 1;
|
|
199
|
+
|
|
200
|
+
const found = await autoconsent.findCmp(1);
|
|
201
|
+
|
|
202
|
+
expect(found).to.have.length(1);
|
|
203
|
+
expect(found[0].name).to.equal('HEURISTIC-TIER1');
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
it('returns HEURISTIC-TIER2 for accept-only popup when mode is Tier2', async () => {
|
|
207
|
+
document.getElementById('heuristic-popup')!.style.display = 'none';
|
|
208
|
+
document.getElementById('heuristic-popup-accept-only')!.style.display = 'block';
|
|
209
|
+
|
|
210
|
+
autoconsent = new Autoconsent((msg) => Promise.resolve(), {
|
|
211
|
+
enabled: false,
|
|
212
|
+
autoAction: null,
|
|
213
|
+
enableHeuristicAction: true,
|
|
214
|
+
heuristicMode: PopupHandlingModes.Tier2,
|
|
215
|
+
});
|
|
216
|
+
autoconsent.state.findCmpAttempts = 1;
|
|
217
|
+
|
|
218
|
+
const found = await autoconsent.findCmp(1);
|
|
219
|
+
|
|
220
|
+
expect(found).to.have.length(1);
|
|
221
|
+
expect(found[0].name).to.equal('HEURISTIC-TIER2');
|
|
222
|
+
});
|
|
181
223
|
});
|
|
182
224
|
});
|