CN Bing return to Global Bing

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

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

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

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

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

您需要先安装一款用户脚本管理器扩展,例如 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...
})();