CN Bing return to Global Bing

重定向国内版bing到国际版bing

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         CN Bing return to Global Bing
// @namespace    http://tampermonkey.net/
// @version      0.1.3
// @description  重定向国内版bing到国际版bing
// @author       You
// @license MIT
// @match        https://cn.bing.com/search*
// @match        https://cn.bing.com/*
// @match        https://www.bing.com
// @match        https://cn.bing.com/
// @match        https://cn.bing.com
// @match        https://global.bing.com/*
// @match        https://www.bing.com/
// @match        https://bing.com/*
// @match        https://bing.com/
// @match        https://www.bing.com/search*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=bing.com
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var global_bing = "https://global.bing.com/search?setmkt=en-US&setlang=en-US&filt=custom&cc=US";
    let current_url = window.location.href;
    if (current_url == "https://global.bing.com/?scope=web&cc=US" || current_url.startsWith("https://global.bing.com/account" )){

    return 0;}
    var query = "";
    var cc = "";
    var mkt = "";
    var lang = "";
    var filters = "";
    var form = "";
    if (current_url.match (/[\?\&]q=([^\&\#]+)[\&\#]/i)){
    query = current_url.match (/[\?\&]q=([^\&\#]+)[\&\#]/i) [1];}

    if (current_url == "https://cn.bing.com/" || current_url == "https://cn.bing.com"){
        window.location.replace("https://global.bing.com/?FORM=Z9FD1")
        return 0;
    }


    if (current_url.startsWith("https://cn.bing.com") || current_url.startsWith("https://www.bing.com") && query == ""){
        window.location.hostname = "global.bing.com"
        if(current_url.match(/[\?\&]*=([^\&\#]+)[\&\#]/i)){
        window.location.href(window.location+"&setmkt=en-US&setlang=en-US&cc=US")}
        else{
            window.location.href(window.location+"?setmkt=en-US&setlang=en-US&cc=US")
        }
        return 0;
    }


    if (!current_url.startsWith("https://global.bing.com") && query != "" ) {
        window.location.hostname = "global.bing.com"
        window.location.href(window.location+"&setmkt=en-US&setlang=en-US&cc=US")
        return 0;

    }

    if (current_url.match (/[\?\&]cc=([^\&\#]+)[\&\#]/i)){
    cc = current_url.match (/[\?\&]cc=([^\&\#]+)[\&\#]/i) [1];}
    if (current_url.match (/[\?\&]setmkt=([^\&\#]+)[\&\#]/i)){
    mkt = current_url.match (/[\?\&]setmkt=([^\&\#]+)[\&\#]/i) [1];}
    if (current_url.match (/[\?\&]setlang=([^\&\#]+)[\&\#]/i)){
    lang = current_url.match (/[\?\&]setlang=([^\&\#]+)[\&\#]/i) [1];}
    if (current_url.match (/[\?\&]filters=([^\&\#]+)[\&\#]/i)){
    filters = current_url.match (/[\?\&]filters=([^\&\#]+)[\&\#]/i) [1];}
    if (current_url.match (/[\?\&]FORM=([^\&\#]+)[\&\#]/i)){
    form = current_url.match (/[\?\&]FORM=([^\&\#]+)[\&\#]/i) [1];}

    if (current_url.startsWith("https://global.bing.com") && (cc.endsWith("CN") || mkt.endsWith("CN") || lang.endsWith("CN")||mkt == "" || lang == "")){
        window.location.hostname = "global.bing.com"
        if(current_url.match(/[\?\&]*=([^\&\#]+)[\&\#]/i)){
        window.location.replace(window.location+"&setmkt=en-US&setlang=en-US&cc=US")}
        else{
            window.location.replace(window.location+"?setmkt=en-US&setlang=en-US&cc=US")
        }
        return 0;
    return 0;
    }

    document.body.innerHTML = document.body.innerHTML.replace(/cn.bing.com/g,"global.bing.com");

    // Your code here...
})();