diff --git a/configs/noi.mode.json b/configs/noi.mode.json index 80f6791..0ee6b67 100644 --- a/configs/noi.mode.json +++ b/configs/noi.mode.json @@ -1,6 +1,6 @@ { "name": "Noi Mode", - "version": "0.1.2", + "version": "0.1.3", "sync": "https://github.com/lencx/noi/blob/main/configs/noi.mode.json", "modes": [ { @@ -45,6 +45,12 @@ "text": "Poe", "url": "https://poe.com" }, + { + "id": "noi:perplexity", + "parent": "noi@ai", + "text": "Perplexity", + "url": "https://www.perplexity.ai" + }, { "id": "noi:copilot", "parent": "noi@ai", @@ -52,11 +58,16 @@ "url": "https://copilot.microsoft.com" }, { - "id": "noi:perplexity", + "id": "noi:huggingchat", "parent": "noi@ai", - "text": "Perplexity", - "url": "https://www.perplexity.ai", - "logo": "" + "text": "HuggingChat", + "url": "https://huggingface.co/chat" + }, + { + "id": "noi:pi", + "parent": "noi@ai", + "text": "Pi", + "url": "https://pi.ai/talk" }, { "id": "noi:github", @@ -76,6 +87,12 @@ "text": "Hugging Face", "url": "https://huggingface.co" }, + { + "id": "noi:vscode", + "parent": "noi@dev", + "text": "VS Code", + "url": "https://vscode.dev" + }, { "id": "noi:x", "parent": "noi@community", diff --git a/extensions/noi-ask/README.md b/extensions/noi-ask/README.md index 2008b32..934c02a 100644 --- a/extensions/noi-ask/README.md +++ b/extensions/noi-ask/README.md @@ -1 +1 @@ -# Noi Ask +# @noi/ask diff --git a/extensions/noi-ask/main.js b/extensions/noi-ask/main.js index 335ff8b..9f357af 100644 --- a/extensions/noi-ask/main.js +++ b/extensions/noi-ask/main.js @@ -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 { static sync(message) { 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) { btn.focus(); 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 = { OpenAIAsk, PoeAsk, @@ -130,4 +204,6 @@ window.NoiAsk = { BardAsk, HuggingChatAsk, PerplexityAsk, + CopilotAsk, + PiAsk, }; diff --git a/extensions/noi-ask/manifest.json b/extensions/noi-ask/manifest.json index 14d1a50..69a7b40 100644 --- a/extensions/noi-ask/manifest.json +++ b/extensions/noi-ask/manifest.json @@ -11,7 +11,9 @@ "https://poe.com/*", "https://claude.ai/*", "https://huggingface.co/chat/*", - "https://www.perplexity.ai/*" + "https://www.perplexity.ai/*", + "https://copilot.microsoft.com/*", + "https://pi.ai/talk/*" ], "js": ["main.js"], "run_at": "document_end", diff --git a/extensions/noi-export-chatgpt/README.md b/extensions/noi-export-chatgpt/README.md index b6fa9a6..98771d4 100644 --- a/extensions/noi-export-chatgpt/README.md +++ b/extensions/noi-export-chatgpt/README.md @@ -1 +1 @@ -# Noi Export - ChatGPT +# @noi/export-chatgpt diff --git a/extensions/noi-reset/README.md b/extensions/noi-reset/README.md new file mode 100644 index 0000000..83c81d2 --- /dev/null +++ b/extensions/noi-reset/README.md @@ -0,0 +1 @@ +# @noi/reset diff --git a/extensions/noi-reset/main.js b/extensions/noi-reset/main.js new file mode 100644 index 0000000..a7ed7a6 --- /dev/null +++ b/extensions/noi-reset/main.js @@ -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); diff --git a/extensions/noi-reset/manifest.json b/extensions/noi-reset/manifest.json new file mode 100644 index 0000000..56edc23 --- /dev/null +++ b/extensions/noi-reset/manifest.json @@ -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" + } + ] +} \ No newline at end of file