lencx / Noi

🚀 Power Your World with AI - Explore, Extend, Empower.
https://noi.nofwl.com
5.46k stars 395 forks source link

fix ChatGPT btn selector #158

Closed lroolle closed 1 month ago

ls-jingbo-jin commented 1 month ago

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 commented 1 month ago

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

lencx commented 1 month ago

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 commented 1 month ago

@lencx I see, thanks for the detail about TailwindCSS👍 I have created another PR based on your approach, please check 🙏: https://github.com/lencx/Noi/pull/165