Bing Tab Title Changer

Change the tab title to the keys you type on Bing search pages

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name Bing Tab Title Changer
// @namespace https://tampermonkey.net/
// @version 0.2
// @description Change the tab title to the keys you type on Bing search pages
// @author perXautomatik
// @match https://www.bing.com/search?q=*
// @grant none
// @license MIT 
// ==/UserScript==

(function() {
    'use strict';

    // Create an array to store the buffered keys
    var buffer = [];

    // Create a variable to store the prefix
    var prefix = "Bing ChatGPT: ";

    // Add a keydown event listener to the document
    document.addEventListener("keydown", function(event) {
        // Check if the key is Enter
        if (event.key === "Enter") {
            // Set the tab title to the prefix and the buffered keys joined as a string
            document.title = prefix + buffer.join("");
            // Clear the buffer
            buffer = [];
        } else if (event.key === "Backspace" || event.key === "Delete") {
            // Remove the last key from the buffer
            buffer.pop();
        } else {
            // Check if the key is an arrow key
            if (event.key !== "ArrowUp" && event.key !== "ArrowDown") {
                // Push the key to the buffer
                buffer.push(event.key);
            }
        }
    });
})();