When I found out about UI.Vision, the first thing I checked was if I could get it to run my javascript.
I discovered that you can only enter single line commands so I investigated further and realized that getting multi-line commands to work was surprisingly easy.
Multi-line input is especially important for the executeScript command and also solves the problem Emil_Szymecki was having in the previous topic Cmd executeScript run extend *.js
The executeScript command can execute normal multi-line javascript snippets which are saved in the JSON source with \n inserted for each newline.
The only problem is that the target input field does not allow entering new lines since it is a input element and not a textarea.
The fix is simple, change the target input field into a text area and add a code-mirror editor which is linked to the target field into the bottom panel with the Logs/Variables/Screenshots/CSV/Visual.
This requires 2 changes to the popup.js file.
I have edited the Firefox addon and uploaded a modified version of the popup.js file aswell as the modified addon which you can install it if you have Firefox developer edition here:
Line 7602: Change target input to textarea and set fixed height/resize none
c.a.createElement(B.a.TextArea, { style: { height: "28px", resize: "none", flex: 1, maxWidth: "60%", marginRight: "10px" }, placeholder: "target", disabled: !d, value: u && u.target, onChange: function(t) { return e.onDetailChange("target", t.target.value) }, size: "default" }),
Line 8370: Add a code mirror editor to the bottom panel
c.a.createElement(V.a.TabPane, { tab: "Target", key: "Target" }, c.a.createElement(Jt.UnControlled, { ref: function(t) { e.codeMirror = t }, className: this.props.sourceErrMsg ? "has-error" : "no-error", value: "", onFocus: function(t) { let input = document.querySelector('textarea[placeholder="target"]'); t.setValue(input.value); return; }, onChange: function(t) { let input = document.querySelector('textarea[placeholder="target"]'); let lastValue = input.value; input.value = t.getValue(); let event = new Event('input', { bubbles: true }); event.simulated = true; let tracker = input._valueTracker; if (tracker) { tracker.setValue(lastValue); } input.dispatchEvent(event); return; }, onCursor: function(t, r) { e.setState({ cmEdtiorInstance: t }), r.sticky && e.setState({ cursor: { line: r.line, ch: r.ch } }) }, options: { mode: { name: "javascript", json: 0 }, lineNumbers: !0, matchBrackets: !0, autoCloseBrackets: !0 } })),
I believe this would be a great enhancement since it enables users to easily include entire scripts in their macros instead of just javascript one liners allowing for more complex operations which would otherwise not be possible.
Please let me know if you think this would be a suitable enhancement or if you think there would need to be any additional changes.