Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

mefengl/bing-utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Bing Utils

AI Friendly AI Assisted Maybe Commit Messages by AI

Notice

this repo has been put into chatkit, you can find more about it in chat-play/packages/chatkit/bingchat.

Description

getSubmitButton, getTextarea, getRegenerateButton, getNewChatButton...

Usage

just copy and paste the code below

function getActionBar() {
  return document.querySelector("cib-serp")?.shadowRoot?.querySelector("cib-action-bar")?.shadowRoot;
};
function getSubmitButton() {
  const actionBar = getActionBar();
  if (!actionBar) { return null; }
  return actionBar.querySelector('button[aria-label="Submit"]');
};
function getTextarea() {
  const actionBar = getActionBar();
  if (!actionBar) { return null; }
  return actionBar.querySelector('textarea');
};
function getStopGeneratingButton() {
  const actionBar = getActionBar();
  if (!actionBar) { return null; }
  const stopGeneratingButton = actionBar.querySelector('cib-typing-indicator')?.shadowRoot?.querySelector('button[aria-label="Stop Responding"]');
  if (!stopGeneratingButton) { return null; }
  if (stopGeneratingButton.disabled) { return null; }
  return stopGeneratingButton;
};
function getNewChatButton() {
  const actionBar = getActionBar();
  if (!actionBar) { return null; }
  return actionBar.querySelector('button[aria-label="New topic"]');
};
function getConversation() {
  return document.querySelector("cib-serp")?.shadowRoot?.querySelector("cib-conversation")?.shadowRoot;
};
function getChatTurns() {
  const conversation = getConversation();
  if (!conversation) { return null; }
  return Array.from(conversation.querySelectorAll('cib-chat-turn')).map(t => t.shadowRoot);
};
function getLastChatTurn() {
  const chatTurns = getChatTurns();
  if (!chatTurns) { return null; }
  return chatTurns[chatTurns.length - 1];
};
function getLastResponse() {
  const lastChatTurn = getLastChatTurn();
  if (!lastChatTurn) { return null; }
  return lastChatTurn.querySelectorAll('cib-message-group')[1]?.shadowRoot;
};
function getLastResponseText() {
  const lastResponse = getLastResponse();
  if (!lastResponse) { return null; }
  return Array.from( lastResponse.querySelectorAll('cib-message') )
    .map(m => m.shadowRoot)
    .find(m => m.querySelector('cib-shared'))
    .textContent.trim();
};
function send(text) {
  const textarea = getTextarea();
  if (!textarea) { return null; }
  textarea.value = text;
  textarea.dispatchEvent(new Event('input'));
  const submitButton = getSubmitButton();
  if (!submitButton) { return null; }
  submitButton.click();
};

Contributing

Contributions, issues and feature requests are welcome!

License

This project is licensed under the terms of the MIT license.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published