User-Agent Switcher for Fluxus

Switch user-agent to Google Chrome for Fluxus

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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!");
})();