0

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?

  1. I am aware of the ChatGPT API but it is not useful for my purpose.
  2. Safari has a do JavaScript method in its AppleScript dictionary that I use.
New contributor
gulp is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
3
  • you need to go 1 layer deeper, currently you're at the <span> which is the parent of the button that you want to click. Commented Apr 21 at 8:10
  • @LãNgọcHải Was it that simple. LOL. Thank you.
    – gulp
    Commented Apr 21 at 8:24
  • Please take the tour and see How to Ask. You didn't provide enough information in your question for anyone to help you.
    – isherwood
    Commented Apr 21 at 14:10

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.