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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tag base element #2

Closed
mefengl opened this issue Mar 16, 2023 · 5 comments
Closed

tag base element #2

mefengl opened this issue Mar 16, 2023 · 5 comments

Comments

@mefengl
Copy link
Contributor

mefengl commented Mar 16, 2023

Cause ChatGPT web is using Tailwind, if we pre-tag elements with id, it will make other scripts' development easier.

Such as, I used to get sendButton by the last button in the form, but after installing the wide-screen mode script, that function actually returned the wrong button.

this should not be much work, cause can use the function defined in #1

@adamlui
Copy link
Member

adamlui commented Mar 16, 2023

OK create a PR so I know what you mean

@adamlui
Copy link
Member

adamlui commented Mar 16, 2023

(ChatGPT Widescreen uses get button with class containing bottom in form)

@mefengl
Copy link
Contributor Author

mefengl commented Mar 16, 2023

like this:

// Use the added functions to get the elements
const submitButton = chatgpt.getSubmitButton();
const textarea = chatgpt.getTextarea();
const regenerateButton = chatgpt.getRegenerateButton();
const stopGeneratingButton = chatgpt.getStopGeneratingButton();
const newChatButton = chatgpt.getNewChatButton();

// Assign reasonable IDs to the elements
submitButton.id = 'chatgpt-submit-button';
textarea.id = 'chatgpt-textarea';
regenerateButton.id = 'chatgpt-regenerate-button';
stopGeneratingButton.id = 'chatgpt-stop-generating-button';
newChatButton.id = 'chatgpt-new-chat-button';

@mefengl
Copy link
Contributor Author

mefengl commented Mar 16, 2023

or make it an init method?

Seems not good if adding runtime to a package

@adamlui
Copy link
Member

adamlui commented Mar 16, 2023

I like your first idea, also using var instead of const ensures compatibility with older browsers (const doesn't work in browser versions before 2015, var works since 1995)

@mefengl mefengl closed this as completed Mar 16, 2023
Rojojun added a commit to Rojojun/chatgpt.js that referenced this issue Jul 14, 2023
Rojojun added a commit to Rojojun/chatgpt.js that referenced this issue Jul 14, 2023
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

No branches or pull requests

2 participants