使用Greasemonkey提交表单

vbe*_*van 3 javascript forms greasemonkey submit

第一次,每天,我尝试访问工作中的网页,我被重定向到内部托管的网页,其中包含IT指南和带有两个按钮"同意"和"不同意"的表单.点击"同意",然后允许当天的外部互联网访问,并将您发送到您最初寻找的网站.

我想制作一个自动提交表单的Greasemonkey脚本,因为我已经有一个批处理文件在启动时启动所有正常的应用程序,这将允许我在每天启动20分钟时离开PC; )

该页面只有一个表单:

<form method="post">
<input type="submit" value="I Agree" class="agree" onsubmit="submitonce(this)" /> 
<input type="button" onclick="javascript:window.close();" value="I Disagree"
  class="disagree"/>
</form>
Run Code Online (Sandbox Code Playgroud)

并且不确定它是否重要,因为我只需要点击,但功能submitonce是:

function submitonce(theform) {
  //if IE 4+ or NS 6+
  console.log("Submitting");
  if (document.all || document.getElementById) {
    //screen thru every element in the form, and hunt down "submit" and "reset"
    for (i = 0; i < theform.length; i++) {
      var tempobj = theform.elements[i];
      if (tempobj.type.toLowerCase() == "submit" ||
        tempobj.type.toLowerCase() == "reset")
        //disable em
        tempobj.disabled = true;
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

我有其余的来源,但看起来没有任何其他相关的东西.我之前在Greasemonkey/JS中没有真正编码,所以任何帮助都会受到赞赏.我玩弄现有userscript使用CtrlEnter单击按钮.

显然我不在乎它是虚拟的"点击"还是仅仅是提交功能的触发器,因为我会说它们是同一个东西不是吗?

dda*_*dda 5

这应该是一个简单的工作:

// ==UserScript==
// @name           myscript
// @namespace      whatever
// @include        http://path to the internal page
// ==/UserScript==

document.forms[0].submit();
Run Code Online (Sandbox Code Playgroud)

  • 请报告回来:-) (2认同)