Created
July 25, 2017 19:11
-
-
Save moiz-frost/3384b13b4bc4fca0dc5fc21db25161e2 to your computer and use it in GitHub Desktop.
Nightmare
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var $ = require('jquery'); | |
var Nightmare = require('nightmare'); | |
var nightmare = Nightmare( | |
{ | |
show: true | |
}); | |
var hostName = ''; | |
var username = 'justagamer3k'; | |
var password = 'helloDarkness!'; | |
nightmare | |
.goto('https://store.steampowered.com//login/?redir=') | |
.type('#input_username', username) | |
.type('#input_password', password) | |
.click('.btnv6_blue_hoverfade.btn_medium') | |
.wait(10000) | |
.inject('js', './node_modules/jquery/dist/jquery.min.js') | |
.evaluate(function () { | |
return document.getElementsByClassName('user_avatar playerAvatar')[0].href; | |
}) | |
.then(function (url) { | |
nightmare | |
.goto(url + 'friends') | |
.wait(5000) | |
.url() | |
.then(function (url) { | |
console.log(url); | |
nightmare | |
.evaluate(function () { | |
var elements = document.getElementsByClassName('friendBlock persona in-game'); | |
return elements; | |
}) | |
.then(function (result) { | |
console.log(result); | |
nightmare | |
.end() | |
.then(function (result) { | |
console.log('Done!'); | |
console.log(result); | |
}) | |
.catch(function (error) { | |
console.log('Done with Errors'); | |
console.log(error); | |
}); | |
}) | |
.catch(function (error) { | |
console.log(error); | |
}) | |
}) | |
.catch(function (error) { | |
console.log(error); | |
}) | |
}) | |
.catch(function (error) { | |
console.log(error); | |
}); | |
// .click($("span:contains('justagamer3k')")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment