I need to create a script that make an HTTP request and simulate browser's behavior when it comes to cookie management. That means that it has access to all the cookies set by that 'page' (So server-set cookies, async client-set cookies, cookies of every domain.)
I mean, inspecting the page using a console, i can see all the cookies from all domains on that page.
I am figuring out a way to do that from my code.
I am almost sure i have to somehow run page's javascript and to emulate the DOM behavior (thought to use jsDom in a node.js script).
But, but. Still have many doubts. Any suggestion on how i can intercept all cookies by simulating browser behavior ?
Any suggestion about how to implement it would be really appreciated.
for those who have time
I had a weird idea about how to implement it:
Would it make sense to overload the prototype of the function of the xhr object that handles HTTP response (i mean making something like: this), to check all the client-loaded cookies ?
I need it to work on any page, even those which don't use the native XMLHttpRequest object. Any suggestion around this ?