single-file-extension.js 41 KB

1
  1. !function(){"use strict";const t=8388608,e=0,n=[e],r=Symbol(),o=new TextEncoder,a=new TextDecoder,s=new Array(256);let i=0;function c(t,e,r,o){if(void 0===o){if(i++,!(s.length-i>=n.length))throw new Error("Reached maximum number of custom types");s[s.length-i]={serialize:t,parse:e,test:r}}else s[o]={serialize:t,parse:e,test:r}}async function l(t,e){const n=f(t,e);let r=new Uint8Array([]);for await(const t of n){const e=r;r=new Uint8Array(e.length+t.length),r.set(e,0),r.set(t,e.length)}return r}c((async function(t,e){const n=t.objects.indexOf(e);await m(t,n)}),(async function(t){const e=await S(t);return new b(e,t)}),x,e),c(null,(function(){return{}}),L),c(p,T,U),c(h,I,(function(t){return"string"==typeof t})),c(y,(async function(t){const e=await S(t),n=await t.consume(8*e);return new Float64Array(n.buffer)}),(function(t){return"Float64Array"==t.constructor.name})),c(y,(async function(t){const e=await S(t),n=await t.consume(4*e);return new Float32Array(n.buffer)}),(function(t){return"Float32Array"==t.constructor.name})),c(y,(async function(t){const e=await S(t),n=await t.consume(4*e);return new Uint32Array(n.buffer)}),(function(t){return"Uint32Array"==t.constructor.name})),c(y,(async function(t){const e=await S(t),n=await t.consume(4*e);return new Int32Array(n.buffer)}),(function(t){return"Int32Array"==t.constructor.name})),c(y,(async function(t){const e=await S(t),n=await t.consume(2*e);return new Uint16Array(n.buffer)}),(function(t){return"Uint16Array"==t.constructor.name})),c(y,(async function(t){const e=await S(t),n=await t.consume(2*e);return new Int16Array(n.buffer)}),(function(t){return"Int16Array"==t.constructor.name})),c(y,(async function(t){const e=await S(t),n=await t.consume(e);return new Uint8ClampedArray(n.buffer)}),(function(t){return"Uint8ClampedArray"==t.constructor.name})),c(y,(async function(t){const e=await S(t);return await t.consume(e)}),(function(t){return"Uint8Array"==t.constructor.name})),c(y,(async function(t){const e=await S(t),n=await t.consume(e);return new Int8Array(n.buffer)}),(function(t){return"Int8Array"==t.constructor.name})),c((async function(t,e){await m(t,e.byteLength),await t.append(new Uint8Array(e))}),(async function(t){const e=await S(t);return(await t.consume(e)).buffer}),(function(t){return"ArrayBuffer"==t.constructor.name})),c(g,C,k),c((async function(t,e){const n=new Uint8Array(new Uint32Array([e]).buffer);await t.append(n)}),(async function(t){const e=await t.consume(4);return new Uint32Array(e.buffer)[0]}),(function(t){return O(t)&&t>=0&&t<=4294967295})),c((async function(t,e){const n=new Uint8Array(new Int32Array([e]).buffer);await t.append(n)}),(async function(t){const e=await t.consume(4);return new Int32Array(e.buffer)[0]}),(function(t){return O(t)&&t>=-2147483648&&t<=2147483647})),c((async function(t,e){const n=new Uint8Array(new Uint16Array([e]).buffer);await t.append(n)}),(async function(t){const e=await t.consume(2);return new Uint16Array(e.buffer)[0]}),(function(t){return O(t)&&t>=0&&t<=65535})),c((async function(t,e){const n=new Uint8Array(new Int16Array([e]).buffer);await t.append(n)}),(async function(t){const e=await t.consume(2);return new Int16Array(e.buffer)[0]}),(function(t){return O(t)&&t>=-32768&&t<=32767})),c((async function(t,e){const n=new Uint8Array([e]);await t.append(n)}),(async function(t){const e=await t.consume(1);return new Uint8Array(e.buffer)[0]}),(function(t){return O(t)&&t>=0&&t<=255})),c((async function(t,e){const n=new Uint8Array(new Int8Array([e]).buffer);await t.append(n)}),(async function(t){const e=await t.consume(1);return new Int8Array(e.buffer)[0]}),(function(t){return O(t)&&t>=-128&&t<=127})),c(null,(function(){return}),(function(t){return void 0===t})),c(null,(function(){return null}),(function(t){return null===t})),c(null,(function(){return NaN}),(function(t){return Number.isNaN(t)})),c(w,R,(function(t){return"boolean"==typeof t})),c((async function(t,e){await h(t,e.description)}),(async function(t){const e=await I(t);return Symbol(e)}),N),c(null,(function(){return r}),D),c((async function(t,e){const n=e.entries();await m(t,e.size);for(const[e,r]of n)await m(t,e),await m(t,r)}),(async function(t){const e=await S(t),n=new Map;e&&await async function r(o=0){const a=await S(t),s=await S(t);t.setObject([a,s],((t,e)=>n.set(t,e))),o<e-1&&await r(o+1)}();return n}),(function(t){return t instanceof Map})),c((async function(t,e){await m(t,e.size);for(const n of e)await m(t,n)}),(async function(t){const e=await S(t),n=new Set;e&&await async function r(o=0){const a=await S(t);t.setObject([a],(t=>n.add(t))),o<e-1&&await r(o+1)}();return n}),(function(t){return t instanceof Set})),c((async function(t,e){await g(t,e.getTime())}),(async function(t){const e=await C(t);return new Date(e)}),(function(t){return t instanceof Date})),c((async function(t,e){await h(t,e.message),await h(t,e.stack)}),(async function(t){const e=await I(t),n=await I(t),r=new Error(e);return r.stack=n,r}),(function(t){return t instanceof Error})),c((async function(t,e){await h(t,e.source),await h(t,e.flags)}),(async function(t){const e=await I(t),n=await I(t);return new RegExp(e,n)}),(function(t){return t instanceof RegExp})),c((async function(t,e){await h(t,e.valueOf())}),(async function(t){return new String(await I(t))}),(function(t){return t instanceof String})),c((async function(t,e){await g(t,e.valueOf())}),(async function(t){return new Number(await C(t))}),(function(t){return t instanceof Number})),c((async function(t,e){await w(t,e.valueOf())}),(async function(t){return new Boolean(await R(t))}),(function(t){return t instanceof Boolean}));class d{constructor(t,e){this.stream=new u(t,e),this.objects=[]}append(t){return this.stream.append(t)}flush(){return this.stream.flush()}addObject(t){this.objects.push(M(t)&&!x(t,this)?t:void 0)}}class u{constructor(t,e){this.offset=0,this.appendData=t,this.value=new Uint8Array(e)}async append(t){if(this.offset+t.length>this.value.length){const e=this.value.length-this.offset;await this.append(new Uint8Array(t).subarray(0,e)),await this.appendData({value:this.value}),this.offset=0,await this.append(new Uint8Array(t).subarray(e))}else this.value.set(t,this.offset),this.offset+=t.length}async flush(){this.offset&&await this.appendData({value:new Uint8Array(this.value).subarray(0,this.offset),done:!0})}}function f(e,{chunkSize:n=t}={}){let r,o,a,s,i,c;return{[Symbol.asyncIterator]:()=>({next:()=>s?{done:s}:async function(){c?c():l().catch((()=>{}));i=new Promise((t=>c=t));const t=await async function(){const{value:t,done:e}=await o;s=e,e||u();return t}();return{value:t}}(),return:()=>({done:!0})})};async function l(){u(),r=new d(f,n),await m(r,e),await r.flush()}function u(){o=new Promise((t=>a=t))}async function f(t){a(t),await i}}async function m(t,n){const r=s.findIndex((({test:e}={})=>e&&e(n,t)));t.addObject(n),await t.append(new Uint8Array([r]));const o=s[r].serialize;o&&await o(t,n),r!=e&&L(n)&&(await async function(t,e){const n=Object.getOwnPropertySymbols(e),r=n.map((t=>[t,e[t]]));await p(t,r)}(t,n),await async function(t,e){if(ArrayBuffer.isView(e))await m(t,0);else{let n=Object.entries(e);U(e)&&(n=n.filter((([t])=>!O(Number(t))))),await m(t,n.length);for(const[e,r]of n)await h(t,e),await m(t,r)}}(t,n))}async function p(t,e){await m(t,e.length);const n=Object.keys(e).filter((t=>O(Number(t)))).map((t=>Number(t)));let o=0,a=n[o];for(const[s,i]of e.entries())a==s?(a=n[++o],await m(t,i)):await m(t,r)}async function h(t,e){const n=o.encode(e);await m(t,n.length),await t.append(n)}async function y(t,e){await m(t,e.length),await t.append("Uint8Array"==e.constructor.name?e:new Uint8Array(e.buffer))}async function g(t,e){const n=new Uint8Array(new Float64Array([e]).buffer);await t.append(n)}async function w(t,e){const n=new Uint8Array([Number(e)]);await t.append(n)}class b{constructor(t,e){this.index=t,this.data=e}getObject(){return this.data.objects[this.index]}}class A{constructor(t){this.stream=new v(t),this.objects=[],this.setters=[]}consume(t){return this.stream.consume(t)}getObjectId(){const t=this.objects.length;return this.objects.push(void 0),t}resolveObject(t,e){M(e)&&!P(e)&&(this.objects[t]=e)}setObject(t,e){this.setters.push({functionArguments:t,setterFunction:e})}executeSetters(){this.setters.forEach((({functionArguments:t,setterFunction:e})=>{e(...t.map((t=>P(t)?t.getObject():t)))}))}}class v{constructor(t){this.offset=0,this.value=new Uint8Array(0),this.consumeData=t}async consume(t){if(this.offset+t>this.value.length){const e=new Uint8Array(this.value).subarray(this.offset,this.value.length),n=await this.consumeData();return e.length+n.length!=this.value.length&&(this.value=new Uint8Array(e.length+n.length)),this.value.set(e),this.value.set(n,e.length),this.offset=0,this.consume(t)}{const e=this.value.slice(this.offset,this.offset+t);return this.offset+=e.length,e}}}function E(){let t,e,n,r,o,a;return{next:async e=>e?async function(e){o?await o:async function(){let e;r=new Promise((t=>e=t)),t=new A(i),s();const n=await S(t);t.executeSetters(),e(n)}().catch((()=>{}));return function(){o=new Promise((t=>a=t))}(),n(e),{done:!1}}(e):{value:await r,done:!0},return:()=>({done:!0})};function s(){e=new Promise((t=>n=t))}async function i(){const t=await e;return s(),a&&a(),t}}async function S(t){const n=(await t.consume(1))[0],r=s[n].parse,o=t.getObjectId(),a=await r(t);return n!=e&&L(a)&&(await async function(t,e){const n=await T(t);t.setObject([n],(t=>t.forEach((([t,n])=>e[t]=n))))}(t,a),await async function(t,e){const n=await S(t);n&&await r();async function r(o=0){const a=await I(t),s=await S(t);t.setObject([s],(t=>e[a]=t)),o<n-1&&await r(o+1)}}(t,a)),t.resolveObject(o,a),a}async function T(t){const e=await S(t),n=new Array(e);return e&&await async function r(o=0){const a=await S(t);D(a)||t.setObject([a],(t=>n[o]=t));o<e-1&&await r(o+1)}(),n}async function I(t){const e=await S(t),n=await t.consume(e);return a.decode(n)}async function C(t){const e=await t.consume(8);return new Float64Array(e.buffer)[0]}async function R(t){const e=await t.consume(1);return Boolean(e[0])}function x(t,e){return L(t)&&e.objects.includes(t)}function P(t){return t instanceof b}function L(t){return t===Object(t)}function U(t){return"number"==typeof t.length}function D(t){return t===r}function k(t){return"number"==typeof t}function O(t){return k(t)&&Number.isInteger(t)}function N(t){return"symbol"==typeof t}function M(t){return L(t)||N(t)}const B=globalThis.singlefile,F=B.helper.SELECTED_CONTENT_ATTRIBUTE_NAME,_="singlefile-mask",j="singlefile-mask-content",G="singlefile-progress-bar",W="singlefile-progress-bar-content",H="single-file-selection-zone",q="singlefile-logs-window",z="singlefile-logs",V="singlefile-logs-line",X="singlefile-logs-line-text",Z="singlefile-logs-line-icon",K=B.helper.SINGLE_FILE_UI_ELEMENT_CLASS,Q=8,J=new Set(Array.from(getComputedStyle(document.documentElement)));let Y,$,tt,et,nt,rt,ot;try{Y=browser.i18n.getMessage("logPanelWidth"),$=browser.i18n.getMessage("logPanelDeferredImages"),tt=browser.i18n.getMessage("logPanelFrameContents"),et=browser.i18n.getMessage("logPanelEmbeddedImage"),nt=browser.i18n.getMessage("logPanelStep")}catch(t){}function at(t,e){return prompt(t,e)}function st(t){const e=document.querySelector(_);e&&e.style.setProperty("display",t?"block":"none"),ot&&ot.style.setProperty("display",t?"block":"none")}function it(t){if(!document.querySelector(_)&&(t.logsEnabled&&document.documentElement.appendChild(ot),t.shadowEnabled)){const e=function(){try{let t=document.querySelector(_);if(!t){t=Et(_,document.documentElement);const e=t.attachShadow({mode:"open"}),n=document.createElement("style");n.textContent=`\n\t\t\t\t@keyframes single-file-progress { \n\t\t\t\t\t0% { \n\t\t\t\t\t\tleft: -50px;\n\t\t\t\t\t} \n\t\t\t\t\t100% { \n\t\t\t\t\t\tleft: 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t.${G} {\n\t\t\t\t\tposition: fixed;\n\t\t\t\t\ttop: 0;\n\t\t\t\t\tleft: 0;\n\t\t\t\t\twidth: 0;\n\t\t\t\t\theight: 8px;\n\t\t\t\t\tz-index: 2147483646;\n\t\t\t\t\topacity: .5;\n\t\t\t\t\toverflow: hidden;\t\t\t\t\t\n\t\t\t\t\ttransition: width 200ms ease-in-out;\n\t\t\t\t}\n\t\t\t\t.${W} {\n\t\t\t\t\tposition: absolute;\n\t\t\t\t\tleft: 0;\n\t\t\t\t\tanimation: single-file-progress 3s linear infinite reverse;\n\t\t\t\t\tbackground: \n\t\t\t\t\t\twhite \n\t\t\t\t\t\tlinear-gradient(-45deg, rgba(0, 0, 0, 0.075) 25%, \n\t\t\t\t\t\t\ttransparent 25%, \n\t\t\t\t\t\t\ttransparent 50%, \n\t\t\t\t\t\t\trgba(0, 0, 0, 0.075) 50%, \n\t\t\t\t\t\t\trgba(0, 0, 0, 0.075) 75%, \n\t\t\t\t\t\t\ttransparent 75%, transparent)\n\t\t\t\t\t\trepeat scroll 0% 0% / 50px 50px padding-box border-box;\n\t\t\t\t\twidth: calc(100% + 50px);\n\t\t\t\t\theight: 100%;\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\t.${j} {\n\t\t\t\t\tposition: fixed;\n\t\t\t\t\ttop: 0;\n\t\t\t\t\tleft: 0;\n\t\t\t\t\twidth: 100%;\n\t\t\t\t\theight: 100%;\n\t\t\t\t\tz-index: 2147483646;\n\t\t\t\t\topacity: 0;\n\t\t\t\t\tbackground-color: black;\n\t\t\t\t\ttransition: opacity 250ms;\n\t\t\t\t}\n\t\t\t`,e.appendChild(n);let r=document.createElement("div");r.classList.add(j),e.appendChild(r),t.offsetWidth,r.style.setProperty("opacity",.3),t.offsetWidth}return t}catch(t){}}();t.progressBarEnabled&&function(t){try{if(!t.shadowRoot.querySelector("."+G)){let e=document.createElement("div");e.classList.add(G),t.shadowRoot.appendChild(e);const n=document.createElement("div");n.classList.add(W),e.appendChild(n)}}catch(t){}}(e)}}function ct(){const t=document.querySelector(_);t&&t.remove(),ot.remove(),wt()}function lt(t,e,n){n.shadowEnabled&&n.progressBarEnabled&&function(t,e){try{const n=document.querySelector(_);if(n){const r=n.shadowRoot.querySelector("."+G);if(r&&e){const n=Math.floor(t/e*100)+"%";r.style.getPropertyValue("width")!=n&&(r.style.setProperty("width",n),r.offsetWidth)}}}catch(t){}}(t,e)}function dt(t){bt("insert-embedded-image",et,"…",t)}function ut(t){bt("insert-embedded-image",et,"✓",t)}function ft(){let t;const e=[],n=getSelection();for(let r=0;r<n.rangeCount;r++){let o=n.getRangeAt(r);if(o&&o.commonAncestorContainer){const n=document.createTreeWalker(o.commonAncestorContainer);let r=!1,a=!1;for(;!a;)(r||n.currentNode==o.startContainer||n.currentNode==o.endContainer)&&(r=!0,o.startContainer==o.endContainer&&o.startOffset==o.endOffset||(t=!0,"A"==n.currentNode.tagName&&n.currentNode.href&&e.push(n.currentNode.href))),n.currentNode==o.endContainer?a=!0:n.nextNode();t&&n.currentNode==o.endContainer&&n.currentNode.querySelectorAll&&n.currentNode.querySelectorAll("*").forEach((t=>{"A"==t.tagName&&t.href&&e.push(n.currentNode.href)}))}}return Array.from(new Set(e))}async function mt(t){let e=pt();return e||t?e:(e=await new Promise((t=>{let e=[];function n(t){e=[],i(),t.preventDefault()}function r(t){const e=function(t){let e,n=t.target,r=n.getBoundingClientRect();for(e=vt("floor",n,t.clientX-r.left,At(n,"left")),e==n&&(e=vt("ceil",n,r.left+r.width-t.clientX,At(n,"right"))),e==n&&(e=vt("floor",n,t.clientY-r.top,At(n,"top"))),e==n&&(e=vt("ceil",n,r.top+r.height-t.clientY,At(n,"bottom"))),n=e;n&&n.clientWidth<=Q&&n.clientHeight<=Q;)n=n.parentElement;return n}(t);var n;e&&(rt=e,n=e,requestAnimationFrame((()=>{const t=gt(),e=n.getBoundingClientRect(),r=document.scrollingElement||document.documentElement;t.style.setProperty("top",r.scrollTop+e.top-10+"px"),t.style.setProperty("left",r.scrollLeft+e.left-10+"px"),t.style.setProperty("width",e.width+20+"px"),t.style.setProperty("height",e.height+20+"px")})))}function o(t){t.preventDefault(),t.stopPropagation(),0==t.button?i(rt,t.ctrlKey):s()}function a(t){"Escape"==t.key&&s()}function s(){e.length&&getSelection().removeAllRanges(),e=[],l()}function i(t,e){if(t){e||d();const n=document.createRange();n.selectNodeContents(t),c(),getSelection().addRange(n),u(),e||l()}else l()}function c(){const t=getSelection();for(let e=t.rangeCount-1;e>=0;e--){const n=t.getRangeAt(e);n.startOffset==n.endOffset&&(t.removeRange(n),e--)}}function l(){gt().remove(),removeEventListener("mousemove",r,!0),removeEventListener("click",o,!0),removeEventListener("keyup",a,!0),rt=null,t(Boolean(e.length)),setTimeout((()=>document.removeEventListener("contextmenu",n,!0)),0)}function d(){getSelection().removeAllRanges(),e.forEach((t=>getSelection().addRange(t)))}function u(){e=[];for(let t=0;t<getSelection().rangeCount;t++){const n=getSelection().getRangeAt(t);e.push(n)}}addEventListener("mousemove",r,!0),addEventListener("click",o,!0),addEventListener("keyup",a,!0),document.addEventListener("contextmenu",n,!0),getSelection().removeAllRanges()})),e?pt():void 0)}function pt(){const t=getSelection();let e;for(let n=0;n<t.rangeCount;n++){let r=t.getRangeAt(n);if(r&&r.commonAncestorContainer){const t=document.createTreeWalker(r.commonAncestorContainer);let n=!1,o=!1;for(;!o;)(n||t.currentNode==r.startContainer||t.currentNode==r.endContainer)&&(n=!0,r.startContainer==r.endContainer&&r.startOffset==r.endOffset||(e=!0,ht(t.currentNode))),e&&t.currentNode==r.startContainer&&yt(t.currentNode),t.currentNode==r.endContainer?o=!0:t.nextNode();if(e&&t.currentNode==r.endContainer&&t.currentNode.querySelectorAll)for(let t=r.startContainer===r.endContainer?r.startOffset:0;t<r.endOffset;t++){const e=r.endContainer.childNodes[t];e&&(ht(e),e.querySelectorAll&&e.querySelectorAll("*").forEach(ht))}}}return e}function ht(t){(t.nodeType==Node.ELEMENT_NODE?t:t.parentElement).setAttribute(F,"")}function yt(t){t.parentElement&&(ht(t),yt(t.parentElement))}function gt(){let t=document.querySelector(H);return t||(t=Et(H,document.body),t.style.setProperty("box-sizing","border-box","important"),t.style.setProperty("background-color","#3ea9d7","important"),t.style.setProperty("border","10px solid #0b4892","important"),t.style.setProperty("border-radius","2px","important"),t.style.setProperty("opacity",".25","important"),t.style.setProperty("pointer-events","none","important"),t.style.setProperty("position","absolute","important"),t.style.setProperty("transition","all 100ms","important"),t.style.setProperty("cursor","pointer","important"),t.style.setProperty("z-index","2147483647","important"),t.style.removeProperty("border-inline-end"),t.style.removeProperty("border-inline-start"),t.style.removeProperty("inline-size"),t.style.removeProperty("block-size"),t.style.removeProperty("inset-block-start"),t.style.removeProperty("inset-inline-end"),t.style.removeProperty("inset-block-end"),t.style.removeProperty("inset-inline-start")),t}function wt(){try{if(ot=document.querySelector(q),!ot){ot=Et(q);const t=ot.attachShadow({mode:"open"}),e=document.createElement("style");e.textContent=`\n\t\t\t\t@keyframes single-file-pulse { \n\t\t\t\t\t0% { \n\t\t\t\t\t\topacity: .25;\n\t\t\t\t\t} \n\t\t\t\t\t100% { \n\t\t\t\t\t\topacity: 1;\n\t\t\t\t\t} \n\t\t\t\t}\n\t\t\t\t.${z} {\n\t\t\t\t\tposition: fixed;\n\t\t\t\t\tbottom: 24px;\n\t\t\t\t\tleft: 8px;\n\t\t\t\t\tz-index: 2147483647;\n\t\t\t\t\topacity: 0.9;\n\t\t\t\t\tpadding: 4px;\n\t\t\t\t\tbackground-color: white;\n\t\t\t\t\tmin-width: ${Y}px;\n\t\t\t\t\tmin-height: 16px;\n\t\t\t\t\ttransition: height 100ms;\n\t\t\t\t}\n\t\t\t\t.${V} {\n\t\t\t\t\tdisplay: flex;\n\t\t\t\t\tjustify-content: space-between;\n\t\t\t\t\tpadding: 2px;\n\t\t\t\t\tfont-family: arial, sans-serif;\n\t\t\t\t\tcolor: black;\n\t\t\t\t\tbackground-color: white;\n\t\t\t\t}\n\t\t\t\t.${X} {\n\t\t\t\t\tfont-size: 13px;\n\t\t\t\t\topacity: 1;\n\t\t\t\t\ttransition: opacity 200ms;\n\t\t\t\t}\n\t\t\t\t.${Z} {\n\t\t\t\t\tfont-size: 11px;\n\t\t\t\t\tmin-width: 15px;\n\t\t\t\t\ttext-align: center;\n\t\t\t\t\tposition: relative;\n\t\t\t\t\ttop: 1px;\n\t\t\t\t}\n\t\t\t`,t.appendChild(e);const n=document.createElement("div");n.classList.add(z),t.appendChild(n)}}catch(t){}}function bt(t,e,n,r){try{if(r.logsEnabled){const r=ot.shadowRoot.querySelector("."+z);let o=r.querySelector("[data-id='"+t+"']");if(!o){o=document.createElement("div"),o.classList.add(V),r.appendChild(o),o.setAttribute("data-id",t);const n=document.createElement("div");n.classList.add(X),o.appendChild(n),n.textContent=e;const a=document.createElement("div");a.classList.add(Z),o.appendChild(a)}!function(t,e,n){const r=t.childNodes[0],o=t.childNodes[1];r.textContent=e,o.style.setProperty("color","✓"==n?"#055000":"black"),"✓"==n?(r.style.setProperty("opacity",".5"),o.style.setProperty("opacity",".5"),o.style.setProperty("animation","none")):o.style.setProperty("animation","1s ease-in-out 0s infinite alternate none running single-file-pulse");o.textContent=n}(o,e,n)}}catch(t){}}function At(t,e){let n,r=t,o=[];do{const t=r.getBoundingClientRect();if(r.parentElement){const a=r.parentElement.getBoundingClientRect();n=Math.abs(a[e]-t[e])<=Q,n&&(r.parentElement.clientWidth>Q&&r.parentElement.clientHeight>Q&&(r.parentElement.clientWidth-r.clientWidth>Q||r.parentElement.clientHeight-r.clientHeight>Q)&&o.push(r.parentElement),r=r.parentElement)}else n=!1}while(n&&r);return o}function vt(t,e,n,r){return Math[t](n/Q)<=r.length&&(e=r[r.length-Math[t](n/Q)-1]),e}function Et(t,e){const n=document.createElement(t);return n.className=K,e&&e.appendChild(n),J.forEach((t=>n.style.setProperty(t,"initial","important"))),n}wt();const St=globalThis.singlefile,Tt="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAABhmlDQ1BJQ0MgcHJvZmlsZQAAKJF9kT1Iw0AYht+mSlUqHewg4hChOogFURFHqWIRLJS2QqsOJpf+CE0akhQXR8G14ODPYtXBxVlXB1dBEPwBcXNzUnSREr9LCi1ivOO4h/e+9+XuO0Col5lqdowDqmYZqXhMzOZWxMAruhGiOYohiZl6Ir2Qgef4uoeP73dRnuVd9+foVfImA3wi8SzTDYt4nXh609I57xOHWUlSiM+Jxwy6IPEj12WX3zgXHRZ4ZtjIpOaIw8RisY3lNmYlQyWeIo4oqkb5QtZlhfMWZ7VcZc178hcG89pymuu0BhHHIhJIQoSMKjZQhoUo7RopJlJ0HvPwDzj+JLlkcm2AkWMeFaiQHD/4H/zurVmYnHCTgjGg88W2P4aBwC7QqNn297FtN04A/zNwpbX8lTow80l6raVFjoDQNnBx3dLkPeByB+h/0iVDciQ/LaFQAN7P6JtyQN8t0LPq9q15jtMHIEO9WroBDg6BkSJlr3m8u6u9b//WNPv3A6mTcr3f/E/sAAAABmJLR0QAigCKAIrj2uckAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAB3RJTUUH5QkPDysvCdPVuwAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAAELSURBVHja7ZpLFsIwDAPj3v/OsGHDe1BIa8tKO7Mnlkw+dpoxAAAAAGCfx4ur6Yx/B337UUS4mp/VuWUEcjSfOgO+BXCZCWe0hSqQo/npBLglIUNLdAV2MH84Ad1JyIwdLkK6YoabIHWscBWmihHuAqvHtv+XqmdXOK9TxdKy3axUm2vZkXXGgPJksTuz1bVFeeU2Y6ijsLIpXbtKa1kDs2ews69o7+A+ihJ2lvI+/lcS1G21zUVG18XKNm4OS4BNkGOQQohSmGaIdpgLESvzyiRwKepsXjE2H0ZWMF8Zi4+jK5mviM0DiRXNZ2rhkdTK5jO0xermz2o8dCnq+FS2XNNVH0sDAAAA3JYnre9cH8BZmhEAAAAASUVORK5CYII=",It=St.helper.SINGLE_FILE_UI_ELEMENT_CLASS,Ct="singlefile-error-bar",Rt="singlefile-open-file-bar",xt="singlefile-share-page-bar";let Pt,Lt,Ut,Dt;const kt=new Set(Array.from(getComputedStyle(document.documentElement)));function Ot(t){({EMBEDDED_IMAGE_BUTTON_MESSAGE:Pt,SHARE_PAGE_BUTTON_MESSAGE:Lt,SHARE_SELECTION_BUTTON_MESSAGE:Ut,ERROR_TITLE_MESSAGE:Dt}=t)}function Nt(t,e){console.error("SingleFile",t,e),Mt(Ct,Dt+t,{link:e})}function Mt(t,e,{link:n,buttonLabel:r,buttonOnclick:o}={}){try{if(!document.querySelector(t)){const a=function(t,e){const n=document.createElement(t);n.className=It,e&&e.appendChild(n);return kt.forEach((t=>n.style.setProperty(t,"initial","important"))),n}(t),s=a.attachShadow({mode:"open"}),i=document.createElement("style");i.textContent="\n\t\t\t\t.container {\n\t\t\t\t\tbackground-color: #ff6c00;\n\t\t\t\t\tcolor: white;\n\t\t\t\t\tdisplay: flex;\n\t\t\t\t\tposition: fixed;\n\t\t\t\t\ttop: 0px;\n\t\t\t\t\tleft: 0px;\n\t\t\t\t\tright: 0px;\n\t\t\t\t\theight: auto;\n\t\t\t\t\twidth: auto;\n\t\t\t\t\tmin-height: 24px;\n\t\t\t\t\tmin-width: 24px;\t\t\t\t\t\n\t\t\t\t\tz-index: 2147483647;\n\t\t\t\t\tmargin: 0;\n\t\t\t\t\tpadding: 2px;\n\t\t\t\t\tfont-family: Arial;\n\t\t\t\t}\n\t\t\t\t.singlefile-open-file-bar.container, .singlefile-share-page-bar.container {\n\t\t\t\t\tbackground-color: gainsboro;\n\t\t\t\t\tborder-block-end: gray 1px solid;\n\t\t\t\t}\n\t\t\t\t.text {\n\t\t\t\t\tflex: 1;\n\t\t\t\t\tpadding-top: 4px;\n\t\t\t\t\tpadding-bottom: 4px;\n\t\t\t\t\tpadding-left: 8px;\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\tbutton {\n\t\t\t\t\tbackground-color: grey;\n\t\t\t\t\tcolor: white;\n\t\t\t\t\tborder: 1px solid darkgrey;\n\t\t\t\t\tpadding: 3px;\n\t\t\t\t\tpadding-left: 8px;\n\t\t\t\t\tpadding-right: 8px;\n\t\t\t\t\tborder-radius: 4px;\n\t\t\t\t\tcursor: pointer;\n\t\t\t\t}\n\t\t\t\t.close-button {\n\t\t\t\t\topacity: .7;\n\t\t\t\t\tpadding-left: 8px;\n\t\t\t\t\tpadding-right: 8px;\n\t\t\t\t\tcursor: pointer;\n\t\t\t\t\ttransition: opacity 250ms;\n\t\t\t\t\theight: 16px;\n\t\t\t\t\tfont-size: .8rem;\n\t\t\t\t\talign-self: center;\n\t\t\t\t}\n\t\t\t\t.singlefile-open-file-bar button, .singlefile-share-page-bar button{\n\t\t\t\t\tbackground-color: dimgrey;\n\t\t\t\t}\n\t\t\t\t.singlefile-open-file-bar .close-button, .singlefile-share-page-bar .close-button{\n\t\t\t\t\tfilter: invert(1);\n\t\t\t\t}\n\t\t\t\ta {\n\t\t\t\t\tcolor: #303036;\n\t\t\t\t}\n\t\t\t\t.close-button:hover {\n\t\t\t\t\topacity: 1;\n\t\t\t\t}\n\t\t\t",s.appendChild(i);const c=document.createElement("div");c.classList.add(t),c.classList.add("container");const l=document.createElement("span");l.classList.add("text");const d=e.split("__DOC_LINK__");if(l.textContent=d[0],n&&2==d.length){const t=document.createElement("a");t.textContent=n,t.href=n,t.target="_blank",l.appendChild(t),l.appendChild(document.createTextNode(d[1]))}if(r&&o){const t=document.createElement("button");t.textContent=r,t.onclick=()=>o(),l.appendChild(t)}c.appendChild(l);const u=document.createElement("img");u.classList.add("close-button"),c.appendChild(u),s.appendChild(c),u.src=Tt,u.onclick=t=>{0===t.button&&(o&&o(!0),a.remove())},document.documentElement.appendChild(a)}}catch(t){}}const Bt=16777216;let Ft,_t,jt,Gt,Wt;try{Ft=browser.i18n.getMessage("topPanelEmbeddedImageButton"),_t=browser.i18n.getMessage("topPanelSharePageButton"),jt=browser.i18n.getMessage("topPanelShareSelectionButton"),Gt=browser.i18n.getMessage("topPanelError")}catch(t){}async function Ht(t,e){e.includeBOM&&(t.content="\ufeff"+t.content);const n=e.embeddedImage,r={method:"downloads.download",taskId:e.taskId,insertTextBody:e.insertTextBody,confirmFilename:e.confirmFilename,filenameConflictAction:e.filenameConflictAction,filename:t.filename,mimeType:t.mimeType,saveToClipboard:e.saveToClipboard,saveToGDrive:e.saveToGDrive,saveToDropbox:e.saveToDropbox,saveWithWebDAV:e.saveWithWebDAV,webDAVURL:e.webDAVURL,webDAVUser:e.webDAVUser,webDAVPassword:e.webDAVPassword,saveToGitHub:e.saveToGitHub,githubToken:e.githubToken,githubUser:e.githubUser,githubRepository:e.githubRepository,githubBranch:e.githubBranch,saveWithCompanion:e.saveWithCompanion,forceWebAuthFlow:e.forceWebAuthFlow,filenameReplacementCharacter:e.filenameReplacementCharacter,openEditor:e.openEditor,openSavedPage:e.openSavedPage,compressHTML:e.compressHTML,backgroundSave:e.backgroundSave,bookmarkId:e.bookmarkId,replaceBookmarkURL:e.replaceBookmarkURL,applySystemTheme:e.applySystemTheme,defaultEditorMode:e.defaultEditorMode,includeInfobar:e.includeInfobar,warnUnsavedPage:e.warnUnsavedPage,createRootDirectory:e.createRootDirectory,selfExtractingArchive:e.selfExtractingArchive,embeddedImage:n?Array.from(n):null,preventAppendedData:e.preventAppendedData,extractDataFromPage:e.extractDataFromPage,insertCanonicalLink:e.insertCanonicalLink,insertMetaNoIndex:e.insertMetaNoIndex,insertMetaCSP:e.insertMetaCSP,password:e.password,compressContent:e.compressContent,foregroundSave:e.foregroundSave,sharePage:e.sharePage,saveToRestFormApi:e.saveToRestFormApi,saveToRestFormApiUrl:e.saveToRestFormApiUrl,saveToRestFormApiFileFieldName:e.saveToRestFormApiFileFieldName,saveToRestFormApiUrlFieldName:e.saveToRestFormApiUrlFieldName,saveToRestFormApiToken:e.saveToRestFormApiToken,saveToS3:e.saveToS3,S3Domain:e.S3Domain,S3Region:e.S3Region,S3Bucket:e.S3Bucket,S3AccessKey:e.S3AccessKey,S3SecretKey:e.S3SecretKey},o=setInterval((()=>{browser.runtime.sendMessage({method:"ping"}).then((()=>{}))}),15e3);if(e.compressContent){const o=new Blob([await l(t)],{type:t.mimeType}),a=URL.createObjectURL(o);r.blobURL=a;const s=await browser.runtime.sendMessage(r);if(URL.revokeObjectURL(a),s.error){r.embeddedImage=n,r.blobURL=null,r.pageData=t;const e=f(r);for await(const t of e)await browser.runtime.sendMessage({method:"downloads.download",compressContent:!0,data:Array.from(t)});await browser.runtime.sendMessage({method:"downloads.download",compressContent:!0,mimeType:t.mimeType})}e.backgroundSave&&await browser.runtime.sendMessage({method:"downloads.end",taskId:e.taskId})}else{if(e.backgroundSave&&!e.sharePage||e.openEditor||e.saveToGDrive||e.saveToGitHub||e.saveWithCompanion||e.saveWithWebDAV||e.saveToDropbox||e.saveToRestFormApi||e.saveToS3){let n=t.filename;if((e.saveToGDrive||e.saveToGitHub||e.saveWithCompanion||e.saveWithWebDAV||e.saveToDropbox||e.saveToRestFormApi||e.saveToS3)&&e.confirmFilename&&!e.openEditor&&(n=at("Save as",t.filename)),n){r.filename=t.filename=n;const e=URL.createObjectURL(new Blob([t.content],{type:t.mimeType}));r.blobURL=e;const o=await browser.runtime.sendMessage(r);if(URL.revokeObjectURL(e),o.error){r.blobURL=null;for(let e=0;e*Bt<t.content.length;e++)r.truncated=t.content.length>Bt,r.truncated?(r.finished=(e+1)*Bt>t.content.length,r.content=t.content.substring(e*Bt,(e+1)*Bt)):r.content=t.content,await browser.runtime.sendMessage(r)}}else browser.runtime.sendMessage({method:"downloads.cancel"}),browser.runtime.sendMessage({method:"ui.processCancelled"})}else e.saveToClipboard?function(t){const e="copy";function n(e){e.clipboardData.setData(t.mimeType,t.content),e.clipboardData.setData("text/plain",t.content),e.preventDefault()}document.addEventListener(e,n),document.execCommand(e),document.removeEventListener(e,n)}(t):await qt(t,e),e.openSavedPage&&open(URL.createObjectURL(new Blob([t.content],{type:t.mimeType}))),browser.runtime.sendMessage({method:"ui.processEnd"});await browser.runtime.sendMessage({method:"downloads.end",taskId:e.taskId,hash:t.hash,woleetKey:e.woleetKey})}clearInterval(o)}async function qt(t,e){if(Array.isArray(t.content)&&(t.content=new Uint8Array(t.content)),e.sharePage&&navigator.share)await zt(t,e);else{let n=t.filename;if(e.confirmFilename&&(n=at("Save as",t.filename),n?t.filename=n:(browser.runtime.sendMessage({method:"downloads.cancel"}),browser.runtime.sendMessage({method:"ui.processCancelled"}))),n){const e=document.createElement("a");return e.download=t.filename,e.href=URL.createObjectURL(new Blob([t.content],{type:t.mimeType})),e.dispatchEvent(new MouseEvent("click")),new Promise((t=>setTimeout((()=>{URL.revokeObjectURL(e.href),t()}),1e3)))}}}async function zt(t,e){Wt=function(){let t;return{display:async function(e){return new Promise((n=>{t=n,Mt(xt,"",{buttonLabel:e?Ut:Lt,buttonOnclick:n})}))},hide:function(){const t=document.querySelector(xt);t&&t.remove()},cancel:function(){this.hide(),t&&t(!0)}}}();if(!await Wt.display(e.selected)){const n={files:[new File([t.content],t.filename,{type:t.mimeType})]};try{await navigator.share(n),Wt.hide()}catch(n){if(Wt.hide(),"AbortError"!==n.name)throw n;await zt(t,e)}}}Ot({EMBEDDED_IMAGE_BUTTON_MESSAGE:Ft,SHARE_PAGE_BUTTON_MESSAGE:_t,SHARE_SELECTION_BUTTON_MESSAGE:jt,ERROR_TITLE_MESSAGE:Gt});const Vt="single-file-request-fetch-supported",Xt="single-file-response-fetch-supported",Zt="single-file-request-fetch",Kt="single-file-response-fetch",Qt="Host fetch error (SingleFile)",Jt=Boolean(window.wrappedJSObject),Yt=(t,e)=>(e.cache="force-cache",e.referrerPolicy="strict-origin-when-cross-origin",window.fetch(t,e));let $t,te=0,ee=new Map;async function ne(t,e={}){try{const n={cache:"force-cache",headers:e.headers,referrerPolicy:"strict-origin-when-cross-origin"};let r;try{r=e.referrer&&!Jt?await Yt(t,n):await async function(t,e){if(void 0===$t&&($t=!1,document.addEventListener(Xt,(()=>$t=!0),!1),document.dispatchEvent(new CustomEvent(Vt))),!$t)return Yt(t,e);{const n=new Promise(((n,r)=>{document.dispatchEvent(new CustomEvent(Zt,{detail:JSON.stringify({url:t,options:e})})),document.addEventListener(Kt,(function e(o){o.detail?o.detail.url==t&&(document.removeEventListener(Kt,e,!1),o.detail.response?n({status:o.detail.status,headers:new Map(o.detail.headers),arrayBuffer:async()=>o.detail.response}):r(o.detail.error)):r()}),!1)}));try{return await n}catch(n){if(n&&n.message==Qt)return Yt(t,e);throw n}}}(t,n)}catch(e){if(!e||e.message!=Qt)throw e;r=await Yt(t,n)}return r}catch(n){te++;const r=new Promise(((t,e)=>ee.set(te,{resolve:t,reject:e})));return await re({method:"singlefile.fetch",url:t,requestId:te,referrer:e.referrer,headers:e.headers}),r}}async function re(t){const e=await browser.runtime.sendMessage(t);if(!e||e.error)throw new Error(e&&e.error&&e.error.toString());return e}browser.runtime.onMessage.addListener((t=>"singlefile.fetchFrame"==t.method&&window.frameId&&window.frameId==t.frameId?async function(t){try{const e=await Yt(t.url,{cache:"force-cache",headers:t.headers,referrerPolicy:"strict-origin-when-cross-origin"});return{status:e.status,headers:[...e.headers],array:Array.from(new Uint8Array(await e.arrayBuffer()))}}catch(t){return{error:t&&t.toString()}}}(t):"singlefile.fetchResponse"==t.method?async function(t){const e=ee.get(t.requestId);e&&(t.error?(e.reject(new Error(t.error)),ee.delete(t.requestId)):(t.truncated&&(e.array?e.array=e.array.concat(t.array):(e.array=t.array,ee.set(t.requestId,e)),t.finished&&(t.array=e.array)),t.truncated&&!t.finished||(e.resolve({status:t.status,headers:{get:e=>t.headers&&t.headers[e]},arrayBuffer:async()=>new Uint8Array(t.array).buffer}),ee.delete(t.requestId))));return{}}(t):void 0));const oe=globalThis.singlefile,ae=globalThis.singlefileBootstrap,se="moz-extension:";let ie,ce,le,de,ue,fe,me;Ot({EMBEDDED_IMAGE_BUTTON_MESSAGE:browser.i18n.getMessage("topPanelEmbeddedImageButton"),SHARE_PAGE_BUTTON_MESSAGE:browser.i18n.getMessage("topPanelSharePageButton"),SHARE_SELECTION_BUTTON_MESSAGE:browser.i18n.getMessage("topPanelShareSelectionButton"),ERROR_TITLE_MESSAGE:browser.i18n.getMessage("topPanelError")}),ae&&ae.initializedSingleFile||(oe.init({fetch:ne,frameFetch:async function(t,e){const n=await re({method:"singlefile.fetchFrame",url:t,frameId:e.frameId,referrer:e.referrer,headers:e.headers});return{status:n.status,headers:new Map(n.headers),arrayBuffer:async()=>new Uint8Array(n.array).buffer}}}),browser.runtime.onMessage.addListener((t=>{if("content.save"==t.method||"content.cancelSave"==t.method||"content.download"==t.method||"content.getSelectedLinks"==t.method||"content.error"==t.method||"content.prompt"==t.method||"content.beginScrollTo"==t.method||"content.scrollTo"==t.method||"content.endScrollTo"==t.method)return async function(t){if(!location.href.startsWith(se)){if("content.save"==t.method)return await async function(t){const e=setInterval((()=>{browser.runtime.sendMessage({method:"ping"}).then((()=>{}))}),15e3),n=t.options;let r;(n.selected||n.optionallySelected)&&(r=await mt(n.optionallySelected));if(!(ce||ae&&ae.pageInfo.processing)){if(n.updatedResources=ae?ae.pageInfo.updatedResources:{},n.visitDate=ae?ae.pageInfo.visitDate:new Date,Object.keys(n.updatedResources).forEach((t=>n.updatedResources[t].retrieved=!1)),n.optionallySelected&&r&&(n.selected=!0),!n.selected||r){ae&&(ae.pageInfo.processing=!0),ce=!0;try{const t=await async function(t){const e=oe.processors.frameTree;let n;t.keepFilename=t.saveToGDrive||t.saveToGitHub||t.saveWithWebDAV||t.saveToDropbox||t.saveToRestFormApi||t.saveToS3,oe.helper.initDoc(document),it(t),ie=new oe.SingleFile(t);const r=[];t.insertCanonicalLink=!0;let o,a=0,s=0;t.onprogress=async t=>{const{options:e}=t.detail;if(!ie.cancelled){if(t.type==t.RESOURCES_INITIALIZING&&!o&&e.insertEmbeddedScreenshotImage&&e.compressContent){o=!0,st(!1);const t=await browser.runtime.sendMessage({method:"tabs.getScreenshot",width:document.documentElement.scrollWidth,height:document.documentElement.scrollHeight,innerHeight:globalThis.innerHeight});st(!0),dt(e),e.embeddedImage=new Uint8Array(await(await ne(t)).arrayBuffer()),URL.revokeObjectURL(t),ut(e)}t.type==t.RESOURCES_INITIALIZED&&(s=t.detail.max,e.loadDeferredImages&&oe.processors.lazy.resetZoomLevel(e)),t.type==t.RESOURCES_INITIALIZED||t.type==t.RESOURCE_LOADED?(t.type==t.RESOURCE_LOADED&&a++,await browser.runtime.sendMessage({method:"ui.processProgress",index:a,maxIndex:s}),lt(a,s,e)):t.detail.frame||t.type==t.PAGE_LOADING||t.type==t.PAGE_LOADED||(t.type==t.STAGE_STARTED?t.detail.step<3&&function(t,e){bt("step-"+t,`${nt} ${t+1} / 3`,"…",e)}(t.detail.step,e):t.type==t.STAGE_ENDED&&t.detail.step<3&&function(t,e){bt("step-"+t,`${nt} ${t+1} / 3`,"✓",e)}(t.detail.step,e))}};const i=ie.cancel.bind(ie);if(t.insertEmbeddedImage&&t.compressContent){dt(t),de=function(){let t;return{display:async function(){return new Promise((e=>{t=e,Mt(Rt,"",{buttonLabel:Pt,buttonOnclick:e})}))},hide:function(){const t=document.querySelector(Rt);t&&t.remove()},cancel:function(){this.hide(),t&&t(!0)}}}();await de.display()||(t.embeddedImage=await function({accept:t}={accept:"image/*"}){const e=document.createElement("input");return e.type="file",e.accept=t,e.click(),new Promise((t=>{e.addEventListener("change",(async e=>{if(e.target.files.length){const n=e.target.files[0];if("image/png"==n.type){const e=new FileReader;e.addEventListener("load",(async()=>t(new Uint8Array(e.result)))),e.addEventListener("error",(()=>t())),e.readAsArrayBuffer(n)}else{const e=await new Promise((t=>{const e=new FileReader;e.addEventListener("load",(()=>t(e.result))),e.addEventListener("error",(()=>t())),e.readAsDataURL(n)}));if(e){const r=await createImageBitmap(n),o=new Image;o.src=e,o.addEventListener("error",(()=>t())),await new Promise((t=>o.addEventListener("load",t)));const a=new OffscreenCanvas(o.width,o.height);a.getContext("2d").drawImage(r,0,0);const s=await a.convertToBlob({type:"image/png"}),i=new FileReader;i.addEventListener("load",(()=>t(new Uint8Array(i.result)))),i.addEventListener("error",(()=>t())),i.readAsArrayBuffer(s)}else t()}}else t()})),e.addEventListener("cancel",(()=>t()))}))}({accept:"image/*"}),de.hide()),ut(t)}if(!t.saveRawPage&&!ie.cancelled){let n;if(t.loadDeferredImages&&(n=oe.processors.lazy.process(t),function(t){bt("load-deferred-images",$,"…",t)}(t),n.then((()=>{ie.cancelled||function(t){bt("load-deferred-images",$,"✓",t)}(t)})),t.loadDeferredImagesBeforeFrames&&await n),!t.removeFrames&&e&&globalThis.frames){let n;n=t.loadDeferredImages?new Promise((n=>globalThis.setTimeout((()=>n(e.getAsync(t))),t.loadDeferredImagesBeforeFrames||!t.loadDeferredImages?0:t.loadDeferredImagesMaxIdleTime))):e.getAsync(t),function(t){bt("load-frames",tt,"…",t)}(t),n.then((()=>{ie.cancelled||function(t){bt("load-frames",tt,"✓",t)}(t)})),t.loadDeferredImagesBeforeFrames?t.frames=await new Promise((t=>{ie.cancel=function(){i(),t([])},n.then(t)})):r.push(n)}t.loadDeferredImages&&!t.loadDeferredImagesBeforeFrames&&r.push(n)}t.loadDeferredImagesBeforeFrames||ie.cancelled||([t.frames]=await new Promise((t=>{const e=Promise.all(r);ie.cancel=function(){i(),t([[]])},e.then((()=>t(e)))})));t.delayBeforeProcessing&&await new Promise((e=>setTimeout(e,1e3*t.delayBeforeProcessing)));n=t.frames&&t.frames.sessionId;const c=t.frames&&t.frames.find((t=>t.requestedFrame));t.win=globalThis,c?(t.content=c.content,t.url=c.baseURI,t.canvases=c.canvases,t.fonts=c.fonts,t.stylesheets=c.stylesheets,t.images=c.images,t.posters=c.posters,t.videos=c.videos,t.usedFonts=c.usedFonts,t.shadowRoots=c.shadowRoots,t.adoptedStyleSheets=c.adoptedStyleSheets):t.doc=document;ie.cancelled||await ie.run();n&&e.cleanup(n);let l;ie.cancelled||(t.confirmInfobarContent&&(t.infobarContent=at("Infobar content",t.infobarContent)||""),l=await ie.getPageData(),(t.selected||t.optionallySelected)&&document.querySelectorAll("["+F+"]").forEach((t=>t.removeAttribute(F))),ct(),t.displayStats&&(console.log("SingleFile stats"),console.table(l.stats)));return l}(n);if(t)if((!n.backgroundSave&&!n.saveToClipboard||n.saveToGDrive||n.saveToGitHub||n.saveWithCompanion||n.saveWithWebDAV||n.saveToDropbox||n.saveToRestFormApi||n.saveToS3)&&n.confirmFilename&&!n.openEditor){const e=at("Save as",t.filename);e?(t.filename=e,await Ht(t,n)):(browser.runtime.sendMessage({method:"downloads.cancel"}),browser.runtime.sendMessage({method:"ui.processCancelled"}))}else await Ht(t,n)}catch(t){if(!ie.cancelled){console.error(t);const e=t.toString();browser.runtime.sendMessage({method:"ui.processError",error:e}),Nt(e)}}}else browser.runtime.sendMessage({method:"ui.processCancelled"});ce=!1,ae&&(ae.pageInfo.processing=!1)}clearInterval(e)}(t),{};if("content.cancelSave"==t.method)return ie&&(ie.cancel(),ct(),de&&(de.cancel(),de=null),browser.runtime.sendMessage({method:"ui.processCancelled"})),t.options.loadDeferredImages&&oe.processors.lazy.resetZoomLevel(t.options),{};if("content.getSelectedLinks"==t.method)return{urls:ft()};if("content.download"==t.method){le||(le=E());const e=await le.next(t.data);if(e.done){le=null;try{await qt(e.value,{foregroundSave:e.value.foregroundSave,sharePage:e.value.sharePage})}catch(t){return{error:t.toString()}}finally{await browser.runtime.sendMessage({method:"downloads.end",taskId:e.value.taskId})}}return{}}if("content.error"==t.method)return Nt(t.error,t.link),{};if("content.prompt"==t.method)return at(t.message,t.value);if("content.beginScrollTo"==t.method)return ue=globalThis.scrollY,fe=document.documentElement.style.getPropertyValue("transform"),me=document.documentElement.style.getPropertyValue("overflow"),globalThis.scrollTo(0,0),document.documentElement.style.setProperty("transform","translateY(0px)"),document.documentElement.style.setProperty("overflow","hidden"),{};if("content.scrollTo"==t.method)return document.documentElement.style.setProperty("transform","translateY(-"+t.y+"px)"),await new Promise((t=>setTimeout(t,500))),{};if("content.endScrollTo"==t.method)return globalThis.scrollTo(0,ue),document.documentElement.style.setProperty("transform",fe),document.documentElement.style.setProperty("overflow",me),{}}}(t)})),ae?ae.initializedSingleFile=!0:globalThis.singlefileBootstrap={initializedSingleFile:!0})}();