Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix ChatGPT btn selector #158

Closed
wants to merge 1 commit into from
Closed

Conversation

lroolle
Copy link

@lroolle lroolle commented May 15, 2024

No description provided.

Copy link
Owner

@lencx lencx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ChatGPT UI DOM nesting structure changes frequently, so this approach might be more stable:

// ...
const btns = document.querySelectorAll('main form button');
const btn = btns[btns.length - 1];

@ls-jingbo-jin
Copy link
Contributor

I created another approach before seeing this PR.
Both approaches sees okay to me:

const btns = document.querySelectorAll('main form button');
const btn = btns[btns.length - 1];

This one based on the last button is likely always be the submit button

const svg = document.querySelectorAll('svg[class*="icon-2xl"]')[0];
  btn = svg.parentElement;

This one assume upload svg only appears once in the whole page.

@lroolle
Copy link
Author

lroolle commented May 18, 2024

@lencx I like @ls-jingbo-jin's approach, so I'm going to close this PR for now.

@lroolle lroolle closed this May 18, 2024
@lencx
Copy link
Owner

lencx commented May 18, 2024

The .icon-2xl class is controlled via TailwindCSS. If OpenAI updates the UI, the class name .icon-2xl might change at any time. On the other hand, using form button is not associated with any specific class and, therefore, is less likely to be affected by changes in class names.

@ls-jingbo-jin
Copy link
Contributor

@lencx I see, thanks for the detail about TailwindCSS馃憤
I have created another PR based on your approach, please check 馃檹:
#165

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants