I’m looking for a way to submit a value with two clicks in drop-down list (which is auto-sized) using Greasemonkey.
Target HTML:
<form method="post">
<select size="3" name="z_pos_id">
<option value="2463">Option A</option>
<option value="2609">Option B</option>
<option value="3013">Option C</option>
</select>
<input type="submit" value="Button">
</form>
At the moment I click on the option to select it and then I click on the button to submit the value (Press Enter works too).
But with a Greasemonkey script I want to click on the option to select it and click again on the selected option to submit it.
Is this possible?
One way to handle double left-clicks, without interfering with center and right-clicks (too much), is to:
<option>was selected when themousedownevent fires.To simplify the code greatly, use jQuery this time. See the code in action at jsFiddle.
A complete script would look something like this:
Update: Here’s a version that will work on Chrome as well (need to use script injection).
This assumes that the target page does not already have jQuery: