lencx / Noi

🚀 Power Your World with AI - Explore, Extend, Empower.
https://noi.nofwl.com
5.46k stars 395 forks source link

win11 noi0.4.0 noi ask模式,gpt-4o 无法同步发送prompt #178

Open yangxuangui1117 opened 1 month ago

yangxuangui1117 commented 1 month ago

win11 noi0.4.0 noi ask模式,gpt-4o 无法同步发送prompt 20240528-211857

neo-ai-zh commented 1 month ago

我也有同样的问题,很急切地期望能新版本或者有别的方法临时解决 @lencx

yangxuangui1117 commented 1 month ago

lencx给了答复: 是 openai 的域名改成 chatgpt.com 了,导致之前的脚本失效了 我已经修改了,你重新更新一下扩展,如何更新扩展之前写过教程。

  1. 查看插件教程:https://mp.weixin.qq.com/s/M6gO6MdK5obCvs2LIBZA3w
  2. 修改扩展代码:https://github.com/lencx/Noi/tree/main/extensions/noi-ask
  3. 编辑侧栏 ChatGPT 链接为 https://chatgpt.com
yangxuangui1117 commented 1 month ago

但目前只有gpt-4o单独用的时候可以同步prompt,多个AI一起用还是无法同步prompt到gpt-4o的输入框 单用 单用 多个AI一起用 多个一起用

hayashitomoharu commented 1 month ago

I am a beginner with JavaScript and this application, but I was able to resolve the issue by overriding main.js.

我是一个JavaScript和这个应用程序的初学者,但我通过覆盖main.js解决了这个问题。

它可以与多个AI一起使用。 你还需要编辑侧边栏和manifest.json中的URL。

class OpenAIAsk extends NoiAsk {
  static name = 'ChatGPT';
  static url = 'https://chatgpt.com';
  static sync(message) {
    const inputElement = document.querySelector('textarea#prompt-textarea');
    if (inputElement) {
      const nativeTextareaSetter = Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype, 'value').set;
      nativeTextareaSetter.call(inputElement, message);
      const inputEvent = new InputEvent('input', {
        bubbles: true,
        cancelable: true,
      });
      inputElement.dispatchEvent(inputEvent);
    }
  }

  static autoFocus() {
    const inputElement = document.querySelector('textarea#prompt-textarea');
    if (inputElement) {
      inputElement.focus();
    }
  }

  static submit() {
    const btn = document.querySelector('button[data-testid="fruitjuice-send-button"]');
    if (btn) this.autoClick(btn);
  }
}
neo-ai-zh commented 1 month ago

lencx给了答复: 是 openai 的域名改成 chatgpt.com 了,导致这个密钥脚本失效了 我已经修改了,你重新更新一下扩展,如何更新扩展之前写过教程。

  1. 查看插件教程:https://mp.weixin.qq.com/s/M6gO6MdK5obCvs2LIBZA3w
  2. 修改扩展代码:https://github.com/lencx/Noi/tree/main/extensions/noi-ask
  3. 编辑侧栏 ChatGPT 链接为https://chatgpt.com

解决了非常感谢

DjTj1312 commented 1 month ago

Thanks to @hayashitomoharu and @neo-ai-zh for the guidance.

For my solution, it was simply about changing the URL in the sidebar, manifest.json, and main.js (no actual code changes required).

  1. Click on the three dots next to ChatGPT in the Sidebar => Edit => change the URL to https://chatgpt.com/.

  2. In both manifest.json and main.js => update the URL from https://chat.openai.com to https://chatgpt.com/.

My OpenAIAsk class still looks like this:

class OpenAIAsk extends NoiAsk {
  static name = 'ChatGPT';
  static url = 'https://chatgpt.com';

  static submit() {
    const btn = document.querySelector('button[data-testid="send-button"]');
    if (btn) this.autoClick(btn);
  }
}
gustavogmoraes commented 1 month ago

I am a beginner with JavaScript and this application, but I was able to resolve the issue by overriding .main.js

  • It can be used with multiple AIs.
  • You also need to edit the URL in the sidebar and .manifest.json

I'm a beginner in JavaScript and this app, but I solved this problem by overlaying main.js.

It can be used with multiple AIs. You'll also need to edit the URLs in the sidebar and manifest.json.

class OpenAIAsk extends NoiAsk {
  static name = 'ChatGPT';
  static url = 'https://chatgpt.com';
  static sync(message) {
    const inputElement = document.querySelector('textarea#prompt-textarea');
    if (inputElement) {
      const nativeTextareaSetter = Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype, 'value').set;
      nativeTextareaSetter.call(inputElement, message);
      const inputEvent = new InputEvent('input', {
        bubbles: true,
        cancelable: true,
      });
      inputElement.dispatchEvent(inputEvent);
    }
  }

  static autoFocus() {
    const inputElement = document.querySelector('textarea#prompt-textarea');
    if (inputElement) {
      inputElement.focus();
    }
  }

  static submit() {
    const btn = document.querySelector('button[data-testid="fruitjuice-send-button"]');
    if (btn) this.autoClick(btn);
  }
}

I am a beginner with JavaScript and this application, but I was able to resolve the issue by overriding .main.js

  • It can be used with multiple AIs.
  • You also need to edit the URL in the sidebar and .manifest.json

I'm a beginner in JavaScript and this app, but I solved this problem by overlaying main.js.

It can be used with multiple AIs. You'll also need to edit the URLs in the sidebar and manifest.json.

class OpenAIAsk extends NoiAsk {
  static name = 'ChatGPT';
  static url = 'https://chatgpt.com';
  static sync(message) {
    const inputElement = document.querySelector('textarea#prompt-textarea');
    if (inputElement) {
      const nativeTextareaSetter = Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype, 'value').set;
      nativeTextareaSetter.call(inputElement, message);
      const inputEvent = new InputEvent('input', {
        bubbles: true,
        cancelable: true,
      });
      inputElement.dispatchEvent(inputEvent);
    }
  }

  static autoFocus() {
    const inputElement = document.querySelector('textarea#prompt-textarea');
    if (inputElement) {
      inputElement.focus();
    }
  }

  static submit() {
    const btn = document.querySelector('button[data-testid="fruitjuice-send-button"]');
    if (btn) this.autoClick(btn);
  }
}

You're on the right path, here's my quick-workaround (without using the custom ask mode). Easy for even non-developers to apply:

  1. Go to Noi > Settings > Extensions
  2. Ensure you have the @noi/ask one, and remember when you change the files, if you sync again it will be overwriten, and you'll have to edit again
  3. Click the purple button pointing to your Roaming AppData folder (usually %appdata%\Noi -> that is the '~' in the button)
  4. Here I recommend using VSCode for it, Just Open the Folder, hit Ctrl + Shift + F This changes the domain to the new one 4.1 Search for https://chat.openai.com click the down arrow and replace it by https://chatgpt.com This matches the selector for all send-buttons for any model or custom gpt you're using 4.2 Search for button[data-testid="send-button"] and replace it by button[data-testid$="send-button"]
  5. File > Save All and restart your Noi