asticode / astilectron

Electron app that provides an API over a TCP socket that allows executing Electron's method as well as capturing Electron's events

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

interupt will navigate

nanu-c opened this issue · comments

commented

I need a programmatically interruption here to prevent site navigation on a page that generates a token. Would it be possible to have the a callback function?

Are you using astilectron in go-astilectron?

commented

Yes, in go-astilectron. The function in js that is triggering the navigation event is a callback function from google recaptcha. It's not possible for me to overwrite the captacha rendering.

An example js snippet would be:

function execute() {
	window.location ="appidentifier://token"
}
setTimeout(execute, 1000);

And this should go to window.location='http://" + config.ServerHost + ":" + config.ServerPort + "/?token=" + e.URLNew

but maybe i should open this issue in go-astilectron.

This is a tricky one, since right now there's no way in js astilectron to send a message and wait for its response before continuing js execution. Which is what would be needed:

  • in will-navigate, call go-astilectron to see whether we need to redirect this request
  • based on go-astilectron, call event.preventDefault() and update window.location manually if we need a redirection

I don't have a proper answer for you right now, I'd have to think about it.

commented

I found another way, because i needed to circumvent the situation. I replace the original js with my own js that I have sideloaded. Then i reinitialize the captcha and finally i have the captcha on the correct domain and i can get the token and everyone is happy. Not a good solution in my eyes because it shows how sensible electron is, because i can do whatever i want and break sandboxing and browser security.