How can I make Firefox automatically fill a username/password form and submit it?

3

2

In our staff lounge I have installed a PC with a large TV to display our company notices. The notices are published on an external SharePoint page at head office and displayed in the lounge with Firefox (v33.0.3). I've set the PC to boot every morning and start Firefox but the SharePoint page requires authentication so I have to manually login:

enter image description here

I also use ReloadEvery to reload the page every 5 minutes to show any new content but the session only lasts for about 30 minutes and requires logging in again.

I would like to automate this so every time Firefox encounters this page it automatically fills the Logon ID and Password and submits them.

Answers to similar questions have suggested the AutoFill Forms add-on but it neither fills nor submits the username/password when that pages loads. I still have to click the Autofill button and then click submit. The feature list also says it can submit forms automatically but I can find nowhere to enable this.

If I right click and choose "Display form details" I see this:

enter image description here

Page source code:

<!DOCTYPE html>
<!-- template name: html.form.login.template.html -->
<html lang="en" dir="ltr">
<head>
    <script type="text/javascript">
        function postOk()
        {
            document.forms[0]['pf.ok'].value = 'Login';
            document.forms[0].submit();
        }

        function postOnReturn(e)
        {
            var keycode;
            if (window.event) keycode = window.event.keyCode;
            else if (e) keycode = e.which;
            else return true;

            if (keycode == 13)
            {
                document.forms[0].submit();
                return false;
            }
            else
                return true;
         }

         function setFocus()
         {
            var platform = navigator.platform;
            if(platform != null && platform.indexOf("iPhone") == -1)
            {
              document.getElementById('username').focus();
            }
         }

    </script>
    <base href="https://our.company.web.address.com/"/>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta name="viewport" content="minimum-scale=0.1, maximum-scale=2.0, user-    scalable=1"/>
    <title>Our Company Name</title>
    <link rel="stylesheet" media="all" type="text/css" href="assets/css/screen.1.css"/>
    <link rel="shortcut icon" href="assets/images/favicon.ico" />
</head>     
<body onload="setFocus()">
<div class="ping-container">
    <div class="ping-header">
        <div class="ping-header-bg">
            <div class="COMPANY-name"><a href="http://our.company.web.address.com/"><img src="assets/images/agencyname.png" alt="Our motto"></a></div>
        </div>
    </div><!-- .ping-header -->
    <div class="ping-body-container" >
        <div id="content-left">
        </div>
        <div class="ping-body">
            <div style="display:none">html.form.login.template.info.4 $escape.escape($spEntityId)</div>
            <form method="POST" action="/idp/7krkY/resumeSAML20/idp/SSO.ping" autocomplete="off">
                <div style="padding: 0px 5px 14px; font-size: 110%">

                </div>
                <div style="margin-bottom: 12px; font-size: 84%; font-weight: bold;"><span>Logon ID</span>
                <input id="username" type="text" size="36" name="pf.username" value="" autocorrect="off" autocapitalize="off" onKeyPress="return postOnReturn(event)" /><!---->    </div>
                <div style="font-size: 84%; font-weight: bold;"><span>Password</span>
                <input id="password" type="password" size="36" name="pf.pass" onKeyPress="return postOnReturn(event)" autocomplete="off"/></div>
                                <div class="ping-buttons">
                    <input type="button" name="pf.ok" onclick="postOk();" value="Login"/>
                </div><!-- .ping-buttons -->
            </form>
        </div><!-- .ping-body -->
        <div id="logonHelp">
            <h4>
                Our Company Name
            </h4>

            <p>
                The section of the website you are trying to access requires a 
                Logon ID and password. 
            </p>
            <p>
                If you have forgotten your Logon ID and/or password please
                contact {redacted phone number}
            </p>
        </div>
    </div><!-- .ping-body-container -->
    <div class="ping-footer-container">
        <div class="ping-footer">
           <p><a href="http://our.company.web.address.com/home/copyr.html">Copyright</a> 
            | <a     href="http://our.company.web.address.com/home/copyr.html#disclaimer">Disclaimer</a> 
            | <a href="http://our.company.web.address.com/home/privacy.html">Privacy</a> 
            | <a href="http://our.company.web.address.com/about/access/keys.html" accesskey="0">Access keys</a> 
            | <a href="http://our.company.web.address.com/other_languages/index.html"><img src="assets/images/icon-

flags.gif" alt="">Other languages</a></p> 
            <p></p> 
            <p></p> 
        </div><!-- .ping-footer -->
    </div><!-- .ping-footer-container -->
</div><!-- .ping-container -->
</body>
</html>

I have no access to the SharePoint system.

How can I make Firefox automatically fill this username/password form and submit it?

x-x

Posted 2014-12-03T01:27:09.387

Reputation: 445

If you are familiar with JS, I would recommend making a userscript to do this. – DragoonHP – 2014-12-04T04:28:02.780

Answers

2

One solution would be to create a local HTML file with a copy of the login form and some additional javascript to automatically submit the form. Add the username and password to the form inputs, ex value="MYUSERNAME".

Modify your local file like so:

Line 62:

<input id="username" type="text" size="36" name="pf.username" value="MYUSERNAME"  autocorrect="off" autocapitalize="off" onKeyPress="return postOnReturn(event)" />

Line 64:

<input id="password" type="password" size="36" name="pf.pass" onKeyPress="return postOnReturn(event)" autocomplete="off" value="MYPASSWORD" />

And insert after line 99 (before </body> tag):

<script type="text/javascript">
postOk();
</script>

This will auto-submit the form when the file is opened. The last step is to set the file as Firefox's homepage.

jjz

Posted 2014-12-03T01:27:09.387

Reputation: 347

Your answer has made me think of a missing detail in my original question which would mean this answer probably wouldn't work. I also use ReloadEvery to refresh the page every 5 minutes, but the session times outs after 30 minutes and returns me to the login page. – x-x – 2014-12-03T02:28:17.743

You might want to try the solution before you claim it might not work. – Ramhound – 2014-12-03T04:19:32.827

@DrTwox The session timeout sounds like a separate issue. You could do something like sticking this page in an iframe with some javascript in the outer page that automatically reloads the iframe sooner than the session times out. – jjz – 2014-12-03T18:00:32.863