I want to script Safari to automate some actions in ChatGPT. To achieve that I need to click plus-button in the input field.
Usually when I try to do something like this I use JavaScript like
var button = document.evaluate("//div/div/div[2]/form/div[1]/div/div[2]/div/div[1]/div[1]/div/div/div/span[2]", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
button.click();
but for some reason this snippet doesn't work - nothing happens - with the ChatGPT UI.
How do I click this button using JavaScript?
- I am aware of the ChatGPT API but it is not useful for my purpose.
- Safari has a do JavaScript method in its AppleScript dictionary that I use.