效果
直接在页面上添加请求头的key-value,就可以在请求中携带请求头。
暴力猴插件代码
// ==UserScript==
// @name Swagger Headers Injection
// @name:zh-CN Swagger Headers 注入
// @namespace https://github.com/liuycy
// @include *://**/swagger-ui*
// @grant GM_setValue
// @grant GM_getValue
// @require https://cdn.jsdelivr.net/npm/vue@2.6.12/dist/vue.min.js
// @require https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js
// @version 2.0.0
// @author liuycy
// ==/UserScript==
!(function () {
var FETCH = unsafeWindow.fetch
var XHR_SEND = XMLHttpRequest.prototype.send
function resetHeader(headers) {
Object.defineProperty(unsafeWindow, 'fetch', {
value: funct