Submit Form Using Greasemonkey
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 'Disa
Solution 1:
It should be a simple job:
// ==UserScript==
// @name myscript
// @namespace whatever
// @include http://path to the internal page
// ==/UserScript==
document.forms[0].submit();
Solution 2:
Got some help from a friend who said this should work, though it's not nearly as simple as the answer from dda. Apparently this works in Chrome:
function ClicktheButton(obj) {
var evt = document.createEvent("MouseEvents");
evt.initMouseEvent("click", true, true, window,
0, 0, 0, 0, 0, false, false, false, false, 0, null);
var cancelled = !obj.dispatchEvent(evt);
/*
if(cancelled) {
// A handler called preventDefault
alert("cancelled");
} else {
// None of the handlers called preventDefault
alert("not cancelled");
}
*/
}
var StupidButton = document.querySelector('input[type="submit"][value="I Agree!"]');
ClicktheButton(StupidButton);
And it would also need the includes etc. that GreaseMonkey scripts always have.
Post a Comment for "Submit Form Using Greasemonkey"