hero icon indicating copy to clipboard operation
hero copied to clipboard

How to fake a URL/window.location on page load?

Open bratao opened this issue 4 years ago • 7 comments

Hello, First of all, thanks for this great project!

I have a local page with a javascript code (Rcaptcha v3). I want to load it and pretend that I´m on a remote URL (target site). How I would do this with secret-agent? On Puppeteer/playwright I can intercept a Request and return my own content, but I did not found a way to do it using secret-agent.

bratao avatar Sep 16 '21 22:09 bratao

Thanks! We have this feature in Core (ie, the backend), but I'm not sure we've exposed it to the client yet.

blakebyrnes avatar Sep 17 '21 14:09 blakebyrnes

Awesome @blakebyrnes . In the meantime can you please point how to do with core? I'm communicating directly with the core using the Websocket protocol. I plan to release a python client soon.

bratao avatar Sep 17 '21 14:09 bratao

Wow. Awesome!!

Here's an example of intercepting using the internals: https://github.com/ulixee/secret-agent/blob/efdf434044109e3f25ab6283768bd47ff4bae1d9/core/test/user-profile.test.ts#L312

What you're doing is awesome, but please be aware the internals are not considered "stable apis" by our team, so we will change those without an appropriate semver on occasion. We're also underway on SecretAgent 2.0 (https://github.com/ulixee/hero) which will have some changes as well. As long as you're ok chasing a moving target, no worries :)

blakebyrnes avatar Sep 17 '21 14:09 blakebyrnes

This api isn't actually in use at the moment, but we intend to eventually have an api like so to have a referer for your first "goto" without having to load up the refering url.

https://github.com/ulixee/secret-agent/blob/efdf434044109e3f25ab6283768bd47ff4bae1d9/core/lib/Tab.ts#L269

I like your use case of providing start html!

blakebyrnes avatar Sep 17 '21 14:09 blakebyrnes

I would accept a PR that exposes setOrigin and adds an "html" parameter

blakebyrnes avatar Sep 17 '21 14:09 blakebyrnes

Great @blakebyrnes , I understand that it is a moving target. Great to know that hero will be the next version. I will try to use it.

I have zero experience with node/ts/yarn. I will try to code this PR to expose setOrigin, it looks easy to do, but I need to grasp how the dev env works before.

bratao avatar Sep 17 '21 16:09 bratao

NOTE: this feature exists in Agent, but we might need to change it to use a temporary network interceptor instead of the MITM so that it works when the MITM is disabled.

blakebyrnes avatar Oct 14 '22 14:10 blakebyrnes