===website source code===
<form method="post" name="form1" id="s2t">
// Omitted info not related to button
<p style="display:none;"><input type="submit" name="save"
value="OK" id="fbbtn" class="btn" /></p>
<p><input type="button" value="OK" disabled=true id="fbsb"
class="btn" onclick="document.form1.action='/
s2t';document.getElementById('fbbtn').click(); this.disabled=true;" /
></p>
</form>
====================
Right now I am running this code:
var allInput, thisInput, allImg, thisImg;
allInput = document.evaluate(
'//input[@value]',
document,
null,
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
null);
for (var i = 0; i < allInput.snapshotLength; i++) {
thisInput = allInput.snapshotItem(i);
if (thisInput.value == 'OK'){
thisInput.click();
}
}
It clicks the button but the webpage just refreshes itself instead of
doing what the button does when manually clicked.
Any suggestions to fix this so the button clicks as if manually done
is welcomed! Thanks in advanced.
/* ===== Click on an element (borrowed from Facebook Fixer, @namespace http://userscripts.org/people/14536) ===== */
function click(elm) {
var evt = document.createEvent('MouseEvents');
evt.initMouseEvent('click', true, true, window, 0, 1, 1, 1, 1, false, false, false, false, 0, null);
elm.dispatchEvent(evt);
}
It works very nicely for everything I've tried it on so far. The basic
mechanism is to simulate a mouse click by dispatching a click event to
the element in question, which seems to do just about everything you
could wish (it does in fact trigger Firefox's built-in clicking
mechanisms, too).
HTH.
> --
>
> You received this message because you are subscribed to the Google Groups "greasemonkey-users" group.
> To post to this group, send email to greasemon...@googlegroups.com.
> To unsubscribe from this group, send email to greasemonkey-us...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/greasemonkey-users?hl=en.
>
>
>
> ____________________________________________________________________________________
> Download thousands of great movies, for free!
> http://click.lavabit.com/?r=MTc0
> ____________________________________________________________________________________
>
--
cc | pseudonymous |<http://carlclark.mp/>
On Dec 30, 10:06 pm, cc <carlcl...@lavabit.com> wrote:
> Personally, I use a utility function I borrowed from a popular GM script
> on userscripts.org:
>
> /* ===== Click on an element (borrowed from Facebook Fixer, @namespacehttp://userscripts.org/people/14536) ===== */
> > For more options, visit this group athttp://groups.google.com/group/greasemonkey-users?hl=en.
Hello everyone, I just started using grease monkeys and am attempting to code a greasemonkey script. This script is supposed to click this button automatically when it goes to this website. (snip) Any suggestions to fix this so the button clicks as if manually done is welcomed! Thanks in advanced.
-- cc | pseudonymous | <http://carlclark.mp/>
http://www.quirksmode.org/js/contents.html#events
On Thu, Dec 31, 2009 at 10:02 AM, cc <carl...@lavabit.com> wrote:
>...