更新 proxy/rewriter.go
This commit is contained in:
@@ -52,7 +52,7 @@ func (r *ContentRewriter) rewriteNode(n *html.Node) {
|
||||
}
|
||||
script.AppendChild(&html.Node{
|
||||
Type: html.TextNode,
|
||||
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)}})();`,
|
||||
Data: `(function(){var t="/p/` + r.token + `";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)};Object.defineProperty(window.location,"pathname",{get:function(){var p=window.location.href.split(window.location.host)[1]||"/";return p.startsWith(t)?p.substring(t.length):p}});var oa=Element.prototype.setAttribute;Element.prototype.setAttribute=function(n,v){if((n==="href"||n==="src"||n==="action")&&typeof v==="string"&&v.startsWith("/")){v=t+v}return oa.call(this,n,v)}})();`,
|
||||
})
|
||||
script.NextSibling = n.FirstChild
|
||||
n.FirstChild.PrevSibling = script
|
||||
|
||||
Reference in New Issue
Block a user