Bing to Google Tab

Adds a Google button to Bing search header

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Bing to Google Tab
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Adds a Google button to Bing search header
// @author       Your Name
// @match        https://www.bing.com/search*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // 1. Get the current search query from the URL
    const urlParams = new URLSearchParams(window.location.search);
    const query = urlParams.get('q');

    if (query) {
        // 2. Find the Bing navigation menu (where "Images", "Videos", etc. are)
        const navBar = document.querySelector('#b_header .b_scopebar ul') || document.querySelector('.b_scopebar ul');

        if (navBar) {
            // 3. Create the new list item and link
            const googleLi = document.createElement('li');
            const googleLink = document.createElement('a');

            googleLink.href = `https://www.google.com/search?q=${encodeURIComponent(query)}`;
            googleLink.target = "_blank"; // Opens in a new tab
            googleLink.innerText = "Google";
            googleLink.style.color = "#4285F4"; // Google Blue
            googleLink.style.fontWeight = "bold";

            googleLi.appendChild(googleLink);
            navBar.appendChild(googleLi);
        }
    }
})();