summaryrefslogtreecommitdiff
path: root/util.coffee
diff options
context:
space:
mode:
authorYaohan Chen <yaohan.chen@gmail.com>2014-04-05 00:26:38 -0400
committerYaohan Chen <yaohan.chen@gmail.com>2014-04-05 00:26:38 -0400
commitafc97d764b5d3b6279d05fadc3e5aea593d62eaf (patch)
treea1e7e8451155060cbac2834cafad69705f6e43e3 /util.coffee
parent9bd67f7b1e29ac08ea5bc9085c8e662d525b7c53 (diff)
downloadhib-dlagent-afc97d764b5d3b6279d05fadc3e5aea593d62eaf.tar.gz
hib-dlagent-afc97d764b5d3b6279d05fadc3e5aea593d62eaf.zip
Minor changes in PhantomJS script
Diffstat (limited to 'util.coffee')
-rw-r--r--util.coffee11
1 files changed, 4 insertions, 7 deletions
diff --git a/util.coffee b/util.coffee
index 8b11814..e0ddb33 100644
--- a/util.coffee
+++ b/util.coffee
@@ -32,10 +32,8 @@ exports.handle_login = handle_login = (username, password) ->
page.evaluate (username, password) ->
username_box = document.querySelector 'input[name="username"]'
password_box = document.querySelector 'input[name="password"]'
- if username_box
- username_box.value = username
- if password_box
- password_box.value = password
+ username_box?.value = username
+ password_box?.value = password
(username_box or password_box)?
, username, password
@@ -52,7 +50,7 @@ exports.handle_captcha = handle_captcha = ->
Recaptcha.reload()
else
captcha_box = document.querySelector '#recaptcha_response_field'
- captcha_box.value = input
+ captcha_box?.value = input
, input
# handles login/captcha, repeating if necessary, and performs the action
@@ -66,8 +64,7 @@ exports.handle_login_captcha = handle_login_captcha = (action, username, passwor
page.evaluate ->
# FIXME make sure we're submitting the right form
form = document.querySelector('form')
- if form
- form.submit()
+ form?.submit()
else
log 'Logged in...'
action()