Skip to content

Instantly share code, notes, and snippets.

@Fog3211
Last active December 21, 2020 02:50
Show Gist options
  • Save Fog3211/2990b2b21712be14cb65fe6054b30f2a to your computer and use it in GitHub Desktop.
Save Fog3211/2990b2b21712be14cb65fe6054b30f2a to your computer and use it in GitHub Desktop.
swagger自动填充token(油猴脚本)
// ==UserScript==
// @name swagger自动填充token
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match http://huce-sit.hupu.io/admin/swagger-ui.html
// @grant none
// ==/UserScript==
(function () {
'use strict';
window.addEventListener('click', () => {
const tokenInputDomList = document.querySelectorAll('input[type=text]')
tokenInputDomList.forEach(element => {
const ev = new Event('input', {
bubbles: true
})
ev.simulated = true;
element.value = 'Bearer ' + localStorage.token
element.dispatchEvent(ev)
})
})
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment