Better xCloud No VPN - Xbox Cloud Gaming Region Unlocker

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

// ==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);
}