chore: extensions

This commit is contained in:
lencx
2024-02-05 00:08:04 +08:00
parent 12ca5cd40e
commit eb20b55726
8 changed files with 157 additions and 5 deletions

View File

@@ -0,0 +1 @@
# @noi/ask-custom

View File

@@ -0,0 +1,61 @@
/**
* NoiAskCustom: Batch send messages to AI Chat.
*/
class NoiAskCustom {
static sync(message) {
const inputElement = document.querySelector('textarea');
if (inputElement) {
const nativeTextareaSetter = Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype, 'value').set;
nativeTextareaSetter.call(inputElement, message);
const inputEvent = new InputEvent('input', {
bubbles: true,
cancelable: true,
});
inputElement.dispatchEvent(inputEvent);
}
}
static simulateUserInput(element, text) {
const inputEvent = new InputEvent('input', {
bubbles: true,
cancelable: true,
});
element.focus();
element.value = text;
element.dispatchEvent(inputEvent);
}
static autoClick(btn) {
btn.focus();
btn.disabled = false;
btn.click();
}
}
// TODO: Implement your custom AI Chat
// TODO: In manifest.json to match the url of your AI Chat
// ref: https://github.com/lencx/Noi/tree/main/extensions/noi-ask
class MyAsk extends NoiAskCustom {
// TODO: Change the name and url to your AI Chat
static name = 'MyChat';
// TODO: Change the url to your AI Chat
static url = '';
// TODO: Implement the sync method
static sync() {
// code...
}
// TODO: Implement the submit method
static submit() {
// code...
}
}
// Register your AI Chat class within the NoiAsk global namespace for accessibility.
window.NoiAsk = {
...window.NoiAsk || {},
// TODO: Add your AI Chat class here
MyAsk,
};

View File

@@ -0,0 +1,15 @@
{
"manifest_version": 3,
"name": "@noi/ask-custom",
"version": "0.1.0",
"homepage": "https://github.com/lencx/Noi/tree/main/extensions/noi-ask-custom",
"description": "The best assistant for batch asking and quick typing of prompts.",
"content_scripts": [
{
"matches": [],
"js": ["main.js"],
"run_at": "document_end",
"world": "MAIN"
}
]
}