interupt will navigate
nanu-c opened this issue · comments
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
?
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
, callgo-astilectron
to see whether we need to redirect this request - based on
go-astilectron
, callevent.preventDefault()
and updatewindow.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.
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.