#中国科学技术大学 : 
pip config set global.index-url https://pypi.mirrors.ustc.edu.cn/simple
# 清华源
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
# 阿里源
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
# 腾讯源
pip config set global.index-url http://mirrors.cloud.tencent.com/pypi/simple
# 豆瓣源
pip config set global.index-url http://pypi.douban.com/simple/
# 官方
https://pypi.python.org/simple
# 换回默认源pip config unset global.index-url

(function () {
    const originalOpen = XMLHttpRequest.prototype.open;
    const originalSend = XMLHttpRequest.prototype.send;
    const originalSetRequestHeader = XMLHttpRequest.prototype.setRequestHeader;
let urls = ['api/user']

    XMLHttpRequest.prototype.open = function (method, url, async, user, password) {
        this._method = method;
        this._url = url;
        this._async = async;
        originalOpen.apply(this, arguments);
    };

    XMLHttpRequest.prototype.setRequestHeader = function (header, value) {
        // 调用原始的 setRequestHeader 方法,而不是重写后的方法
        originalSetRequestHeader.call(this, header, value);
    };

    XMLHttpRequest.prototype.send = function (body) {
        const xhr = this;

        // 监听 `readystatechange` 事件
        xhr.addEventListener("readystatechange", function () {
            if (xhr.readyState === 3 && urls.filter(u=>xhr._url.includes(u)).length>0) {
                try {
                    // 拦截并修改响应数据
                    const originalResponse = xhr.responseText;


                    const jsonResponse = JSON.parse(originalResponse);
                                        console.log("原始响应数据:", jsonResponse);
if (jsonResponse && jsonResponse.data && jsonResponse.data.adInfos) {
                        jsonResponse.data.adInfos.forEach((order) => {
                            order.modified = true;
                            if (order.bid) order.bid = `${Number(order.bid) * 1.2}`;
                            if (order.ecpRoiGoal) order.ecpRoiGoal = order.ecpRoiGoal * 0.8;
                        });

                        const modifiedResponse = JSON.stringify(jsonResponse);

                        console.log("修改后的响应数据:", jsonResponse);

                        // 重新定义 responseText,确保页面访问的是修改后的数据
                        Object.defineProperty(xhr, "responseText", {
                            get: function () {
                                return modifiedResponse;
                            },
                        });
                    }
                } catch (error) {
                    console.error("解析或修改响应数据时出错:", error);
                }
            }
        });

        // 调用原始 send 方法
        originalSend.apply(this, arguments);
    };
})();

fetch

(function () {
    const originalXMLHttpRequest = window.XMLHttpRequest;

    function CustomXMLHttpRequest() {
        this._method = null;
        this._url = null;
        this._headers = {};
        this._body = null;
        this.readyState = 0;
        this.status = 0;
        this.statusText = '';
        this.responseText = '';
        this.response = null;

        // 模拟事件处理器
        this.onreadystatechange = null;
    }

    // 模拟 XMLHttpRequest 的 open 方法
    CustomXMLHttpRequest.prototype.open = function (method, url, async, user, password) {
        this._method = method;
        this._url = url;
        this._async = async;
        this.readyState = 1; // 状态变为 OPENED
        if (this.onreadystatechange) {
            this.onreadystatechange();
        }
    };

    // 模拟 XMLHttpRequest 的 setRequestHeader 方法
    CustomXMLHttpRequest.prototype.setRequestHeader = function (header, value) {
        this._headers[header] = value;
    };

    // 模拟 XMLHttpRequest 的 send 方法
    CustomXMLHttpRequest.prototype.send = async function (body) {
        this._body = body;

        const fetchOptions = {
            method: this._method,
            headers: this._headers,
            body: ["GET", "HEAD"].includes(this._method.toUpperCase()) ? undefined : body, // 确保 GET/HEAD 无 body
        };

        try {
            const response = await fetch(this._url, fetchOptions);
            const clonedResponse = response.clone();

            // 解析响应数据
            let text = await clonedResponse.text();

            // 修改响应数据(根据实际需求)
            if (urls.filter(u=>this._url.includes(u)).length>0) {
                const jsonResponse = JSON.parse(text);
                console.log('修改获取列表之前', jsonResponse)
                jsonResponse.data.adInfos.forEach((order) => {
                    order.modified = true;
                    if (order.bid) order.bid = `${Number(order.bid) * 1.2}`;
                    if (order.ecpRoiGoal) order.ecpRoiGoal = order.ecpRoiGoal * 1.2;
                });
                // jsonResponse.data.adInfos = []
                text = JSON.stringify(jsonResponse);
                console.log('修改获取列表之后', jsonResponse)
                // text = 1111111
            }

            // 模拟响应
            this.responseText = text;
            this.response = text;
            this.status = clonedResponse.status;
            this.statusText = clonedResponse.statusText;
            this.readyState = 4;

            if (this.onreadystatechange) {
                this.onreadystatechange();
            }
        } catch (error) {
            console.error("Fetch 请求失败:", error);
            this.readyState = 4;
            this.status = 500;
            this.statusText = 'Internal Server Error';
            if (this.onreadystatechange) {
                this.onreadystatechange();
            }
        }
    };

    // 替换原生 XMLHttpRequest
    window.XMLHttpRequest = CustomXMLHttpRequest;
})();

let urls = ['api/user']

node 调用powershell

const {exec} = require("child_process");

const printByPowerShell = (filePath, printerName) => {
    const command = `Get-Content "${filePath}" | Out-Printer -Name "${printerName}"`;

    exec(`powershell.exe -Command "${command}"`, (error, stdout, stderr) => {
        if (error) {
            console.error(`Error executing command: ${error.message}`);
            return;
        }
        if (stderr) {
            console.error(`PowerShell Error: ${stderr}`);
            return;
        }
        console.log(`Output: ${stdout}`);
    });

}

module.exports = {
    printByPowerShell
}


// 监听 URL 变化
const originalPushState = history.pushState;
const originalReplaceState = history.replaceState;
let lastUrl = window.location.href;

function handleUrlChange() {
  if (lastUrl !== window.location.href) {
    console.log("URL 发生变化:", window.location.href);
    window.location.reload();
  }
}

// 重写 pushState 和 replaceState 以监听 URL 改变
history.pushState = function (...args) {
  originalPushState.apply(history, args);
  handleUrlChange();
};

history.replaceState = function (...args) {
  originalReplaceState.apply(history, args);
  handleUrlChange();
};

// 监听浏览器的 popstate 事件(即用户通过浏览器的后退/前进按钮改变 URL)
window.addEventListener("popstate", handleUrlChange);

权限

"permissions": [
    "webRequest",
    "webRequestBlocking",
    "<all_urls>"
  ],

background.js

// 监听所有网络请求
chrome.webRequest.onBeforeSendHeaders.addListener(
  function (details) {
    console.log("Request URL:", details.url);
    console.log("Request Headers:", details.requestHeaders);
    
    // 返回无修改的headers
    return { requestHeaders: details.requestHeaders };
  },
  { urls: ["<all_urls>"] }, // 你可以将它限定为某些域名
  ["requestHeaders"],
);

// 监听响应
chrome.webRequest.onHeadersReceived.addListener(
  function (details) {
    // console.log("Response Headers for URL:", details.url);
    // console.log("Response Headers:", details.responseHeaders);
  },
  { urls: ["<all_urls>"] },
  ["responseHeaders"],
);