Show HN: Use cookies from Chrome (CDP) in cURL without copy pasting
github.com
github.com
edit: JavaScript not Java
I have found it's quite easy to snoop on those JavaScript API requests using the Network tab of Chrome Devtools, then copy the network request as a curl command for bash scripts or as JavaScript for browser extensions.
Tongue in cheek: You'd never know - servers running Java code generating HTML pages have probably conditionally not-rendered many pieces of HTML that you've never come across in your browsing :)
What if the phrase "everything interesting" was replaced with specific examples and questions. Something like, "I cannot access X without Javascript. How do I access X without using Javascript."
2. Provide examples of sites that do not "work".
It's possible that people might disagree on the definition of "works". For example, perhaps web developers might be biased toward a definition that puts them in control instead of the user. If I can retrieve information from a server with HTTP requests then the website "works" for me. As a user, I certainly do not need to use Javascript to make HTTP requests. Nor do I need to use a particular client.
One could argue that even HN does not "work" completely without Javascript. For example, the script at https://news.ycombinator.com/hn.js will not run.
But anyway... You know this is also easily accessible within DevTools, yah? https://umaar.com/dev-tips/3-copy-as-curl/
FYI for anyone that does this, MITM Proxy is usually a better option for this type of stuff. Not sure about Chrome, but especially with Firefox, you have no way of getting the full raw request on anything with a request body like POST. You have to Copy Request Headers, then Copy POST Data. With MITM Proxy or similar you can just get the full request at once. Also you can inject headers like X-Forwarded-For into all or specific requests.
On FF right click on Request -> Copy Value -> As cURL This gives everything and works with POST since a few years at least.
Has anyone seen this happening anywhere else?
I agree; should've at least tested the change before raising a PR, but I would've just dropped the idea, so felt it best to share my findings at least.
But when you wrote that you ported my 3 line bash script to rust I thought you were kidding.
You just need to copy/paste the generated text content to a cookies.txt and you're set, so it worked for my workflow in the terminal.
A more universal solution, one that does not require enabling websockets, is a localhost-bound forward proxy where HTTP traffic, including cookies, is saved in log files. No need to copy/paste with a GUI or mouse. Can use standard UNIX utilities to work with log files.