Last active
August 29, 2015 14:20
-
-
Save krizko/c2453183aac06a9c9211 to your computer and use it in GitHub Desktop.
SielDNS Update IP to specific subdomain automatization
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
#!/usr/bin/nodejs | |
var baseUrl = "https://dns.siel.si/"; | |
var username = "someUsername"; | |
var password = "somePass"; | |
var editDomain = 'https://dns.siel.si/domain/DOMAIN.NAME'; | |
var domainName = 'SUB.DOMAIN.NAME.TO.CHANGE'; | |
var ip = 'IP TO COMPARE'; | |
var Nightmare = require('nightmare'); | |
new Nightmare() .viewport(1024,768) | |
.goto(baseUrl) | |
.type('input[name="username"]', username) | |
.type('input[name="password"]', password) | |
.click('#submitLogin') | |
.wait() | |
.screenshot('postLogin.png') | |
.goto(editDomain) | |
.evaluate(function(domainName) { | |
var elements = $('td:contains("' + domainName + '")'); | |
if (elements.size() > 0) { | |
var parentElement = $(elements[0]).parent(); | |
$('a.edit', parentElement).click(); | |
} | |
return [ 'nothing to show here' ]; | |
}, | |
function(result) { console.log(result); }, | |
domainName) | |
.wait(40) | |
.evaluate(function(ip) { | |
var contentInputs = $('input[name="content"]'); | |
if (contentInputs.size() > 0) { | |
var input = contentInputs[1]; | |
if (ip == $(input).val()) { | |
return "same"; | |
} else { | |
$(input).val(ip); | |
$('button.btn-success', $(input).parent().parent()).click() | |
return [ "diff", $(input).val() ]; | |
} | |
} else { | |
return [ contentInputs ]; | |
} | |
}, | |
function(result) { console.log(result); }, | |
ip) | |
.wait(500) | |
.screenshot('postEdit.png') | |
.run(function(err, nightmare) { | |
if (err) return console.log(err); | |
console.log('Done!'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment