// ==UserScript== // @name 修改用户代理 // @namespace http://your.namespace.com // @version 0.2 // @description 修改用户代理字符串 // @author Your Name // @license MIT // @match http://*/* // @match https://*/* // @grant none // @downloadURL none // ==/UserScript== (function() { 'use strict'; // 设置新的用户代理字符串,模拟 iPhone 用户 var newUserAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 15_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.2 Mobile/15E148 Safari/604.1"; // 重写 navigator.userAgent 属性 Object.defineProperty(navigator, 'userAgent', { value: newUserAgent, writable: false, configurable: false, enumerable: true }); // 移除可能存在的重定向 history.pushState = function(state, title, url) {}; })();