chore: extensions

This commit is contained in:
lencx
2024-01-31 17:36:52 +08:00
parent 22a87c0b3d
commit a0cd0b4de4
13 changed files with 117 additions and 25 deletions

View File

@@ -7,7 +7,7 @@
class NoiAsk {
static sync(message) {
const inputElement = document.querySelector(`textarea`);
const inputElement = document.querySelector('textarea');
if (inputElement) {
const nativeTextareaSetter = Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype, 'value').set;
nativeTextareaSetter.call(inputElement, message);
@@ -41,7 +41,7 @@ class OpenAIAsk extends NoiAsk {
static url = 'https://chat.openai.com';
static submit() {
const btn = document.querySelector(`button[data-testid="send-button"]`);
const btn = document.querySelector('button[data-testid="send-button"]');
if (btn) this.autoClick(btn);
}
}
@@ -51,7 +51,7 @@ class PoeAsk extends NoiAsk {
static url = 'https://poe.com';
static submit() {
const btn = document.querySelectorAll(`button[class*="ChatMessageSendButton_sendButton"]`)[0];
const btn = document.querySelectorAll('button[class*="ChatMessageSendButton_sendButton"]')[0];
if (btn) this.autoClick(btn);
}
}
@@ -61,7 +61,7 @@ class ClaudeAsk extends NoiAsk {
static url = 'https://claude.ai';
static sync(message) {
const inputElement = document.querySelector(`div.ProseMirror`);
const inputElement = document.querySelector('div.ProseMirror');
if (inputElement) {
inputElement.focus();
inputElement.innerHTML = '';
@@ -71,12 +71,12 @@ class ClaudeAsk extends NoiAsk {
static submit() {
// subsequent screens use this
let btn = document.querySelector(`button[aria-label*="Send Message"]`);
let btn = document.querySelector('button[aria-label*="Send Message"]');
if (!btn) { // new chats use this
btn = document.querySelector(`button:has(div svg)`);
btn = document.querySelector('button:has(div svg)');
}
if (!btn) { // last ditch attempt
btn = document.querySelector(`button:has(svg)`);
btn = document.querySelector('button:has(svg)');
}
if (btn) this.autoClick(btn);
}
@@ -87,7 +87,7 @@ class BardAsk extends NoiAsk {
static url = 'https://bard.google.com';
static sync(message) {
const inputElement = document.querySelector(`.ql-editor.textarea`);
const inputElement = document.querySelector('.ql-editor.textarea');
if (inputElement) {
const inputEvent = new Event('input', { bubbles: true });
inputElement.value = message;
@@ -98,7 +98,7 @@ class BardAsk extends NoiAsk {
}
static submit() {
const btn = document.querySelector(`button[aria-label*="Send message"]`);
const btn = document.querySelector('button[aria-label*="Send message"]');
if (btn) {
btn.setAttribute('aria-disabled', 'false'); // doesn't work alone
btn.focus();
@@ -112,7 +112,7 @@ class HuggingChatAsk extends NoiAsk {
static url = 'https://huggingface.co/chat';
static sync(message) {
var inputElement = document.querySelector(`textarea[placeholder*="Ask anything"]`);
var inputElement = document.querySelector('textarea[placeholder*="Ask anything"]');
if (inputElement) {
const inputEvent = new Event('input', { bubbles: true });
inputElement.value = message;
@@ -121,7 +121,7 @@ class HuggingChatAsk extends NoiAsk {
}
static submit() {
var btn = document.querySelector(`form.relative > div > button[type="submit"]`);
var btn = document.querySelector('form.relative > div > button[type="submit"]');
if (btn) this.autoClick(btn);
}
}
@@ -131,7 +131,7 @@ class PerplexityAsk extends NoiAsk {
static url = 'https://www.perplexity.ai';
static submit() {
const btns = Array.from(document.querySelectorAll(`button.bg-super`));
const btns = Array.from(document.querySelectorAll('button.bg-super'));
if (btns[0]) {
const btnsWithSvgPath = btns.filter(button => button.querySelector('svg path'));
const btn = btnsWithSvgPath[btnsWithSvgPath.length - 1];
@@ -197,6 +197,32 @@ class PiAsk extends NoiAsk {
}
}
class CozeAsk extends NoiAsk {
static name = 'Coze';
static url = 'https://www.coze.com/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 YouAsk extends NoiAsk {
static name = 'YouAsk';
static url = 'https://you.com';
static submit() {
const btn = document.querySelector('button[data-eventactionname="click_send"]');
if (btn) btn.click();
}
}
window.NoiAsk = {
OpenAIAsk,
PoeAsk,
@@ -206,4 +232,6 @@ window.NoiAsk = {
PerplexityAsk,
CopilotAsk,
PiAsk,
CozeAsk,
YouAsk,
};

View File

@@ -1,8 +1,9 @@
{
"manifest_version": 3,
"name": "@noi/ask",
"version": "0.1.0",
"version": "0.1.1",
"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": [
{
"matches": [
@@ -13,7 +14,9 @@
"https://huggingface.co/chat/*",
"https://www.perplexity.ai/*",
"https://copilot.microsoft.com/*",
"https://pi.ai/talk/*"
"https://pi.ai/talk/*",
"https://www.coze.com/home/*",
"https://you.com/*"
],
"js": ["main.js"],
"run_at": "document_end",

View File

@@ -3,6 +3,7 @@
"name": "@noi/export-chatgpt",
"version": "0.1.0",
"homepage": "https://github.com/lencx/Noi/tree/main/extensions/noi-export-chatgpt",
"description": "ChatGPT chat history export, supports PDF, Image, and Markdown formats.",
"content_scripts": [
{
"matches": ["https://*.openai.com/*"],

View File

@@ -3,6 +3,7 @@
"name": "@noi/reset",
"version": "0.1.0",
"homepage": "https://github.com/lencx/Noi/tree/main/extensions/noi-reset",
"description": "Reset certain website styles to enhance compatibility with Noi.",
"content_scripts": [
{
"matches": [

View File

@@ -0,0 +1,27 @@
{
"name": "Noi Extensions",
"homepage": "https://github.com/lencx/Noi/blob/main/extensions/noi.extensions.json",
"extensions": [
{
"name": "@noi/ask",
"description": "The best assistant for batch asking and quick typing of prompts.",
"version": "0.1.1",
"url": "https://github.com/lencx/Noi/tree/main/extensions/noi-ask",
"disabled": false
},
{
"name": "@noi/export-chatgpt",
"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",
"disabled": false
},
{
"name": "@noi/reset",
"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",
"disabled": false
}
]
}