User-Agent Switcher for Fluxus

Switch user-agent to Google Chrome for Fluxus

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

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

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

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

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

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

作者
jhondrhey dacudao
日安装量
0
总安装量
29
评分
0 0 0
版本
1.0
创建于
2024-11-26
更新于
2024-11-26
大小
1.6 KB
许可证
暂无
适用于

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