@titaniumnetwork-dev/ultraviolet
Advanced tools
Comparing version 1.0.4-beta.3 to 1.0.4-beta.4
@@ -1,4 +0,5 @@ | ||
importScripts('/uv.bundle.js'); | ||
importScripts('/uv.config.js'); | ||
importScripts('/uv.sw.js'); | ||
/*global UVServiceWorker*/ | ||
importScripts('uv.bundle.js'); | ||
importScripts('uv.config.js'); | ||
importScripts('uv.sw.js'); | ||
@@ -5,0 +6,0 @@ const sw = new UVServiceWorker(); |
@@ -0,1 +1,2 @@ | ||
/*global Ultraviolet*/ | ||
self.__uv$config = { | ||
@@ -7,2 +8,3 @@ prefix: '/service/', | ||
handler: '/uv.handler.js', | ||
client: '/uv.client.js', | ||
bundle: '/uv.bundle.js', | ||
@@ -9,0 +11,0 @@ config: '/uv.config.js', |
@@ -1,2 +0,2 @@ | ||
(()=>{"use strict";const e=globalThis.Ultraviolet;function t(a,r={},o="/bare/"){if("__uv"in a&&a.__uv instanceof e)return!1;a.document&&a.window&&a.document.querySelectorAll("script[__uv-script]").forEach((e=>e.remove()));const n=!a.window,i="__uv",s="__uv$",l=new e({...r,window:a});"function"==typeof r.construct&&r.construct(l,n?"worker":"window");const{client:c}=l,{HTMLMediaElement:d,HTMLScriptElement:u,HTMLAudioElement:h,HTMLVideoElement:m,HTMLInputElement:v,HTMLEmbedElement:p,HTMLTrackElement:g,HTMLAnchorElement:b,HTMLIFrameElement:f,HTMLAreaElement:y,HTMLLinkElement:_,HTMLBaseElement:w,HTMLFormElement:S,HTMLImageElement:k,HTMLSourceElement:P}=a;c.nativeMethods.defineProperty(a,"__uv",{value:l,enumerable:!1}),l.meta.origin=location.origin,l.location=c.location.emulate((e=>"about:srcdoc"===e?new URL(e):(e.startsWith("blob:")&&(e=e.slice("blob:".length)),new URL(l.sourceUrl(e)))),(e=>l.rewriteUrl(e))),l.bareData=a.__uv$bareData,l.cookieStr=a.__uv$cookies||"",l.meta.url=l.location,l.domain=l.meta.url.host,l.blobUrls=new a.Map,l.referrer="",l.cookies=[],l.localStorageObj={},l.sessionStorageObj={};try{l.bare=new URL(o,a.location.href)}catch(e){l.bare=a.parent.__uv.bare}const U=new e.BareClient(l.bare,l.bareData);if("about:srcdoc"===l.location.href&&(l.meta=a.parent.__uv.meta),a.EventTarget&&(l.addEventListener=a.EventTarget.prototype.addEventListener,l.removeListener=a.EventTarget.prototype.removeListener,l.dispatchEvent=a.EventTarget.prototype.dispatchEvent),c.nativeMethods.defineProperty(c.storage.storeProto,"__uv$storageObj",{get(){return this===c.storage.sessionStorage?l.sessionStorageObj:this===c.storage.localStorage?l.localStorageObj:void 0},enumerable:!1}),a.localStorage){for(const e in a.localStorage)e.startsWith(s+l.location.origin+"@")&&(l.localStorageObj[e.slice((s+l.location.origin+"@").length)]=a.localStorage.getItem(e));l.lsWrap=c.storage.emulate(c.storage.localStorage,l.localStorageObj)}if(a.sessionStorage){for(const e in a.sessionStorage)e.startsWith(s+l.location.origin+"@")&&(l.sessionStorageObj[e.slice((s+l.location.origin+"@").length)]=a.sessionStorage.getItem(e));l.ssWrap=c.storage.emulate(c.storage.sessionStorage,l.sessionStorageObj)}let M=a.document?c.node.baseURI.get.call(a.document):a.location.href,x=l.sourceUrl(M);c.nativeMethods.defineProperty(l.meta,"base",{get:()=>a.document?(c.node.baseURI.get.call(a.document)!==M&&(M=c.node.baseURI.get.call(a.document),x=l.sourceUrl(M)),x):l.meta.url.href}),l.methods={setSource:"__uv$setSource",source:"__uv$source",location:"__uv$location",function:"__uv$function",string:"__uv$string",eval:"__uv$eval",parent:"__uv$parent",top:"__uv$top"},l.filterKeys=[i,l.methods.setSource,l.methods.source,l.methods.location,l.methods.function,l.methods.string,l.methods.eval,l.methods.parent,l.methods.top,"__uv$protocol","__uv$storageObj","__uv$url","__uv$modifiedStyle","__uv$config","__uv$dispatched","Ultraviolet","__uvHook"],c.on("wrap",((e,t)=>{c.nativeMethods.defineProperty(t,"name",c.nativeMethods.getOwnPropertyDescriptor(e,"name")),c.nativeMethods.defineProperty(t,"length",c.nativeMethods.getOwnPropertyDescriptor(e,"length")),c.nativeMethods.defineProperty(t,l.methods.string,{enumerable:!1,value:c.nativeMethods.fnToString.call(e)}),c.nativeMethods.defineProperty(t,l.methods.function,{enumerable:!1,value:e})})),c.fetch.on("request",(e=>{e.data.input=l.rewriteUrl(e.data.input)})),c.fetch.on("requestUrl",(e=>{e.data.value=l.sourceUrl(e.data.value)})),c.fetch.on("responseUrl",(e=>{e.data.value=l.sourceUrl(e.data.value)})),c.xhr.on("open",(e=>{e.data.input=l.rewriteUrl(e.data.input)})),c.xhr.on("responseUrl",(e=>{e.data.value=l.sourceUrl(e.data.value)})),c.workers.on("worker",(e=>{e.data.url=l.rewriteUrl(e.data.url)})),c.workers.on("addModule",(e=>{e.data.url=l.rewriteUrl(e.data.url)})),c.workers.on("importScripts",(e=>{for(const t in e.data.scripts)e.data.scripts[t]=l.rewriteUrl(e.data.scripts[t])})),c.workers.on("postMessage",(e=>{let t=e.data.origin;e.data.origin="*",e.data.message={__data:e.data.message,__origin:l.meta.url.origin,__to:t}})),c.navigator.on("sendBeacon",(e=>{e.data.url=l.rewriteUrl(e.data.url)})),c.document.on("getCookie",(e=>{e.data.value=l.cookieStr})),c.document.on("setCookie",(e=>{Promise.resolve(l.cookie.setCookies(e.data.value,l.db,l.meta)).then((()=>{l.cookie.db().then((e=>{l.cookie.getCookies(e).then((e=>{l.cookieStr=l.cookie.serialize(e,l.meta,!0)}))}))}));const t=l.cookie.setCookie(e.data.value)[0];t.path||(t.path="/"),t.domain||(t.domain=l.meta.url.hostname),l.cookie.validateCookie(t,l.meta,!0)&&(l.cookieStr.length&&(l.cookieStr+="; "),l.cookieStr+=`${t.name}=${t.value}`),e.respondWith(e.data.value)})),c.element.on("setInnerHTML",(e=>{switch(e.that.tagName){case"SCRIPT":e.data.value=l.js.rewrite(e.data.value);break;case"STYLE":e.data.value=l.rewriteCSS(e.data.value);break;default:e.data.value=l.rewriteHtml(e.data.value)}})),c.element.on("getInnerHTML",(e=>{if("SCRIPT"===e.that.tagName)e.data.value=l.js.source(e.data.value);else e.data.value=l.sourceHtml(e.data.value)})),c.element.on("setOuterHTML",(e=>{e.data.value=l.rewriteHtml(e.data.value,{document:"HTML"===e.that.tagName})})),c.element.on("getOuterHTML",(e=>{switch(e.that.tagName){case"HEAD":e.data.value=l.sourceHtml(e.data.value.replace(/<head(.*)>(.*)<\/head>/s,"<op-head$1>$2</op-head>")).replace(/<op-head(.*)>(.*)<\/op-head>/s,"<head$1>$2</head>");break;case"BODY":e.data.value=l.sourceHtml(e.data.value.replace(/<body(.*)>(.*)<\/body>/s,"<op-body$1>$2</op-body>")).replace(/<op-body(.*)>(.*)<\/op-body>/s,"<body$1>$2</body>");break;default:e.data.value=l.sourceHtml(e.data.value,{document:"HTML"===e.that.tagName})}})),c.document.on("write",(e=>{if(!e.data.html.length)return!1;e.data.html=[l.rewriteHtml(e.data.html.join(""))]})),c.document.on("writeln",(e=>{if(!e.data.html.length)return!1;e.data.html=[l.rewriteHtml(e.data.html.join(""))]})),c.element.on("insertAdjacentHTML",(e=>{e.data.html=l.rewriteHtml(e.data.html)})),c.eventSource.on("construct",(e=>{e.data.url=l.rewriteUrl(e.data.url)})),c.eventSource.on("url",(e=>{e.data.url=l.rewriteUrl(e.data.url)})),c.history.on("replaceState",(e=>{e.data.url&&(e.data.url=l.rewriteUrl(e.data.url,"__uv"in e.that?e.that.__uv.meta:l.meta))})),c.history.on("pushState",(e=>{e.data.url&&(e.data.url=l.rewriteUrl(e.data.url,"__uv"in e.that?e.that.__uv.meta:l.meta))})),c.element.on("getAttribute",(e=>{c.element.hasAttribute.call(e.that,l.attributePrefix+"-attr-"+e.data.name)&&e.respondWith(e.target.call(e.that,l.attributePrefix+"-attr-"+e.data.name))})),c.message.on("postMessage",(e=>{let t=e.data.origin,a=l.call;e.that&&(a=e.that.__uv$source.call),e.data.origin="*",e.data.message={__data:e.data.message,__origin:(e.that||e.target).__uv$source.location.origin,__to:t},e.respondWith(a(e.target,n?[e.data.message,e.data.transfer]:[e.data.message,e.data.origin,e.data.transfer],e.that))})),c.message.on("data",(e=>{const{value:t}=e.data;"object"==typeof t&&"__data"in t&&"__origin"in t&&e.respondWith(t.__data)})),c.message.on("origin",(e=>{const t=c.message.messageData.get.call(e.that);"object"==typeof t&&t.__data&&t.__origin&&e.respondWith(t.__origin)})),c.overrideDescriptor(a,"origin",{get:(e,t)=>l.location.origin}),c.node.on("baseURI",(e=>{e.data.value.startsWith(a.location.origin)&&(e.data.value=l.sourceUrl(e.data.value))})),c.element.on("setAttribute",(e=>{if(e.that instanceof d&&"src"===e.data.name&&e.data.value.startsWith("blob:"))return e.target.call(e.that,l.attributePrefix+"-attr-"+e.data.name,e.data.value),void(e.data.value=l.blobUrls.get(e.data.value));l.attrs.isUrl(e.data.name)&&(e.target.call(e.that,l.attributePrefix+"-attr-"+e.data.name,e.data.value),e.data.value=l.rewriteUrl(e.data.value)),l.attrs.isStyle(e.data.name)&&(e.target.call(e.that,l.attributePrefix+"-attr-"+e.data.name,e.data.value),e.data.value=l.rewriteCSS(e.data.value,{context:"declarationList"})),l.attrs.isHtml(e.data.name)&&(e.target.call(e.that,l.attributePrefix+"-attr-"+e.data.name,e.data.value),e.data.value=l.rewriteHtml(e.data.value,{...l.meta,document:!0,injectHead:l.createHtmlInject(l.handlerScript,l.bundleScript,l.configScript,l.bareData,l.cookieStr,a.location.href)})),l.attrs.isSrcset(e.data.name)&&(e.target.call(e.that,l.attributePrefix+"-attr-"+e.data.name,e.data.value),e.data.value=l.html.wrapSrcset(e.data.value)),l.attrs.isForbidden(e.data.name)&&(e.data.name=l.attributePrefix+"-attr-"+e.data.name)})),c.element.on("audio",(e=>{e.data.url=l.rewriteUrl(e.data.url)})),c.element.hookProperty([b,y,_,w],"href",{get:(e,t)=>l.sourceUrl(e.call(t)),set:(e,t,[a])=>{c.element.setAttribute.call(t,l.attributePrefix+"-attr-href",a),e.call(t,l.rewriteUrl(a))}}),c.element.hookProperty([u,h,m,d,k,v,p,f,g,P],"src",{get:(e,t)=>l.sourceUrl(e.call(t)),set:(e,t,[a])=>{if(new String(a).toString().trim().startsWith("blob:")&&t instanceof d)return c.element.setAttribute.call(t,l.attributePrefix+"-attr-src",a),e.call(t,l.blobUrls.get(a)||a);c.element.setAttribute.call(t,l.attributePrefix+"-attr-src",a),e.call(t,l.rewriteUrl(a))}}),c.element.hookProperty([S],"action",{get:(e,t)=>l.sourceUrl(e.call(t)),set:(e,t,[a])=>{c.element.setAttribute.call(t,l.attributePrefix+"-attr-action",a),e.call(t,l.rewriteUrl(a))}}),c.element.hookProperty([k],"srcset",{get:(e,t)=>c.element.getAttribute.call(t,l.attributePrefix+"-attr-srcset")||e.call(t),set:(e,t,[a])=>{c.element.setAttribute.call(t,l.attributePrefix+"-attr-srcset",a),e.call(t,l.html.wrapSrcset(a))}}),c.element.hookProperty(u,"integrity",{get:(e,t)=>c.element.getAttribute.call(t,l.attributePrefix+"-attr-integrity"),set:(e,t,[a])=>{c.element.setAttribute.call(t,l.attributePrefix+"-attr-integrity",a)}}),c.element.hookProperty(f,"sandbox",{get:(e,t)=>c.element.getAttribute.call(t,l.attributePrefix+"-attr-sandbox")||e.call(t),set:(e,t,[a])=>{c.element.setAttribute.call(t,l.attributePrefix+"-attr-sandbox",a)}});const E=Object.getOwnPropertyDescriptor(f.prototype,"contentWindow").get;function $(e){const a=E.call(e);try{a.__uv$bareData=l.bareData,a.__uv$cookies=l.cookieStr,a.__uv||t(a,r,o)}catch(e){console.error("catastrophic failure"),console.error(e)}}function j(e,t){const a=`on${t}`,r=new WeakMap;Reflect.defineProperty(e,a,{enumerable:!0,configurable:!0,get(){return r.has(this)?r.get(this):null},set(e){return"function"==typeof e&&(r.has(this)&&this.removeEventListener(t,r.get(this)),r.set(this,e),this.addEventListener(t,e)),e}})}c.element.hookProperty(f,"contentWindow",{get:(e,t)=>($(t),e.call(t))}),c.element.hookProperty(f,"contentDocument",{get:(e,t)=>($(t),e.call(t))}),c.element.hookProperty(f,"srcdoc",{get:(e,t)=>c.element.getAttribute.call(t,l.attributePrefix+"-attr-srcdoc")||e.call(t),set:(e,t,[r])=>{e.call(t,l.rewriteHtml(r,{document:!0,injectHead:l.createHtmlInject(l.handlerScript,l.bundleScript,l.configScript,l.bareData,l.cookieStr,a.location.href)}))}}),c.node.on("getTextContent",(e=>{"SCRIPT"===e.that.tagName&&(e.data.value=l.js.source(e.data.value))})),c.node.on("setTextContent",(e=>{"SCRIPT"===e.that.tagName&&(e.data.value=l.js.rewrite(e.data.value))})),"serviceWorker"in a.navigator&&delete a.Navigator.prototype.serviceWorker,c.document.on("getDomain",(e=>{e.data.value=l.domain})),c.document.on("setDomain",(e=>{if(!e.data.value.toString().endsWith(l.meta.url.hostname.split(".").slice(-2).join(".")))return e.respondWith("");e.respondWith(l.domain=e.data.value)})),c.document.on("url",(e=>{e.data.value=l.location.href})),c.document.on("documentURI",(e=>{e.data.value=l.location.href})),c.document.on("referrer",(e=>{e.data.value=l.referrer||l.sourceUrl(e.data.value)})),c.document.on("parseFromString",(e=>{if("text/html"!==e.data.type)return!1;e.data.string=l.rewriteHtml(e.data.string,{...l.meta,document:!0})})),c.attribute.on("getValue",(e=>{c.element.hasAttribute.call(e.that.ownerElement,l.attributePrefix+"-attr-"+e.data.name)&&(e.data.value=c.element.getAttribute.call(e.that.ownerElement,l.attributePrefix+"-attr-"+e.data.name))})),c.attribute.on("setValue",(e=>{l.attrs.isUrl(e.data.name)&&(c.element.setAttribute.call(e.that.ownerElement,l.attributePrefix+"-attr-"+e.data.name,e.data.value),e.data.value=l.rewriteUrl(e.data.value)),l.attrs.isStyle(e.data.name)&&(c.element.setAttribute.call(e.that.ownerElement,l.attributePrefix+"-attr-"+e.data.name,e.data.value),e.data.value=l.rewriteCSS(e.data.value,{context:"declarationList"})),l.attrs.isHtml(e.data.name)&&(c.element.setAttribute.call(e.that.ownerElement,l.attributePrefix+"-attr-"+e.data.name,e.data.value),e.data.value=l.rewriteHtml(e.data.value,{...l.meta,document:!0,injectHead:l.createHtmlInject(l.handlerScript,l.bundleScript,l.configScript,l.bareData,l.cookieStr,a.location.href)})),l.attrs.isSrcset(e.data.name)&&(c.element.setAttribute.call(e.that.ownerElement,l.attributePrefix+"-attr-"+e.data.name,e.data.value),e.data.value=l.html.wrapSrcset(e.data.value))})),c.url.on("createObjectURL",(e=>{let t=e.target.call(e.that,e.data.object);if(t.startsWith("blob:"+location.origin)){let r="blob:"+("about:blank"!==l.meta.url.href?l.meta.url.origin:a.parent.__uv.meta.url.origin)+t.slice("blob:".length+location.origin.length);l.blobUrls.set(r,t),e.respondWith(r)}else e.respondWith(t)})),c.url.on("revokeObjectURL",(e=>{if(l.blobUrls.has(e.data.url)){const t=e.data.url;e.data.url=l.blobUrls.get(e.data.url),l.blobUrls.delete(t)}})),c.storage.on("get",(e=>{e.data.name=s+l.meta.url.origin+"@"+e.data.name})),c.storage.on("set",(e=>{e.that.__uv$storageObj&&(e.that.__uv$storageObj[e.data.name]=e.data.value),e.data.name=s+l.meta.url.origin+"@"+e.data.name})),c.storage.on("delete",(e=>{e.that.__uv$storageObj&&delete e.that.__uv$storageObj[e.data.name],e.data.name=s+l.meta.url.origin+"@"+e.data.name})),c.storage.on("getItem",(e=>{e.data.name=s+l.meta.url.origin+"@"+e.data.name})),c.storage.on("setItem",(e=>{e.that.__uv$storageObj&&(e.that.__uv$storageObj[e.data.name]=e.data.value),e.data.name=s+l.meta.url.origin+"@"+e.data.name})),c.storage.on("removeItem",(e=>{e.that.__uv$storageObj&&delete e.that.__uv$storageObj[e.data.name],e.data.name=s+l.meta.url.origin+"@"+e.data.name})),c.storage.on("clear",(e=>{if(e.that.__uv$storageObj)for(const t of c.nativeMethods.keys.call(null,e.that.__uv$storageObj))delete e.that.__uv$storageObj[t],c.storage.removeItem.call(e.that,s+l.meta.url.origin+"@"+t),e.respondWith()})),c.storage.on("length",(e=>{e.that.__uv$storageObj&&e.respondWith(c.nativeMethods.keys.call(null,e.that.__uv$storageObj).length)})),c.storage.on("key",(e=>{e.that.__uv$storageObj&&e.respondWith(c.nativeMethods.keys.call(null,e.that.__uv$storageObj)[e.data.index]||null)}));const O=["ws:","wss:"];class T extends EventTarget{#e;#t;#a="blob";#r="";#o="";#n="";async#i(e,t){const a={};Reflect.setPrototypeOf(a,null),a.Origin=l.meta.url.origin,a["User-Agent"]=navigator.userAgent,""!==l.cookieStr&&(a.Cookie=l.cookieStr.toString()),this.#e=await U.createWebSocket(e,a,t),this.#e.binaryType=this.#a,this.#e.addEventListener("message",(e=>{this.dispatchEvent(new MessageEvent("message",e))})),this.#e.addEventListener("open",(async e=>{this.dispatchEvent(new Event("open",e))})),this.#e.addEventListener("error",(e=>{this.dispatchEvent(new ErrorEvent("error",e))})),this.#e.addEventListener("close",(e=>{this.dispatchEvent(new Event("close",e))}));const r=await this.#e.meta;r.headers.has("sec-websocket-protocol")&&(this.#r=r.headers.get("sec-websocket-protocol")),r.headers.has("sec-websocket-extensions")&&(this.#o=r.headers.get("sec-websocket-extensions"));let o=r.rawHeaders["set-cookie"]||[];Array.isArray(o)||(o=[]);for(const e of o)document.cookie=e}get url(){return this.#n}constructor(...e){if(super(),!e.length)throw new DOMException("Failed to construct 'WebSocket': 1 argument required, but only 0 present.");const[t,a]=e;let r;try{r=new URL(t)}catch(e){throw new DOMException(`Faiiled to construct 'WebSocket': The URL '${t}' is invalid.`)}if(!O.includes(r.protocol))throw new DOMException(`Failed to construct 'WebSocket': The URL's scheme must be either 'ws' or 'wss'. '${r.protocol}' is not allowed.`);this.#t=this.#i(r,a)}get protocol(){return this.#r}get extensions(){return this.#o}get readyState(){return this.#e?this.#e.readyState:T.CONNECTING}get binaryType(){return this.#a}set binaryType(e){return this.#a=e,this.#e&&(this.#e.binaryType=e),e}send(e){if(!this.#e)throw new DOMException("Failed to execute 'send' on 'WebSocket': Still in CONNECTING state.");this.#e.send(e)}close(e,t){if(void 0!==e&&("number"!=typeof e&&(e=0),1e3!==e&&(e<3e3||e>4999)))throw new DOMException(`Failed to execute 'close' on 'WebSocket': The code must be either 1000, or between 3000 and 4999. ${e} is neither.`);this.#t.then((()=>this.#e.close(e,t)))}}j(T.prototype,"close"),j(T.prototype,"open"),j(T.prototype,"message"),j(T.prototype,"error");for(const e of["url","protocol","extensions","readyState","binaryType"]){const t=Object.getOwnPropertyDescriptor(a.WebSocket.prototype,e),r=Object.getOwnPropertyDescriptor(T.prototype,e);r?.get&&t?.get&&c.emit("wrap",r.get,t.get),r?.set&&t?.set&&c.emit("wrap",r.get,t.get)}if(c.emit("wrap",a.WebSocket.prototype.send,T.prototype.send),c.emit("wrap",a.WebSocket.prototype.close,T.prototype.close),c.override(a,"WebSocket",((e,t,a)=>new T(...a)),!0),T.prototype.constructor=a.WebSocket,c.function.on("function",(e=>{e.data.script=l.rewriteJS(e.data.script)})),c.function.on("toString",(e=>{l.methods.string in e.that&&e.respondWith(e.that[l.methods.string])})),c.object.on("getOwnPropertyNames",(e=>{e.data.names=e.data.names.filter((e=>!l.filterKeys.includes(e)))})),c.object.on("getOwnPropertyDescriptors",(e=>{for(const t of l.filterKeys)delete e.data.descriptors[t]})),c.style.on("setProperty",(e=>{c.style.dashedUrlProps.includes(e.data.property)&&(e.data.value=l.rewriteCSS(e.data.value,{context:"value",...l.meta}))})),c.style.on("getPropertyValue",(e=>{c.style.dashedUrlProps.includes(e.data.property)&&e.respondWith(l.sourceCSS(e.target.call(e.that,e.data.property),{context:"value",...l.meta}))})),"CSS2Properties"in a)for(const e of c.style.urlProps)c.overrideDescriptor(a.CSS2Properties.prototype,e,{get:(e,t)=>l.sourceCSS(e.call(t),{context:"value",...l.meta}),set:(e,t,a)=>{e.call(t,l.rewriteCSS(a,{context:"value",...l.meta}))}});else"HTMLElement"in a&&c.overrideDescriptor(a.HTMLElement.prototype,"style",{get:(e,t)=>{const a=e.call(t);if(!a.__uv$modifiedStyle)for(const e of c.style.urlProps)c.nativeMethods.defineProperty(a,e,{enumerable:!0,configurable:!0,get(){const t=c.style.getPropertyValue.call(this,e)||"";return l.sourceCSS(t,{context:"value",...l.meta})},set(t){c.style.setProperty.call(this,c.style.propToDashed[e]||e,l.rewriteCSS(t,{context:"value",...l.meta}))}}),c.nativeMethods.defineProperty(a,"__uv$modifiedStyle",{enumerable:!1,value:!0});return a}});c.style.on("setCssText",(e=>{e.data.value=l.rewriteCSS(e.data.value,{context:"declarationList",...l.meta})})),c.style.on("getCssText",(e=>{e.data.value=l.sourceCSS(e.data.value,{context:"declarationList",...l.meta})})),a.window&&l.addEventListener.call(a,"hashchange",(e=>{if(e.__uv$dispatched)return!1;e.stopImmediatePropagation();const t=a.location.hash;c.history.replaceState.call(a.history,"","",e.oldURL),l.location.hash=t})),c.location.on("hashchange",((e,t,r)=>{if(r.HashChangeEvent&&c.history.replaceState){c.history.replaceState.call(a.history,"","",l.rewriteUrl(t));const o=new r.HashChangeEvent("hashchange",{newURL:t,oldURL:e});c.nativeMethods.defineProperty(o,"__uv$dispatched",{value:!0,enumerable:!1}),l.dispatchEvent.call(a,o)}})),c.fetch.overrideRequest(),c.fetch.overrideUrl(),c.xhr.overrideOpen(),c.xhr.overrideResponseUrl(),c.element.overrideHtml(),c.element.overrideAttribute(),c.element.overrideInsertAdjacentHTML(),c.element.overrideAudio(),c.node.overrideBaseURI(),c.node.overrideTextContent(),c.attribute.overrideNameValue(),c.document.overrideDomain(),c.document.overrideURL(),c.document.overrideDocumentURI(),c.document.overrideWrite(),c.document.overrideReferrer(),c.document.overrideParseFromString(),c.storage.overrideMethods(),c.storage.overrideLength(),c.object.overrideGetPropertyNames(),c.object.overrideGetOwnPropertyDescriptors(),c.history.overridePushState(),c.history.overrideReplaceState(),c.eventSource.overrideConstruct(),c.eventSource.overrideUrl(),c.url.overrideObjectURL(),c.document.overrideCookie(),c.message.overridePostMessage(),c.message.overrideMessageOrigin(),c.message.overrideMessageData(),c.workers.overrideWorker(),c.workers.overrideAddModule(),c.workers.overrideImportScripts(),c.workers.overridePostMessage(),c.style.overrideSetGetProperty(),c.style.overrideCssText(),c.navigator.overrideSendBeacon(),c.function.overrideFunction(),c.function.overrideToString(),c.location.overrideWorkerLocation((e=>new URL(l.sourceUrl(e)))),c.overrideDescriptor(a,"localStorage",{get:(e,t)=>(t||a).__uv.lsWrap}),c.overrideDescriptor(a,"sessionStorage",{get:(e,t)=>(t||a).__uv.ssWrap}),c.override(a,"open",((e,t,a)=>{if(!a.length)return e.apply(t,a);let[r]=a;return r=l.rewriteUrl(r),e.call(t,r)})),l.$wrap=function(e){return"location"===e?l.methods.location:"eval"===e?l.methods.eval:e},l.$get=function(e){return e===a.location?l.location:e===a.eval?l.eval:e===a.parent?a.__uv$parent:e===a.top?a.__uv$top:e},l.eval=c.wrap(a,"eval",((e,t,a)=>{if(!a.length||"string"!=typeof a[0])return e.apply(t,a);let[r]=a;return r=l.rewriteJS(r),e.call(t,r)})),l.call=function(e,t,a){return a?e.apply(a,t):e(...t)},l.call$=function(e,t,a=[]){return e[t].apply(e,a)},c.nativeMethods.defineProperty(a.Object.prototype,i,{get:()=>l,enumerable:!1}),c.nativeMethods.defineProperty(a.Object.prototype,l.methods.setSource,{value:function(e){return c.nativeMethods.isExtensible(this)?(c.nativeMethods.defineProperty(this,l.methods.source,{value:e,writable:!0,enumerable:!1}),this):this},enumerable:!1}),c.nativeMethods.defineProperty(a.Object.prototype,l.methods.source,{value:l,writable:!0,enumerable:!1}),c.nativeMethods.defineProperty(a.Object.prototype,l.methods.location,{configurable:!0,get(){return this===a.document||this===a?l.location:this.location},set(e){this===a.document||this===a?l.location.href=e:this.location=e}}),c.nativeMethods.defineProperty(a.Object.prototype,l.methods.parent,{configurable:!0,get(){const e=this.parent;if(this===a)try{return"__uv"in e?e:this}catch(e){return this}return e},set(e){this.parent=e}}),c.nativeMethods.defineProperty(a.Object.prototype,l.methods.top,{configurable:!0,get(){const e=this.top;if(this===a){if(e===this.parent)return this[l.methods.parent];try{if("__uv"in e)return e;{let t=this;for(;t.parent!==e;)t=t.parent;return"__uv"in t?t:this}}catch(e){return this}}return e},set(e){this.top=e}}),c.nativeMethods.defineProperty(a.Object.prototype,l.methods.eval,{configurable:!0,get(){return this===a?l.eval:this.eval},set(e){this.eval=e}})}self.__uv||t(self,self.__uv$config,self.__uv$config.bare),self.__uvHook=t})(); | ||
(()=>{"use strict";const e=globalThis.Ultraviolet,t=globalThis.UVClient;function a(r,o={},n="/bare/"){if("__uv"in r&&r.__uv instanceof e)return!1;r.document&&r.window&&r.document.querySelectorAll("script[__uv-script]").forEach((e=>e.remove()));const i=!r.window,s="__uv",l="__uv$",c=new e(o);"function"==typeof o.construct&&o.construct(c,i?"worker":"window");const d=new t(r),{HTMLMediaElement:u,HTMLScriptElement:h,HTMLAudioElement:m,HTMLVideoElement:v,HTMLInputElement:p,HTMLEmbedElement:g,HTMLTrackElement:b,HTMLAnchorElement:f,HTMLIFrameElement:y,HTMLAreaElement:_,HTMLLinkElement:S,HTMLBaseElement:w,HTMLFormElement:k,HTMLImageElement:P,HTMLSourceElement:U}=r;d.nativeMethods.defineProperty(r,"__uv",{value:c,enumerable:!1}),c.meta.origin=location.origin,c.location=d.location.emulate((e=>"about:srcdoc"===e?new URL(e):(e.startsWith("blob:")&&(e=e.slice("blob:".length)),new URL(c.sourceUrl(e)))),(e=>c.rewriteUrl(e))),c.bareData=r.__uv$bareData,c.cookieStr=r.__uv$cookies||"",c.meta.url=c.location,c.domain=c.meta.url.host,c.blobUrls=new r.Map,c.referrer="",c.cookies=[],c.localStorageObj={},c.sessionStorageObj={};try{c.bare=new URL(n,r.location.href)}catch(e){c.bare=r.parent.__uv.bare}const M=new e.BareClient(c.bare,c.bareData);if("about:srcdoc"===c.location.href&&(c.meta=r.parent.__uv.meta),r.EventTarget&&(c.addEventListener=r.EventTarget.prototype.addEventListener,c.removeListener=r.EventTarget.prototype.removeListener,c.dispatchEvent=r.EventTarget.prototype.dispatchEvent),d.nativeMethods.defineProperty(d.storage.storeProto,"__uv$storageObj",{get(){return this===d.storage.sessionStorage?c.sessionStorageObj:this===d.storage.localStorage?c.localStorageObj:void 0},enumerable:!1}),r.localStorage){for(const e in r.localStorage)e.startsWith(l+c.location.origin+"@")&&(c.localStorageObj[e.slice((l+c.location.origin+"@").length)]=r.localStorage.getItem(e));c.lsWrap=d.storage.emulate(d.storage.localStorage,c.localStorageObj)}if(r.sessionStorage){for(const e in r.sessionStorage)e.startsWith(l+c.location.origin+"@")&&(c.sessionStorageObj[e.slice((l+c.location.origin+"@").length)]=r.sessionStorage.getItem(e));c.ssWrap=d.storage.emulate(d.storage.sessionStorage,c.sessionStorageObj)}let x=r.document?d.node.baseURI.get.call(r.document):r.location.href,E=c.sourceUrl(x);d.nativeMethods.defineProperty(c.meta,"base",{get:()=>r.document?(d.node.baseURI.get.call(r.document)!==x&&(x=d.node.baseURI.get.call(r.document),E=c.sourceUrl(x)),E):c.meta.url.href}),c.methods={setSource:"__uv$setSource",source:"__uv$source",location:"__uv$location",function:"__uv$function",string:"__uv$string",eval:"__uv$eval",parent:"__uv$parent",top:"__uv$top"},c.filterKeys=[s,c.methods.setSource,c.methods.source,c.methods.location,c.methods.function,c.methods.string,c.methods.eval,c.methods.parent,c.methods.top,"__uv$protocol","__uv$storageObj","__uv$url","__uv$modifiedStyle","__uv$config","__uv$dispatched","Ultraviolet","__uvHook"],d.on("wrap",((e,t)=>{d.nativeMethods.defineProperty(t,"name",d.nativeMethods.getOwnPropertyDescriptor(e,"name")),d.nativeMethods.defineProperty(t,"length",d.nativeMethods.getOwnPropertyDescriptor(e,"length")),d.nativeMethods.defineProperty(t,c.methods.string,{enumerable:!1,value:d.nativeMethods.fnToString.call(e)}),d.nativeMethods.defineProperty(t,c.methods.function,{enumerable:!1,value:e})})),d.fetch.on("request",(e=>{e.data.input=c.rewriteUrl(e.data.input)})),d.fetch.on("requestUrl",(e=>{e.data.value=c.sourceUrl(e.data.value)})),d.fetch.on("responseUrl",(e=>{e.data.value=c.sourceUrl(e.data.value)})),d.xhr.on("open",(e=>{e.data.input=c.rewriteUrl(e.data.input)})),d.xhr.on("responseUrl",(e=>{e.data.value=c.sourceUrl(e.data.value)})),d.workers.on("worker",(e=>{e.data.url=c.rewriteUrl(e.data.url)})),d.workers.on("addModule",(e=>{e.data.url=c.rewriteUrl(e.data.url)})),d.workers.on("importScripts",(e=>{for(const t in e.data.scripts)e.data.scripts[t]=c.rewriteUrl(e.data.scripts[t])})),d.workers.on("postMessage",(e=>{let t=e.data.origin;e.data.origin="*",e.data.message={__data:e.data.message,__origin:c.meta.url.origin,__to:t}})),d.navigator.on("sendBeacon",(e=>{e.data.url=c.rewriteUrl(e.data.url)})),d.document.on("getCookie",(e=>{e.data.value=c.cookieStr})),d.document.on("setCookie",(e=>{Promise.resolve(c.cookie.setCookies(e.data.value,c.db,c.meta)).then((()=>{c.cookie.db().then((e=>{c.cookie.getCookies(e).then((e=>{c.cookieStr=c.cookie.serialize(e,c.meta,!0)}))}))}));const t=c.cookie.setCookie(e.data.value)[0];t.path||(t.path="/"),t.domain||(t.domain=c.meta.url.hostname),c.cookie.validateCookie(t,c.meta,!0)&&(c.cookieStr.length&&(c.cookieStr+="; "),c.cookieStr+=`${t.name}=${t.value}`),e.respondWith(e.data.value)})),d.element.on("setInnerHTML",(e=>{switch(e.that.tagName){case"SCRIPT":e.data.value=c.js.rewrite(e.data.value);break;case"STYLE":e.data.value=c.rewriteCSS(e.data.value);break;default:e.data.value=c.rewriteHtml(e.data.value)}})),d.element.on("getInnerHTML",(e=>{if("SCRIPT"===e.that.tagName)e.data.value=c.js.source(e.data.value);else e.data.value=c.sourceHtml(e.data.value)})),d.element.on("setOuterHTML",(e=>{e.data.value=c.rewriteHtml(e.data.value,{document:"HTML"===e.that.tagName})})),d.element.on("getOuterHTML",(e=>{switch(e.that.tagName){case"HEAD":e.data.value=c.sourceHtml(e.data.value.replace(/<head(.*)>(.*)<\/head>/s,"<op-head$1>$2</op-head>")).replace(/<op-head(.*)>(.*)<\/op-head>/s,"<head$1>$2</head>");break;case"BODY":e.data.value=c.sourceHtml(e.data.value.replace(/<body(.*)>(.*)<\/body>/s,"<op-body$1>$2</op-body>")).replace(/<op-body(.*)>(.*)<\/op-body>/s,"<body$1>$2</body>");break;default:e.data.value=c.sourceHtml(e.data.value,{document:"HTML"===e.that.tagName})}})),d.document.on("write",(e=>{if(!e.data.html.length)return!1;e.data.html=[c.rewriteHtml(e.data.html.join(""))]})),d.document.on("writeln",(e=>{if(!e.data.html.length)return!1;e.data.html=[c.rewriteHtml(e.data.html.join(""))]})),d.element.on("insertAdjacentHTML",(e=>{e.data.html=c.rewriteHtml(e.data.html)})),d.eventSource.on("construct",(e=>{e.data.url=c.rewriteUrl(e.data.url)})),d.eventSource.on("url",(e=>{e.data.url=c.rewriteUrl(e.data.url)})),d.history.on("replaceState",(e=>{e.data.url&&(e.data.url=c.rewriteUrl(e.data.url,"__uv"in e.that?e.that.__uv.meta:c.meta))})),d.history.on("pushState",(e=>{e.data.url&&(e.data.url=c.rewriteUrl(e.data.url,"__uv"in e.that?e.that.__uv.meta:c.meta))})),d.element.on("getAttribute",(e=>{d.element.hasAttribute.call(e.that,c.attributePrefix+"-attr-"+e.data.name)&&e.respondWith(e.target.call(e.that,c.attributePrefix+"-attr-"+e.data.name))})),d.message.on("postMessage",(e=>{let t=e.data.origin,a=c.call;e.that&&(a=e.that.__uv$source.call),e.data.origin="*",e.data.message={__data:e.data.message,__origin:(e.that||e.target).__uv$source.location.origin,__to:t},e.respondWith(a(e.target,i?[e.data.message,e.data.transfer]:[e.data.message,e.data.origin,e.data.transfer],e.that))})),d.message.on("data",(e=>{const{value:t}=e.data;"object"==typeof t&&"__data"in t&&"__origin"in t&&e.respondWith(t.__data)})),d.message.on("origin",(e=>{const t=d.message.messageData.get.call(e.that);"object"==typeof t&&t.__data&&t.__origin&&e.respondWith(t.__origin)})),d.overrideDescriptor(r,"origin",{get:()=>c.location.origin}),d.node.on("baseURI",(e=>{e.data.value.startsWith(r.location.origin)&&(e.data.value=c.sourceUrl(e.data.value))})),d.element.on("setAttribute",(e=>{if(e.that instanceof u&&"src"===e.data.name&&e.data.value.startsWith("blob:"))return e.target.call(e.that,c.attributePrefix+"-attr-"+e.data.name,e.data.value),void(e.data.value=c.blobUrls.get(e.data.value));c.attrs.isUrl(e.data.name)&&(e.target.call(e.that,c.attributePrefix+"-attr-"+e.data.name,e.data.value),e.data.value=c.rewriteUrl(e.data.value)),c.attrs.isStyle(e.data.name)&&(e.target.call(e.that,c.attributePrefix+"-attr-"+e.data.name,e.data.value),e.data.value=c.rewriteCSS(e.data.value,{context:"declarationList"})),c.attrs.isHtml(e.data.name)&&(e.target.call(e.that,c.attributePrefix+"-attr-"+e.data.name,e.data.value),e.data.value=c.rewriteHtml(e.data.value,{...c.meta,document:!0,injectHead:c.createHtmlInject(c.handlerScript,c.bundleScript,c.clientScript,c.configScript,c.bareData,c.cookieStr,r.location.href)})),c.attrs.isSrcset(e.data.name)&&(e.target.call(e.that,c.attributePrefix+"-attr-"+e.data.name,e.data.value),e.data.value=c.html.wrapSrcset(e.data.value.toString())),c.attrs.isForbidden(e.data.name)&&(e.data.name=c.attributePrefix+"-attr-"+e.data.name)})),d.element.on("audio",(e=>{e.data.url=c.rewriteUrl(e.data.url)})),d.element.hookProperty([f,_,S,w],"href",{get:(e,t)=>c.sourceUrl(e.call(t)),set:(e,t,[a])=>{d.element.setAttribute.call(t,c.attributePrefix+"-attr-href",a),e.call(t,c.rewriteUrl(a))}}),d.element.hookProperty([h,m,v,u,P,p,g,y,b,U],"src",{get:(e,t)=>c.sourceUrl(e.call(t)),set:(e,t,[a])=>{if(new String(a).toString().trim().startsWith("blob:")&&t instanceof u)return d.element.setAttribute.call(t,c.attributePrefix+"-attr-src",a),e.call(t,c.blobUrls.get(a)||a);d.element.setAttribute.call(t,c.attributePrefix+"-attr-src",a),e.call(t,c.rewriteUrl(a))}}),d.element.hookProperty([k],"action",{get:(e,t)=>c.sourceUrl(e.call(t)),set:(e,t,[a])=>{d.element.setAttribute.call(t,c.attributePrefix+"-attr-action",a),e.call(t,c.rewriteUrl(a))}}),d.element.hookProperty([P],"srcset",{get:(e,t)=>d.element.getAttribute.call(t,c.attributePrefix+"-attr-srcset")||e.call(t),set:(e,t,[a])=>{d.element.setAttribute.call(t,c.attributePrefix+"-attr-srcset",a),e.call(t,c.html.wrapSrcset(a.toString()))}}),d.element.hookProperty(h,"integrity",{get:(e,t)=>d.element.getAttribute.call(t,c.attributePrefix+"-attr-integrity"),set:(e,t,[a])=>{d.element.setAttribute.call(t,c.attributePrefix+"-attr-integrity",a)}}),d.element.hookProperty(y,"sandbox",{get:(e,t)=>d.element.getAttribute.call(t,c.attributePrefix+"-attr-sandbox")||e.call(t),set:(e,t,[a])=>{d.element.setAttribute.call(t,c.attributePrefix+"-attr-sandbox",a)}});const $=y&&Object.getOwnPropertyDescriptor(y.prototype,"contentWindow").get;function T(e){const t=$.call(e);try{t.__uv$bareData=c.bareData,t.__uv$cookies=c.cookieStr,t.__uv||a(t,o,n)}catch(e){console.error("catastrophic failure"),console.error(e)}}function j(e,t){const a=`on${t}`,r=new WeakMap;Reflect.defineProperty(e,a,{enumerable:!0,configurable:!0,get(){return r.has(this)?r.get(this):null},set(e){"function"==typeof e&&(r.has(this)&&this.removeEventListener(t,r.get(this)),r.set(this,e),this.addEventListener(t,e))}})}d.element.hookProperty(y,"contentWindow",{get:(e,t)=>(T(t),e.call(t))}),d.element.hookProperty(y,"contentDocument",{get:(e,t)=>(T(t),e.call(t))}),d.element.hookProperty(y,"srcdoc",{get:(e,t)=>d.element.getAttribute.call(t,c.attributePrefix+"-attr-srcdoc")||e.call(t),set:(e,t,[a])=>{e.call(t,c.rewriteHtml(a,{document:!0,injectHead:c.createHtmlInject(c.handlerScript,c.bundleScript,c.clientScript,c.configScript,c.bareData,c.cookieStr,r.location.href)}))}}),d.node.on("getTextContent",(e=>{"SCRIPT"===e.that.tagName&&(e.data.value=c.js.source(e.data.value))})),d.node.on("setTextContent",(e=>{"SCRIPT"===e.that.tagName&&(e.data.value=c.js.rewrite(e.data.value))})),"serviceWorker"in r.navigator&&delete r.Navigator.prototype.serviceWorker,d.document.on("getDomain",(e=>{e.data.value=c.domain})),d.document.on("setDomain",(e=>{if(!e.data.value.toString().endsWith(c.meta.url.hostname.split(".").slice(-2).join(".")))return e.respondWith("");e.respondWith(c.domain=e.data.value)})),d.document.on("url",(e=>{e.data.value=c.location.href})),d.document.on("documentURI",(e=>{e.data.value=c.location.href})),d.document.on("referrer",(e=>{e.data.value=c.referrer||c.sourceUrl(e.data.value)})),d.document.on("parseFromString",(e=>{if("text/html"!==e.data.type)return!1;e.data.string=c.rewriteHtml(e.data.string,{...c.meta,document:!0})})),d.attribute.on("getValue",(e=>{d.element.hasAttribute.call(e.that.ownerElement,c.attributePrefix+"-attr-"+e.data.name)&&(e.data.value=d.element.getAttribute.call(e.that.ownerElement,c.attributePrefix+"-attr-"+e.data.name))})),d.attribute.on("setValue",(e=>{c.attrs.isUrl(e.data.name)&&(d.element.setAttribute.call(e.that.ownerElement,c.attributePrefix+"-attr-"+e.data.name,e.data.value),e.data.value=c.rewriteUrl(e.data.value)),c.attrs.isStyle(e.data.name)&&(d.element.setAttribute.call(e.that.ownerElement,c.attributePrefix+"-attr-"+e.data.name,e.data.value),e.data.value=c.rewriteCSS(e.data.value,{context:"declarationList"})),c.attrs.isHtml(e.data.name)&&(d.element.setAttribute.call(e.that.ownerElement,c.attributePrefix+"-attr-"+e.data.name,e.data.value),e.data.value=c.rewriteHtml(e.data.value,{...c.meta,document:!0,injectHead:c.createHtmlInject(c.handlerScript,c.bundleScript,c.clientScript,c.configScript,c.bareData,c.cookieStr,r.location.href)})),c.attrs.isSrcset(e.data.name)&&(d.element.setAttribute.call(e.that.ownerElement,c.attributePrefix+"-attr-"+e.data.name,e.data.value),e.data.value=c.html.wrapSrcset(e.data.value.toString()))})),d.url.on("createObjectURL",(e=>{let t=e.target.call(e.that,e.data.object);if(t.startsWith("blob:"+location.origin)){let a="blob:"+("about:blank"!==c.meta.url.href?c.meta.url.origin:r.parent.__uv.meta.url.origin)+t.slice("blob:".length+location.origin.length);c.blobUrls.set(a,t),e.respondWith(a)}else e.respondWith(t)})),d.url.on("revokeObjectURL",(e=>{if(c.blobUrls.has(e.data.url)){const t=e.data.url;e.data.url=c.blobUrls.get(e.data.url),c.blobUrls.delete(t)}})),d.storage.on("get",(e=>{e.data.name=l+c.meta.url.origin+"@"+e.data.name})),d.storage.on("set",(e=>{e.that.__uv$storageObj&&(e.that.__uv$storageObj[e.data.name]=e.data.value),e.data.name=l+c.meta.url.origin+"@"+e.data.name})),d.storage.on("delete",(e=>{e.that.__uv$storageObj&&delete e.that.__uv$storageObj[e.data.name],e.data.name=l+c.meta.url.origin+"@"+e.data.name})),d.storage.on("getItem",(e=>{e.data.name=l+c.meta.url.origin+"@"+e.data.name})),d.storage.on("setItem",(e=>{e.that.__uv$storageObj&&(e.that.__uv$storageObj[e.data.name]=e.data.value),e.data.name=l+c.meta.url.origin+"@"+e.data.name})),d.storage.on("removeItem",(e=>{e.that.__uv$storageObj&&delete e.that.__uv$storageObj[e.data.name],e.data.name=l+c.meta.url.origin+"@"+e.data.name})),d.storage.on("clear",(e=>{if(e.that.__uv$storageObj)for(const t of d.nativeMethods.keys.call(null,e.that.__uv$storageObj))delete e.that.__uv$storageObj[t],d.storage.removeItem.call(e.that,l+c.meta.url.origin+"@"+t),e.respondWith()})),d.storage.on("length",(e=>{e.that.__uv$storageObj&&e.respondWith(d.nativeMethods.keys.call(null,e.that.__uv$storageObj).length)})),d.storage.on("key",(e=>{e.that.__uv$storageObj&&e.respondWith(d.nativeMethods.keys.call(null,e.that.__uv$storageObj)[e.data.index]||null)}));const O=["ws:","wss:"];class L extends EventTarget{#e;#t;#a="blob";#r="";#o="";#n="";async#i(e,t){const a={};Reflect.setPrototypeOf(a,null),a.Origin=c.meta.url.origin,a["User-Agent"]=navigator.userAgent,""!==c.cookieStr&&(a.Cookie=c.cookieStr.toString()),this.#e=await M.createWebSocket(e,a,t),this.#e.binaryType=this.#a,this.#e.addEventListener("message",(e=>{this.dispatchEvent(new MessageEvent("message",e))})),this.#e.addEventListener("open",(async e=>{this.dispatchEvent(new Event("open",e))})),this.#e.addEventListener("error",(e=>{this.dispatchEvent(new ErrorEvent("error",e))})),this.#e.addEventListener("close",(e=>{this.dispatchEvent(new Event("close",e))}));const r=await this.#e.meta;r.headers.has("sec-websocket-protocol")&&(this.#r=r.headers.get("sec-websocket-protocol")),r.headers.has("sec-websocket-extensions")&&(this.#o=r.headers.get("sec-websocket-extensions"));let o=r.rawHeaders["set-cookie"]||[];Array.isArray(o)||(o=[]);for(const e of o)document.cookie=e}get url(){return this.#n}constructor(...e){if(super(),!e.length)throw new DOMException("Failed to construct 'WebSocket': 1 argument required, but only 0 present.");const[t,a]=e;let r;try{r=new URL(t)}catch(e){throw new DOMException(`Faiiled to construct 'WebSocket': The URL '${t}' is invalid.`)}if(!O.includes(r.protocol))throw new DOMException(`Failed to construct 'WebSocket': The URL's scheme must be either 'ws' or 'wss'. '${r.protocol}' is not allowed.`);this.#t=this.#i(r,a)}get protocol(){return this.#r}get extensions(){return this.#o}get readyState(){return this.#e?this.#e.readyState:L.CONNECTING}get binaryType(){return this.#a}set binaryType(e){this.#a=e,this.#e&&(this.#e.binaryType=e)}send(e){if(!this.#e)throw new DOMException("Failed to execute 'send' on 'WebSocket': Still in CONNECTING state.");this.#e.send(e)}close(e,t){if(void 0!==e&&("number"!=typeof e&&(e=0),1e3!==e&&(e<3e3||e>4999)))throw new DOMException(`Failed to execute 'close' on 'WebSocket': The code must be either 1000, or between 3000 and 4999. ${e} is neither.`);this.#t.then((()=>this.#e.close(e,t)))}}j(L.prototype,"close"),j(L.prototype,"open"),j(L.prototype,"message"),j(L.prototype,"error");for(const e of["url","protocol","extensions","readyState","binaryType"]){const t=Object.getOwnPropertyDescriptor(r.WebSocket.prototype,e),a=Object.getOwnPropertyDescriptor(L.prototype,e);a?.get&&t?.get&&d.emit("wrap",a.get,t.get),a?.set&&t?.set&&d.emit("wrap",a.get,t.get)}if(d.emit("wrap",r.WebSocket.prototype.send,L.prototype.send),d.emit("wrap",r.WebSocket.prototype.close,L.prototype.close),d.override(r,"WebSocket",((e,t,a)=>new L(...a)),!0),L.prototype.constructor=r.WebSocket,d.function.on("function",(e=>{e.data.script=c.rewriteJS(e.data.script)})),d.function.on("toString",(e=>{c.methods.string in e.that&&e.respondWith(e.that[c.methods.string])})),d.object.on("getOwnPropertyNames",(e=>{e.data.names=e.data.names.filter((e=>!c.filterKeys.includes(e)))})),d.object.on("getOwnPropertyDescriptors",(e=>{for(const t of c.filterKeys)delete e.data.descriptors[t]})),d.style.on("setProperty",(e=>{d.style.dashedUrlProps.includes(e.data.property)&&(e.data.value=c.rewriteCSS(e.data.value,{context:"value",...c.meta}))})),d.style.on("getPropertyValue",(e=>{d.style.dashedUrlProps.includes(e.data.property)&&e.respondWith(c.sourceCSS(e.target.call(e.that,e.data.property),{context:"value",...c.meta}))})),"CSS2Properties"in r)for(const e of d.style.urlProps)d.overrideDescriptor(r.CSS2Properties.prototype,e,{get:(e,t)=>c.sourceCSS(e.call(t),{context:"value",...c.meta}),set:(e,t,a)=>{e.call(t,c.rewriteCSS(a,{context:"value",...c.meta}))}});else"HTMLElement"in r&&d.overrideDescriptor(r.HTMLElement.prototype,"style",{get:(e,t)=>{const a=e.call(t);if(!a.__uv$modifiedStyle)for(const e of d.style.urlProps)d.nativeMethods.defineProperty(a,e,{enumerable:!0,configurable:!0,get(){const t=d.style.getPropertyValue.call(this,e)||"";return c.sourceCSS(t,{context:"value",...c.meta})},set(t){d.style.setProperty.call(this,d.style.propToDashed[e]||e,c.rewriteCSS(t,{context:"value",...c.meta}))}}),d.nativeMethods.defineProperty(a,"__uv$modifiedStyle",{enumerable:!1,value:!0});return a}});d.style.on("setCssText",(e=>{e.data.value=c.rewriteCSS(e.data.value,{context:"declarationList",...c.meta})})),d.style.on("getCssText",(e=>{e.data.value=c.sourceCSS(e.data.value,{context:"declarationList",...c.meta})})),c.addEventListener.call(r,"hashchange",(e=>{if(e.__uv$dispatched)return!1;e.stopImmediatePropagation();const t=r.location.hash;d.history.replaceState.call(r.history,"","",e.oldURL),c.location.hash=t})),d.location.on("hashchange",((e,t,a)=>{if(a.HashChangeEvent&&d.history.replaceState){d.history.replaceState.call(r.history,"","",c.rewriteUrl(t));const o=new a.HashChangeEvent("hashchange",{newURL:t,oldURL:e});d.nativeMethods.defineProperty(o,"__uv$dispatched",{value:!0,enumerable:!1}),c.dispatchEvent.call(r,o)}})),d.fetch.overrideRequest(),d.fetch.overrideUrl(),d.xhr.overrideOpen(),d.xhr.overrideResponseUrl(),d.element.overrideHtml(),d.element.overrideAttribute(),d.element.overrideInsertAdjacentHTML(),d.element.overrideAudio(),d.node.overrideBaseURI(),d.node.overrideTextContent(),d.attribute.overrideNameValue(),d.document.overrideDomain(),d.document.overrideURL(),d.document.overrideDocumentURI(),d.document.overrideWrite(),d.document.overrideReferrer(),d.document.overrideParseFromString(),d.storage.overrideMethods(),d.storage.overrideLength(),d.object.overrideGetPropertyNames(),d.object.overrideGetOwnPropertyDescriptors(),d.history.overridePushState(),d.history.overrideReplaceState(),d.eventSource.overrideConstruct(),d.eventSource.overrideUrl(),d.url.overrideObjectURL(),d.document.overrideCookie(),d.message.overridePostMessage(),d.message.overrideMessageOrigin(),d.message.overrideMessageData(),d.workers.overrideWorker(),d.workers.overrideAddModule(),d.workers.overrideImportScripts(),d.workers.overridePostMessage(),d.style.overrideSetGetProperty(),d.style.overrideCssText(),d.navigator.overrideSendBeacon(),d.function.overrideFunction(),d.function.overrideToString(),d.location.overrideWorkerLocation((e=>new URL(c.sourceUrl(e)))),d.overrideDescriptor(r,"localStorage",{get:(e,t)=>(t||r).__uv.lsWrap}),d.overrideDescriptor(r,"sessionStorage",{get:(e,t)=>(t||r).__uv.ssWrap}),d.override(r,"open",((e,t,a)=>{if(!a.length)return e.apply(t,a);let[r]=a;return r=c.rewriteUrl(r),e.call(t,r)})),c.$wrap=function(e){return"location"===e?c.methods.location:"eval"===e?c.methods.eval:e},c.$get=function(e){return e===r.location?c.location:e===r.eval?c.eval:e===r.parent?r.__uv$parent:e===r.top?r.__uv$top:e},c.eval=d.wrap(r,"eval",((e,t,a)=>{if(!a.length||"string"!=typeof a[0])return e.apply(t,a);let[r]=a;return r=c.rewriteJS(r),e.call(t,r)})),c.call=function(e,t,a){return a?e.apply(a,t):e(...t)},c.call$=function(e,t,a=[]){return e[t].apply(e,a)},d.nativeMethods.defineProperty(r.Object.prototype,s,{get:()=>c,enumerable:!1}),d.nativeMethods.defineProperty(r.Object.prototype,c.methods.setSource,{value:function(e){return d.nativeMethods.isExtensible(this)?(d.nativeMethods.defineProperty(this,c.methods.source,{value:e,writable:!0,enumerable:!1}),this):this},enumerable:!1}),d.nativeMethods.defineProperty(r.Object.prototype,c.methods.source,{value:c,writable:!0,enumerable:!1}),d.nativeMethods.defineProperty(r.Object.prototype,c.methods.location,{configurable:!0,get(){return this===r.document||this===r?c.location:this.location},set(e){this===r.document||this===r?c.location.href=e:this.location=e}}),d.nativeMethods.defineProperty(r.Object.prototype,c.methods.parent,{configurable:!0,get(){const e=this.parent;if(this===r)try{return"__uv"in e?e:this}catch(e){return this}return e},set(e){this.parent=e}}),d.nativeMethods.defineProperty(r.Object.prototype,c.methods.top,{configurable:!0,get(){const e=this.top;if(this===r){if(e===this.parent)return this[c.methods.parent];try{if("__uv"in e)return e;{let t=this;for(;t.parent!==e;)t=t.parent;return"__uv"in t?t:this}}catch(e){return this}}return e},set(e){this.top=e}}),d.nativeMethods.defineProperty(r.Object.prototype,c.methods.eval,{configurable:!0,get(){return this===r?c.eval:this.eval},set(e){this.eval=e}})}self.__uv||a(self,self.__uv$config,self.__uv$config.bare),self.__uvHook=a})(); | ||
//# sourceMappingURL=uv.handler.js.map |
@@ -1,2 +0,2 @@ | ||
(()=>{"use strict";const e=globalThis.Ultraviolet,t=["cross-origin-embedder-policy","cross-origin-opener-policy","cross-origin-resource-policy","content-security-policy","content-security-policy-report-only","expect-ct","feature-policy","origin-isolation","strict-transport-security","upgrade-insecure-requests","x-content-type-options","x-download-options","x-frame-options","x-permitted-cross-domain-policies","x-powered-by","x-xss-protection"],r=["GET","HEAD"];class s extends e.EventEmitter{constructor(t=__uv$config){super(),t.bare||(t.bare="/bare/"),t.prefix||(t.prefix="/service/"),this.addresses="string"==typeof t.bare?[new URL(t.bare,location)]:t.bare.map((e=>new URL(e,location))),this.config=t,this.bareClient=new e.BareClient(this.address),this.browser=e.Bowser.getParser(self.navigator.userAgent).getBrowserName()}async fetch({request:s}){try{if(!s.url.startsWith(location.origin+this.config.prefix))return await fetch(s);const n=new e(this.config);"function"==typeof this.config.construct&&this.config.construct(n,"service");const c=await n.cookie.db();n.meta.origin=location.origin,n.meta.base=n.meta.url=new URL(n.sourceUrl(s.url));const l=new o(s,this,n,r.includes(s.method.toUpperCase())?null:await s.blob());if("blob:"===n.meta.url.protocol&&(l.blob=!0,l.base=l.url=new URL(l.url.pathname)),s.referrer&&s.referrer.startsWith(location.origin)){const e=new URL(n.sourceUrl(s.referrer));(l.headers.origin||n.meta.url.origin!==e.origin&&"cors"===s.mode)&&(l.headers.origin=e.origin),l.headers.referer=e.href}const u=await n.cookie.getCookies(c)||[],h=n.cookie.serialize(u,n.meta,!1);l.headers["user-agent"]=navigator.userAgent,h&&(l.headers.cookie=h),l.headers.Host=l.url.host;const d=new a(l,null,null);if(this.emit("request",d),d.intercepted)return d.returnValue;const m=await this.bareClient.fetch(l.blob?"blob:"+location.origin+l.url.pathname:l.url,{headers:l.headers,method:l.method,body:l.body,credentials:l.credentials,mode:location.origin!==l.address.origin?"cors":l.mode,redirect:l.redirect}),p=new i(l,m),b=new a(p,null,null);if(this.emit("beforemod",b),b.intercepted)return b.returnValue;for(const e of t)p.headers[e]&&delete p.headers[e];if(p.headers.location&&(p.headers.location=n.rewriteUrl(p.headers.location)),p.headers["set-cookie"]&&(Promise.resolve(n.cookie.setCookies(p.headers["set-cookie"],c,n.meta)).then((()=>{self.clients.matchAll().then((function(e){e.forEach((function(e){e.postMessage({msg:"updateCookies",url:n.meta.url.href})}))}))})),delete p.headers["set-cookie"]),p.body)switch(s.destination){case"script":case"worker":p.body=`if (!self.__uv && self.importScripts) importScripts('${__uv$config.bundle}', '${__uv$config.config}', '${__uv$config.handler}');\n`,p.body+=n.js.rewrite(await m.text());break;case"style":p.body=n.rewriteCSS(await m.text());break;case"iframe":case"document":(function(t,r=""){return"text/html"===(e.mime.contentType(r||t.pathname)||"text/html").split(";")[0]})(n.meta.url,p.headers["content-type"]||"")&&(p.body=n.rewriteHtml(await m.text(),{document:!0,injectHead:n.createHtmlInject(this.config.handler,this.config.bundle,this.config.config,this.bareClient.data,n.cookie.serialize(u,n.meta,!0),s.referrer)}))}return"text/event-stream"===l.headers.accept&&(p.headers["content-type"]="text/event-stream"),this.emit("response",b),b.intercepted?b.returnValue:new Response(p.body,{headers:p.headers,status:p.status,statusText:p.statusText})}catch(e){return console.error(e),new Response(e.toString(),{status:500})}}get address(){return this.addresses[Math.floor(Math.random()*this.addresses.length)]}static Ultraviolet=e}self.UVServiceWorker=s;class i{constructor(e,t){this.request=e,this.raw=t,this.ultraviolet=e.ultraviolet,this.headers=Object.fromEntries(t.headers.entries()),this.status=t.status,this.statusText=t.statusText,this.body=t.body}get url(){return this.request.url}get base(){return this.request.base}set base(e){this.request.base=e}}class o{constructor(e,t,r,s=null){this.ultraviolet=r,this.request=e,this.headers=Object.fromEntries(e.headers.entries()),this.method=e.method,this.address=t.address,this.body=s||null,this.redirect=e.redirect,this.credentials="omit",this.mode="cors"===e.mode?e.mode:"same-origin",this.blob=!1}get url(){return this.ultraviolet.meta.url}set url(e){this.ultraviolet.meta.url=e}get base(){return this.ultraviolet.meta.base}set base(e){this.ultraviolet.meta.base=e}}class a{#e;#t;constructor(e={},t=null,r=null){this.#e=!1,this.#t=null,this.data=e,this.target=t,this.that=r}get intercepted(){return this.#e}get returnValue(){return this.#t}respondWith(e){this.#t=e,this.#e=!0}}})(); | ||
(()=>{"use strict";const e=globalThis.Ultraviolet,t=["cross-origin-embedder-policy","cross-origin-opener-policy","cross-origin-resource-policy","content-security-policy","content-security-policy-report-only","expect-ct","feature-policy","origin-isolation","strict-transport-security","upgrade-insecure-requests","x-content-type-options","x-download-options","x-frame-options","x-permitted-cross-domain-policies","x-powered-by","x-xss-protection"],r=["GET","HEAD"];class s extends e.EventEmitter{constructor(t=__uv$config){super(),t.bare||(t.bare="/bare/"),t.prefix||(t.prefix="/service/"),this.addresses="string"==typeof t.bare?[new URL(t.bare,location)]:t.bare.map((e=>new URL(e,location))),this.config=t,this.bareClient=new e.BareClient(this.address)}async fetch({request:s}){try{if(!s.url.startsWith(location.origin+this.config.prefix))return await fetch(s);const n=new e(this.config);"function"==typeof this.config.construct&&this.config.construct(n,"service");const c=await n.cookie.db();n.meta.origin=location.origin,n.meta.base=n.meta.url=new URL(n.sourceUrl(s.url));const l=new o(s,this,n,r.includes(s.method.toUpperCase())?null:await s.blob());if("blob:"===n.meta.url.protocol&&(l.blob=!0,l.base=l.url=new URL(l.url.pathname)),s.referrer&&s.referrer.startsWith(location.origin)){const e=new URL(n.sourceUrl(s.referrer));(l.headers.origin||n.meta.url.origin!==e.origin&&"cors"===s.mode)&&(l.headers.origin=e.origin),l.headers.referer=e.href}const u=await n.cookie.getCookies(c)||[],h=n.cookie.serialize(u,n.meta,!1);l.headers["user-agent"]=navigator.userAgent,h&&(l.headers.cookie=h),l.headers.Host=l.url.host;const d=new a(l,null,null);if(this.emit("request",d),d.intercepted)return d.returnValue;const p=await this.bareClient.fetch(l.blob?"blob:"+location.origin+l.url.pathname:l.url,{headers:l.headers,method:l.method,body:l.body,credentials:l.credentials,mode:location.origin!==l.address.origin?"cors":l.mode,redirect:l.redirect}),m=new i(l,p),b=new a(m,null,null);if(this.emit("beforemod",b),b.intercepted)return b.returnValue;for(const e of t)m.headers[e]&&delete m.headers[e];if(m.headers.location&&(m.headers.location=n.rewriteUrl(m.headers.location)),m.headers["set-cookie"]&&(Promise.resolve(n.cookie.setCookies(m.headers["set-cookie"],c,n.meta)).then((()=>{self.clients.matchAll().then((function(e){e.forEach((function(e){e.postMessage({msg:"updateCookies",url:n.meta.url.href})}))}))})),delete m.headers["set-cookie"]),m.body)switch(s.destination){case"script":case"worker":{const e=[n.bundleScript,n.clientScript,n.configScript,n.handlerScript].map((e=>JSON.stringify(e))).join(",");m.body=`if (!self.__uv && self.importScripts) importScripts(${e});\n`,m.body+=n.js.rewrite(await p.text())}break;case"style":m.body=n.rewriteCSS(await p.text());break;case"iframe":case"document":(function(t,r=""){return"text/html"===(e.mime.contentType(r||t.pathname)||"text/html").split(";")[0]})(n.meta.url,m.headers["content-type"]||"")&&(m.body=n.rewriteHtml(await p.text(),{document:!0,injectHead:n.createHtmlInject(n.handlerScript,n.bundleScript,n.clientScript,n.configScript,this.bareClient.data,n.cookie.serialize(u,n.meta,!0),s.referrer)}))}return"text/event-stream"===l.headers.accept&&(m.headers["content-type"]="text/event-stream"),this.emit("response",b),b.intercepted?b.returnValue:new Response(m.body,{headers:m.headers,status:m.status,statusText:m.statusText})}catch(e){return console.error(e),new Response(e.toString(),{status:500})}}get address(){return this.addresses[Math.floor(Math.random()*this.addresses.length)]}static Ultraviolet=e}self.UVServiceWorker=s;class i{constructor(e,t){this.request=e,this.raw=t,this.ultraviolet=e.ultraviolet,this.headers=Object.fromEntries(t.headers.entries()),this.status=t.status,this.statusText=t.statusText,this.body=t.body}get url(){return this.request.url}get base(){return this.request.base}set base(e){this.request.base=e}}class o{constructor(e,t,r,s=null){this.ultraviolet=r,this.request=e,this.headers=Object.fromEntries(e.headers.entries()),this.method=e.method,this.address=t.address,this.body=s||null,this.redirect=e.redirect,this.credentials="omit",this.mode="cors"===e.mode?e.mode:"same-origin",this.blob=!1}get url(){return this.ultraviolet.meta.url}set url(e){this.ultraviolet.meta.url=e}get base(){return this.ultraviolet.meta.base}set base(e){this.ultraviolet.meta.base=e}}class a{#e;#t;constructor(e={},t=null,r=null){this.#e=!1,this.#t=null,this.data=e,this.target=t,this.that=r}get intercepted(){return this.#e}get returnValue(){return this.#t}respondWith(e){this.#t=e,this.#e=!0}}})(); | ||
//# sourceMappingURL=uv.sw.js.map |
{ | ||
"name": "@titaniumnetwork-dev/ultraviolet", | ||
"version": "1.0.4-beta.3", | ||
"version": "1.0.4-beta.4", | ||
"description": "Highly sophisticated proxy used for evading internet censorship or accessing websites in a controlled sandbox using the power of service-workers and more!", | ||
@@ -18,15 +18,14 @@ "main": "lib/index.cjs", | ||
"build": "cross-env NODE_ENV=production webpack-cli", | ||
"build:dev": "cross-env NODE_ENV=development webpack-cli", | ||
"build:watch": "cross-env NODE_ENV=development webpack-cli --watch" | ||
"dev": "cross-env NODE_ENV=development webpack-cli", | ||
"watch": "cross-env NODE_ENV=development webpack-cli --watch" | ||
}, | ||
"dependencies": { | ||
"@tomphttp/bare-client": "^1.1.2-beta", | ||
"bowser": "^2.11.0", | ||
"@tomphttp/bare-client": "^1.1.2-beta.1", | ||
"css-tree": "^2.0.4", | ||
"esotope-hammerhead": "^0.6.1", | ||
"events": "^3.3.0", | ||
"idb": "^7.0.0", | ||
"meriyah": "^4.2.0", | ||
"idb": "^7.1.1", | ||
"meriyah": "^4.3.3", | ||
"mime-db": "^1.51.0", | ||
"parse5": "^6.0.1", | ||
"parse5": "^7.1.2", | ||
"set-cookie-parser": "^2.4.8" | ||
@@ -37,8 +36,10 @@ }, | ||
"cross-env": "^7.0.3", | ||
"eslint": "^8.8.0", | ||
"prettier": "^2.7.1", | ||
"eslint": "^8.28.0", | ||
"eslint-webpack-plugin": "^3.2.0", | ||
"prettier": "^2.8.0", | ||
"source-map-loader": "^4.0.1", | ||
"terser-webpack-plugin": "^5.3.6", | ||
"webpack": "^5.74.0", | ||
"webpack-cli": "^4.10.0" | ||
"webpack": "^5.75.0", | ||
"webpack-cli": "^5.0.0" | ||
} | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9
16
2911804
9
2895
+ Addedentities@4.5.0(transitive)
+ Addedparse5@7.2.1(transitive)
- Removedbowser@^2.11.0
- Removedbowser@2.11.0(transitive)
- Removedparse5@6.0.1(transitive)
Updatedidb@^7.1.1
Updatedmeriyah@^4.3.3
Updatedparse5@^7.1.2