CoreLibs icon indicating copy to clipboard operation
CoreLibs copied to clipboard

Add a modifier for changing HTTP headers

Open ameshkov opened this issue 8 years ago • 3 comments

Consider adding a modifier that allows modifying HTTP headers. This could be pretty much the same as $replace, but for HTTP headers.

There are several applications for such a header:

  1. Emulating a cookie (can help with cookie notices). On the other hand, there's already a scriptlet for that.
  2. Change user agent in some requests.
  3. Change referrer.
  4. Set own policies, etc.

You can do A LOT with this so it must be a trusted-level modifier.

We need to see how many upvotes this feature request gets.

Discussion: https://github.com/AdguardTeam/AdguardForWindows/issues/1720

ameshkov avatar Nov 30 '17 14:11 ameshkov

It would be nice to have such feature. Maybe it's not ad related but some websites (for example this one - https://github.com/AdguardTeam/AdguardFilters/issues/162841) displays a different content basing on some headers (it seems that in this case they check accept-language header if it starts with pl, and if not, other content is displayed) to see full content, it's necessary to change browser language or use extension to modify it.

AdamWr avatar Nov 28 '24 12:11 AdamWr

Good example, but we'll need a couple more to justify this. Please provide more examples so that we could figure out how to implement this.

ameshkov avatar Dec 01 '24 15:12 ameshkov

Another case is Twitch and ads which are currently not blocked in Brave browser. It looks like that if we could change request header sec-ch-ua (for gql.twitch.tv/gql request) to something like (it's from Chrome):

"Not;A=Brand";v="99", "Google Chrome";v="139","Chromium";v="139"

(in Brave it's "Not)A;Brand";v="8", "Chromium";v="138", "Brave";v="138") then ads would be blocked. Removing this header causes that ads are not blocked also in other browsers, so it's not a solution in this case.

Related issue - https://github.com/AdguardTeam/AdGuardExtra/issues/599#issuecomment-3009710977

In general, it would be nice to have similar options like in Requestly extension - https://chromewebstore.google.com/detail/requestly-supercharge-you/mdnleldcmiljblolnjhpnblkcekpdkpa where is possible to override request and response headers.

So we could use something like (commas probably should be escaped, like in other modifiers):

||gql.twitch.tv/gql$setheader=request:sec-ch-ua:"Not;A=Brand";v="99", "Google Chrome";v="139", "Chromium";v="139",app=brave.exe

Also an option to just replace some value would be nice, for example:

||gql.twitch.tv/gql$replaceheader=request:sec-ch-ua:/Brave/Google Chrome/

AdamWr avatar Jun 27 '25 18:06 AdamWr