From 38167214fd5d6fc9e8f8252c9b7359026274c6a1 Mon Sep 17 00:00:00 2001 From: XOF Date: Mon, 15 Dec 2025 17:40:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20proxy/rewriter.go?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- proxy/rewriter.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/proxy/rewriter.go b/proxy/rewriter.go index 138136a..5b25562 100644 --- a/proxy/rewriter.go +++ b/proxy/rewriter.go @@ -52,13 +52,14 @@ func (r *ContentRewriter) rewriteNode(n *html.Node) { } script.AppendChild(&html.Node{ Type: html.TextNode, - Data: `(function(){var o=XMLHttpRequest.prototype.open,s=XMLHttpRequest.prototype.send;XMLHttpRequest.prototype.open=function(m,u){if(typeof u==="string"&&u.startsWith("/")){u="/p/` + r.token + `"+u}return o.apply(this,arguments)};fetch=new Proxy(fetch,{apply:function(t,c,a){if(typeof a[0]==="string"&&a[0].startsWith("/")){a[0]="/p/` + r.token + `"+a[0]}return Reflect.apply(t,c,a)}})})();`, + Data: `(function(){var o=XMLHttpRequest.prototype.open;XMLHttpRequest.prototype.open=function(m,u){if(typeof u==="string"&&u.startsWith("/")){arguments[1]="/p/` + r.token + `"+u}return o.apply(this,arguments)};var f=window.fetch;window.fetch=function(u,opt){if(typeof u==="string"&&u.startsWith("/")){u="/p/` + r.token + `"+u}return f.call(this,u,opt)}})();`, }) script.NextSibling = n.FirstChild n.FirstChild.PrevSibling = script script.Parent = n n.FirstChild = script } + attrs := map[string]bool{"href": true, "src": true, "action": true, "data": true}