Skip to content

Instantly share code, notes, and snippets.

@laiso
Created March 4, 2011 10:51
Show Gist options
  • Save laiso/854458 to your computer and use it in GitHub Desktop.
Save laiso/854458 to your computer and use it in GitHub Desktop.
//
// USAGE:
// phantomjs ./login_facebook.js
//
// EXAMPLE:
// phantomjs login_facebook.js | growl -t 'Facebook Auto Login' -H localhost
// phantomjs login_facebook.js | cowsay -f daemon | growl -t 'Facebook Auto Login' -H localhost
// while; do; phantomjs login_facebook.js | cowsay -f daemon | growl -t 'Facebook Auto Login' -H localhost && sleep 180 ; done
//
// SCREENSHOT:
// http://gyazo.com/8415ea4c9932e84b75f92c16dc85033f.png
//
// NOTE:
// Perhaps you'll can't login successive within 60-sec(?) period over Facebook's restriction.
// たぶんfacebooの制限により60秒以内(?)に連続でログインできない
//
if (phantom.state.length === 0) {
phantom.state = 'setup';
phantom.open('http://www.facebook.com/');
} else {
if (document.URL == 'http://www.facebook.com/') {
var body = document.body;
body.querySelector('input#email.inputtext').value = '[email protected]';
body.querySelector('input#pass.inputtext').value = 'kogai.ban';
body.querySelector('label.uiButton.uiButtonConfirm input').click();
} else if (document.URL == 'http://www.facebook.com/home.php') {
console.log('success');
phantom.exit(0);
} else if (document.URL == 'https://www.facebook.com/login.php?login_attempt=1') {
console.log('fail');
phantom.exit(0);
} else {
console.log('Unknown');
console.log(document.URL);
phantom.exit(1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment