KudoAI / chatgpt.js

🤖 A powerful, open source client-side JavaScript library for ChatGPT
https://chatgpt.js.org
MIT License
1.86k stars 122 forks source link

Fixing changes in ChatGPT web interface #258

Closed micz closed 4 months ago

micz commented 4 months ago

SendButton CSS selector fixed. Stripping only one ChatGPT in the response (it was ChatGPTChatGPT).

micz commented 4 months ago

@adamlui are they changing the web interface always so often?

adamlui commented 4 months ago

@adamlui are they changing the web interface always so often?

Not usually but lately I've made frequent design changes to my https://github.com/adamlui/chatgpt-apps and their programmers and designers tend to follow my activity (notice they changed favicon to black/white, that came shortly after I updated the robot emoji to black/white OpenAI icon to represent ChatGPT in https://github.com/KudoAI/chatgpt.js#-contributors) so that is why all the sudden updates lately it is my fault

Since you have the new UI, the chatgpt.isLoaded() needs updating too because the sidebar changed so nav button[id*="menu"] no longer exists, could you inspect the menu button for new attr maybe? (in separate PR is best)

micz commented 4 months ago

hey @micz I didn't get the UI update yet so button[class*="cursor"][class*="bottom"] is still the working selector for me, but can you inspect it and see if it has data-testid="send-button"? If so, you should use that instead because the class is selecting the close button to an alert my GPT-4o usage is depleted

This is what I see:

<button disabled="" class="mb-1 mr-1 flex h-8 w-8 items-center justify-center rounded-full bg-black text-white transition-colors hover:opacity-70 focus-visible:outline-none focus-visible:outline-black disabled:bg-[#D7D7D7] disabled:text-[#f4f4f4] disabled:hover:opacity-100 dark:bg-white dark:text-black dark:focus-visible:outline-white disabled:dark:bg-token-text-quaternary dark:disabled:text-token-main-surface-secondary"><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="none" viewBox="0 0 32 32" class="icon-2xl"><path fill="currentColor" fill-rule="evenodd" d="M15.192 8.906a1.143 1.143 0 0 1 1.616 0l5.143 5.143a1.143 1.143 0 0 1-1.616 1.616l-3.192-3.192v9.813a1.143 1.143 0 0 1-2.286 0v-9.813l-3.192 3.192a1.143 1.143 0 1 1-1.616-1.616z" clip-rule="evenodd"></path></svg></button>

micz commented 4 months ago

Since you have the new UI, the chatgpt.isLoaded() needs updating too because the sidebar changed so nav button[id*="menu"] no longer exists, could you inspect the menu button for new attr maybe? (in separate PR is best)

I'm not using it, I use a few functions here. It's a Thunderbird add-on, I wait for the new window to load and then check for the login, you can see it here.

This is the new menu button: <button class="flex h-10 w-10 items-center justify-center rounded-full hover:bg-token-main-surface-secondary focus-visible:bg-token-main-surface-secondary focus-visible:outline-0" type="button" id="radix-:ra:" aria-haspopup="menu" aria-expanded="true" data-state="open" aria-controls="radix-:rb:">

adamlui commented 4 months ago

@micz ok unless you can find some common path[d*=""] in the old Send button's child svg (still displayed to many):

<path fill="currentColor" fill-rule="evenodd" d="M12 3a1 1 0 0 1 .707.293l7 7a1 1 0 0 1-1.414 1.414L13 6.414V20a1 1 0 1 1-2 0V6.414l-5.293 5.293a1 1 0 0 1-1.414-1.414l7-7A1 1 0 0 1 12 3" clip-rule="evenodd"></path>

...then the best/shortest return for .getSendButton() would probably be

    return document.querySelector('[data-testid="send-button"]') // pre-GPT-4o
        || document.querySelector('path[d*="M15.192 8.906a1.143"]')?.parentNode.parentNode; // post-GPT-4o
adamlui commented 4 months ago

This is the new menu button: <button class="flex h-10 w-10 items-center justify-center rounded-full hover:bg-token-main-surface-secondary focus-visible:bg-token-main-surface-secondary focus-visible:outline-0" type="button" id="radix-:ra:" aria-haspopup="menu" aria-expanded="true" data-state="open" aria-controls="radix-:rb:">

I registered a new dummy acct upon the recommendation of a buddy and got the new UI, so I can fix the chatgpt.isLoaded() so don't worry bout that one

sonarcloud[bot] commented 4 months ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

micz commented 4 months ago

@adamlui I see you fixed it. Thanks!