CoreLibs icon indicating copy to clipboard operation
CoreLibs copied to clipboard

Add ability to block request for requests "unblocked" by `$replace` rule

Open AdamWr opened this issue 8 months ago • 2 comments

Issue Details

Sometimes website uses "random" path for scripts or requests and broad $replace rule is used, like for example - ||example.org^$replace=/ads/no_ads/,script,xmlhttprequest so other request like example.org/tracker.js are not blocked.

So I think that it would be nice to have an option to block requests even if there is $replace rule used.

Another related issue - https://github.com/AdguardTeam/CoreLibs/issues/1715#issuecomment-1375373415

Proposed solution

Add additional modifier which allows to block request even if there is $replace rule.

Alternative solution

Maybe another workaround would be to add similar modifier to $replace but it would replace content only for not blocked requests?

AdamWr avatar Apr 22 '25 08:04 AdamWr

I'm not sure if this is the best solution, as it may result in the need to change a huge number of rules (ad servers, generic rules etc.). Or do you suggest a modifier, applied to the target site?

Alex-302 avatar Apr 22 '25 08:04 Alex-302

The current behavior is for long time (if I'm not wrong), and there are not so many cases where these kind of rules are used (but having such option still would be useful), so I don't think that it would require to change many rules.

Also it should not require any changes for requests which are not from the same domain to which $replace rule is applied.

For example, in case of dzen.ru, if there would be rule like:

||dzen.ru^$script,xmlhttprequest,replace=/ads/no_ads/

then it could be just:

||dzen.ru/api/v4/launcher/stats/bulk$blockRequestImportant

Or instead of using $replace rule:

||dzen.ru^$script,xmlhttprequest,newReplace=/ads/no_ads/

AdamWr avatar Apr 22 '25 08:04 AdamWr