Remove Char Limit for Bing Chat AI

This Tampermonkey script enhances your search experience on Bing Chat by removing the character limit from the search input. Enjoy unrestricted search queries and explore endless possibilities with ease, as the script displays an infinity symbol (∞) in place of the character counter.

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Remove Char Limit for Bing Chat AI
// @namespace    http://tampermonkey.net/
// @version      0.4
// @description  This Tampermonkey script enhances your search experience on Bing Chat by removing the character limit from the search input. Enjoy unrestricted search queries and explore endless possibilities with ease, as the script displays an infinity symbol (∞) in place of the character counter.
// @author       RomainC-lab
// @match        *://www.bing.com/*
// @grant        none
// @icon         https://raw.githubusercontent.com/RomainC-lab/Tampermonkey-Scripts-Collection/master/remove-char-limit-bing-chat.user.png
// @run-at       document-end
// ==/UserScript==

(function () {
	"use strict";

	async function waitForElement(root, selector) {
		return new Promise((resolve, reject) => {
			if (root.querySelector(selector)) {
				resolve(root.querySelector(selector));
			} else {
				const observer = new MutationObserver((mutations) => {
					mutations.forEach((mutation) => {
						if (mutation.type === "childList") {
							if (root.querySelector(selector)) {
								resolve(root.querySelector(selector));
								observer.disconnect();
								clearTimeout(timeout);
							}
						}
					});
				});
				observer.observe(root, { childList: true, subtree: true });
				const timeout = setTimeout(() => {
					observer.disconnect();
					reject(new Error("Timeout"));
				}, 10000);
			}
		});
	}

	async function removeCharLimit() {
		const serp = await waitForElement(
			document,
			"cib-serp[serp-slot='none']"
		);
		const serpShadowRoot = serp.shadowRoot;
		const actionBar = await waitForElement(
			serpShadowRoot,
			"cib-action-bar"
		);
		const actionBarShadowRoot = actionBar.shadowRoot;
		const serpTextInput = await waitForElement(
			actionBarShadowRoot,
			"cib-text-input[serp-slot='none']"
		);
	        const serpTextInputShadowRoot = serpTextInput.shadowRoot;
		const textarea = await waitForElement(
			serpTextInputShadowRoot,
			"textarea[maxlength]"
		);
		textarea.removeAttribute("maxlength");
		const letterCounter = await waitForElement(
			actionBarShadowRoot,
			".letter-counter"
		);
		letterCounter.childNodes[
			letterCounter.childNodes.length - 1
		].textContent = "∞";
	}

	window.addEventListener("load", removeCharLimit);
	window.addEventListener("popstate", removeCharLimit);
})();