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

@ -32,6 +32,10 @@
|![theme-dark](./website/static/readme/noi-theme-dark.png)|![theme-light](./website/static/readme/noi-theme-light.png)|
|![batch-ask](./website/static/readme/noi-batch-ask.png)|![settings-prompts](./website/static/readme/noi-settings-prompts.png)|
---
[![Star History Chart](https://api.star-history.com/svg?repos=lencx/Noi&type=Timeline)](https://star-history.com/#lencx/Noi&Timeline)
## FAQ
### macOS

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"
}
]
}

View File

@ -214,7 +214,7 @@ class CozeAsk extends NoiAsk {
}
class YouAsk extends NoiAsk {
static name = 'YouAsk';
static name = 'YOU';
static url = 'https://you.com';
static submit() {
@ -223,6 +223,58 @@ class YouAsk extends NoiAsk {
}
}
class CozeCNAsk extends NoiAsk {
static name = 'Coze';
static url = 'https://www.coze.cn/home';
static submit() {
const inputElement = document.querySelector('textarea');
if (inputElement) {
const nextElement = inputElement.nextElementSibling;
if (nextElement) {
const btn = nextElement.querySelector('button');
if (btn) btn.click();
}
}
}
}
class ChatGMLAsk extends NoiAsk {
static name = 'ChatGLM'; // 智谱清言
static url = 'https://chatglm.cn';
static submit() {
const btn = document.querySelector('#search-input-box .enter img');
if (btn) btn.click();
}
}
class DoubaoAsk extends NoiAsk {
static name = 'Doubao'; // 豆包
static url = 'https://www.doubao.com';
static submit() {
const btn = document.querySelector('#flow-end-msg-send');
if (btn) btn.click();
}
}
class TongyiAsk extends NoiAsk {
static name = 'TongYi'; // 通义千问
static url = 'https://tongyi.aliyun.com/qianwen';
static submit() {
const inputElement = document.querySelector('textarea');
if (inputElement) {
const nextElement = inputElement.nextElementSibling;
if (nextElement) {
const btn = nextElement.querySelector('div[class^="chatBtn"]');
if (btn) btn.click();
}
}
}
}
window.NoiAsk = {
OpenAIAsk,
PoeAsk,
@ -234,4 +286,8 @@ window.NoiAsk = {
PiAsk,
CozeAsk,
YouAsk,
CozeCNAsk,
DoubaoAsk,
ChatGMLAsk,
TongyiAsk,
};

View File

@ -1,7 +1,7 @@
{
"manifest_version": 3,
"name": "@noi/ask",
"version": "0.1.1",
"version": "0.1.2",
"homepage": "https://github.com/lencx/Noi/tree/main/extensions/noi-ask",
"description": "The best assistant for batch asking and quick typing of prompts.",
"content_scripts": [
@ -16,7 +16,11 @@
"https://copilot.microsoft.com/*",
"https://pi.ai/talk/*",
"https://www.coze.com/home/*",
"https://you.com/*"
"https://you.com/*",
"https://www.coze.cn/home/*",
"https://chatglm.cn/*",
"https://www.doubao.com/*",
"https://tongyi.aliyun.com/qianwen/*"
],
"js": ["main.js"],
"run_at": "document_end",

View File

@ -6,7 +6,7 @@
"description": "ChatGPT chat history export, supports PDF, Image, and Markdown formats.",
"content_scripts": [
{
"matches": ["https://*.openai.com/*"],
"matches": ["https://chat.openai.com/*"],
"js": ["main.js"],
"css": ["style.css"],
"run_at": "document_end",

View File

@ -5,8 +5,17 @@
{
"name": "@noi/ask",
"description": "The best assistant for batch asking and quick typing of prompts.",
"version": "0.1.1",
"version": "0.1.2",
"url": "https://github.com/lencx/Noi/tree/main/extensions/noi-ask",
"dirname": "noi-ask",
"disabled": false
},
{
"name": "@noi/ask-custom",
"description": "The best assistant for batch asking and quick typing of prompts.",
"version": "0.1.0",
"url": "https://github.com/lencx/Noi/tree/main/extensions/noi-ask-custom",
"dirname": "noi-ask-custom",
"disabled": false
},
{
@ -14,6 +23,7 @@
"description": "ChatGPT chat history export, supports PDF, Image, and Markdown formats.",
"version": "0.1.0",
"url": "https://github.com/lencx/Noi/tree/main/extensions/noi-export-chatgpt",
"dirname": "noi-export-chatgpt",
"disabled": false
},
{
@ -21,6 +31,7 @@
"description": "Reset certain website styles to enhance compatibility with Noi.",
"version": "0.1.0",
"url": "https://github.com/lencx/Noi/tree/main/extensions/noi-reset",
"dirname": "noi-reset",
"disabled": false
}
]