-
Notifications
You must be signed in to change notification settings - Fork 59
Try to use regex heuristics instead of llm for generating one-click rules #176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Replaces LLM-based popup confirmation (llmMatch) with regex-based confirmation (regexMatch) for generating one-click autoconsent rules. Introduces a new required regexConfirmedPopups field in the manifest type while leaving legacy llm code commented out.
- Swaps logic from llmMatch to regexMatch throughout rule generation and processing.
- Updates type definitions to add regexConfirmedPopups and optionally retain a deprecated _llmConfirmedPopups field.
- Leaves prior llm-related code commented out instead of removing it, increasing noise.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| post-processing/generate-autoconsent-rules/types.js | Adds regexConfirmedPopups field and renames llmConfirmedPopups to optional _llmConfirmedPopups. |
| post-processing/generate-autoconsent-rules/main.js | Replaces llmMatch-based filtering with regexMatch and comments out former logic. |
| post-processing/generate-autoconsent-rules/generation.js | Updates rule generation to use regexMatch; retains commented llm code and re-derives popup list. |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| // const llmConfirmedPopups = collectorResult.scrapedFrames.flatMap((frame) => frame.potentialPopups).filter((popup) => popup.llmMatch); | ||
| const regexConfirmedPopups = collectorResult.scrapedFrames.flatMap((frame) => frame.potentialPopups).filter((popup) => popup.regexMatch); | ||
| // if (llmConfirmedPopups.length > 1 || llmConfirmedPopups[0].rejectButtons.length > 1) { | ||
| if (regexConfirmedPopups.length > 1 || regexConfirmedPopups[0].rejectButtons.length > 1) { |
Copilot
AI
Oct 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block assumes regexConfirmedPopups is non-empty (accessing regexConfirmedPopups[0]) based on an earlier guard in the caller; add an explicit guard or an assertion here to make the dependency clear, and consider passing the already-filtered list from the caller instead of recomputing it to avoid duplicated logic.
| if (regexConfirmedPopups.length > 1 || regexConfirmedPopups[0].rejectButtons.length > 1) { | |
| if (regexConfirmedPopups.length > 1 || (regexConfirmedPopups.length > 0 && regexConfirmedPopups[0].rejectButtons.length > 1)) { |
| // const llmConfirmedPopups = collectorResult.scrapedFrames.flatMap((frame) => frame.potentialPopups).filter((popup) => popup.llmMatch); | ||
| const regexConfirmedPopups = collectorResult.scrapedFrames.flatMap((frame) => frame.potentialPopups).filter((popup) => popup.regexMatch); | ||
|
|
||
| // shortcut if no popups with llmMatch | ||
| if (llmConfirmedPopups.length === 0) { | ||
| // if (llmConfirmedPopups.length === 0) { | ||
| if (regexConfirmedPopups.length === 0) { | ||
| return { newRuleFiles, updatedRuleFiles, keptCount: 0, reviewNotes: [], updatedExistingRules }; | ||
| } | ||
|
|
||
| const matchingRules = findMatchingExistingRules(initialUrl, finalUrl, collectorResult, existingRules); | ||
| console.log( | ||
| `Detected ${llmConfirmedPopups.length} unhandled cookie popup(s) on ${finalUrl} (matched ${matchingRules.length} existing rules)`, | ||
| // `Detected ${llmConfirmedPopups.length} unhandled cookie popup(s) on ${finalUrl} (matched ${matchingRules.length} existing rules)`, |
Copilot
AI
Oct 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commented-out legacy llm* code increases noise; remove it or add a concise comment explaining when (or if) it will be reintroduced. Version control preserves history, so keeping multiple commented lines inline can hinder readability.
4d35c4e to
7dc59f6
Compare
No description provided.