您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
js修改xhr请求的header
当前为
// ==UserScript== // @name suizhikuo-edit-xhr-header // @namespace http://tampermonkey.net/ // @version 2024-04-09 // @description js修改xhr请求的header // @author 随智阔 // @match *://*/* // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== // @grant none // @require https://code.jquery.com/jquery-3.7.1.js // @license MIT // ==/UserScript== (function () { 'use strict'; debugger; console.log("篡改猴(Tampermonkey)脚本--->运行"); // window.alert("篡改猴(Tampermonkey)脚本--->运行"); // 原生js修改xhr请求header var originalOpen = XMLHttpRequest.prototype.open; XMLHttpRequest.prototype.open = function (method, url, async, user, password) { this._headers = {}; this.open = originalOpen.bind(this, method, url, async, user, password); var setRequestHeader = this.setRequestHeader; this.setRequestHeader = function (header, value) { this._headers[header.toLowerCase()] = value; return setRequestHeader.apply(this, arguments); }; var send = this.send; this.send = function (body) { // 在这里添加你想要的header this.setRequestHeader("accept-language", "en-US"); return send.apply(this, arguments); }; this.open(method, url, async, user, password); }; })();