mirror of
https://github.com/lencx/Noi.git
synced 2025-12-15 17:40:48 +01:00
extensions: grok (noi-ask)
This commit is contained in:
@@ -9,8 +9,7 @@ Learn more: [electronjs/doc](https://www.electronjs.org/docs/latest/api/extensio
|
||||
<!-- EXTENSIONS_START -->
|
||||
| Name | Version | Description |
|
||||
| --- | --- | --- |
|
||||
| [@noi/ask](https://github.com/lencx/Noi/tree/main/extensions/noi-ask) | 0.1.17 | The best assistant for batch asking and quick typing of prompts. |
|
||||
| [@noi/ask](https://github.com/lencx/Noi/tree/main/extensions/noi-ask) | 0.1.18 | The best assistant for batch asking and quick typing of prompts. |
|
||||
| [@noi/ask-custom](https://github.com/lencx/Noi/tree/main/extensions/noi-ask-custom) | 0.1.0 | The best assistant for batch asking and quick typing of prompts. |
|
||||
| [@noi/export-chatgpt](https://github.com/lencx/Noi/tree/main/extensions/noi-export-chatgpt) | 0.1.1 | ChatGPT chat history export, supports PDF, Image, and Markdown formats. |
|
||||
| [@noi/reset](https://github.com/lencx/Noi/tree/main/extensions/noi-reset) | 0.1.3 | Reset certain website styles to enhance compatibility with Noi. |
|
||||
<!-- EXTENSIONS_END -->
|
||||
@@ -70,24 +70,13 @@ class OpenAIAsk extends NoiAsk {
|
||||
}
|
||||
}
|
||||
|
||||
class SoraAsk extends NoiAsk {
|
||||
static name = 'Sora';
|
||||
static url = 'https://sora.com';
|
||||
class GrokAsk extends NoiAsk {
|
||||
static name = 'Grok';
|
||||
static url = 'https://grok.com';
|
||||
|
||||
static submit() {
|
||||
const buttons = document.querySelectorAll('.surface-composer button');
|
||||
const lastButton = buttons[buttons.length - 1];
|
||||
if (lastButton) this.autoClick(lastButton);
|
||||
}
|
||||
}
|
||||
|
||||
class PoeAsk extends NoiAsk {
|
||||
static name = 'Poe';
|
||||
static url = 'https://poe.com';
|
||||
|
||||
static submit() {
|
||||
const btn = document.querySelectorAll('button[class*="ChatMessageSendButton_sendButton"]')[0];
|
||||
if (btn) this.autoClick(btn);
|
||||
const btn = document.querySelector('button[type="submit"]');
|
||||
if (btn) btn.click();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,6 +168,28 @@ class HuggingChatAsk extends NoiAsk {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class SoraAsk extends NoiAsk {
|
||||
static name = 'Sora';
|
||||
static url = 'https://sora.com';
|
||||
|
||||
static submit() {
|
||||
const buttons = document.querySelectorAll('.surface-composer button');
|
||||
const lastButton = buttons[buttons.length - 1];
|
||||
if (lastButton) this.autoClick(lastButton);
|
||||
}
|
||||
}
|
||||
|
||||
class PoeAsk extends NoiAsk {
|
||||
static name = 'Poe';
|
||||
static url = 'https://poe.com';
|
||||
|
||||
static submit() {
|
||||
const btn = document.querySelectorAll('button[class*="ChatMessageSendButton_sendButton"]')[0];
|
||||
if (btn) this.autoClick(btn);
|
||||
}
|
||||
}
|
||||
|
||||
class PerplexityAsk extends NoiAsk {
|
||||
static name = 'Perplexity';
|
||||
static url = 'https://www.perplexity.ai';
|
||||
@@ -243,6 +254,36 @@ class CopilotAsk extends NoiAsk {
|
||||
}
|
||||
}
|
||||
|
||||
class GitHubCopilotAsk extends NoiAsk {
|
||||
static name = 'GitHub';
|
||||
static url = 'https://github.com/copilot';
|
||||
|
||||
static sync(message) {
|
||||
const inputElement = document.querySelector('form #copilot-chat-textarea');
|
||||
if (inputElement) {
|
||||
inputElement.focus();
|
||||
document.execCommand('undo');
|
||||
document.execCommand('insertText', false, message);
|
||||
}
|
||||
}
|
||||
|
||||
static submit() {
|
||||
const btns = document.querySelectorAll('form button');
|
||||
const btn = btns[btns.length - 1];
|
||||
if (btn) this.autoClick(btn);
|
||||
}
|
||||
}
|
||||
|
||||
class NotebooklmAsk extends NoiAsk {
|
||||
static name = 'NotebookLM';
|
||||
static url = 'https://notebooklm.google.com';
|
||||
|
||||
static submit() {
|
||||
const btn = document.querySelector('form button[type="submit"]');
|
||||
if (btn) btn.click();
|
||||
}
|
||||
}
|
||||
|
||||
class PiAsk extends NoiAsk {
|
||||
static name = 'Pi';
|
||||
static url = 'https://pi.ai/talk';
|
||||
@@ -286,6 +327,27 @@ class YouAsk extends NoiAsk {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class GroqAsk extends NoiAsk {
|
||||
static name = 'Groq';
|
||||
static url = 'https://groq.com';
|
||||
|
||||
static submit() {
|
||||
const btn = document.querySelector('form button[type="submit"]');
|
||||
if (btn) btn.click();
|
||||
}
|
||||
}
|
||||
|
||||
class SunoAsk extends NoiAsk {
|
||||
static name = 'Suno AI';
|
||||
static url = 'https://suno.com';
|
||||
|
||||
static submit() {
|
||||
const btn = Array.from(document.querySelectorAll('button')).find(i => i.innerText.includes('Create'));
|
||||
if (btn) btn.click();
|
||||
}
|
||||
}
|
||||
|
||||
class CozeCNAsk extends NoiAsk {
|
||||
static name = 'Coze';
|
||||
static url = 'https://www.coze.cn/home';
|
||||
@@ -342,36 +404,6 @@ class TongyiAsk extends NoiAsk {
|
||||
}
|
||||
}
|
||||
|
||||
class GroqAsk extends NoiAsk {
|
||||
static name = 'Groq';
|
||||
static url = 'https://groq.com';
|
||||
|
||||
static submit() {
|
||||
const btn = document.querySelector('form button[type="submit"]');
|
||||
if (btn) btn.click();
|
||||
}
|
||||
}
|
||||
|
||||
class SunoAsk extends NoiAsk {
|
||||
static name = 'Suno AI';
|
||||
static url = 'https://suno.com';
|
||||
|
||||
static submit() {
|
||||
const btn = Array.from(document.querySelectorAll('button')).find(i => i.innerText.includes('Create'));
|
||||
if (btn) btn.click();
|
||||
}
|
||||
}
|
||||
|
||||
class NotebooklmAsk extends NoiAsk {
|
||||
static name = 'NotebookLM';
|
||||
static url = 'https://notebooklm.google.com';
|
||||
|
||||
static submit() {
|
||||
const btn = document.querySelector('form button[type="submit"]');
|
||||
if (btn) btn.click();
|
||||
}
|
||||
}
|
||||
|
||||
class JimengAsk extends NoiAsk {
|
||||
static name = 'Jimeng';
|
||||
static url = 'https://jimeng.jianying.com';
|
||||
@@ -401,26 +433,6 @@ class JimengAsk extends NoiAsk {
|
||||
}
|
||||
}
|
||||
|
||||
class GitHubCopilotAsk extends NoiAsk {
|
||||
static name = 'GitHub';
|
||||
static url = 'https://github.com/copilot';
|
||||
|
||||
static sync(message) {
|
||||
const inputElement = document.querySelector('form #copilot-chat-textarea');
|
||||
if (inputElement) {
|
||||
inputElement.focus();
|
||||
document.execCommand('undo');
|
||||
document.execCommand('insertText', false, message);
|
||||
}
|
||||
}
|
||||
|
||||
static submit() {
|
||||
const btns = document.querySelectorAll('form button');
|
||||
const btn = btns[btns.length - 1];
|
||||
if (btn) this.autoClick(btn);
|
||||
}
|
||||
}
|
||||
|
||||
class MetasoAsk extends NoiAsk {
|
||||
static name = 'Metaso'; // 秘塔
|
||||
static url = 'https://metaso.cn';
|
||||
@@ -433,25 +445,26 @@ class MetasoAsk extends NoiAsk {
|
||||
|
||||
window.NoiAsk = {
|
||||
OpenAIAsk,
|
||||
SoraAsk,
|
||||
PoeAsk,
|
||||
ClaudeAsk,
|
||||
GeminiAsk,
|
||||
GrokAsk,
|
||||
CopilotAsk,
|
||||
HuggingChatAsk,
|
||||
PerplexityAsk,
|
||||
CopilotAsk,
|
||||
NotebooklmAsk,
|
||||
GitHubCopilotAsk,
|
||||
PiAsk,
|
||||
GroqAsk,
|
||||
PoeAsk,
|
||||
SoraAsk,
|
||||
SunoAsk,
|
||||
CozeAsk,
|
||||
YouAsk,
|
||||
CozeCNAsk,
|
||||
DoubaoAsk,
|
||||
ChatGLMAsk,
|
||||
TongyiAsk,
|
||||
GroqAsk,
|
||||
SunoAsk,
|
||||
NotebooklmAsk,
|
||||
JimengAsk,
|
||||
DeepSeekAsk,
|
||||
GitHubCopilotAsk,
|
||||
MetasoAsk,
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"manifest_version": 3,
|
||||
"name": "@noi/ask",
|
||||
"version": "0.1.17",
|
||||
"version": "0.1.18",
|
||||
"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": [
|
||||
@@ -10,6 +10,7 @@
|
||||
"https://chatgpt.com/*",
|
||||
"https://sora.com/*",
|
||||
"https://gemini.google.com/*",
|
||||
"https://grok.com/*",
|
||||
"https://poe.com/*",
|
||||
"https://claude.ai/*",
|
||||
"https://huggingface.co/chat/*",
|
||||
@@ -17,17 +18,17 @@
|
||||
"https://copilot.microsoft.com/*",
|
||||
"https://groq.com/*",
|
||||
"https://pi.ai/talk/*",
|
||||
"https://www.coze.com/home/*",
|
||||
"https://suno.com/*",
|
||||
"https://notebooklm.google.com/*",
|
||||
"https://github.com/copilot/*",
|
||||
"https://you.com/*",
|
||||
"https://www.coze.com/home/*",
|
||||
"https://www.coze.cn/home/*",
|
||||
"https://chatglm.cn/*",
|
||||
"https://www.doubao.com/*",
|
||||
"https://tongyi.aliyun.com/qianwen/*",
|
||||
"https://suno.com/*",
|
||||
"https://notebooklm.google.com/*",
|
||||
"https://jimeng.jianying.com/*",
|
||||
"https://chat.deepseek.com/*",
|
||||
"https://github.com/copilot/*",
|
||||
"https://metaso.cn/*"
|
||||
],
|
||||
"js": ["main.js"],
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
# @noi/export-chatgpt
|
||||
|
||||
ChatGPT chat history export, supports PDF, Image, and Markdown formats.
|
||||
@@ -1,174 +0,0 @@
|
||||
const icons = {
|
||||
check: `<svg width="18" height="18" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="currentColor" d="m10.6 16.2l7.05-7.05l-1.4-1.4l-5.65 5.65l-2.85-2.85l-1.4 1.4zM5 21q-.825 0-1.412-.587T3 19V5q0-.825.588-1.412T5 3h14q.825 0 1.413.588T21 5v14q0 .825-.587 1.413T19 21zm0-2h14V5H5zM5 5v14z"/></svg>`,
|
||||
noCheck: `<svg width="18" height="18" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="currentColor" d="M5 21q-.825 0-1.412-.587T3 19V5q0-.825.588-1.412T5 3h14q.825 0 1.413.588T21 5v14q0 .825-.587 1.413T19 21zm0-2h14V5H5z"/></svg>`,
|
||||
}
|
||||
|
||||
const QUERY_CHAT_LIST = 'main [role="presentation"] div[data-testid]';
|
||||
const QUERY_CHECKBOX_AREA = '.empty\\:hidden div.visible';
|
||||
const QUERY_ACTION_BUTTON = '.empty\\:hidden div.visible button';
|
||||
|
||||
window.noiExport = function() {
|
||||
const allNodes = Array.from(document.querySelectorAll(QUERY_CHAT_LIST));
|
||||
if (!allNodes.length) {
|
||||
return {
|
||||
selected: [],
|
||||
all: [],
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
selected: window._noiSelectedNodes,
|
||||
all: allNodes.map((el) => {
|
||||
const node = el.cloneNode(true);
|
||||
const msgNode = node.querySelector('[data-message-author-role]');
|
||||
if (msgNode) {
|
||||
msgNode.className = 'whitespace-pre-wrap break-words';
|
||||
}
|
||||
return node;
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
// ------------------------------
|
||||
|
||||
window.addEventListener('load', () => {
|
||||
window._noiSelectedNodes = [];
|
||||
const debouncedHandleMainChanges = debounce(handleMainChanges, 250);
|
||||
|
||||
const observer = new MutationObserver(mutations => {
|
||||
mutations.forEach(mutation => {
|
||||
if (!mutation.target.form) {
|
||||
debouncedHandleMainChanges();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
const mainElement = document.querySelector('main');
|
||||
observer.observe(mainElement, { childList: true, subtree: true });
|
||||
|
||||
debouncedHandleMainChanges();
|
||||
|
||||
changeURL(() => {
|
||||
window._noiSelectedNodes = [];
|
||||
});
|
||||
})
|
||||
|
||||
function debounce(func, wait) {
|
||||
let timeout;
|
||||
return function(...args) {
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(() => {
|
||||
func.apply(this, args);
|
||||
}, wait);
|
||||
};
|
||||
}
|
||||
|
||||
function createButtonForNode(i, index, nodesMap) {
|
||||
i.setAttribute('noi-node-id', index);
|
||||
nodesMap.set(index, i);
|
||||
|
||||
const btnArea = i.querySelector(QUERY_CHECKBOX_AREA);
|
||||
if (!btnArea) return;
|
||||
|
||||
if (btnArea.querySelector('button.noi-checkbox')) return;
|
||||
|
||||
const defaultBtn = i.querySelector(QUERY_ACTION_BUTTON);
|
||||
if (!defaultBtn) return;
|
||||
|
||||
const btn = document.createElement('button');
|
||||
btn.classList.add(...defaultBtn.classList, 'noi-checkbox');
|
||||
btn.innerHTML = icons.noCheck;
|
||||
btn.setAttribute('data-checked', 'false');
|
||||
|
||||
btn.onclick = () => {
|
||||
const isChecked = btn.getAttribute('data-checked') === 'true';
|
||||
btn.innerHTML = isChecked ? icons.noCheck : icons.check;
|
||||
btn.setAttribute('data-checked', `${!isChecked}`);
|
||||
i.classList.toggle('noi-selected', !isChecked);
|
||||
updateSelectedNodes(isChecked, i.cloneNode(true), nodesMap);
|
||||
}
|
||||
|
||||
btnArea.insertBefore(btn, btnArea.firstChild);
|
||||
}
|
||||
|
||||
function updateSelectedNodes(isChecked, node, nodesMap) {
|
||||
const nodeId = node.getAttribute('noi-node-id');
|
||||
const indexInAll = nodesMap.get(Number(nodeId));
|
||||
const indexInSelected = window._noiSelectedNodes.findIndex(n => n.getAttribute('noi-node-id') === nodeId);
|
||||
|
||||
if (!isChecked) {
|
||||
if (indexInSelected === -1) {
|
||||
let inserted = false;
|
||||
for (let i = 0; i < window._noiSelectedNodes.length; i++) {
|
||||
const currentId = window._noiSelectedNodes[i].getAttribute('noi-node-id');
|
||||
if (nodesMap.get(Number(currentId)) > indexInAll) {
|
||||
window._noiSelectedNodes.splice(i, 0, node);
|
||||
inserted = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!inserted) {
|
||||
const msgNode = node.querySelector('[data-message-author-role]');
|
||||
if (msgNode) {
|
||||
msgNode.className = 'whitespace-pre-wrap break-words';
|
||||
}
|
||||
window._noiSelectedNodes.push(node);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (indexInSelected > -1) {
|
||||
window._noiSelectedNodes.splice(indexInSelected, 1);
|
||||
}
|
||||
}
|
||||
window._noiSelectedNodes.sort((a, b) => {
|
||||
const nodeIdA = a.getAttribute('noi-node-id');
|
||||
const nodeIdB = b.getAttribute('noi-node-id');
|
||||
return Number(nodeIdA) - Number(nodeIdB);
|
||||
});
|
||||
console.log(window._noiSelectedNodes);
|
||||
}
|
||||
|
||||
function handleMainChanges() {
|
||||
const nodesMap = new Map();
|
||||
document.querySelectorAll(QUERY_CHAT_LIST)
|
||||
.forEach((node, index) => createButtonForNode(node, index, nodesMap));
|
||||
}
|
||||
|
||||
(function (history) {
|
||||
function triggerEvent(eventName, state) {
|
||||
if (typeof history[eventName] === 'function') {
|
||||
history[eventName]({ state: state, url: window.location.href });
|
||||
}
|
||||
}
|
||||
|
||||
function overrideHistoryMethod(methodName, eventName) {
|
||||
const originalMethod = history[methodName];
|
||||
history[methodName] = function (state, ...rest) {
|
||||
const result = originalMethod.apply(this, [state, ...rest]);
|
||||
triggerEvent(eventName, state);
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
overrideHistoryMethod('pushState', 'onpushstate');
|
||||
overrideHistoryMethod('replaceState', 'onreplacestate');
|
||||
|
||||
window.addEventListener('popstate', () => {
|
||||
triggerEvent('onpopstate', null);
|
||||
});
|
||||
})(window.history);
|
||||
|
||||
function changeURL(callback) {
|
||||
window.history.onpushstate = (event) => {
|
||||
console.log('pushState called:', event.url);
|
||||
callback && callback(event);
|
||||
};
|
||||
window.history.onreplacestate = (event) => {
|
||||
console.log('replaceState called:', event.url);
|
||||
callback && callback(event);
|
||||
};
|
||||
window.history.onpopstate = (event) => {
|
||||
console.log('popstate event triggered', window.location.href);
|
||||
callback && callback(event);
|
||||
};
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
{
|
||||
"manifest_version": 3,
|
||||
"name": "@noi/export-chatgpt",
|
||||
"version": "0.1.1",
|
||||
"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://chatgpt.com/*"],
|
||||
"js": ["main.js"],
|
||||
"css": ["style.css"],
|
||||
"run_at": "document_end",
|
||||
"world": "MAIN"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
.noi-selected {
|
||||
border: dashed 2px rgb(34 197 94);
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
{
|
||||
"name": "@noi/ask",
|
||||
"description": "The best assistant for batch asking and quick typing of prompts.",
|
||||
"version": "0.1.17",
|
||||
"version": "0.1.18",
|
||||
"url": "https://github.com/lencx/Noi/tree/main/extensions/noi-ask",
|
||||
"dirname": "noi-ask",
|
||||
"disabled": false
|
||||
@@ -18,14 +18,6 @@
|
||||
"dirname": "noi-ask-custom",
|
||||
"disabled": false
|
||||
},
|
||||
{
|
||||
"name": "@noi/export-chatgpt",
|
||||
"description": "ChatGPT chat history export, supports PDF, Image, and Markdown formats.",
|
||||
"version": "0.1.1",
|
||||
"url": "https://github.com/lencx/Noi/tree/main/extensions/noi-export-chatgpt",
|
||||
"dirname": "noi-export-chatgpt",
|
||||
"disabled": false
|
||||
},
|
||||
{
|
||||
"name": "@noi/reset",
|
||||
"description": "Reset certain website styles to enhance compatibility with Noi.",
|
||||
|
||||
Reference in New Issue
Block a user