Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mefengl/bard-utils
getSubmitButton, getTextarea, getRegenerateButton, getNewChatButton...
https://github.com/mefengl/bard-utils
Last synced: 10 days ago
JSON representation
getSubmitButton, getTextarea, getRegenerateButton, getNewChatButton...
- Host: GitHub
- URL: https://github.com/mefengl/bard-utils
- Owner: mefengl
- License: mit
- Created: 2023-03-27T04:58:53.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-04-06T16:37:33.000Z (over 1 year ago)
- Last Synced: 2024-10-30T10:15:33.504Z (about 2 months ago)
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Bard Utils
[![AI Friendly](https://img.shields.io/badge/AI-Friendly-pink?style=for-the-badge)](https://github.com/mefengl/made-by-ai)
[![AI Assisted Maybe](https://img.shields.io/badge/AI%20Assisted-Maybe-yellow?style=for-the-badge)](https://github.com/mefengl/made-by-ai)
[![Commit Messages by AI](https://img.shields.io/badge/Commit%20Messages%20by-AI-green?style=for-the-badge)](https://github.com/mefengl/made-by-ai)## Notice
this repo has been put into `chatkit`, you can find more about it in [chat-play/packages/chatkit/bard](https://github.com/mefengl/chat-play).
## Description
getSubmitButton, getTextarea, getRegenerateButton, getNewChatButton...
## Usage
just copy and paste the code below
```js
function getInputArea() {
return document.querySelector(".input-area");
};
``````js
function getSubmitButton() {
return document.querySelector('button[aria-label="Send message"]');
};
``````js
function getTextarea() {
const inputArea = getInputArea();
return inputArea.querySelector('textarea');
};
``````js
function getRegenerateButton() {
return document.querySelector('button[aria-label="Retry"]');
};
``````js
function getNewChatButton() {
const navButtons = document.querySelector('mat-nav-list').children;
return Array.from(navButtons).find(b => b.textContent.trim().toLowerCase().includes('reset chat'));
};
``````js
function getLastResponse() {
const responseElements = document.querySelectorAll('.model-response-text');
const lastResponse = responseElements[responseElements.length - 1];
return lastResponse;
};
``````js
function getLastResponseText() {
const lastPrompt = this.getLastPrompt();
if (!lastPrompt) return "";
const lastPromptText = lastPrompt.textContent;
return lastPromptText;
};
``````js
function getLastPrompt() {
const promptElements = document.querySelectorAll('.query-text');
const lastPrompt = promptElements[promptElements.length - 1];
return lastPrompt;
};
``````js
function getLastPromptText() {
const lastPrompt = getLastPrompt();
return lastPrompt.textContent;
};
``````js
function send(text) {
const textarea = getTextarea();
textarea.value = text;
textarea.dispatchEvent(new Event('input'));
getSubmitButton().click();
};
```## Contributing
Contributions, issues and feature requests are welcome!
## License
This project is licensed under the terms of the [MIT license](/LICENSE).