更新 proxy/rewriter.go
This commit is contained in:
@@ -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}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user