Bypass Permission Check

Bypass permission check for daily report system

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Bypass Permission Check
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Bypass permission check for daily report system
// @match        http://10.6.*/*
// @match        http://10.6.1.129/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    const originalXHROpen = XMLHttpRequest.prototype.open;
    XMLHttpRequest.prototype.open = function() {
        const url = arguments[1];

        if (url.includes('/daily_reportapi/permission?user=') ||
            url.includes('/prod-api/getProcess?card=')) {

            const self = this;
            this.addEventListener('readystatechange', function() {
                if (this.readyState === 4) {
                    Object.defineProperty(this, 'response', {writable: true});
                    Object.defineProperty(this, 'responseText', {writable: true});
                    Object.defineProperty(this, 'status', {writable: true});

                    if (url.includes('/daily_reportapi/permission?user=')) {
                        // 模拟第一个API的成功响应
                        this.response = this.responseText = '1';
                    } else if (url.includes('/prod-api/getProcess?card=')) {
                        // 模拟第二个API的成功响应
                        const fakeResponse = {
                            "msg": "操作成功",
                            "code": 200,
                            "data": {
                                "processName": "全部权限"
                            }
                        };
                        this.response = this.responseText = JSON.stringify(fakeResponse);
                    }

                    this.status = 200;
                }
            });
        }
        originalXHROpen.apply(this, arguments);
    };

    console.log('Multiple permission bypass script loaded');
})();