BigSearch icon indicating copy to clipboard operation
BigSearch copied to clipboard

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

Open xubuild opened this issue 5 months ago • 1 comments

尝试添加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"
  }

谢谢!

xubuild avatar Jan 26 '24 03:01 xubuild