Bing US Region Setter and License Acceptor with Persistent US Setting

Keep Bing region set to US and language to English persistently

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Bing US Region Setter and License Acceptor with Persistent US Setting
// @namespace    http://tampermonkey.net/
// @version      1.4
// @description  Keep Bing region set to US and language to English persistently
// @author       Shadow_Kurgansk
// @match        https://www.bing.com/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // Function to persistently set Bing region to US and language to English
    function setBingRegionToUS() {
        const url = new URL(window.location.href);
        const params = url.searchParams;

        // Check if the language is already set to English (US)
        if (params.get('setlang') !== 'en-us') {
            params.set('setlang', 'en-us'); // Set language to English (US)
            // If the URL has changed, reload the page with the new parameters
            if (window.location.href !== url.href) {
                window.location.href = url.href;
            }
        }
    }

    // Function to accept the license agreement with a delay
    function acceptLicenseAgreement() {
        // Wait for 200 milliseconds (0.2 seconds) before trying to click the button
        setTimeout(function() {
            const acceptButton = document.querySelector('#bnp_btn_accept.bnp_btn_accept');
            if (acceptButton) {
                acceptButton.click();
            }
        }, 200); // Adjust the time as needed
    }

    // Execute the acceptLicenseAgreement function when the page includes 'bing.com'
    if (window.location.href.includes('bing.com')) {
        acceptLicenseAgreement();
    }

    // Set an interval to check the region and language every 3 seconds
    setInterval(setBingRegionToUS, 500);
})();