I’m trying to set up a Safari script to do some stuff automatically in ChatGPT. The tricky part is getting it to click the plus icon next to the input box.
I’ve tried the usual JavaScript approach:
let plusIcon = document.querySelector('.some-class-for-plus-icon');
plusIcon.click();
But it’s not working on the ChatGPT page. The button just won’t respond. Any ideas on how to make this work?
I know about the ChatGPT API but that’s not what I need right now. I’m using Safari’s JavaScript feature in AppleScript to run these commands.
Anyone have experience with this? What am I missing here?
I’ve encountered similar issues when automating interactions with complex web applications. In ChatGPT’s case, the interface likely uses React or a similar framework, which can complicate direct DOM manipulation. Have you considered using MutationObserver to detect when the plus icon becomes available? This approach might be more reliable:
I’ve dealt with similar challenges when automating web interfaces. One approach that’s worked for me is using JavaScript’s built-in setTimeout function to delay the click action. This gives the page time to fully load and render all elements:
This waits 2 seconds before attempting to click the button. You might need to adjust the delay based on your connection speed. Also, make sure you’re using the correct selector - I’ve found that ChatGPT often uses aria-labels for accessibility, which can be more reliable than class names.