intel-screenbot

An Ingress Intel Map Bot for Hangoutsbot
git clone git://archive.git.mtrnord.blog/MTRNord/intel-screenbot.git
Log | Files | Refs | README | LICENSE

commit cadb8fdc702cd29407c88455c9845c393ed25d7b
parent 0c2183a2ac29ce02becc86711af8ba24f3d253c4
Author: Marcel <MTRNord@users.noreply.github.com>
Date:   Tue, 15 Nov 2016 19:34:58 +0100

Try to wait until login is there
Diffstat:
Mscreencap_iitc.js | 99++++++++++++++++++++++++++++++++++++++++++++++---------------------------------
1 file changed, 58 insertions(+), 41 deletions(-)

diff --git a/screencap_iitc.js b/screencap_iitc.js @@ -102,48 +102,65 @@ function firePlainLogin(SACSID, CSRF) { function login(l, p) { console.log("Login") - page.evaluate(function (l) { - document.getElementById('Email').value = l; - }, l); - page.evaluate(function () { - document.querySelector("#next").click(); - }); - window.setTimeout(function () { - page.evaluate(function (p) { - document.getElementById('Passwd').value = p; - }, p); - page.evaluate(function () { - document.querySelector("#next").click(); - }); - page.evaluate(function () { - document.getElementById('gaia_loginform').submit(); + waitFor({ + timeout: 240000, + check: function () { + return page.evaluate(function() { + if (document.querySelector('.gaia_loginform').textContent.indexOf('done') != -1) { + return true; + }else{ + return false; + } + }); + }, + success: function () { + page.evaluate(function (l) { + document.getElementById('Email').value = l; + }, l); + page.evaluate(function () { + document.querySelector("#next").click(); + }); + window.setTimeout(function () { + page.evaluate(function (p) { + document.getElementById('Passwd').value = p; + }, p); + page.evaluate(function () { + document.querySelector("#next").click(); + }); + page.evaluate(function () { + document.getElementById('gaia_loginform').submit(); + }); + window.setTimeout(function () { + if (page.url.substring(0,40) === 'https://accounts.google.com/ServiceLogin') { + quit('login failed: wrong email and/or password'); + } + if (page.url.substring(0,40) === 'https://appengine.google.com/_ah/loginfo') { + page.evaluate(function () { + document.getElementById('persist_checkbox').checked = true; + document.getElementsByTagName('form').submit(); + }); + } + if (page.url.substring(0,44) === 'https://accounts.google.com/signin/challenge') { + //twostep = system.stdin.readLine(); + console.log("twostep Bug") + } + // if (twostep) { + // page.evaluate(function (code) { + // document.getElementById('totpPin').value = code; + // }, twostep); + // page.evaluate(function () { + // document.getElementById('submit').click(); + // document.getElementById('challenge').submit(); + // }); + // } + window.setTimeout(afterPlainLogin(IntelURL, search), loginTimeout); + }, loginTimeout) + }, loginTimeout / 10); + }, + error: function () { + quit(); + } }); - window.setTimeout(function () { - if (page.url.substring(0,40) === 'https://accounts.google.com/ServiceLogin') { - quit('login failed: wrong email and/or password'); - } - if (page.url.substring(0,40) === 'https://appengine.google.com/_ah/loginfo') { - page.evaluate(function () { - document.getElementById('persist_checkbox').checked = true; - document.getElementsByTagName('form').submit(); - }); - } - if (page.url.substring(0,44) === 'https://accounts.google.com/signin/challenge') { - //twostep = system.stdin.readLine(); - console.log("twostep Bug") - } -// if (twostep) { -// page.evaluate(function (code) { -// document.getElementById('totpPin').value = code; -// }, twostep); -// page.evaluate(function () { -// document.getElementById('submit').click(); -// document.getElementById('challenge').submit(); -// }); -// } - window.setTimeout(afterPlainLogin(IntelURL, search), loginTimeout); - }, loginTimeout) - }, loginTimeout / 10); } function afterPlainLogin(IntelURL, search) {