Skip to content

Instantly share code, notes, and snippets.

@dhilipsiva
Last active July 19, 2017 05:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dhilipsiva/7aba5905c963dd9c9da82fef17b101bc to your computer and use it in GitHub Desktop.
Save dhilipsiva/7aba5905c963dd9c9da82fef17b101bc to your computer and use it in GitHub Desktop.
SumHR Login Click-In script. Using PhantomJS.
// INSTRUCTIONS:
// 1. Update "USERNAME", "PASSWORD" and "COMPANY"
// 2. In terminal, run `pjantomjs clockin.js`
// 3. Have a coffee and start coding away :)
// You can also run this as a CRON script everyday!
var USERNAME="USERNAME",
PASSWORD="PASSWORD",
COMPANY="COMPANY",
sys = require("system"),
page = require("webpage").create(),
logResources = false,
postBody = "UserLogin[username]=" + USERNAME + "&UserLogin[password]=" + PASSWORD;
page.open("https://" + COMPANY + ".sumhr.com/user/login", 'POST', postBody, function(status){
page.evaluate(function() {
var btn = document.getElementById("attendance-logger-widget");
btn.click();
});
});
setTimeout(function () {phantom.exit();}, 10000); // Wait for 10 secs because SumHR takes a long time to load :P
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment