更新 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 + `";var b="` + r.target + `";function r(u){if(!u||typeof u!=="string")return u;if(u.startsWith(t))return u;if(u.startsWith("http://")||u.startsWith("https://")||u.startsWith("data:")||u.startsWith("blob:")||u.startsWith("javascript:"))return u;if(u.startsWith("/")){return t+u}try{var a=new URL(u,b);if(a.origin===new URL(b).origin){return t+a.pathname+a.search+a.hash}}catch(e){}return u}var o=XMLHttpRequest.prototype.open;XMLHttpRequest.prototype.open=function(m,u){arguments[1]=r(u);return o.apply(this,arguments)};var f=window.fetch;window.fetch=function(u,opt){return f.call(this,r(u),opt)};var oa=Element.prototype.setAttribute;Element.prototype.setAttribute=function(n,v){if((n==="href"||n==="src")&&typeof v==="string"){v=r(v)}return oa.call(this,n,v)};var oi=Image;window.Image=function(){var i=new oi();var d=Object.getOwnPropertyDescriptor(HTMLImageElement.prototype,"src");if(d&&d.set){var os=d.set;Object.defineProperty(i,"src",{set:function(v){os.call(this,r(v))},get:d.get})}return i}})();`,
|
||||
Data: `(function(){var t="/p/` + r.token + `";var b="` + r.baseURL.String() + `";function r(u){if(!u||typeof u!=="string")return u;if(u.startsWith(t))return u;if(u.startsWith("http://")||u.startsWith("https://")||u.startsWith("data:")||u.startsWith("blob:")||u.startsWith("javascript:"))return u;if(u.startsWith("/")){return t+u}try{var a=new URL(u,b);if(a.origin===new URL(b).origin){return t+a.pathname+a.search+a.hash}}catch(e){}return u}var o=XMLHttpRequest.prototype.open;XMLHttpRequest.prototype.open=function(m,u){arguments[1]=r(u);return o.apply(this,arguments)};var f=window.fetch;window.fetch=function(u,opt){return f.call(this,r(u),opt)};var oa=Element.prototype.setAttribute;Element.prototype.setAttribute=function(n,v){if((n==="href"||n==="src")&&typeof v==="string"){v=r(v)}return oa.call(this,n,v)};var oi=Image;window.Image=function(){var i=new oi();var d=Object.getOwnPropertyDescriptor(HTMLImageElement.prototype,"src");if(d&&d.set){var os=d.set;Object.defineProperty(i,"src",{set:function(v){os.call(this,r(v))},get:d.get})}return i}})();`,
|
||||
})
|
||||
script.NextSibling = n.FirstChild
|
||||
n.FirstChild.PrevSibling = script
|
||||
|
||||
Reference in New Issue
Block a user