Last active
December 22, 2015 23:38
-
-
Save ernestom/6547819 to your computer and use it in GitHub Desktop.
Restarts my shitty modem.
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
// | |
// This script restarts my shitty modem. | |
// | |
// $ casperjs restartmodem.js --password=thepass | |
// | |
var casper = require('casper').create(), | |
startPage = 'http://192.168.1.254/xslt?PAGE=A08&THISPAGE=A07&NEXTPAGE=A08'; | |
function login(password) { | |
document.querySelector('input[name=PASSWORD]').value = password; | |
document.querySelector('form[name=pagepost]').submit(); | |
} | |
function confirm() { | |
document.querySelector('form[name=pagepost]').submit(); | |
} | |
function main() { | |
if (!casper.cli.has('password')) { | |
casper.echo('Usage: casperjs restartmodem.js --password=thepassword'); | |
casper.exit(); | |
} | |
casper.start(startPage); | |
casper.then(function() { | |
this.thenEvaluate(login, this.cli.get('password')); | |
this.echo('Login done.'); | |
}); | |
casper.then(function() { | |
this.thenEvaluate(confirm); | |
this.echo('Confirm done.'); | |
}); | |
casper.run(); | |
} | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment