BingChat QuickPrompt

Instantly prompts BingChat based on the provided query in URL search params. For instance, https://www.bing.com/chat?prompt="Who is Harry Potter" will instantly prompt BingChat.

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         BingChat QuickPrompt
// @version      1.0
// @description  Instantly prompts BingChat based on the provided query in URL search params. For instance, https://www.bing.com/chat?prompt="Who is Harry Potter" will instantly prompt BingChat.
// @match        https://www.bing.com/*
// @grant        none
// @namespace https://greasyfork.org/users/1071946
// ==/UserScript==

(function () {
  "use strict";
  console.log("BingChat QuickPrompt: Activated");

  var queryString = window.location.search;
  // Create a URLSearchParams object
  var urlParams = new URLSearchParams(queryString);

  // Get the value of the prompt parameter
  var promptValue = urlParams.get("prompt");

  // Remove the quotation marks from the value
  promptValue = promptValue.replace(/"/g, "");

  function retry(fn, attempts, delay) {
    if (attempts === undefined) attempts = 10;
    if (delay === undefined) delay = 500;
    return function () {
      var args = Array.prototype.slice.call(arguments);
      var context = this;
      var i = 0;
      var retryFn = function () {
        try {
          fn.apply(context, args); // delegate
        } catch (e) {
          if (i < attempts) setTimeout(retryFn, delay);
          else throw e;
        }
        i++;
      };
      retryFn();
    };
  }
  // Define a function that changes the maxlength attribute
  function prompt() {
    function simulateTyping(string, element) {
      // loop through each character in the string
      for (var i = 0; i < string.length; i++) {
        // create a keydown event with the character as the key property
        var event = new KeyboardEvent("keydown", { key: string[i] });
        // dispatch the event on the element
        element.dispatchEvent(event);
      }
    }

    var element =
      document.getElementsByClassName("cib-serp-main")[0].shadowRoot;
    var element2 = element.getElementById("cib-action-bar-main").shadowRoot;
    var root = element2.querySelector(".root");
    root.setAttribute("has-text", "");
    var searchbox = root.querySelector(".text-area");
    var controlSubmit = root.querySelector(".control.submit");
    controlSubmit.style.display = "block";
    var button = root.querySelector(".button.primary");

    // Set the maxlength attribute to 9999999
    searchbox.setAttribute("maxlength", "9999999");

    // Set the value of the searchbox to the promptValue
    searchbox.value = promptValue;
    // Trigger change event
    var changeEvent = document.createEvent("Events");
    changeEvent.initEvent("change", true, true);
    searchbox.dispatchEvent(changeEvent);

    var clickEvent = document.createEvent("MouseEvents");
    clickEvent.initMouseEvent(
      "click",
      true,
      true,
      window,
      0,
      1,
      1,
      1,
      1,
      false,
      false,
      false,
      false,
      0,
      null
    );

    // Trigger a click event on the button
    button.dispatchEvent(clickEvent);
  }
  // Create a retried version of the function
  var retried = retry(prompt);
  // Call the retried function
  retried();
})();