Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

对话搜索无法触发输入和搜索 #16

Open
xubuild opened this issue Jan 26, 2024 · 1 comment
Open

对话搜索无法触发输入和搜索 #16

xubuild opened this issue Jan 26, 2024 · 1 comment

Comments

@xubuild
Copy link

xubuild commented Jan 26, 2024

尝试添加kimi,打开新网页后,无法正常触发输入和搜索。在用的油猴脚本使用粘贴方式可以正常触发。

站点:https://kimi.moonshot.cn/

以下配置无法触发输入和搜索

"kimi": {
    "dname": "kimi",
    "addr": "https://kimi.moonshot.cn",
    "ajax": [
      3000,
      "[data-testid='msh-chatinput-editor']",
      500,
      "[data-testid='msh-chatinput-send-button']"
    ],
    "action": "https://kimi.moonshot.cn/chat"
  },

使用js脚本可以完成输入和搜索

  function saveTextToClipboard(text) {
      navigator.clipboard.writeText(text)
          .then(() => {
              console.log('文本已成功保存到剪贴板');
          })
          .catch((error) => {
              console.error('保存文本到剪贴板时出现错误:', error);
          });
  }

  function triggerPasteEvent(element, value) {
      const event = new ClipboardEvent('paste', {
          dataType: 'text/plain',
          clipboardData: new DataTransfer(),
          bubbles: true,
          cancelable: true,
      });

      event.clipboardData.setData('text/plain', value);

      element.dispatchEvent(event);
  }

  var arxiv_paper = urlParams.get('arxiv');
  var editorElement = document.querySelector('[data-testid="msh-chatinput-editor"]');

  if (!editorElement && retryCount < maxRetries) {
      retryCount++;
      setTimeout(getElementWithRetry, retryInterval);
  } else if (editorElement) {
      editorElement.focus();
      saveTextToClipboard(arxiv_paper);

      // 获取剪贴板中的值
      navigator.clipboard.readText().then((clipboardValue) => {
          triggerPasteEvent(document.querySelector('[data-testid="msh-chatinput-editor"]'), clipboardValue);
          setTimeout(function () {
              document.querySelector('button[data-testid="msh-chatinput-send-button"]').click();
              
          }, 500);
      });

  }

同样的bing copilot也无法完成输入和搜索: https://www.bing.com/search?form=MY0291&OCID=MY0291&q=Bing+AI&showconv=1

"bing_chat": {
    "dname": "bing_chat",
    "addr": "https://www.bing.com/search?form=MY0291&OCID=MY0291&q=Bing+AI&showconv=1",
    "ajax": [
      5000,
      "#searchbox",
      500,
      "[aria-label='Submit']"
    ],
    "action": "https://www.bing.com/search?q=Bing+AI&showconv=1"
  }

谢谢!

@garywill
Copy link
Owner

kimi那个网页的主页(我没有账号,只能看主页)的输入框[data-testid='msh-chatinput-editor']不是<input><textarea>,是个<div>

这种情况还没有添加
看你贴出的那个脚本,如果要像它那样在content script读剪贴板然后粘贴,应该有要求我们的扩展有权限才行

我想下先,应该怎么处理这种用<div>来当输入框的情况。你有什么好建议也可以说下


那个copilot我没有账号,不显示#searchbox,我目前没法检查

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants