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

Add $redirect-rule modifier #1303

Closed
AdamWr opened this issue Jun 5, 2020 · 5 comments
Closed

Add $redirect-rule modifier #1303

AdamWr opened this issue Jun 5, 2020 · 5 comments

Comments

@AdamWr
Copy link
Member

AdamWr commented Jun 5, 2020

$redirect-rule should redirects only these requests which are blocked.
For example, rule like this:
*$script,redirect-rule=noopjs,domain=example.org
should redirects pagead2.googlesyndication.com/pagead/js/adsbygoogle.js, because it's blocked by this rule (from Base filter) /pagead2., but it shouldn't redirects requests like this example.org/script.js.

Description - https://github.com/gorhill/uBlock/wiki/Static-filter-syntax#redirect-rule

@ameshkov ameshkov added this to the v1.7 milestone Jun 5, 2020
@ameshkov
Copy link
Member

ameshkov commented Jun 5, 2020

Let's wait and see how the adoption of it goes

@AdamWr
Copy link
Member Author

AdamWr commented Sep 25, 2020

Do I understand correctly that it was implemented?
If so, then I think that it doesn't work correctly or maybe I just don't understand how it should works:)

Steps to reproduce:

  1. Add this rule:
    *$script,redirect-rule=noopjs,domain=ghacks.net
  2. Go here - https://www.ghacks.net/

As far as I understand, this rule should redirects only blocked requests (requests which are blocked by existing rules in filters), but it seems that it also redirects requests which are not blocked by any rule.

Screenshot without redirect-rule

image

Screenshot with redirect-rule

image

@sxgunchenko
Copy link

For now, it is implemented just as an alias for redirect modifier.

@AdamWr
Copy link
Member Author

AdamWr commented Sep 25, 2020

Okay I understand, but it works differently in uBO, so I'm not sure if it's a good idea.
For example, there is rule like this (in CJX's Annoyance List):
*$image,redirect-rule=1x1.gif,domain=youku.com
https://github.com/AdguardTeam/FiltersRegistry/blob/722d91981b8e6590b9ffd6f6c059c63138339aa9/filters/ThirdParty/filter_220_CJXsAnnoyanceList/diff.txt#L102
and with current implementation it will blocks (redirects) all images.

@ameshkov
Copy link
Member

@sxgunchenko reopened.

It's a popular modifier that needs to be implemented properly.

Modifier description (should be adopted in KB as well):

This is basically an alias to $redirect since it has the same "redirection" values and the logic is almost similar. The difference is that $redirect-rule is applied only in the case when the target request is blocked by a different basic rule.

Negating $redirect-rule works exactly the same way as for regular $redirect rules. Even more than that, @@||example.org^$redirect will negate both $redirect and $redirect-rule rules.

Examples:

||example.org/script.js
||example.org^$redirect-rule=noopjs

In this case, only requests to example.org/script.js will be "redirected". All other requests to example.org will be kept intact.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants