Bing AI No Limit

Remove character limitation from Bing AI search.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Bing AI No Limit
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Remove character limitation from Bing AI search.
// @author       guohaiping
// @match        https://www.bing.com/search?*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';
    var script = document.createElement('script');
    script.textContent = `
        const DEBUG = false;

        async function waitForElement(parent, selector) {
            return new Promise((resolve, reject) => {
                const interval = setInterval(function () {
                    const element = parent.querySelector(selector);

                    if (element) {
                        if (DEBUG) {
                            console.log(element);
                        }
                        clearInterval(interval);
                        resolve(element);
                    }
                }, 10);
            });
        }

        const removeLimitation = async () => {
            const mainHost = await waitForElement(document, ".cib-serp-main");
            const mainRoot = mainHost.shadowRoot;
            const secondHost = await waitForElement(mainRoot, "#cib-action-bar-main");
            const secondRoot = secondHost.shadowRoot;
            const searchInput = await waitForElement(secondRoot, "#searchbox");
            searchInput.removeAttribute("maxlength");
            const letterCounter = await waitForElement(secondRoot, ".letter-counter");
            letterCounter.innerHTML = "Unlimited characters by guohaiping";
            console.log("Character limit was removed.");

            const observer = new MutationObserver((mutationsList) => {
                for (const mutation of mutationsList) {
                    if (!searchInput.isConnected) {
                        removeLimitation();
                        observer.disconnect();
                    }
                }
            });

            observer.observe(secondRoot, { childList: true });
        };

        removeLimitation();
    `;
    (document.head||document.documentElement).appendChild(script);
    script.remove();
})();