From e14b0baa086a687c0f3068b10bf250ab96599ef9 Mon Sep 17 00:00:00 2001 From: XOF Date: Mon, 15 Dec 2025 17:49:28 +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, 1 insertion(+), 2 deletions(-) diff --git a/proxy/rewriter.go b/proxy/rewriter.go index 5b25562..d6ef019 100644 --- a/proxy/rewriter.go +++ b/proxy/rewriter.go @@ -52,14 +52,13 @@ func (r *ContentRewriter) rewriteNode(n *html.Node) { } script.AppendChild(&html.Node{ Type: html.TextNode, - 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)}})();`, + Data: `(function(){var t="/p/` + r.token + `",b="` + r.baseURL.String() + `";Object.defineProperty(window.location,"origin",{get:function(){return b}});Object.defineProperty(window.location,"host",{get:function(){return"` + r.baseURL.Host + `"}});var o=XMLHttpRequest.prototype.open;XMLHttpRequest.prototype.open=function(m,u){if(typeof u==="string"&&u.startsWith("/")){arguments[1]=t+u}return o.apply(this,arguments)};var f=window.fetch;window.fetch=function(u,opt){if(typeof u==="string"&&u.startsWith("/")){u=t+u}return f.call(this,u,opt)};var U=window.URL;window.URL=function(u,base){if(typeof u==="string"&&u.startsWith("/")){u=t+u}return new U(u,base)}})();`, }) 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}