mirror of
https://github.com/lencx/Noi.git
synced 2024-10-26 20:57:35 +03:00
chore: noi ask
This commit is contained in:
parent
e12983d630
commit
81963c12d5
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "Noi Mode",
|
"name": "Noi Mode",
|
||||||
"version": "0.1.2",
|
"version": "0.1.3",
|
||||||
"sync": "https://github.com/lencx/noi/blob/main/configs/noi.mode.json",
|
"sync": "https://github.com/lencx/noi/blob/main/configs/noi.mode.json",
|
||||||
"modes": [
|
"modes": [
|
||||||
{
|
{
|
||||||
@ -45,6 +45,12 @@
|
|||||||
"text": "Poe",
|
"text": "Poe",
|
||||||
"url": "https://poe.com"
|
"url": "https://poe.com"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "noi:perplexity",
|
||||||
|
"parent": "noi@ai",
|
||||||
|
"text": "Perplexity",
|
||||||
|
"url": "https://www.perplexity.ai"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "noi:copilot",
|
"id": "noi:copilot",
|
||||||
"parent": "noi@ai",
|
"parent": "noi@ai",
|
||||||
@ -52,11 +58,16 @@
|
|||||||
"url": "https://copilot.microsoft.com"
|
"url": "https://copilot.microsoft.com"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "noi:perplexity",
|
"id": "noi:huggingchat",
|
||||||
"parent": "noi@ai",
|
"parent": "noi@ai",
|
||||||
"text": "Perplexity",
|
"text": "HuggingChat",
|
||||||
"url": "https://www.perplexity.ai",
|
"url": "https://huggingface.co/chat"
|
||||||
"logo": "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 48 48\"><path fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"3\" d=\"M24 4.5v39M13.73 16.573v-9.99L24 16.573m0 14.5L13.73 41.417V27.01L24 16.573m0 0l10.27-9.99v9.99\"/><path fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"3\" d=\"M13.73 31.396H9.44V16.573h29.12v14.823h-4.29\"/><path fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"3\" d=\"M24 16.573L34.27 27.01v14.407L24 31.073\"/></svg>"
|
},
|
||||||
|
{
|
||||||
|
"id": "noi:pi",
|
||||||
|
"parent": "noi@ai",
|
||||||
|
"text": "Pi",
|
||||||
|
"url": "https://pi.ai/talk"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "noi:github",
|
"id": "noi:github",
|
||||||
@ -76,6 +87,12 @@
|
|||||||
"text": "Hugging Face",
|
"text": "Hugging Face",
|
||||||
"url": "https://huggingface.co"
|
"url": "https://huggingface.co"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "noi:vscode",
|
||||||
|
"parent": "noi@dev",
|
||||||
|
"text": "VS Code",
|
||||||
|
"url": "https://vscode.dev"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "noi:x",
|
"id": "noi:x",
|
||||||
"parent": "noi@community",
|
"parent": "noi@community",
|
||||||
|
@ -1 +1 @@
|
|||||||
# Noi Ask
|
# @noi/ask
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
|
/**
|
||||||
|
* NoiAsk: Batch send messages to AI Chat.
|
||||||
|
*
|
||||||
|
* This file is a modified version of the GodMode.
|
||||||
|
* ref: https://github.com/smol-ai/GodMode/tree/main/src/providers
|
||||||
|
*/
|
||||||
|
|
||||||
class NoiAsk {
|
class NoiAsk {
|
||||||
static sync(message) {
|
static sync(message) {
|
||||||
const inputElement = document.querySelector(`textarea`);
|
const inputElement = document.querySelector(`textarea`);
|
||||||
@ -12,6 +19,16 @@ class NoiAsk {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static simulateUserInput(element, text) {
|
||||||
|
const inputEvent = new InputEvent('input', {
|
||||||
|
bubbles: true,
|
||||||
|
cancelable: true,
|
||||||
|
});
|
||||||
|
element.focus();
|
||||||
|
element.value = text;
|
||||||
|
element.dispatchEvent(inputEvent);
|
||||||
|
}
|
||||||
|
|
||||||
static autoClick(btn) {
|
static autoClick(btn) {
|
||||||
btn.focus();
|
btn.focus();
|
||||||
btn.disabled = false;
|
btn.disabled = false;
|
||||||
@ -123,6 +140,63 @@ class PerplexityAsk extends NoiAsk {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class CopilotAsk extends NoiAsk {
|
||||||
|
static name = 'Copilot';
|
||||||
|
static url = 'https://copilot.microsoft.com';
|
||||||
|
|
||||||
|
static sync(message) {
|
||||||
|
// SERP Shadow DOM
|
||||||
|
const serpDOM = document.querySelector('.cib-serp-main');
|
||||||
|
// Action Bar Shadow DOM
|
||||||
|
const inputDOM = serpDOM.shadowRoot.querySelector('#cib-action-bar-main');
|
||||||
|
// Text Input Shadow DOM
|
||||||
|
const textInputDOM = inputDOM.shadowRoot.querySelector('cib-text-input');
|
||||||
|
// This inner cib-text-input Shadow DOM is not always present
|
||||||
|
const inputElement = textInputDOM ? textInputDOM.shadowRoot.querySelector('#searchbox') : inputDOM.shadowRoot.querySelector('#searchbox');
|
||||||
|
if (inputElement) {
|
||||||
|
this.simulateUserInput(inputElement, message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static submit() {
|
||||||
|
try {
|
||||||
|
// Access SERP Shadow DOM
|
||||||
|
const serpDOM = document.querySelector('.cib-serp-main');
|
||||||
|
// Action Bar Shadow DOM
|
||||||
|
const actionDOM = serpDOM.shadowRoot.querySelector('#cib-action-bar-main');
|
||||||
|
// Submit Button
|
||||||
|
const submitButton = actionDOM.shadowRoot.querySelector('div.submit button');
|
||||||
|
|
||||||
|
if (submitButton) {
|
||||||
|
submitButton.click();
|
||||||
|
submitButton.focus();
|
||||||
|
setTimeout(() => {
|
||||||
|
submitButton.click();
|
||||||
|
}, 100)
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Copilot submit error', e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class PiAsk extends NoiAsk {
|
||||||
|
static name = 'Pi';
|
||||||
|
static url = 'https://pi.ai/talk';
|
||||||
|
|
||||||
|
static submit() {
|
||||||
|
const inputElement = document.querySelector('textarea[placeholder="Talk with Pi"]');
|
||||||
|
if (inputElement) {
|
||||||
|
const event = new KeyboardEvent('keydown', {
|
||||||
|
key: 'Enter',
|
||||||
|
view: window,
|
||||||
|
bubbles: true
|
||||||
|
});
|
||||||
|
inputElement.dispatchEvent(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
window.NoiAsk = {
|
window.NoiAsk = {
|
||||||
OpenAIAsk,
|
OpenAIAsk,
|
||||||
PoeAsk,
|
PoeAsk,
|
||||||
@ -130,4 +204,6 @@ window.NoiAsk = {
|
|||||||
BardAsk,
|
BardAsk,
|
||||||
HuggingChatAsk,
|
HuggingChatAsk,
|
||||||
PerplexityAsk,
|
PerplexityAsk,
|
||||||
|
CopilotAsk,
|
||||||
|
PiAsk,
|
||||||
};
|
};
|
||||||
|
@ -11,7 +11,9 @@
|
|||||||
"https://poe.com/*",
|
"https://poe.com/*",
|
||||||
"https://claude.ai/*",
|
"https://claude.ai/*",
|
||||||
"https://huggingface.co/chat/*",
|
"https://huggingface.co/chat/*",
|
||||||
"https://www.perplexity.ai/*"
|
"https://www.perplexity.ai/*",
|
||||||
|
"https://copilot.microsoft.com/*",
|
||||||
|
"https://pi.ai/talk/*"
|
||||||
],
|
],
|
||||||
"js": ["main.js"],
|
"js": ["main.js"],
|
||||||
"run_at": "document_end",
|
"run_at": "document_end",
|
||||||
|
@ -1 +1 @@
|
|||||||
# Noi Export - ChatGPT
|
# @noi/export-chatgpt
|
||||||
|
1
extensions/noi-reset/README.md
Normal file
1
extensions/noi-reset/README.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
# @noi/reset
|
14
extensions/noi-reset/main.js
Normal file
14
extensions/noi-reset/main.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// fix: sidebar not clickable
|
||||||
|
function removeAppRegion() {
|
||||||
|
const allElements = document.querySelectorAll('*');
|
||||||
|
|
||||||
|
for (let element of allElements) {
|
||||||
|
const style = window.getComputedStyle(element);
|
||||||
|
if (style.webkitAppRegion === 'drag' || style.webkitAppRegion === 'no-drag') {
|
||||||
|
element.style.webkitAppRegion = 'initial';
|
||||||
|
// console.log('Removed -webkit-app-region from:', element);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setTimeout(removeAppRegion, 3000);
|
16
extensions/noi-reset/manifest.json
Normal file
16
extensions/noi-reset/manifest.json
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"manifest_version": 3,
|
||||||
|
"name": "@noi/reset",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"homepage": "https://github.com/lencx/Noi/tree/main/extensions/noi-reset",
|
||||||
|
"content_scripts": [
|
||||||
|
{
|
||||||
|
"matches": [
|
||||||
|
"https://vscode.dev/*"
|
||||||
|
],
|
||||||
|
"js": ["main.js"],
|
||||||
|
"run_at": "document_end",
|
||||||
|
"world": "MAIN"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user