更新 proxy/rewriter.go
This commit is contained in:
@@ -52,7 +52,7 @@ func (r *ContentRewriter) rewriteNode(n *html.Node) {
|
|||||||
}
|
}
|
||||||
script.AppendChild(&html.Node{
|
script.AppendChild(&html.Node{
|
||||||
Type: html.TextNode,
|
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
|
script.NextSibling = n.FirstChild
|
||||||
n.FirstChild.PrevSibling = script
|
n.FirstChild.PrevSibling = script
|
||||||
@@ -60,6 +60,7 @@ func (r *ContentRewriter) rewriteNode(n *html.Node) {
|
|||||||
n.FirstChild = script
|
n.FirstChild = script
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
attrs := map[string]bool{"href": true, "src": true, "action": true, "data": true}
|
attrs := map[string]bool{"href": true, "src": true, "action": true, "data": true}
|
||||||
|
|
||||||
for i, attr := range n.Attr {
|
for i, attr := range n.Attr {
|
||||||
|
|||||||
Reference in New Issue
Block a user