使用Greasemonkey提交表单 [英] Submit form using Greasemonkey

查看:157
本文介绍了使用Greasemonkey提交表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



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

该页面只有一种形式:
$ b

< form method =交的>
< input type =submitvalue =I Agreeclass =agreeonsubmit =submitonce(this)/>
< input type =buttononclick =javascript:window.close(); value =我不同意
class =不同意/>
< / form>

不确定是否重要,因为我只需要点击,但函数 submitonce 是:
$ b

  function submitonce(theform){
// if IE 4+或NS 6+
console.log(Submitting);
if(document.all || document.getElementById){
//通过窗体中的每个元素来屏幕,并追踪submit和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;
}
}
}

我有其余的来源,但它看起来不像其他任何相关的东西。在Greasemonkey / JS中我没有真正编码过,所以任何帮助,将不胜感激。我正在使用使用 Ctrl >输入点击按钮。

显然我不在乎它是虚拟的点击还是只是提交函数的触发器,因为我会说它们是相同的东西不是他们?

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

  // == UserScript == 
// @name myscript
// @namespace any
// @include http://内部页面的路径
// == / UserScript ==

document.forms [0] .submit();


The first time, each day, I try to access a web page at work, I get redirected to an internally hosted web page with the IT guidelines and a form with two buttons "Agree" and "Disagree". Clicking "Agree" then allows external internet access for that day and sends you to the site you were originally looking for.

I want to make a Greasemonkey script that auto-submits the form, since I already have a batch file starting up all my normal apps on boot and this would allow me to just leave the PC while it's doing its 20 minute daily start-up ;)

The page only has the one form:

<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>

And not sure if it matters, since I only need the click, but the function submitonce is:

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;
    }
  }
}

I have the rest of the source, but it doesn't look like there is anything else relevant. I haven't really coded before in Greasemonkey/JS, so any help would be appreciated. I'm playing around with an existing userscript that uses CtrlEnter to click the button.

Obviously I don't care if it's a virtual "click" or just a trigger of the submit function, since I'd say they are the same thing aren't they?

解决方案

It should be a simple job:

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

document.forms[0].submit();

这篇关于使用Greasemonkey提交表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆