Better xCloud No VPN - Xbox Cloud Gaming Region Unlocker

Add-on script for Better xCloud to bypass region restriction (no VPN)

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Better xCloud No VPN - Xbox Cloud Gaming Region Unlocker
// @namespace    https://www.tampermonkey.net/
// @version      1.0.3
// @description  Add-on script for Better xCloud to bypass region restriction (no VPN)
// @match        https://www.xbox.com/*/play*
// @run-at       document-start
// @grant        none
// ==/UserScript==

const FAKE_IP = '9.9.9.9';

let bypassed = false;
const originalFetch = window.fetch;

window.fetch = async (...args) => {
    if (bypassed) {
        return originalFetch(...args);
    }

    const request = args[0];
    const url = (typeof request === 'string') ? request : request.url;

    if (args[0].headers && !url.includes('xhome') && url.endsWith('/v2/login/user')) {
        args[0].headers.set('X-Forwarded-For', FAKE_IP);
        bypassed = true;
    }

    return originalFetch(...args);
}