在我们的员工休息室,我安装了一台带大电视的 PC 来显示我们公司的通知。通知发布在总部的外部 SharePoint 页面上,并通过 Firefox (v33.0.3) 显示在休息室中。我已将 PC 设置为每天早上启动并启动 Firefox,但 SharePoint 页面需要身份验证,因此我必须手动登录:
我还使用 ReloadEvery 每 5 分钟重新加载页面以显示任何新内容,但会话仅持续约 30 分钟并且需要再次登录。
我希望实现这个自动化,这样每次 Firefox 遇到这个页面时,它都会自动填写登录 ID 和密码并提交。
类似问题的答案建议使用自动填充表单插件,但它在页面加载时既不填写也不提交用户名/密码。我仍然必须单击“自动填充”按钮,然后单击“提交”。功能列表还说它可以自动提交表单,但我找不到启用此功能的地方。
如果我右键单击并选择“显示表单详细信息”,我会看到以下内容:
页面源代码:
<!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>
我无法访问 SharePoint 系统。
我如何让 Firefox 自动填写此用户名/密码表单并提交?
答案1
一种解决方案是创建一个本地 HTML 文件,其中包含登录表单的副本和一些额外的 javascript 以自动提交表单。将用户名和密码添加到表单输入中,例如value="MYUSERNAME"
。
像这样修改本地文件:
第 62 行:
<input id="username" type="text" size="36" name="pf.username" value="MYUSERNAME" autocorrect="off" autocapitalize="off" onKeyPress="return postOnReturn(event)" />
第 64 行:
<input id="password" type="password" size="36" name="pf.pass" onKeyPress="return postOnReturn(event)" autocomplete="off" value="MYPASSWORD" />
并在第 99 行之后(标签之前)插入</body>
:
<script type="text/javascript">
postOk();
</script>
这将在文件打开时自动提交表单。最后一步是将文件设置为 Firefox 的主页。