From 7fc7ba7a08078565e3a0bf2ae2f317ea723f8967 Mon Sep 17 00:00:00 2001 From: lencx Date: Tue, 17 Sep 2024 15:55:14 +0800 Subject: [PATCH] fix: chatgpt ask --- README.md | 2 +- extensions/README.md | 2 +- extensions/noi-ask/main.js | 24 ++++++++++-------------- extensions/noi-ask/manifest.json | 2 +- extensions/noi.extensions.json | 2 +- 5 files changed, 14 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index b910b5c..2118ff4 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,7 @@ Learn more: [electronjs/doc](https://www.electronjs.org/docs/latest/api/extensio | Name | Version | Description | | --- | --- | --- | -| [@noi/ask](https://github.com/lencx/Noi/tree/main/extensions/noi-ask) | 0.1.11 | 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.12 | 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. | diff --git a/extensions/README.md b/extensions/README.md index d08d008..5ab545c 100644 --- a/extensions/README.md +++ b/extensions/README.md @@ -9,7 +9,7 @@ Learn more: [electronjs/doc](https://www.electronjs.org/docs/latest/api/extensio | Name | Version | Description | | --- | --- | --- | -| [@noi/ask](https://github.com/lencx/Noi/tree/main/extensions/noi-ask) | 0.1.11 | 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.12 | 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. | diff --git a/extensions/noi-ask/main.js b/extensions/noi-ask/main.js index ab06deb..aaebb2c 100644 --- a/extensions/noi-ask/main.js +++ b/extensions/noi-ask/main.js @@ -48,20 +48,16 @@ class OpenAIAsk extends NoiAsk { static url = 'https://chatgpt.com'; static sync(message) { - if (document.querySelector('form textarea')) { - this.sync(message); - } else { - const inputElement = document.querySelector('form #prompt-textarea'); - if (inputElement) { - inputElement.focus(); - inputElement.innerHTML = ''; // Clear existing content - const lines = message.split('\n'); - lines.forEach(line => { - const p = document.createElement('p'); - p.textContent = line; // Use textContent to prevent HTML injection - inputElement.appendChild(p); - }); - } + const inputElement = document.querySelector('form #prompt-textarea'); + if (inputElement) { + inputElement.focus(); + inputElement.innerHTML = ''; // Clear existing content + const lines = message.split('\n'); + lines.forEach(line => { + const p = document.createElement('p'); + p.textContent = line; // Use textContent to prevent HTML injection + inputElement.appendChild(p); + }); } } diff --git a/extensions/noi-ask/manifest.json b/extensions/noi-ask/manifest.json index f5d1421..1d1aff2 100644 --- a/extensions/noi-ask/manifest.json +++ b/extensions/noi-ask/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 3, "name": "@noi/ask", - "version": "0.1.11", + "version": "0.1.12", "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": [ diff --git a/extensions/noi.extensions.json b/extensions/noi.extensions.json index 46712df..7b36ce0 100644 --- a/extensions/noi.extensions.json +++ b/extensions/noi.extensions.json @@ -5,7 +5,7 @@ { "name": "@noi/ask", "description": "The best assistant for batch asking and quick typing of prompts.", - "version": "0.1.11", + "version": "0.1.12", "url": "https://github.com/lencx/Noi/tree/main/extensions/noi-ask", "dirname": "noi-ask", "disabled": false