single-file-frames.js 19 KB

1
  1. !function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";const e="single-file-load-image",t="single-file-image-loaded",s=globalThis.browser,o=e=>globalThis.dispatchEvent(e),n=globalThis.CustomEvent,i=globalThis.document,a=globalThis.HTMLDocument,r=globalThis.FileReader,l=globalThis.Blob,d=[];if(i instanceof a&&s&&s.runtime&&s.runtime.getURL){c="single-file-new-font-face",m=e=>{const t=e.detail;d.find((e=>JSON.stringify(e)==JSON.stringify(t)))||d.push(e.detail)},globalThis.addEventListener(c,m,u);let e=i.createElement("script");e.textContent="("+function(){const e=globalThis.console,t=e&&e.warn&&((...t)=>e.warn(...t))||(()=>{}),s="single-file-new-font-face",i={family:"font-family",style:"font-style",weight:"font-weight",stretch:"font-stretch",unicodeRange:"unicode-range",variant:"font-variant",featureSettings:"font-feature-settings"};if(globalThis.FontFace){const e=globalThis.FontFace;let a;globalThis.FontFace=function(){a||(t("SingleFile is hooking the FontFace constructor to get font URLs."),a=!0);const d={};d["font-family"]=arguments[0],d.src=arguments[1];const c=arguments[2];if(c&&Object.keys(c).forEach((e=>{i[e]&&(d[i[e]]=c[e])})),d.src instanceof ArrayBuffer){const e=new r;e.readAsDataURL(new l([d.src])),e.addEventListener("load",(()=>{d.src="url("+e.result+")",o(new n(s,{detail:d}))}))}else o(new n(s,{detail:d}));return new e(...arguments)},globalThis.FontFace.toString=function(){return"function FontFace() { [native code] }"}}}.toString()+")()",(i.documentElement||i).appendChild(e),e.remove(),e=i.createElement("script"),e.src=s.runtime.getURL("/lib/single-file/processors/hooks/content/content-hooks-frames-web.js"),e.async=!1,(i.documentElement||i).appendChild(e),e.remove()}var c,m,u;const g=new RegExp("\\\\([\\da-f]{1,6}[\\x20\\t\\r\\n\\f]?|([\\x20\\t\\r\\n\\f])|.)","ig");const f="data-single-file-removed-content",h="data-single-file-hidden-content",p="data-single-file-kept-content",b="data-single-file-hidden-frame",w="data-single-file-preserved-space-element",y="data-single-file-shadow-root-element",E="data-single-file-image",T="data-single-file-poster",A="data-single-file-canvas",I="data-single-file-import",v="data-single-file-input-value",S="data-single-file-lazy-loaded-src",R="data-single-file-stylesheet",F="data-single-file-disabled-noscript",k="data-single-file-async-script",C="*:not(base):not(link):not(meta):not(noscript):not(script):not(style):not(template):not(title)",M=["NOSCRIPT","DISABLED-NOSCRIPT","META","LINK","STYLE","TITLE","TEMPLATE","SOURCE","OBJECT","SCRIPT","HEAD"],N=/^'(.*?)'$/,x=/^"(.*?)"$/,P={regular:"400",normal:"400",bold:"700",bolder:"700",lighter:"100"},q="single-file-ui-element",L=(e,t,s)=>globalThis.addEventListener(e,t,s);let D={};function _(e,t,s,o,n={usedFonts:new Map,canvases:[],images:[],posters:[],shadowRoots:[],imports:[],markedElements:[]},i){return Array.from(s.childNodes).filter((t=>t instanceof e.HTMLElement||t instanceof e.SVGElement)).forEach((s=>{let a,r,l;if(!o.autoSaveExternalSave&&(o.removeHiddenElements||o.removeUnusedFonts||o.compressHTML)&&(l=e.getComputedStyle(s),s instanceof e.HTMLElement&&o.removeHiddenElements&&(r=(i||s.closest("html > head"))&&M.includes(s.tagName)||s.closest("details"),r||(a=i||function(e,t){let s=!1;if(t){const o=t.getPropertyValue("display"),n=t.getPropertyValue("opacity"),i=t.getPropertyValue("visibility");if(s="none"==o,!s&&("0"==n||"hidden"==i)&&e.getBoundingClientRect){const t=e.getBoundingClientRect();s=!t.width&&!t.height}}return Boolean(s)}(s,l),a&&(s.setAttribute(h,""),n.markedElements.push(s)))),!a)){if(o.compressHTML&&l){const e=l.getPropertyValue("white-space");e&&e.startsWith("pre")&&(s.setAttribute(w,""),n.markedElements.push(s))}o.removeUnusedFonts&&(O(l,o,n.usedFonts),O(e.getComputedStyle(s,":first-letter"),o,n.usedFonts),O(e.getComputedStyle(s,":before"),o,n.usedFonts),O(e.getComputedStyle(s,":after"),o,n.usedFonts))}!function(e,t,s,o,n,i,a){if("CANVAS"==s.tagName)try{const t=B(e,s,a);n.canvases.push({dataURI:s.toDataURL("image/png",""),width:t.width,height:t.height}),s.setAttribute(A,n.canvases.length-1),n.markedElements.push(s)}catch(e){}if("IMG"==s.tagName){const t={currentSrc:i?"data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==":o.loadDeferredImages&&s.getAttribute(S)||s.currentSrc};if(n.images.push(t),s.setAttribute(E,n.images.length-1),n.markedElements.push(s),s.removeAttribute(S),a=a||e.getComputedStyle(s)){t.size=B(e,s,a);const o=a.getPropertyValue("box-shadow"),n=a.getPropertyValue("background-image");o&&"none"!=o||n&&"none"!=n||!(t.size.pxWidth>1||t.size.pxHeight>1)||(t.replaceable=!0,t.backgroundColor=a.getPropertyValue("background-color"),t.objectFit=a.getPropertyValue("object-fit"),t.boxSizing=a.getPropertyValue("box-sizing"),t.objectPosition=a.getPropertyValue("object-position"))}}if("VIDEO"==s.tagName&&!s.poster){const e=t.createElement("canvas"),o=e.getContext("2d");e.width=s.clientWidth,e.height=s.clientHeight;try{o.drawImage(s,0,0,e.width,e.height),n.posters.push(e.toDataURL("image/png","")),s.setAttribute(T,n.posters.length-1),n.markedElements.push(s)}catch(e){}}"IFRAME"==s.tagName&&i&&o.removeHiddenElements&&(s.setAttribute(b,""),n.markedElements.push(s));"LINK"==s.tagName&&s.import&&s.import.documentElement&&(n.imports.push({content:W(s.import)}),s.setAttribute(I,n.imports.length-1),n.markedElements.push(s));"INPUT"==s.tagName&&("password"!=s.type&&(s.setAttribute(v,s.value),n.markedElements.push(s)),"radio"!=s.type&&"checkbox"!=s.type||(s.setAttribute(v,s.checked),n.markedElements.push(s)));"TEXTAREA"==s.tagName&&(s.setAttribute(v,s.value),n.markedElements.push(s));"SELECT"==s.tagName&&s.querySelectorAll("option").forEach((e=>{e.selected&&(e.setAttribute(v,""),n.markedElements.push(e))}));"SCRIPT"==s.tagName&&(s.async&&""!=s.getAttribute("async")&&"async"!=s.getAttribute("async")&&(s.setAttribute(k,""),n.markedElements.push(s)),s.textContent=s.textContent.replace(/<\/script>/gi,"<\\/script>"))}(e,t,s,o,n,a,l);const d=!(s instanceof e.SVGElement)&&U(s);if(d&&!s.classList.contains(q)){const i={};s.setAttribute(y,n.shadowRoots.length),n.markedElements.push(s),n.shadowRoots.push(i),_(e,t,d,o,n,a),i.content=d.innerHTML,i.delegatesFocus=d.delegatesFocus,i.mode=d.mode,d.adoptedStyleSheets&&d.adoptedStyleSheets.length&&(i.adoptedStyleSheets=Array.from(d.adoptedStyleSheets).map((e=>Array.from(e.cssRules).map((e=>e.cssText)).join("\n"))))}_(e,t,s,o,n,a),!o.autoSaveExternalSave&&o.removeHiddenElements&&i&&(r||""==s.getAttribute(p)?s.parentElement&&(s.parentElement.setAttribute(p,""),n.markedElements.push(s.parentElement)):a&&(s.setAttribute(f,""),n.markedElements.push(s)))})),n}function O(e,t,s){if(e){const o=e.getPropertyValue("font-style")||"normal";e.getPropertyValue("font-family").split(",").forEach((n=>{if(n=V(n),!t.loadedFonts||t.loadedFonts.find((e=>V(e.family)==n&&e.style==o))){const t=(i=e.getPropertyValue("font-weight"),P[i.toLowerCase().trim()]||i),a=e.getPropertyValue("font-variant")||"normal",r=[n,t,o,a];s.set(JSON.stringify(r),[n,t,o,a])}var i}))}}function U(e){const t=globalThis.chrome;if(e.openOrClosedShadowRoot)return e.openOrClosedShadowRoot;if(!(t&&t.dom&&t.dom.openOrClosedShadowRoot))return e.shadowRoot;try{return t.dom.openOrClosedShadowRoot(e)}catch(t){return e.shadowRoot}}function V(e=""){return function(e){e=e.match(N)?e.replace(N,"$1"):e.replace(x,"$1");return e.trim()}((t=e.trim(),t.replace(g,((e,t,s)=>{const o="0x"+t-65536;return o!=o||s?t:o<0?String.fromCharCode(o+65536):String.fromCharCode(o>>10|55296,1023&o|56320)})))).toLowerCase();var t}function z(e){if(e){const t=[];return e.querySelectorAll("style").forEach(((s,o)=>{try{const n=e.createElement("style");n.textContent=s.textContent,e.body.appendChild(n);const i=n.sheet;n.remove(),i&&i.cssRules.length==s.sheet.cssRules.length||(s.setAttribute(R,o),t[o]=Array.from(s.sheet.cssRules).map((e=>e.cssText)).join("\n"))}catch(e){}})),t}}function B(e,t,s){let o=t.naturalWidth,n=t.naturalHeight;if(!o&&!n){let i,a,r,l,d,c,m,u,g=!1;if("content-box"==(s=s||e.getComputedStyle(t)).getPropertyValue("box-sizing")){const e=t.style.getPropertyValue("box-sizing"),s=t.style.getPropertyPriority("box-sizing"),o=t.clientWidth;t.style.setProperty("box-sizing","border-box","important"),g=t.clientWidth!=o,e?t.style.setProperty("box-sizing",e,s):t.style.removeProperty("box-sizing")}i=H("padding-left",s),a=H("padding-right",s),r=H("padding-top",s),l=H("padding-bottom",s),g?(d=H("border-left-width",s),c=H("border-right-width",s),m=H("border-top-width",s),u=H("border-bottom-width",s)):d=c=m=u=0,o=Math.max(0,t.clientWidth-i-a-d-c),n=Math.max(0,t.clientHeight-r-l-m-u)}return{pxWidth:o,pxHeight:n}}function H(e,t){if(t.getPropertyValue(e).endsWith("px"))return parseFloat(t.getPropertyValue(e))}function W(e){const t=e.doctype;let s="";return t&&(s="<!DOCTYPE "+t.nodeName,t.publicId?(s+=' PUBLIC "'+t.publicId+'"',t.systemId&&(s+=' "'+t.systemId+'"')):t.systemId&&(s+=' SYSTEM "'+t.systemId+'"'),t.internalSubset&&(s+=" ["+t.internalSubset+"]"),s+="> "),s+e.documentElement.outerHTML}L("single-file-user-script-init",(()=>D.callback=async e=>{const t=new CustomEvent(e+"-request",{cancelable:!0}),s=new Promise((t=>L(e+"-response",t)));(e=>{globalThis.dispatchEvent(e)})(t),t.defaultPrevented&&await s}));const j=S,J=q,K="attributes",G=globalThis.browser,Y=globalThis.document,$=globalThis.MutationObserver,X=(e,t,s)=>globalThis.addEventListener(e,t,s),Z=(e,t,s)=>globalThis.removeEventListener(e,t,s),Q=new Map;async function ee(s){if(Y.documentElement){Q.clear();const i=Math.max(Y.documentElement.scrollHeight-1.5*Y.documentElement.clientHeight,0),a=Math.max(Y.documentElement.scrollWidth-1.5*Y.documentElement.clientWidth,0);if(globalThis.scrollY<=i&&globalThis.scrollX<=a)return function(s){return new Promise((async i=>{let a;const r=new Set,l=new $((async e=>{if((e=e.filter((e=>e.type==K))).length){e.filter((e=>{if("src"==e.attributeName&&(e.target.setAttribute(j,e.target.src),e.target.addEventListener("load",d)),"src"==e.attributeName||"srcset"==e.attributeName||"SOURCE"==e.target.tagName)return!e.target.classList||!e.target.classList.contains(J)})).length&&(a=!0,await se(l,s,u),r.size||await te(l,s,u))}}));function d(e){const t=e.target;t.removeAttribute(j),t.removeEventListener("load",d)}async function c(e){a=!0,await se(l,s,u),await te(l,s,u),e.detail&&r.add(e.detail)}async function m(e){await se(l,s,u),await te(l,s,u),r.delete(e.detail),r.size||await te(l,s,u)}function u(s){l.disconnect(),Z(e,c),Z(t,m),i(s)}await ne("idleTimeout",(()=>{a||(ie("loadTimeout"),ie("maxTimeout"),oe(l,s,u))}),2*s.loadDeferredImagesMaxIdleTime),await se(l,s,u),l.observe(Y,{subtree:!0,childList:!0,attributes:!0}),X(e,c),X(t,m),function(e){e.loadDeferredImagesBlockCookies&&o(new n("single-file-block-cookies-start")),e.loadDeferredImagesBlockStorage&&o(new n("single-file-block-storage-start")),e.loadDeferredImagesKeepZoomLevel?o(new n("single-file-load-deferred-images-keep-zoom-level-start")):o(new n("single-file-load-deferred-images-start"))}(s)}))}(s)}}async function te(e,t,s){await ne("loadTimeout",(()=>oe(e,t,s)),t.loadDeferredImagesMaxIdleTime)}async function se(e,t,s){await ne("maxTimeout",(async()=>{await ie("loadTimeout"),await oe(e,t,s)}),10*t.loadDeferredImagesMaxIdleTime)}async function oe(e,t,s){await ie("idleTimeout"),function(e){e.loadDeferredImagesBlockCookies&&o(new n("single-file-block-cookies-end")),e.loadDeferredImagesBlockStorage&&o(new n("single-file-block-storage-end")),e.loadDeferredImagesKeepZoomLevel?o(new n("single-file-load-deferred-images-keep-zoom-level-end")):o(new n("single-file-load-deferred-images-end"))}(t),await ne("endTimeout",(async()=>{await ie("maxTimeout"),s()}),t.loadDeferredImagesMaxIdleTime/2),e.disconnect()}async function ne(e,t,s){if(G&&G.runtime&&G.runtime.sendMessage){if(!Q.get(e)||!Q.get(e).pending){const o={callback:t,pending:!0};Q.set(e,o),await G.runtime.sendMessage({method:"singlefile.lazyTimeout.setTimeout",type:e,delay:s}),o.pending=!1}}else{const o=Q.get(e);o&&globalThis.clearTimeout(o),Q.set(e,t),globalThis.setTimeout(t,s)}}async function ie(e){if(G&&G.runtime&&G.runtime.sendMessage)await G.runtime.sendMessage({method:"singlefile.lazyTimeout.clearTimeout",type:e});else{const t=Q.get(e);Q.delete(e),t&&globalThis.clearTimeout(t)}}G&&G.runtime&&G.runtime.onMessage&&G.runtime.onMessage.addListener&&G.runtime.onMessage.addListener((e=>{if("singlefile.lazyTimeout.onTimeout"==e.method){const t=Q.get(e.type);t&&(Q.delete(e.type),t.callback())}}));const ae={ON_BEFORE_CAPTURE_EVENT_NAME:"single-file-on-before-capture",ON_AFTER_CAPTURE_EVENT_NAME:"single-file-on-after-capture",WIN_ID_ATTRIBUTE_NAME:"data-single-file-win-id",waitForUserScript:D,preProcessDoc:function(e,t,s){let o;return e.querySelectorAll("noscript:not([data-single-file-disabled-noscript])").forEach((e=>{e.setAttribute(F,e.textContent),e.textContent=""})),function(e){e.querySelectorAll("meta[http-equiv=refresh]").forEach((e=>{e.removeAttribute("http-equiv"),e.setAttribute("disabled-http-equiv","refresh")}))}(e),e.head&&e.head.querySelectorAll(C).forEach((e=>e.hidden=!0)),e.querySelectorAll("svg foreignObject").forEach((e=>{const t=e.querySelectorAll("html > head > "+C+", html > body > "+C);t.length&&(Array.from(e.childNodes).forEach((e=>e.remove())),t.forEach((t=>e.appendChild(t))))})),o=t&&e.documentElement?_(t,e,e.documentElement,s):{canvases:[],images:[],posters:[],usedFonts:[],shadowRoots:[],imports:[],markedElements:[]},{canvases:o.canvases,fonts:d,stylesheets:z(e),images:o.images,posters:o.posters,usedFonts:Array.from(o.usedFonts.values()),shadowRoots:o.shadowRoots,imports:o.imports,referrer:e.referrer,markedElements:o.markedElements}},serialize:W,postProcessDoc:function(e,t){if(e.querySelectorAll("[data-single-file-disabled-noscript]").forEach((e=>{e.textContent=e.getAttribute(F),e.removeAttribute(F)})),e.querySelectorAll("meta[disabled-http-equiv]").forEach((e=>{e.setAttribute("http-equiv",e.getAttribute("disabled-http-equiv")),e.removeAttribute("disabled-http-equiv")})),e.head&&e.head.querySelectorAll("*:not(base):not(link):not(meta):not(noscript):not(script):not(style):not(template):not(title)").forEach((e=>e.removeAttribute("hidden"))),!t){const s=[f,b,h,w,E,T,A,v,y,I,R,k];t=e.querySelectorAll(s.map((e=>"["+e+"]")).join(","))}t.forEach((e=>{e.removeAttribute(f),e.removeAttribute(h),e.removeAttribute(p),e.removeAttribute(b),e.removeAttribute(w),e.removeAttribute(E),e.removeAttribute(T),e.removeAttribute(A),e.removeAttribute(v),e.removeAttribute(y),e.removeAttribute(I),e.removeAttribute(R),e.removeAttribute(k)}))},getShadowRoot:U},re="__frameTree__::",le='iframe, frame, object[type="text/html"][data]',de="singlefile.frameTree.initRequest",ce="singlefile.frameTree.ackInitRequest",me="singlefile.frameTree.cleanupRequest",ue="singlefile.frameTree.initResponse",ge=".",fe=globalThis.window==globalThis.top,he=globalThis.browser,pe=globalThis.top,be=globalThis.MessageChannel,we=globalThis.document,ye=new Map;let Ee;function Te(e){e.frames.forEach((t=>Ie("responseTimeouts",e.sessionId,t.windowId)));const t=ye.get(e.sessionId);if(t){e.requestedFrameId&&(t.requestedFrameId=e.requestedFrameId),e.frames.forEach((e=>{let s=t.frames.find((t=>e.windowId==t.windowId));s||(s={windowId:e.windowId},t.frames.push(s)),s.processed||(s.content=e.content,s.baseURI=e.baseURI,s.title=e.title,s.canvases=e.canvases,s.fonts=e.fonts,s.stylesheets=e.stylesheets,s.images=e.images,s.posters=e.posters,s.usedFonts=e.usedFonts,s.shadowRoots=e.shadowRoots,s.imports=e.imports,s.processed=e.processed)}));t.frames.filter((e=>!e.processed)).length||(t.frames=t.frames.sort(((e,t)=>t.windowId.split(ge).length-e.windowId.split(ge).length)),t.resolve&&(t.requestedFrameId&&t.frames.forEach((e=>{e.windowId==t.requestedFrameId&&(e.requestedFrame=!0)})),t.resolve(t.frames)))}}function Ae(e,t,s,o){const n=Ce(e);!function(e,t,s,o,n){const i=[];let a;ye.get(n)?a=ye.get(n).requestTimeouts:(a={},ye.set(n,{requestTimeouts:a}));t.forEach(((e,t)=>{const s=o+ge+t;e.setAttribute(ae.WIN_ID_ATTRIBUTE_NAME,s),i.push({windowId:s})})),Re({frames:i,sessionId:n,requestedFrameId:e.documentElement.dataset.requestedFrameId&&o}),t.forEach(((e,t)=>{const i=o+ge+t;try{Fe(e.contentWindow,{method:de,windowId:i,sessionId:n,options:s})}catch(e){}a[i]=globalThis.setTimeout((()=>Re({frames:[{windowId:i,processed:!0}],sessionId:n})),750)})),delete e.documentElement.dataset.requestedFrameId}(e,n,t,s,o),n.length&&function(e,t,s,o,n){const i=[];t.forEach(((e,t)=>{const a=o+ge+t;let r;try{r=e.contentDocument}catch(e){}if(r)try{const t=e.contentWindow;t.stop(),Ie("requestTimeouts",n,a),Ae(r,s,a,n),i.push(ke(r,t,a,s))}catch(e){i.push({windowId:a,processed:!0})}})),Re({frames:i,sessionId:n,requestedFrameId:e.documentElement.dataset.requestedFrameId&&o}),delete e.documentElement.dataset.requestedFrameId}(e,n,t,s,o)}function Ie(e,t,s){const o=ye.get(t);if(o&&o[e]){const t=o[e][s];t&&(globalThis.clearTimeout(t),delete o[e][s])}}function ve(e,t){const s=ye.get(e);s&&s.responseTimeouts&&(s.responseTimeouts[t]=globalThis.setTimeout((()=>Re({frames:[{windowId:t,processed:!0}],sessionId:e})),1e4))}function Se(e,t,s){e.forEach(((e,o)=>{const n=t+ge+o;e.removeAttribute(ae.WIN_ID_ATTRIBUTE_NAME);try{Fe(e.contentWindow,{method:me,windowId:n,sessionId:s})}catch(e){}})),e.forEach(((e,o)=>{const n=t+ge+o;let i;try{i=e.contentDocument}catch(e){}if(i)try{Se(Ce(i),n,s)}catch(e){}}))}function Re(e){e.method=ue;try{pe.frameTree.initResponse(e)}catch(t){Fe(pe,e,!0)}}function Fe(e,t,s){if(e==pe&&he&&he.runtime&&he.runtime.sendMessage)he.runtime.sendMessage(t);else if(s){const s=new be;e.postMessage(re+JSON.stringify({method:t.method,sessionId:t.sessionId}),"*",[s.port2]),s.port1.postMessage(t)}else e.postMessage(re+JSON.stringify(t),"*")}function ke(e,t,s,o){const n=ae.preProcessDoc(e,t,o),i=ae.serialize(e);ae.postProcessDoc(e,n.markedElements);return{windowId:s,content:i,baseURI:e.baseURI.split("#")[0],title:e.title,canvases:n.canvases,fonts:n.fonts,stylesheets:n.stylesheets,images:n.images,posters:n.posters,usedFonts:n.usedFonts,shadowRoots:n.shadowRoots,imports:n.imports,processed:!0}}function Ce(e){let t=Array.from(e.querySelectorAll(le));return e.querySelectorAll("*").forEach((e=>{const s=ae.getShadowRoot(e);s&&(t=t.concat(...s.querySelectorAll(le)))})),t}fe&&(Ee="0",he&&he.runtime&&he.runtime.onMessage&&he.runtime.onMessage.addListener&&he.runtime.onMessage.addListener((e=>e.method==ue?(Te(e),Promise.resolve({})):e.method==ce?(Ie("requestTimeouts",e.sessionId,e.windowId),ve(e.sessionId,e.windowId),Promise.resolve({})):void 0))),((e,t,s)=>{globalThis.addEventListener(e,t,s)})("message",(async e=>{if("string"==typeof e.data&&e.data.startsWith(re)){e.preventDefault(),e.stopPropagation();const t=JSON.parse(e.data.substring(re.length));if(t.method==de)e.source&&Fe(e.source,{method:ce,windowId:t.windowId,sessionId:t.sessionId}),fe||(globalThis.stop(),t.options.loadDeferredImages&&ee(t.options),await async function(e){const t=ae.waitForUserScript,s=e.sessionId;fe||(Ee=globalThis.frameId=e.windowId);Ae(we,e.options,Ee,s),fe||(e.options.userScriptEnabled&&t.callback&&await t.callback(ae.ON_BEFORE_CAPTURE_EVENT_NAME),Re({frames:[ke(we,globalThis,Ee,e.options)],sessionId:s,requestedFrameId:we.documentElement.dataset.requestedFrameId&&Ee}),e.options.userScriptEnabled&&t.callback&&await t.callback(ae.ON_AFTER_CAPTURE_EVENT_NAME),delete we.documentElement.dataset.requestedFrameId)}(t));else if(t.method==ce)Ie("requestTimeouts",t.sessionId,t.windowId),ve(t.sessionId,t.windowId);else if(t.method==me)!function(e){const t=e.sessionId;Se(Ce(we),e.windowId,t)}(t);else if(t.method==ue&&ye.get(t.sessionId)){e.ports[0].onmessage=e=>Te(e.data)}}}),!0)}));