Skip to content
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

Filterlist experiment #483

Closed
wants to merge 32 commits into from
Closed

Filterlist experiment #483

wants to merge 32 commits into from

Conversation

muodov
Copy link
Member

@muodov muodov commented Aug 12, 2024

@muodov muodov changed the title Filterlist-experiment Filterlist experiment Aug 12, 2024
@muodov muodov changed the base branch from cosmetic-easylist to main August 12, 2024 13:39
Copy link

@kzar kzar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@muodov I think you're better off waiting for @sammacbeth's review before going ahead with this. It's a fairly large change and I'm not familiar with the codebase, I don't have time to get up to speed with the codebase enough to review the changes properly. That said I left a few comments, maybe they will help speed up the review when Sam's back?

@@ -0,0 +1,3 @@
@@||duckduckgo.com^$document
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the $document filter completely allowlist duckduckgo.com (and subdomains)? Why are the other two filters necessary?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The $document filter is not working for some reason. I think it might be a limitation of the adblocker library

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right, that's weird. Might be worth leaving a comment if nothing else to explain that the filter parsing library you chose isn't working with $document allowing filters or something?

rules/build.mjs Outdated Show resolved Hide resolved
addon/background.ts Outdated Show resolved Hide resolved
addon/popup.html Show resolved Hide resolved
lib/cmps/all.ts Outdated Show resolved Hide resolved
lib/dom-actions.ts Outdated Show resolved Hide resolved

export function getFilterlistSelectors(styles: string): string {
if (styles) {
const selectorsOnly = styles.replace(/\s*{[^\\}]*}\s*/g, ',').replace(/,$/, '');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain this part?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is to strip out all {...} parts, so we have just the selectors without the actual CSS rules. Those selectors are then passed to a utility function that determines if there are any "visible" elements matching those.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it would be better to use the already parsed filters, to pull out the selector part. (Assuming the filter parsing library you used let's you do that.)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we write a test for this to ensure that it's robust to changes in the output of the external adblocker library? i.e. a simple unit-test that creates a filter engine with dummy filters, gets the selectors and runs this function, emitting an expected list of selectors.

@muodov muodov requested a review from sammacbeth August 14, 2024 11:00
Copy link
Collaborator

@sammacbeth sammacbeth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had some minor comments and questions. Mostly the approach looks good.

build.sh Show resolved Hide resolved
lib/dom-actions.ts Outdated Show resolved Hide resolved
lib/web.ts Outdated Show resolved Hide resolved

export function getFilterlistSelectors(styles: string): string {
if (styles) {
const selectorsOnly = styles.replace(/\s*{[^\\}]*}\s*/g, ',').replace(/,$/, '');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we write a test for this to ensure that it's robust to changes in the output of the external adblocker library? i.e. a simple unit-test that creates a filter engine with dummy filters, gets the selectors and runs this function, emitting an expected list of selectors.

lib/web.ts Outdated Show resolved Hide resolved
package.json Show resolved Hide resolved
lib/filterlist-engine.ts Outdated Show resolved Hide resolved
@muodov muodov closed this Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants