Sync Google Searches to Bing (Invisible XMLHttpRequest)

Automatically searches on Bing when you search on Google, using an invisible XMLHttpRequest

当前为 2024-09-15 提交的版本,查看 最新版本

// ==UserScript==
// @name         Sync Google Searches to Bing (Invisible XMLHttpRequest)
// @namespace    Violentmonkey Scripts
// @version      1.1
// @description  Automatically searches on Bing when you search on Google, using an invisible XMLHttpRequest
// @author       intercepted16
// @match        https://www.google.com/search*
// @grant        GM_xmlhttpRequest
// @connect      bing.com
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // Function to check if the user is on a mobile device
    function isMobile() {
        return /Mobi|Android|iPhone|iPad|iPod/.test(navigator.userAgent);
    }

    // Extract search query from the Google URL
    const params = new URLSearchParams(window.location.search);
    const query = params.get('q');

    if (query) {
        let bingUrl = `https://www.bing.com/search?q=${encodeURIComponent(query)}`;

        // Add additional query parameters only if the user is not on a mobile device
        if (!isMobile()) {
            bingUrl += `&cvid=5ea855fc7c2446b79bd423c6c8dfcca3&gs_lcrp=EgZjaHJvbWUyBggAEEUYOTIGCAEQABhAMgYIAhAuGEAyBggDEC4YQDIGCAQQLhhAMgYIBRAuGEAyBggGEAAYQDIGCAcQABhAMgYICBAuGEDSAQc1NjZqMGoxqAIAsAIA&FORM=ANSPA1&PC=U531`;
        }

        // Use GM_xmlhttpRequest to send a GET request to Bing
        GM_xmlhttpRequest({
            method: "GET",
            url: bingUrl,
            onload: function(response) {
                console.log("Bing search performed silently");
            },
            onerror: function(error) {
                console.error("Error performing Bing search:", error);
            }
        });
    }
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址