brave/adblock-rust

`remove-attr`/`remove-class` regex/quoted syntax

antonok-edm opened this issue · 3 comments

Followup to 00b250e, which added support for :remove-attr and :remove-class but not the quoted or regex'd variants.

Hi @antonok-edm ,

I’d like to contribute to resolving this issue. Could you please share your plans for addressing it?

As it stands, remove_classes and remove_attrs in UrlSpecificResources manage the removal of attributes and classes for specific URLs. These properties are hash maps where the key is a selector and the value is a vector of attributes or classes to be removed.

Is the issue related to parsing, or is it about setting the type (e.g., regex or quoted syntax) in the UrlSpecificResources object for the remove_attrs and remove_classes properties? Could you please elaborate?

Thank you!

@thirumurugan-git hi, thanks for your interest!

One thing to note is that there are significant changes coming here from the next branch, which I expect to be merged within a week or so. That includes support for procedural filters, but also reworks how these filters are represented (i.e. remove_classes and remove_attrs are just going to be stored in a flat array of procedural filters, each distinguished by an "action" field).

Aside from that - I believe the parsing part should be fairly simple. IIRC, I've just skipped over any filters where the remove-attr or remove-class field starts with a /. I wasn't sure what the best way to represent these filters was at the time, but I think the simplest thing is to stop skipping them and pass the strings directly as-is to the in-page content script, which can detect them and operate accordingly.

adblock-rust is used by a couple of other projects which may have their own content script implementations, but if you're interested in making that work specifically in Brave Browser, the relevant code is located here.

Hi @antonok-edm ,

Thank you for your prompt response. I believe this issue will be addressed in your next branch, as you have methods like forbid_regex_or_quoted_args to tackle it. If it isn’t resolved in the next branch, I am ready to fix it post-merge.

Could you share a good starting point for contributing to the adblocker? I plan to add support for AdGuard syntax, which is currently lacking in adblock-rust. Do you have any suggestions for this?

I understand that starting after the next branch merge might be more efficient due to the major modifications to the procedural filter. Do you think adding support for AdGuard syntax would be feasible without waiting for this merge?

Also, could you list the projects currently using this adblocker so I can code with those in mind?

Thanks!