I am writing a userscript for learning purposes that automatically logs me into my school website. I have an attempt in JavaScript that I am hoping is on track. Could someone help me edit it to work as intended (instead of not at all). I have programming experience in Java and Python but I am very new to web programming. Thanks!
I am using TamperMonkey with the following code
// ==UserScript==
// @name MyMCLogin
// @namespace http://use.i.E.your.homepage/
// @version 0.1
// @description Automatic login to My MC
// @match https://mymcprod.montgomerycollege.edu/cp/home/displaylogin
// @copyright SJL 2015
// ==/UserScript==
document.getElementsByName('user')[0].value = "username";
document.getElementsByName('pass')[0].value = "password";
imageSubmit();
Essentially I want to find the variable for username and variable for password, replace them with my username and password, and then submit
Thank you for any assistance :)
Edit: I had a syntax error that I fixed. The only problem remaining is that it doesn't submit the username and password
Edit2: I have tried the following without success:
I noticed after inspecting the submit button that there is a function login() that occurs on press. Can I use this function somehow?
document.cplogin.submit();
document.userid.submit();
document.userid.login();
OK so i got it to work!! I copied the code from the html source for the login() function.
setQueryAsCookie();
document.cplogin.user.value=document.userid.user.value;
if ( document.cplogin.uuid )
{
document.cplogin.uuid.value=(new Date()).getTime() - clientServerDelta;
}
Which is a very non-eloquent solution :P. I will continue trying variations of the suggestions you guys have made for learning purposes.
Thank you all very much :)
Final? Code:
// ==UserScript==
// @name MyMCLogin
// @namespace http://use.i.E.your.homepage/
// @version 0.1
// @description Automatic login to My MC
// @match https://mymcprod.montgomerycollege.edu/cp/home/displaylogin
// @copyright SJL 2015
// ==/UserScript==
document.getElementsByName('user')[0].value = "username";
document.getElementsByName('pass')[0].value = "password";
setQueryAsCookie();
document.cplogin.user.value=document.userid.user.value;
if ( document.cplogin.uuid )
{
document.cplogin.uuid.value=(new Date()).getTime() - clientServerDelta;
}
}at the end...