CharlieBBS

True_AGI_Believer
True_AGI_Believer

Posted on

一个油猴脚本,解除 Bing Chat 的 4000 字符限制

// ==UserScript==
// @name        Bing Increase Word Limit
// @namespace   Violentmonkey Scripts
// @match       https://www.bing.com/*
// @license     MIT
// @version     6.0
// @author      Reddiepoint and more
// @description Removes the word limit for Bing Search and Bing Chat.
// ==/UserScript==

function addMaxLengthEventListener(object) {
    eventListener = event => {
        if (event.target.getAttribute("maxlength")) {
            event.target.removeAttribute("maxlength")
            const cibSerpElement = document.querySelector("#b_sydConvCont > cib-serp")
            const counterElement = cibSerpElement.shadowRoot.querySelector("#cib-action-bar-main").shadowRoot.querySelector("div > div.main-container.body-2 > div.input-container.as-ghost-placement > div.body-1.bottom-bar > div.letter-counter > span")
            if (counterElement) {
                counterElement.nextSibling.nextSibling.textContent = ""
            }
        }
    }
    object.addEventListener("focusin", eventListener)
    object.addEventListener("mouseover", eventListener)
}

addMaxLengthEventListener(document)

const observer = new MutationObserver(mutations => {
    mutations.forEach(mutation => {
        if (mutation.addedNodes.length > 0) {
            const cibSerpElement = document.querySelector("#b_sydConvCont > cib-serp")
            if (cibSerpElement) {
                const element = cibSerpElement.shadowRoot.querySelector("#cib-action-bar-main").shadowRoot.querySelector("div > div.main-container.body-2 > div.input-container.as-ghost-placement > cib-text-input").shadowRoot.querySelector("#searchbox")
                addMaxLengthEventListener(element)
                observer.disconnect()
            }
        }
    })
})

observer.observe(document.body, {childList: true, subtree: true})
Enter fullscreen mode Exit fullscreen mode

Discussion (1)

Collapse
true_agi_believer profile image
True_AGI_Believer Author

截至目前,Bing 已经能输入约 25K Tokens 上下文