Created
February 15, 2017 10:11
-
-
Save NatkungZ/2b84fe8ec8dda6f1d4caa35c1d2a37f1 to your computer and use it in GitHub Desktop.
NAC Authenticate auto script for KMITL
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
// ==UserScript== | |
// @name Login KMITL | |
// @namespace http://userscripts.org/users/useridnumber | |
// @include https://nac.kmitl.ac.th/dana-na/auth/url_default/welcome.cgi?p=failed | |
// @include https://nac.kmitl.ac.th/dana-na/auth/url_default/welcome.cgi* | |
// @include https://nac.kmitl.ac.th/dana-na/auth/welcome.cgi* | |
// @include https://nac.kmitl.ac.th/dana/home/infranet.cgi* // ==/UserScript== | |
function Check_Login() { | |
if (document.location.href == logedinURL) { | |
var new_obj = document.getElementById('liveclock2').childNodes[2].textContent; | |
var hours = parseInt(new_obj.substring(2, 4)); | |
if (hours <= 4) { | |
document.getElementById('Extendbg').click(); | |
} | |
} else {} | |
} | |
var setURL = 'https://nac.kmitl.ac.th/dana-na/auth/url_default/welcome.cgi'; | |
var sesionURL = 'https://nac.kmitl.ac.th/dana-na/auth/welcome.cgi?p=extend-session'; | |
var logedinURL = 'https://nac.kmitl.ac.th/dana/home/infranet.cgi'; | |
var foff = 'https://nac.kmitl.ac.th/dana-na/auth/url_default/welcome.cgi?p=forced-off'; | |
window.addEventListener('load', function() { | |
if (document.location.href == setURL || | |
document.location.href == foff || | |
document.location.href == sesionURL) { | |
document.forms[0].elements[1].value = '<user>'; | |
document.forms[0].elements[2].value = '<password>'; | |
document.forms[0].submit(); | |
} | |
}, false); | |
if (document.URL.indexOf("/welcome.cgi?p=failed") >= 0) { | |
document.querySelector('btnSubmit').click(); | |
} | |
var checked = function() { | |
Check_Login(); | |
}; | |
window.setInterval(checked, 5000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment