nti56 qrcode dev hook token

二维码项目token放入localstorage便于复制

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

Advertisement:

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

Advertisement:

// ==UserScript==
// @name         nti56 qrcode dev hook token
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  二维码项目token放入localstorage便于复制
// @author       niushuai233
// @match        http://139.159.194.101/engineering/**
// @icon         http://139.159.194.101:21401/engineering/favicon.ico
// @require      https://unpkg.com/[email protected]/dist/ajaxhook.min.js
// @license      GPL-3.0-only
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    Date.prototype.format = function(fmt) {
        var o = {
            "M+" : this.getMonth()+1,                 //月份
            "d+" : this.getDate(),                    //日
            "h+" : this.getHours(),                   //小时
            "m+" : this.getMinutes(),                 //分
            "s+" : this.getSeconds(),                 //秒
            "q+" : Math.floor((this.getMonth()+3)/3), //季度
            "S"  : this.getMilliseconds()             //毫秒
        };
        if(/(y+)/.test(fmt)) {
            fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
        }
        for(var k in o) {
            if(new RegExp("("+ k +")").test(fmt)){
                fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));
            }
        }
        return fmt;
    }

    ah.proxy({
        //请求发起前进入
        onRequest: (config, handler) => {
            // console.log(config.headers);
            var token = config.headers.authorization;

            if (token && token.length > 0) {
                window.localStorage.setItem('@qr token full', token);
                window.localStorage.setItem('@qr token', token.replace("Bearer ", ""));
                window.localStorage.setItem('@qr token reset time', new Date().format("yyyy-MM-dd hh:mm:ss"));
            }
            //var url_arr = config.url.split("?")
            //console.log(url_arr, new Date().toLocaleString())
            handler.next(config);
        },
        onError: (err, handler) => {
            console.log(err.type)
            handler.next(err)
        },
        //请求成功后进入
        onResponse: (response, handler) => {
            var res = response.response;
            //console.log(response)
            handler.next(response)
        }
    });
})();