didierfred / SimpleModifyHeaders

Extension for firefox and chrome to modify headers
164 stars 30 forks source link

Not rewrites headers in request made by another addon #39

Open Baton34 opened 2 years ago

Baton34 commented 2 years ago

I use Imagus addon for view images in full size on certain sites. Its take original picture link and defines new link for fullsize image. In this case it fetch api.500px.com for image data and SMH did not touch header of this request. Why header stays not modified? Here screenshot with "debug mode" and "Filter URL per rules" enabled.

smh

didierfred commented 2 years ago

An explaination could be that you have a space character at the end of the field "When URL contains"

Could you check that ?

I will anyway add a method to remove the spaces at the end of this field

Baton34 commented 2 years ago

Could you check that ?

I checked it, no spaces. If I copy link from net viewer window and paste it to firefox address bar and run it - SMH works fine and adds header to request.

didierfred commented 2 years ago

i check the imagus addon on my computer (either firefox and chrome) and it works for me on 500px.com web site

I was on https://500px.com/popular

Could you check on this precise url and see if the token is set when loading images ?

image

Baton34 commented 2 years ago

Try import this rule to imagus (Imagus settings, import arrow, replace existing data, from text): {"R_500px.com":{"link":"^(?:photos\\.)?(500px\\.)com/(?:photo/)?(\\d+).*","url":"https://api.$1com/v1/photos?ids=$2&image_size[]=34&image_size[]=2048","res":":\nvar i=JSON.parse($._).photos[$[2]],u=i.image_url\nreturn [[['#'+u[1], u[0]], [i.name, i.description, i.location, i.camera, i.lens, 'by ' + i.user.username + ' (' + i.user.fullname + ')'].filter(Boolean).join(' | ')]]","img":"^(?:pp?|drs)cdn\\.(500px\\.)org/+(?:photo/)?(\\d+)/+[^/]+/.+","note":"by Baton34V + Gros-Poulet (SMH rule)"}} Then import this SMH rule {"format_version":"1.2","target_page":"","headers":[{"url_contains":"api.500px.com","action":"add","header_name":"X-500PX-TOKEN","header_value":"fetch","comment":"500PX","apply_on":"req","status":"on"}],"debug_mode":false,"show_comments":true,"use_url_contains":true} Then reload 500px.com page. Move mouse to any picture, imagus show it in full size. Now look in net view tab and find request to "api.500px.com/..." and there is no token in header. I dont understand why.

didierfred commented 2 years ago

I load your imagus + smh configuration , but i did not reproduce the problem the header is modified .

Having no account , i'm not connected to 500px.com ,did you test being disconnected , the behavior may change ..

image

image

Baton34 commented 2 years ago

You not have request made by Imagus on your screenshot. It must be api.500px.com/v1/photos?ids=... smh2 You need to hover mouse pointer over any image on 500px page, then image should be shown in full size. And after than there will be request from imagus in the net view tab.

didierfred commented 2 years ago

I tested beeing connected , beeing disconnect to the web site , i have not the problem .

I have not exactly your url as the parameter ids is not the first parameter of the request

image

Baton34 commented 2 years ago

I capture video for you https://user-images.githubusercontent.com/10797316/155097588-5a8d026f-98c9-41ca-80ae-19e146bb7bc0.mp4

didierfred commented 2 years ago

still not able to reproduce on my computer

Baton34 commented 2 years ago

Does this mean imagus is down and you can't see the full size image? Are you clicking the save button after importing the rule into imagus and then reloading the tab with 500px.com open? After that, a pop-up window with a full-sized image should appear when you hover your mouse over the image on the 500px.com page (without authorization on 500px.com).

didierfred commented 2 years ago

imagus is working well , i have the full size images . It s just in my case the header is modify

Baton34 commented 2 years ago

Just in my case the title has been changed

but I don't see any requests to "api.500px.com/v1/photos?ids=..." on your screens. Do you have a different rule for 500px.com in imagus? Maybe this request just doesn't show up in the network tab... I don't understand what's going on... Without this request, imagus cannot get the link to the full size image in order to download it.