Baidu Netdisk UA Switcher

Force User-Agent to pan.baidu.com for specific domains

当前为 2025-03-25 提交的版本,查看 最新版本

// ==UserScript==
// @name         Baidu Netdisk UA Switcher
// @namespace    https://greasyfork.org
// @version      1.2.1
// @description  Force User-Agent to pan.baidu.com for specific domains
// @author       Andy
// @match        *://resource.qblb.net/*
// @match        *://pan.baidu.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // 自定义User-Agent
    const baiduUA = "pan.baidu.com";

    // 覆盖XMLHttpRequest的open方法
    const originalXhrOpen = XMLHttpRequest.prototype.open;
    XMLHttpRequest.prototype.open = function(method, url, async, user, password) {
        this.setRequestHeader('User-Agent', baiduUA);
        originalXhrOpen.call(this, method, url, async, user, password);
    };

})();