These are chat archives for rosshinkley/nightmare

7th
Jun 2016
coyotte508
@coyotte508
Jun 07 2016 17:43
Possibly beginner question
If I want to follow a link in a page:
nightmare.evaluate( function() {
     return linkLocation;
}).then( function(result) {
    nightmare.goto(result).doStuff();
})
is there an easy way to chain the goto outside the then?
because the current way it's done, if someone does nightmare.doStuff() before the evaluate function concludes, those will be chained before going to the url I want
Rick Medina
@rickmed
Jun 07 2016 18:24
@coyotte508 I don't think there is, it's just the async nature of js/nightmare...alternatively, you could use async functions
coyotte508
@coyotte508
Jun 07 2016 18:27
async functions?
coyotte508
@coyotte508
Jun 07 2016 21:41
This message was deleted
This message was deleted
This message was deleted
Rick Medina
@rickmed
Jun 07 2016 22:03
es7 async/await using babel or bluebird's coroutines which are the same
coyotte508
@coyotte508
Jun 07 2016 22:04
alright, thanks
Valeri Karpov
@vkarpov15
Jun 07 2016 22:50
Hey dudes, anybody know if you can manipulate your geolocation data with nightmare? Like if I wanted to browse google.com and have window.navigator.geolocation spit out that I was in France?
Ross Hinkley
@rosshinkley
Jun 07 2016 22:52
great question
how is the geolocation API being used?
you might be able to override it with a preload script
Valeri Karpov
@vkarpov15
Jun 07 2016 22:54
right now I'm just planning on monkey-patching window.navigator.geolocation.watchPosition() in a .evaluate() script
rosshinkley @rosshinkley nods
Ross Hinkley
@rosshinkley
Jun 07 2016 22:54
that would probably be my first inclination
Valeri Karpov
@vkarpov15
Jun 07 2016 22:54
which is what I need anyway, I was just wondering if there's a way to instrument nightmare/electron to do it properly
because right now it pulls my real location
Ross Hinkley
@rosshinkley
Jun 07 2016 22:54
not that i am aware of short of setting up an actual proxy
doesn't mean it doesn't exist :)
checking...
Ross Hinkley
@rosshinkley
Jun 07 2016 23:02
doesn't look like it
but my dive was pretty cursory
Valeri Karpov
@vkarpov15
Jun 07 2016 23:03
yeah monkey-patching doesn't quite work as expected either, I'm gonna hold off on worrying about this until later. Thanks for your help :+1:
Ross Hinkley
@rosshinkley
Jun 07 2016 23:04
if you're feeling enterprising, you could probably spoof the googleapi with some hosts voodoo
re monkeypatching, i'd be curious to know what happens