Remove Bing Character Limit

Removes character limit from search input field

// ==UserScript==
// @name         Remove Bing Character Limit
// @version      2.2
// @description  Removes character limit from search input field
// @match        https://www.bing.com/*
// @run-at       document-end
// @license MIT
// @namespace NOLIMIT
// ==/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 = "∞";

                // Add mutation observer to textarea
                const config = { attributes: true, childList: false, subtree: false };
                const callback = function (mutationsList, observer) {
                    for (const mutation of mutationsList) {
                        if (mutation.type === 'attributes') {
                            textarea.removeAttribute("maxlength");
                            console.log('Attribute ' + mutation.attributeName + ' changed to: ' + textarea.getAttribute(mutation.attributeName));
                        }
                    }
                };
                const observer = new MutationObserver(callback);
                observer.observe(textarea, config);
	}

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