From f889e27b3a9f500e104889eb9356293d32173524 Mon Sep 17 00:00:00 2001 From: jjaw Date: Thu, 6 Jun 2024 16:29:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8B=A6=E6=88=AA=E6=97=A0=E7=94=A8=E7=9A=84?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E8=AF=B7=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ClientScript.html | 79 +++++++++++++++++++++++++++++++++++++++++++ src/index.ts | 12 +++++++ 2 files changed, 91 insertions(+) create mode 100644 src/ClientScript.html diff --git a/src/ClientScript.html b/src/ClientScript.html new file mode 100644 index 0000000..7b0c2e8 --- /dev/null +++ b/src/ClientScript.html @@ -0,0 +1,79 @@ + \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 186835a..2af5aa2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -13,6 +13,7 @@ import { proxyLinkHttp } from "./proxyLink/proxyLinkHttp"; import { usIps } from './ips/usIps'; +import ClientScript from './ClientScript.html'; const XForwardedForIP = usIps[Math.floor(Math.random()*usIps.length)][0]; console.log(XForwardedForIP) @@ -217,6 +218,12 @@ export default { // retBody = retBody.replace(/https?:\\\/\\\/copilot\.microsoft\.com(:[0-9]{1,6})?/g, `${porxyOrigin.replaceAll("/",`\\/`)}`); // retBody = retBody.replaceAll(`"copilot.microsoft.com"`,`"${porxyHostName}"`); // retBody = retBody.replaceAll(`"copilot.microsoft.com/"`,`"${porxyHostName}/"`); + const resUrl = new URL(res.url); + + //特定页面注入脚本 + if(resUrl.pathname=="/"){ + retBody = injectionHtml(retBody); + } config.body = retBody; return config; }, @@ -262,3 +269,8 @@ async function websocketPorxy(request: Request): Promise { }) as any; } +/** 注入脚本 */ +function injectionHtml(html:string){ + return html.replace("",`${ClientScript}`) +} +