I am writing a Greasemonkey script to interact with orders on Shipstation.com.
The script will select certain values in <select>
and <input>
elements of the order modal based on certain criteria.
Thus, the script must be able to interact with these elements.
However, I cannot figure out how to do so.
So far, I have tried to do the following and have been unable to trigger a click on the element:
- Set the value of the element using JS
.value
- Set the value of the element using jQuery
.val
- Trigger a click event on the element using JS
.click()
- Trigger a click event on the element using this code:
function triggerMostButtons (jNode) {
triggerMouseEvent (jNode, "mouseover");
triggerMouseEvent (jNode, "mousedown");
triggerMouseEvent (jNode, "mouseup");
triggerMouseEvent (jNode, "click");
}
function triggerMouseEvent (node, eventType) {
var clickEvent = document.createEvent('MouseEvents');
clickEvent.initEvent (eventType, true, true);
node.dispatchEvent (clickEvent);
}
triggerMostButtons(jNode);
It appears that Shipstation is locking the value of <select>
and <input>
values.
Here are examples of the SO questions I have read to try and figure this out. I haven't been able to trigger a click on these elements using any of these approaches:
- "Normal" button-clicking approaches are not working in Greasemonkey script?
- How to simulate click in react app using tampermonkey?
- Greasemonkey script to automatically select, and click, a specific button with non-English characters in the value/selector?
- Choosing and activating the right controls on an AJAX-driven site
- Simulating a mousedown, click, mouseup sequence in Tampermonkey?
- javascript click a value in dropdown list
- How to change a <select> value from JavaScript
- How do I programmatically set the value of a select box element using JavaScript?
- Set the value of an input field
How else can I trigger a click on these elements?
Alternatively, how can I set the value of these fields using JS? Do I have to find the data model in the JS and edit the value directly? Or find a way to hijack the functions that are triggered when a user clicks on these elements?
from Click
No comments:
Post a Comment