-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add optional heuristic pattern detection (#555)
* Set waits log default value * Increase the timeout for the prehide filterlist check * Add optional check for heuristic patterns * Make sure the heuristics are tested after a CMP is detected
- Loading branch information
Showing
5 changed files
with
65 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// TODO: check for false positive detections per pattern | ||
export const DETECT_PATTERNS = [ | ||
/accept cookies/gi, | ||
/accept all/gi, | ||
/reject all/gi, | ||
/only necessary cookies/gi, // "only necessary" is probably too broad | ||
/by clicking.*(accept|agree|allow)/gi, | ||
/by continuing/gi, | ||
/we (use|serve)( optional)? cookies/gi, | ||
/we are using cookies/gi, | ||
/use of cookies/gi, | ||
/(this|our) (web)?site.*cookies/gi, | ||
/cookies (and|or) .* technologies/gi, | ||
/such as cookies/gi, | ||
/read more about.*cookies/gi, | ||
/consent to.*cookies/gi, | ||
/we and our partners.*cookies/gi, | ||
/we.*store.*information.*such as.*cookies/gi, | ||
/store and\/or access information.*on a device/gi, | ||
/personalised ads and content, ad and content measurement/gi, | ||
|
||
// it might be tempting to add the patterns below, but they cause too many false positives. Don't do it :) | ||
// /cookies? settings/i, | ||
// /cookies? preferences/i, | ||
]; | ||
|
||
export function checkHeuristicPatterns() { | ||
const allText = document.documentElement.innerText; | ||
const patterns = []; | ||
const snippets = []; | ||
for (const p of DETECT_PATTERNS) { | ||
const matches = allText.match(p); | ||
if (matches) { | ||
patterns.push(p.toString()); | ||
snippets.push(...matches.map((m) => m.substring(0, 200))); | ||
} | ||
} | ||
return { patterns, snippets }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters