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

feat: $removeparam #4528

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open

feat: $removeparam #4528

wants to merge 18 commits into from

Conversation

seia-soto
Copy link
Member

@seia-soto seia-soto commented Dec 13, 2024

This adds experimental $removeparam support for adblocker: https://github.com/gorhill/ublock/wiki/static-filter-syntax#removeparam

The suggested matching process changed by this PR is illustrated as follows:

  1. $important (not subject to exceptions)
  2. redirection ($removeparam and $redirect=resource)
  3. normal filters
  4. exceptions

The removeparam filter priorities are as the followings, and also described in the exception test as a code:

Details
  • s1) global removal + exception => global removal wins
@@||example.com$removeparam=utm
||example.com$removeparam

result.filter=global removal
result.exception=(none)

  • s2) removal + global exception => exception wins
||example.com$removeparam=utm
@@||example.com$removeparam

result.filter=removal
result.exception=global exception

  • s3) removal + exception => exception wins
||example.com$removeparam=utm
@@||example.com$removeparam=utm

result.filter=removal
result.exception=exception


  1. global exception
  2. global removal
  3. exception
  4. removal

TODO

  • Parsing regex as value (in separate PR with refactor and clean up of regex util funcs)

@seia-soto seia-soto added the PR: New Feature 🚀 Increment minor version when merged label Dec 13, 2024
@seia-soto seia-soto self-assigned this Dec 13, 2024
@seia-soto seia-soto added the WIP label Dec 13, 2024
Copy link
Member

@chrmod chrmod left a comment

Choose a reason for hiding this comment

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

@seia-soto
Copy link
Member Author

Note: we're going to apply filters one by one

@seia-soto seia-soto removed the WIP label Dec 25, 2024
@seia-soto
Copy link
Member Author

Leaving a note: regexp wrapping: [\\?&](${value!.slice(1, flagSeparatorIndex)}[^=]*)

test: add `isRemoveParam` and `isRedirectable`

chore: reject on `removeparam` negation

test: parsing removeparam

test: removeparam

test: removeparam
@seia-soto seia-soto marked this pull request as ready for review December 27, 2024 11:03
@seia-soto seia-soto requested a review from remusao as a code owner December 27, 2024 11:03
@seia-soto seia-soto requested a review from chrmod December 27, 2024 11:03
packages/adblocker/src/filters/network.ts Show resolved Hide resolved
packages/adblocker/src/filters/network.ts Outdated Show resolved Hide resolved
packages/adblocker/src/filters/network.ts Show resolved Hide resolved
packages/adblocker/test/parsing.test.ts Show resolved Hide resolved
packages/adblocker/src/engine/engine.ts Outdated Show resolved Hide resolved
@seia-soto seia-soto requested a review from remusao January 6, 2025 06:02
Copy link
Member

@chrmod chrmod left a comment

Choose a reason for hiding this comment

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

Does this support exceptions like $removeparam=igshid,domain=instagram.com|threads.net?

packages/adblocker/src/filters/network.ts Show resolved Hide resolved
* s1) global removal + exception => global removal wins
```
@@||example.com$removeparam=utm
||example.com$removeparam
```
result.filter=global removal
result.exception=(none)

* s2) removal + global exception => exception wins
```
||example.com$removeparam=utm
@@||example.com$removeparam
```
result.filter=removal
result.exception=global exception

* s3) removal + exception => exception wins
```
||example.com$removeparam=utm
@@||example.com$removeparam=utm
```
result.filter=removal
result.exception=exception

---

0. global exception
1. global removal
2. exception
3. removal
@seia-soto seia-soto requested a review from chrmod January 16, 2025 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: New Feature 🚀 Increment minor version when merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants