Skip to content

Commit 2da46b8

Browse files
sammacbethclaude
andauthored
Use the 'page' heuristics input for frame text (#218)
Frame text is a whole document's innerText, so classifyFrameTextRegex now passes 'page' to checkHeuristicPatterns, as autoconsent's own page-level detection does. Without an input, the page-scoped negatives (age gate, cookie-policy footer link, German cookie verb without a control) were skipped for frames. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 0333f52 commit 2da46b8

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

‎post-processing/generate-autoconsent-rules/detection.js‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@ function classifyPopupTextRegex(text) {
2626
}
2727

2828
/**
29-
* Regex detector for full frame text (frame level).
29+
* Regex detector for full frame text (frame level). Frame text is a whole document's innerText,
30+
* so it uses the 'page' input, as autoconsent's own page-level detection does.
3031
* @param {string} text
3132
* @returns {boolean}
3233
*/
3334
function classifyFrameTextRegex(text) {
34-
return checkHeuristicPatterns(text);
35+
return checkHeuristicPatterns(text, 'page');
3536
}
3637

3738
/**

‎tests/post-processing/detection.mocha.js‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,13 @@ describe('detection', () => {
4040
assert.deepStrictEqual(classifyButtons([reject, accept]), { rejectButtons: [reject], otherButtons: [accept] });
4141
});
4242

43-
it('applies the popup exclusions only at popup level', () => {
43+
it('drops age gates at popup level and next to them at page level', () => {
4444
const ageGate = 'You must be 18 or older to enter. We use cookies to improve your experience.';
4545
assert.strictEqual(classifyPopupTextRegex(ageGate), false);
46-
assert.strictEqual(classifyFrameTextRegex(ageGate), true);
46+
assert.strictEqual(classifyFrameTextRegex(ageGate), false);
47+
// a consent notice with its own controls still counts on the page
48+
const withBanner = `${ageGate}\nAccept all\nReject all`;
49+
assert.strictEqual(classifyFrameTextRegex(withBanner), true);
4750
});
4851

4952
it('skips iframes without buttons', () => {

0 commit comments

Comments
 (0)