User-Agent Switcher for Fluxus

Switch user-agent to Google Chrome for Fluxus

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 or Violentmonkey 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         User-Agent Switcher for Fluxus
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Switch user-agent to Google Chrome for Fluxus
// @author       You
// @match        *://fluxus.dev/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    
    // Define the Google Chrome user-agent string (Windows version)
    const chromeUserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36";
    
    // Modify the navigator.userAgent directly (although some sites may block this)
    Object.defineProperty(navigator, 'userAgent', {
        get: function() { return chromeUserAgent; }
    });
    
    // Intercept the XMLHttpRequest to modify the user-agent for network requests
    const originalOpen = XMLHttpRequest.prototype.open;
    XMLHttpRequest.prototype.open = function(method, url, async, user, password) {
        arguments[1] = url;
        arguments[3] = chromeUserAgent; // Override the user-agent for the request
        originalOpen.apply(this, arguments);
    };

    // Intercept the fetch API to modify the user-agent for network requests
    const originalFetch = window.fetch;
    window.fetch = function(input, init) {
        init = init || {};
        init.headers = init.headers || {};
        init.headers['User-Agent'] = chromeUserAgent; // Override user-agent for fetch requests
        return originalFetch(input, init);
    };
    
    console.log("User-Agent has been switched to Google Chrome for Fluxus!");
})();